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

Diff of /contributions/modules/og_content_type_admin/og_content_type_admin.module

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

revision 1.15.2.7, Fri Nov 28 17:27:56 2008 UTC revision 1.15.2.8, Wed Jan 21 15:45:32 2009 UTC
# Line 16  Line 16 
16   * were marked as 'required' by the site admin will always be usable by the group members and   * were marked as 'required' by the site admin will always be usable by the group members and
17   * cannot be deactivated by the group owner.</p>   * cannot be deactivated by the group owner.</p>
18   *   *
19   * @version $Id: og_content_type_admin.module,v 1.15.2.6 2008/11/28 00:35:08 paulbooker Exp $;   * @version $Id: og_content_type_admin.module,v 1.15.2.7 2008/11/28 17:27:56 paulbooker Exp $;
20   * @package OG_CTA   * @package OG_CTA
21   * @category NeighborForge   * @category NeighborForge
22   * @author Ryan Constantine   * @author Ryan Constantine
# Line 71  Group owners can then activate or deacti Line 71  Group owners can then activate or deacti
71   * Implementation of hook_init().   * Implementation of hook_init().
72   */   */
73  function og_content_type_admin_init() {  function og_content_type_admin_init() {
74   drupal_flush_all_caches();    menu_rebuild();
75      node_types_rebuild();
76  }  }
77    
78    
# Line 175  function og_content_type_admin_og_create Line 176  function og_content_type_admin_og_create
176      }      }
177    }    }
178    return $links;    return $links;
179  } // function og_content_type_admin_og_create_links()  }
180    
181  //Site administration section---------------------------------------------------------------------------------  //Site administration section---------------------------------------------------------------------------------
182  //This section is only for administration forms and form processing  //This section is only for administration forms and form processing
# Line 189  function og_content_type_admin_og_create Line 190  function og_content_type_admin_og_create
190   */   */
191  function og_content_type_admin_main($gid = NULL) {  function og_content_type_admin_main($gid = NULL) {
192    if ($admin = user_access('administer og content types')) {    if ($admin = user_access('administer og content types')) {
193        $options = og_all_groups_options();      $options = og_all_groups_options();
194        $added = _og_content_type_admin_get_added();      $added = _og_content_type_admin_get_added();
195        foreach ($added as $group_id => $name) {//remove from the select, groups we're already working with      foreach ($added as $group_id => $name) {//remove from the select, groups we're already working with
196        if (array_key_exists($group_id, $options)) {        if (array_key_exists($group_id, $options)) {
197          unset($options[$group_id]);          unset($options[$group_id]);
198        }        }
# Line 209  function og_content_type_admin_main($gid Line 210  function og_content_type_admin_main($gid
210      }      }
211    }    }
212    return $form;    return $form;
213  } // function og_content_type_admin_main()  }
214    
215  /**  /**
216   * Validate the group name before adding or saving it   * Validate the group name before adding or saving it
# Line 232  function og_content_type_admin_main_vali Line 233  function og_content_type_admin_main_vali
233    else {    else {
234      form_set_error('name', t('You must specify a valid group name.'));      form_set_error('name', t('You must specify a valid group name.'));
235    }    }
236  }//function og_content_type_admin_main_validate()  }
237    
238  /**  /**
239   * Submit the group name and id to be added to the database.   * Submit the group name and id to be added to the database.
# Line 249  function og_content_type_admin_main_subm Line 250  function og_content_type_admin_main_subm
250      drupal_set_message(t('The group has been added.'));      drupal_set_message(t('The group has been added.'));
251    }    }
252    $form_state['redirect'] = 'admin/og/og_content_types';    $form_state['redirect'] = 'admin/og/og_content_types';
253  } //function og_content_type_admin_main_submit()  }
254    
255  /**  /**
256   * Theme for the add page of the main function.   * Theme for the add page of the main function.
# Line 284  function theme_og_content_type_admin_mai Line 285  function theme_og_content_type_admin_mai
285    $output .= theme('table', $header, $rows);    $output .= theme('table', $header, $rows);
286    
287    return $output;    return $output;
288  } //function theme_og_content_type_admin_main()  }
289    
290  /**  /**
291   * Returns a confirmation page for deleting a group from the content type admin table.   * Returns a confirmation page for deleting a group from the content type admin table.
# Line 306  function og_content_type_admin_confirm_d Line 307  function og_content_type_admin_confirm_d
307      array('%name' => $result->name)), $return_address,      array('%name' => $result->name)), $return_address,
308      t('Deleting a group here will revert the content types associated with it to the defaults. This action cannot be undone.'), t('Delete'), t('Cancel'));      t('Deleting a group here will revert the content types associated with it to the defaults. This action cannot be undone.'), t('Delete'), t('Cancel'));
309      return $form;      return $form;
310  } // function og_content_type_admin_confirm_delete()  }
311    
312  /**  /**
313   * Implementation of forms api _submit call. Deletes a group from the og_content_type_admin table after confirmation.   * Implementation of forms api _submit call. Deletes a group from the og_content_type_admin table after confirmation.
# Line 323  function og_content_type_admin_confirm_d Line 324  function og_content_type_admin_confirm_d
324      watchdog('content', t('og_content_type_admin: deleted %gid.', array('%gid' => $form_values['name'])));      watchdog('content', t('og_content_type_admin: deleted %gid.', array('%gid' => $form_values['name'])));
325    }    }
326    $form_state['redirect'] = 'admin/og/og_content_types';    $form_state['redirect'] = 'admin/og/og_content_types';
327  } // function og_content_type_admin_confirm_delete_submit()  }
328    
329  /**  /**
330   * Callback function: Assign or Require content types to groups.   * Callback function: Assign or Require content types to groups.
# Line 741  function theme_og_content_type_admin_own Line 742  function theme_og_content_type_admin_own
742    return $output;    return $output;
743  } //function theme_og_content_type_admin_owner()  } //function theme_og_content_type_admin_owner()
744    
   //Nuts and bolts, Meat and potatoes section---------------------------------------------------------------  
745    //This section contains all processing to make sure that only the authorized content types are useable in    //This section contains all processing to make sure that only the authorized content types are useable in
746    //each situation that may come up    //each situation that may come up
747    
# Line 756  function theme_og_content_type_admin_own Line 756  function theme_og_content_type_admin_own
756   * page's listing, nor does it remove the menu items within the OG 'group detail' menu. It also doesn't account   * page's listing, nor does it remove the menu items within the OG 'group detail' menu. It also doesn't account
757   * for directly entering in an illegal url. Other functions handle these problems.   * for directly entering in an illegal url. Other functions handle these problems.
758   */   */
759  function og_content_type_admin_menu_alter(&$callbacks) {   // $types used twice!!!!!  function og_content_type_admin_menu_alter(&$callbacks) {
760    global $user;    global $user;
761    $post_type = arg(2);    $post_type = arg(2);
762    // First: Deny access to all content types and handle all create content pages.    // First: Deny access to all content types and handle all create content pages.
# Line 767  function og_content_type_admin_menu_alte Line 767  function og_content_type_admin_menu_alte
767      $type_path = "node/add/$node_type";      $type_path = "node/add/$node_type";
768      $callbacks[$type_path]['access callback'] = FALSE;      $callbacks[$type_path]['access callback'] = FALSE;
769      $callbacks[$type_path]['page callback'] = 'og_content_type_admin_node_add';      $callbacks[$type_path]['page callback'] = 'og_content_type_admin_node_add';
770    }    }
771      /*TODO: Would something like the below work above ?
772       *$callbacks[]['access callback'] = FALSE;
773       *$callbacks[]['page callback'] = 'og_content_type_admin_node_add';
774       */
775    $callbacks['node/add']['page callback'] = 'og_content_type_admin_node_add';    $callbacks['node/add']['page callback'] = 'og_content_type_admin_node_add';
776    // Second: Allow access to add a particlar type of group content    // Second: Allow access to add a particlar type of group content
777    if (is_array($_GET[gids])) {    if (is_array($_GET[gids])) {
778      $gid = $_GET[gids][0];      $gid = $_GET[gids][0];
779      $sql = "SELECT octa.types_active, octa.types_allowed FROM {og_content_type_admin} octa WHERE octa.gid = %d";      $sql = "SELECT octa.types_active, octa.types_allowed FROM {og_content_type_admin} octa WHERE octa.gid = %d";
780        //if we're keeping track of this group, get it's active types, otherwise, get the defaults        //if we're keeping track of this group, get it's active types, otherwise, get the defaults
781        $types = db_fetch_object(db_query($sql, $node->nid));        $types = db_fetch_object(db_query($sql, $node->nid)); // TODO: Should this be $gid ?
782        if (!count($types->types_active)) {        if (!count($types->types_active)) {
783          $types = db_fetch_object(db_query($sql, 0));          $types = db_fetch_object(db_query($sql, 0));
784        }        }
# Line 788  function og_content_type_admin_menu_alte Line 792  function og_content_type_admin_menu_alte
792        }        }
793    }    }
794    // Third: Allow access to site wide content ..    // Third: Allow access to site wide content ..
795      //TODO: Shouldn't this be in a an else block
796    $sql = "SELECT octa.types_active FROM {og_content_type_admin} octa WHERE octa.gid = -1";    $sql = "SELECT octa.types_active FROM {og_content_type_admin} octa WHERE octa.gid = -1";
797    $types = db_fetch_object(db_query($sql));    $types = db_fetch_object(db_query($sql));
798    $activated_types = unserialize($types->types_active);    $activated_types = unserialize($types->types_active);
# Line 812  function og_content_type_admin_node_add( Line 817  function og_content_type_admin_node_add(
817      $gid = $_GET[gids][0];      $gid = $_GET[gids][0];
818      $sql = "SELECT octa.types_active, octa.types_allowed FROM {og_content_type_admin} octa WHERE octa.gid = %d";      $sql = "SELECT octa.types_active, octa.types_allowed FROM {og_content_type_admin} octa WHERE octa.gid = %d";
819      //if we're keeping track of this group, get it's active types, otherwise, get the defaults      //if we're keeping track of this group, get it's active types, otherwise, get the defaults
820      if (!$result = db_fetch_object(db_query($sql, $_GET[gids][0]))) {      if (!$result = db_fetch_object(db_query($sql, $gid))) {
821        $result = db_fetch_object(db_query($sql, 0));        $result = db_fetch_object(db_query($sql, 0));
822      }      }
823      $activated_types = unserialize($result->types_active);      $activated_types = unserialize($result->types_active);
# Line 843  function og_content_type_admin_node_add( Line 848  function og_content_type_admin_node_add(
848      $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);      $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
849      drupal_set_title(t('Submit @name', array('@name' => $types[$type]->name)));      drupal_set_title(t('Submit @name', array('@name' => $types[$type]->name)));
850      $output = drupal_get_form($type. '_node_form', $node);      $output = drupal_get_form($type. '_node_form', $node);
851    }// If we have the gid, check if the user is a group admin. If so, allow them to create ALLOWED types that are not activated for their group members.     // TODO: if and elseif have the same logic
852      }// If we have the gid, check if the user is a group admin. If so, allow them to create ALLOWED types that are not ACTIVATED for their group members.
853    // Otherwise, if the user is not a group admin, they can only create types that are not DEACTIVATED.    // Otherwise, if the user is not a group admin, they can only create types that are not DEACTIVATED.
854    elseif (($look_at_allowed == 1) && isset($types[$type]) && node_access('create', $type) && ($allowed_for_group_admins || $allowed_for_users)) {    elseif (($look_at_allowed == 1) && isset($types[$type]) && node_access('create', $type) && ($allowed_for_group_admins || $allowed_for_users)) {
855      // Initialize settings:      // Initialize settings:
856      $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);      $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
857      drupal_set_title(t('Submit @name', array('@name' => $types[$type]->name)));      drupal_set_title(t('Submit @name', array('@name' => $types[$type]->name)));
858      $output = drupal_get_form($type. '_node_form', $node);      $output = drupal_get_form($type. '_node_form', $node);
859       // TODO: if and elseif(2) have the same logic
860    }    }
861    else {    else {
862      // If no (valid) node type has been provided, display a node type overview.      // If no (valid) node type has been provided, display a node type overview.
# Line 883  function og_content_type_admin_node_add( Line 890  function og_content_type_admin_node_add(
890    }    }
891    
892    return $output;    return $output;
893  } // function og_content_type_admin_node_add()  }
894    
895  /**  /**
896   * Implementation of hook_block(). See og_content_type_admin_block_details.   * Implementation of hook_block(). See og_content_type_admin_block_details.

Legend:
Removed from v.1.15.2.7  
changed lines
  Added in v.1.15.2.8

  ViewVC Help
Powered by ViewVC 1.1.2