/[drupal]/contributions/modules/subscriptions_og/subscriptions_og.module
ViewVC logotype

Diff of /contributions/modules/subscriptions_og/subscriptions_og.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.51, Mon Apr 14 16:35:30 2008 UTC revision 1.1.2.52, Tue Apr 29 22:02:01 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: subscriptions_og.module,v 1.1.2.50 2008/04/12 03:07:15 develCuy Exp $  // $Id: subscriptions_og.module,v 1.1.2.51 2008/04/14 16:35:30 develCuy Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 668  function subscriptions_og_form_alter($fo Line 668  function subscriptions_og_form_alter($fo
668        '#description'   => t('Select group types which should be <strong>omitted</strong> from subscription listings. Users will not be able to subscribe to groups of this type.'),        '#description'   => t('Select group types which should be <strong>omitted</strong> from subscription listings. Users will not be able to subscribe to groups of this type.'),
669        '#multiple'      => TRUE,        '#multiple'      => TRUE,
670      );      );
671      // REMOVED  
672      // $form['group']['subscriptions_autosubs_og'] = array(  /*  EXCLUDED
673      //   '#type' => 'checkbox',      $form['group']['subscriptions_autosubs_og'] = array(
674      //   '#title' => t('New members of a group are subscribed automatically.'),       '#type' => 'checkbox',
675      //   '#default_value' => variable_get('subscriptions_autosubs_og', 0),       '#title' => t('New members of a group are subscribed automatically.'),
676      // );       '#default_value' => variable_get('subscriptions_autosubs_og', 0),
677        );
678    */
679        $form['group']['subscriptions_og_list_joined_only'] = array(
680         '#type' => 'checkbox',
681         '#title' => t('Limit listing of subscriptions in account(user/#uid/subscriptions/group) to those where user is member.'),
682         '#default_value' => variable_get('subscriptions_og_list_joined_only', FALSE),
683        );
684    
685    }    }
686  }  }
# Line 698  function subscriptions_og_page_group_typ Line 705  function subscriptions_og_page_group_typ
705    foreach ($omits as $omit) {    foreach ($omits as $omit) {
706      unset($group_types[$omit]);      unset($group_types[$omit]);
707    }    }
708    
709    if (count($group_types)) {    if (count($group_types)) {
710      $query = "      $query = "
711  SELECT  SELECT
# Line 803  WHERE Line 811  WHERE
811        $groups_by_types[$group->type][$group->nid] = $group;        $groups_by_types[$group->type][$group->nid] = $group;
812      }      }
813    }    }
814      // Get a single list of group IDs where user is member
815    $account_groups =& array_keys($account->og_groups);    $account_groups =& array_keys($account->og_groups);
816    
817      // Determines if must restrict or no subscriptions listing in user account
818      $list_joined_only = variable_get("subscriptions_og_list_joined_only", FALSE);
819    
820    // Construct groups subscriptions form    // Construct groups subscriptions form
821    foreach ($group_types as $type) {    foreach ($group_types as $type) {
822      // display group types name and group nodes together      // display group types name and group nodes together
# Line 825  WHERE Line 837  WHERE
837        $tree = $groups_by_types[$type->type];        $tree = $groups_by_types[$type->type];
838      }      }
839      else {      else {
840        // Ensure to display groups where used is subscribed to if such user is        // Ensure to display groups where user is subscribed to if such user is
841        // not subscribed to any group una given group type ($type->type).        // not subscribed to any group una given group type ($type->type).
842        if (        if (
843          in_array($type->type,array_keys($user_group_types)) &&          in_array($type->type,array_keys($user_group_types)) &&
# Line 860  WHERE Line 872  WHERE
872      $defaults = array();      $defaults = array();
873      if (isset($tree)) {      if (isset($tree)) {
874        foreach ($tree as $group) {        foreach ($tree as $group) {
875          if ($account->uid == 0 || (!$group->private || in_array($group->nid, $account_groups)))          if ($account->uid == 0 || ((!$group->private && !$list_joined_only) || in_array($group->nid, $account_groups)))
876            subscriptions_og_group_form(            subscriptions_og_group_form(
877              $form[$type->type][0], $subscriptions_type[$group->nid],              $form[$type->type][0], $subscriptions_type[$group->nid],
878              $defaults, $group, $uid, $account);              $defaults, $group, $uid, $account);
# Line 1064  function subscriptions_og_node_groups_di Line 1076  function subscriptions_og_node_groups_di
1076    
1077    return $current_groups;    return $current_groups;
1078  }  }
1079    
1080    /**
1081     * Returns a list of groups by given group types.
1082     *
1083     * @param $group_types
1084     *   Format: Array('type1', ..., 'typeN')
1085     *   To be populated by og_node_types system variable by default. If
1086     *   provided, only those groups of given types will be listed.
1087     *
1088     * @return
1089     *   Array of nodes of types in $group_types.
1090     */
1091    function subscriptions_og_get_groups_by_types($group_types = array()) {
1092      if (!count($group_types)) {
1093        $group_types = variable_get('og_node_types', array());
1094      }
1095      if (count($group_types)) {
1096        $query = "
1097    SELECT
1098      n.*,
1099      n.title name,
1100      n.nid group_nid
1101    FROM
1102      {node} n
1103    WHERE
1104      n.type IN('". implode("','", $group_types) ."')
1105        ";
1106    
1107        $rs = db_query($query);
1108        while ($group = db_fetch_object($rs)) {
1109          $groups[$group->type][$group->nid] = $group;
1110        }
1111      }
1112      return $groups;
1113    }

Legend:
Removed from v.1.1.2.51  
changed lines
  Added in v.1.1.2.52

  ViewVC Help
Powered by ViewVC 1.1.2