package = Social networking

robertDouglass's picture
public
robertDouglass - Wed, 2006-10-25 18:13

In the buddylist.info file I put the buddylist.module into the "Social networking" package. Is this a good classification of it, and what other modules would fit into the same package?

From buddylist.info:

package = Social networking

Invite and FOAF would definitely fall into this group. How about OG?


don't think so

moshe weitzman's picture
moshe weitzman - Thu, 2006-10-26 12:08

package != category. package is meant to group modules which work closely together and their configuration should be done in the same mindset. so, IMO i would leave buddylist without a package. social networking is a good category for drupal.org though ... i would like to see a Recommended: keyword in .info where you put modules that work nicely with buddylist. There I would mention privatemsg (once that integration is complete) and some ajax chat thing.


Oh, that's exactly what I meant

robertDouglass's picture
robertDouglass - Thu, 2006-10-26 20:59

Thanks for clarifying that and suggesting the exact solution that I was seeking for. Is anybody working on your suggestion?


don't think so

moshe weitzman's picture
moshe weitzman - Thu, 2006-10-26 21:56

i don't think anyone is. i mentioned it on IRC and everyone nodded but thats about it.


The grouping on the admin page

robertDouglass's picture
robertDouglass - Thu, 2006-10-26 21:56

The main reason I'd even care about Package or Recommended is the visual grouping on the admin page. I'd definitely want Invite and Privatemsg to be visually grouped with Buddylist.


package = Social networking

Popboard - Wed, 2006-11-01 19:25

package = Social networking should include:

buddylist.module (friends)
og.module (user groups like facebook)
guestbook.module (can be integrated with user_profile.tpl.php to show comments like MySpace)
privatemsg.module (essential for networking sites)
blog.module (all networking sites today have personal blog/notes features)
profile.module (customizing with user_profile.tpl.php)

mybloglog.module

inactivist's picture
inactivist - Wed, 2007-01-10 16:42

Perhaps this is off topic, but I've added a module to simplify mybloglog integration: http://drupal.org/project/mybloglog

4.7 only at present, but I'll be working on a 5.0 version ASAP.

Does that qualify as a "social networking" module? ('package' usage issues notwithstanding - per other comments in this thread.)

Michael Curry
Exodus Development | Drupal and other developer info


Is there any work being done

billfitzgerald's picture
billfitzgerald - Tue, 2006-11-07 02:58

Is there any work being done on integrating buddylist with the ACL module? It's something we're looking at over here, as it's a pretty key part of an intranet. But the ability to use members from a buddylist as a starting place for allowing users to create access lists to nodes seems like functionality that would be pretty useful in a drupal-based social networking site.


Write a Story for an specific buddy using ACL

akanashiro's picture
akanashiro - Fri, 2007-03-02 13:29

Hi, I wrote a small piece of code which object is to write a Story for an specific buddy in my buddylist using ACL. So, that buddy can only view/write a comment in my Story.
I based the code taking as example Forum Access.

<?php
//$Id: storyacl.module
/**
* @file storyacl.module
*
* A story for my buddies in my buddylist using ACL
*/
/**
* Redefines "add Story"
*/

function storyacl_perm(){
  return array(
'Create story with ACL');
}

function
storyacl_form_alter($form_id, &$form){
  if (
$form['type']['#value'] == 'story'){
   
storyacl_form_form($form_id, $form);
  }
}

function
storyacl_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch (
$op) {
    case
'submit':
      break;
    case
'insert':
      if (
$node && $node->type == 'story') {
       
$acl_id = db_result(db_query("SELECT a.acl_id from {acl} as a WHERE module = 'storyacl'"));
       
acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
      }
      break;
    case
'update':
      break;
    case
'view':
     
storyacl_init($node);
      break;
  }
}

function
storyacl_form_form($form_id, &$form){
  global
$user;
 
$form['storyacl'] = array('#type' => 'fieldset',
   
'#title' => t('Contactos'),
   
'#collapsible' => FALSE,
   
'#tree' => TRUE,
  );
   
 
$sql = "SELECT b.buddy buddy, u.name FROM {users} as u, {buddylist} as b WHERE b.buddy = u.uid AND b.uid=%d";
 
$result = db_query($sql,$user->uid);
  while (
$row = db_fetch_object($result)) {
   
$listbuddy[$row->buddy] = $row->name;
  } 
  if (
$form['nid']['#value']){
   
$sql = "SELECT * FROM {acl_user} as au, {acl_node} as an  WHERE an.acl_id = au.acl_id AND an.nid = %d AND au.uid = %d";
   
$result = db_query($sql, $form['nid']['#value'],$listbuddy);
    if (
db_num_rows($result) == 0){
     
$view = $update = array(1,2);
    }   
    while (
$access = db_fetch_object($result)){
      if (
$access->grant_view){
         
$view[] = $access->uid;
      }
    }
  }
  else{
   
$view = array();
  }
      
 
$form['storyacl']['view'] = array('#type' => 'checkboxes',
     
'#prefix' => '<div>',
     
'#suffix' => '</div>',
     
'#options' => $listbuddy,
     
'#default_value' => $view
 
); 

  if (
$form['nid']['#value']) {
   
$acl_id = db_result(db_query("SELECT a.acl_id from {acl} as a, {acl_node} as n WHERE a.module = 'storyacl' AND a.acl_id = n.acl_id AND n.nid = %d", $form['nid']['#value']));
    if (!
$acl_id) { // create one
     
$acl_id = acl_create_new_acl('storyacl', $form['nid']['#value']);
     
// update every existing node in this forum to use this acl.
      // I only give permission to read, not to update neither delete
     
acl_node_add_acl($form['nid']['#value'], $acl_id, 1, 0, 0);
    }   
   
$form['#submit']['storyacl_form_submit'] = current($form['#submit']);
  }
}

function
storyacl_form_submit($form_id,$form_values){
 
$access = $form_values['storyacl'];
  foreach(
$access['view'] as $listbuddy => $checked) {
   
$grants[] = array(
     
'realm' => 'storyacl',
     
'gid' => $listbuddy,
     
'grant_view' => TRUE,
     
'grant_update' => FALSE,
     
'grant_delete' => FALSE,
    );
   
    if (
$checked){
     
$result = db_query("SELECT acl_id FROM {acl_node} WHERE nid = %d",$form_values['nid']);
     
$acl = db_fetch_object($result);
     
$acl_id = $acl->acl_id;
     
acl_add_user($acl_id,$listbuddy);
   }
  }
}

/**
* use hook init to deny access to story if the user does not have access
* to it.
*/

function storyacl_init($node = NULL) {
  if (!
function_exists('storyacl_access')) {
  
// page is cached
  
return;
  }          
  global
$user;
  if (
$node->type == 'story' && !storyacl_access($node->nid, 'view')){
   
drupal_access_denied();
   
module_invoke_all('exit');
    exit;
  } 
}

function
storyacl_access($nid, $type, $account = NULL) {
  static
$cache = array();
  if (!
$account) {
    global
$user;
   
$account = $user;
  }
  if (!isset(
$cache[$nid])){
   
$acl_id = db_query("
      SELECT
        count(*)
      FROM
        {acl} as a,
    {acl_node} as n,
    {acl_user} as u
      WHERE
        a.module = 'storyacl' AND a.acl_id = n.acl_id AND a.acl_id = u.acl_id AND u.uid = %d AND n.nid = %d"
,
   
$account->uid, $nid);    
   
   
//we found something, ok
   
if ((db_result($acl_id))!=0){
     
$cache[$nid] = TRUE;     
    }
    else {    
// In case no node with access is found, I can't authorize the access
     
$cache[$nid] = FALSE;
    }
  }
  return
$cache[$nid];
}
?>

Hope it helps.

A.

http://nadaenespecial.com.ar


RE: Hope it helps.

billfitzgerald's picture
billfitzgerald - Fri, 2007-03-02 16:34

Hope it helps? Man, this is awesome! We'll be testing this over the next few days, and posting back here.

Seriously. This is sweet!

Cheers,

Bill


hook_init

marcp@drupal.org - Mon, 2007-03-05 19:30

Hello Agustín,

Thank you very much for this code. I am trying to get it working on my development site and running across some problems. The first one, I think, may be due to the storyacl_init function. I have saved your code as storyacl.module, and am running on Drupal 5.x. The hook_init() function, as described here: http://api.drupal.org/api/5/function/hook_init does not take any parameters and is called during bootstrap.

I will try to chase down what is going on, but I was really wondering if you have some updated code that you might like to post?

Thanks again,

Marc


http://www.funnymonkey.com
Tools for Teachers

hook_init

akanashiro's picture
akanashiro - Tue, 2007-03-06 18:01

I'm using Drupal 5.0 and is this code I wrote is a research I did but it is not implemented on an system yet. I tested it with 3 or 4 contacts and it works fine.

Yes, the hook_init() definition has not parameters, but I (hacked) am using $node in order to check if the node type is story and if you have permissions to view it.
Maybe what I did is not standard but it's the first time I write a module.

Thanks for you comment.

A.


hook_init II

akanashiro's picture
akanashiro - Wed, 2007-03-07 12:56

I installed a new "sandbox" with Drupal 5.1
Yes, I've found some errors and I'm fixing the code.
In case I solve it I'll write again, sorry that the code didn't work correctly.
greetings

A.


Rewrote code

akanashiro's picture
akanashiro - Thu, 2007-03-08 20:33

There's a lot of code I re-wrote... :-\

There was a typing error in the ACL module with acl_add_user($acl_id, $uid) so the patch is here: http://drupal.org/node/124070
Now, that I re-wrote the code again I used acl_remove_user($acl_id, $uid) and it has the same typing error. Waiting for a new patch.

It is still a draft, but you can see a progress.
- Now it writes/deletes the records in ACL tables (acl, acl_node, acl_user) correctly.
- In "Create Story", it draws buddies' checkboxes correctly.
- Story can be read by the owner and assigned buddies. So it doesn't allow anonymous users (and not assigned users) to read created stories.

Problems not solved yet: :-(
- If I delete the story owner, that corresponding story is not deleted and that story's owner changes to anonymous. (I'm working with MySQL).

Modules involved:
- ACL
- Buddylist

I included my module and a fixed ACL module.
http://www.esnips.com/doc/8deb52dc-dc36-450c-9afc-39314e533976/acl-and-s...

I'll be working on the module during the week, so if you found another error send me a message please!

Greetings

A.