/[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.4, Thu Nov 6 00:06:49 2008 UTC revision 1.15.2.5, Thu Nov 6 22:52:12 2008 UTC
# Line 758  function theme_og_content_type_admin_own Line 758  function theme_og_content_type_admin_own
758   * for directly entering in an illegal url. Other functions handle these problems.   * for directly entering in an illegal url. Other functions handle these problems.
759   */   */
760  function og_content_type_admin_menu_alter(&$callbacks) {   // $types used twice!!!!!  function og_content_type_admin_menu_alter(&$callbacks) {   // $types used twice!!!!!
761    global $user;    global $user;
762      $post_type = arg(2);
763    if ($node = og_get_group_context()) {    // First: Deny access to all content types and handle all create content pages.
764          $gid = $node->nid;    $types = node_get_types();
765      foreach ($types as $type) {
766            $type = $type->type;
767            $node_type = isset($type) ? str_replace('_', '-', $type) : NULL;
768        $type_path = "node/add/$node_type";
769        $callbacks[$type_path]['access callback'] = FALSE;
770        $callbacks[$type_path]['page callback'] = 'og_content_type_admin_node_add';
771      }
772      $callbacks['node/add']['page callback'] = 'og_content_type_admin_node_add';
773      // Second: Allow access to add a particlar type of group content
774      if (is_array($_GET[gids])) {
775        $gid = $_GET[gids][0];
776      $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";
777        //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
778        $types = db_fetch_object(db_query($sql, $node->nid));        $types = db_fetch_object(db_query($sql, $node->nid));
779        if (!count($types->types_active)) {        if (!count($types->types_active)) {
780          $types = db_fetch_object(db_query($sql, 0));          $types = db_fetch_object(db_query($sql, 0));
781        }        }
782        $activated_types = unserialize($types->types_active);        $activated_types = unserialize($types->types_active);
783        $allowed_types = unserialize($types->types_allowed);        foreach ($activated_types as $type => $value) {
784        $look_at_allowed = 1;           $node_type = isset($type) ? str_replace('_', '-', $type) : NULL;
785    } else {           if ($node_type == $post_type) {
786          $sql = "SELECT octa.types_active FROM {og_content_type_admin} octa WHERE octa.gid = -1";             $type_path = "node/add/$node_type";
787      $types = db_fetch_object(db_query($sql));             $callbacks[$type_path]['access callback'] = TRUE;
788      $activated_types = unserialize($types->types_active);           }
789      $look_at_allowed = 0;        }
790    }    }
791      // Third: Allow access to site wide content ..
792      $sql = "SELECT octa.types_active FROM {og_content_type_admin} octa WHERE octa.gid = -1";
793      $types = db_fetch_object(db_query($sql));
794      $activated_types = unserialize($types->types_active);
795    foreach ($activated_types as $type => $value) {    foreach ($activated_types as $type => $value) {
796          $node_type = isset($type) ? str_replace('_', '-', $type) : NULL;  //print " ".$type;          $node_type = isset($type) ? str_replace('_', '-', $type) : NULL;
797      $type_path = "node/add/$node_type";      $type_path = "node/add/$node_type";  //print_r($types);
798      $callbacks[$type_path]['access callback'] = FALSE;      if ($activated_types[$type] && node_access('create', $type)) {
799      $allowed_for_group_admins = (($allowed_types[$type] != NOT_ASSIGNED_TO_GROUP) && (_og_content_type_admin_is_admin_content_access_nid($gid)));         $callbacks[$type_path]['access callback'] = TRUE;
800      $allowed_for_users = (($activated_types[$type] != DEACTIVATED) && (!_og_content_type_admin_is_admin_content_access_nid($gid)));      }
801      $types = node_get_types();    }
802      if ((($user->uid == 1) && isset($types[$type])) || (($look_at_allowed == 0) && isset($types[$type]) && node_access('create', $type) && ($activated_types[$type] != DEACTIVATED)) || (($look_at_allowed == 1) && isset($types[$type]) && node_access('create', $type) && ($allowed_for_group_admins || $allowed_for_users)) ) {  }
803        $callbacks[$type_path]['access callback'] = TRUE;  // 1. why is this function called twice
804      }  // 2. why is og_content_type_admin_node_add() not being called
   }  
    $callbacks['node/add']['page callback'] = 'og_content_type_admin_node_add';  
  }  
   
   
805   /**   /**
806   * Interception of the node module's node_add function.   * Interception of the node module's node_add function.
807   *   *
808   * Present a node submission form or a set of links to such forms.   * Present a node submission form or a set of links to such forms.
809   */   */
810  function og_content_type_admin_node_add($type = NULL) {  function og_content_type_admin_node_add($type = NULL) {  // we are only coming here for node/add
811    global $user, $_GET;    global $user, $_GET;
   
   $gid = NULL;  
   
812    //if there is a group context, get the active types for the group, otherwise, use the site-wide list    //if there is a group context, get the active types for the group, otherwise, use the site-wide list
813    if (is_array($_GET[gids])) {    if (is_array($_GET[gids])) {
814      $gid = $_GET[gids][0];      $gid = $_GET[gids][0];
# Line 816  function og_content_type_admin_node_add( Line 822  function og_content_type_admin_node_add(
822      $look_at_allowed = 1;      $look_at_allowed = 1;
823    }    }
824    else {    else {
825      $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";
826      $holder = db_fetch_object(db_query($sql));    $result = db_fetch_object(db_query($sql));
827      $activated_types = unserialize($holder->types_active);    $activated_types = unserialize($result->types_active);
828      $look_at_allowed = 0;    $look_at_allowed = 0;
829    }    }
830      $types = node_get_types();
   $types = node_get_types();  
   if (module_exists('nf_registration_mod')) {  
     $pageroute_types = _nf_registration_mod_menu_status();  
     foreach ($pageroute_types as $typea => $nums) {  
       if ($nums[1] == 48) {  
         if (isset($types[$typea])) {  
           unset($types[$typea]);  
         }  
       }  
     }  
   }  
831    $type = isset($type) ? str_replace('-', '_', $type) : NULL;    $type = isset($type) ? str_replace('-', '_', $type) : NULL;
832    $allowed_for_group_admins = (($allowed_types[$type] != NOT_ASSIGNED_TO_GROUP) && (_og_content_type_admin_is_admin_content_access_nid($gid)));    $allowed_for_group_admins = (($allowed_types[$type] != NOT_ASSIGNED_TO_GROUP) && (_og_content_type_admin_is_admin_content_access_nid($gid)));
833    $allowed_for_users = (($activated_types[$type] != DEACTIVATED) && (!_og_content_type_admin_is_admin_content_access_nid($gid)));    $allowed_for_users = (($activated_types[$type] != DEACTIVATED) && (!_og_content_type_admin_is_admin_content_access_nid($gid)));
# Line 867  function og_content_type_admin_node_add( Line 862  function og_content_type_admin_node_add(
862          $type_url_str = str_replace('_', '-', $type->type);          $type_url_str = str_replace('_', '-', $type->type);
863          $title = t('Add a new @s.', array('@s' => $type->name));          $title = t('Add a new @s.', array('@s' => $type->name));
864          if ($gid != NULL) {          if ($gid != NULL) {
865            $out = '<dt>' .l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('title' => $title), "gids[]=$gid"). '</dt>';            $out = '<dt>' .l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('query' => "gids[]=$gid")). '</dt>';
866          }          }
867          else {          else {
868            $out = '<dt>' .l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('title' => $title)). '</dt>';            $out = '<dt>' .l(drupal_ucfirst($type->name), "node/add/$type_url_str"). '</dt>';
869          }          }
870          $out .= '<dd>' .filter_xss_admin($type->description). '</dd>';          $out .= '<dd>' .filter_xss_admin($type->description). '</dd>';
871          $item[$type->type] = $out;          $item[$type->type] = $out;

Legend:
Removed from v.1.15.2.4  
changed lines
  Added in v.1.15.2.5

  ViewVC Help
Powered by ViewVC 1.1.2