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

Diff of /contributions/modules/createcontentblock/createcontentblock.module

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

revision 1.1.2.3, Tue Dec 18 20:53:22 2007 UTC revision 1.1.2.4, Tue Dec 18 23:43:42 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: createcontentblock.module,v 1.1.2.2 2007/11/08 22:45:03 douggreen Exp $  // $Id: createcontentblock.module,v 1.1.2.3 2007/12/18 20:53:22 douggreen Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 55  function createcontentblock_block($op = Line 55  function createcontentblock_block($op =
55  }  }
56    
57  function createcontentblock_form_init() {  function createcontentblock_form_init() {
58    $subscribe = FALSE;    $init = array();
59    
60    if ($og = module_exists('og')) {    if ($og = module_exists('og')) {
61      $group_node = og_get_group_context();      $group_node = og_get_group_context();
62      global $user;      global $user;
63      if (isset($user->og_groups[$group_node->nid])) {      if (isset($user->og_groups[$group_node->nid])) {
64        // add only OG groups we have access to        // add only OG groups we have access to
65        $group_nid = $group_node->nid;        $init['group_nid'] = $group_node->nid;
66      }      }
67      else {      else {
68        $subscribe = $group_node->nid;        $init['subscribe_nid'] = $group_node->nid;
69      }      }
70      $exempt = array_merge(variable_get('og_node_types', array('og')), variable_get('og_omitted', array()));      $exempt = array_merge(variable_get('og_node_types', array('og')), variable_get('og_omitted', array()));
71    }    }
# Line 72  function createcontentblock_form_init() Line 73  function createcontentblock_form_init()
73      $exempt = array();      $exempt = array();
74    }    }
75    
76    $options = array();    $init['options'] = array();
77    foreach (node_get_types() as $type) {    foreach (node_get_types() as $type) {
78      if (module_invoke(node_get_types('module', $type), 'access', 'create', $type)) {      if (module_invoke(node_get_types('module', $type), 'access', 'create', $type)) {
79        $name = $type->name;        $name = $type->name;
80        if ($og) {        if ($og) {
81          if (isset($group_nid)) {          if (isset($init['group_nid'])) {
82            if (!in_array($type->type, $exempt)) {            if (!in_array($type->type, $exempt)) {
83              $name .= ' ('. t('this group') .')';              $name .= ' ('. t('this group') .')';
84            }            }
85          }          }
86          else {          else {
87            if (!in_array($type->type, $exempt)) {            if (!in_array($type->type, $exempt)) {
88              if (isset($subscribe)) {              if (isset($init['subscribe_nid'])) {
89                unset($name);                unset($name);
90              }              }
91              else {              else {
# Line 94  function createcontentblock_form_init() Line 95  function createcontentblock_form_init()
95          }          }
96        }        }
97        if (isset($name)) {        if (isset($name)) {
98          $options[$type->type] = $name;          $init['options'][$type->type] = $name;
99        }        }
100      }      }
101    }    }
102    
103    if (count($options)) {    if (count($init['options'])) {
104      return array('options' => $options, 'group_nid' => $group_nid, 'subscribe' => $subscribe);      return $init;
105    }    }
106  }  }
107    
# Line 112  function createcontentblock_form($init) Line 113  function createcontentblock_form($init)
113        '#value' => $init['group_nid'],        '#value' => $init['group_nid'],
114      );      );
115    }    }
116      if (isset($init['subscribe_nid'])) {
   $options[] = t('-- Select One --');  
   $options += $init['options'];  
   if ($init['subscribe']) {  
117      $form['subscribe'] = array(      $form['subscribe'] = array(
118        '#value' => l(t('Subscribe to Add Content to this Group'), 'og/subscribe/'. $init['subscribe'], array(), 'destination=node/'. $init['subscribe']),        '#value' => l(t('Subscribe to Add Content to this Group'), 'og/subscribe/'. $init['subscribe_nid'], array(), 'destination=node/'. $init['subscribe']),
119      );      );
120    }    }
121      $options = array(t('-- Select One --'));
122      $options += $init['options'];
123    $form['type'] = array(    $form['type'] = array(
124      '#type' => 'select',      '#type' => 'select',
125      '#options' => $options,      '#options' => $options,
# Line 131  function createcontentblock_form($init) Line 131  function createcontentblock_form($init)
131      '#value' => variable_get('createcontentblock_button_label', t('Create Content')),      '#value' => variable_get('createcontentblock_button_label', t('Create Content')),
132    );    );
133    $form['#submit'] = array('createcontentblock_form_submit' => array());    $form['#submit'] = array('createcontentblock_form_submit' => array());
   $empty = (count($options) <= 1);  
134    return $form;    return $form;
135  }  }
136    

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2