/[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.4, Tue Dec 18 23:43:42 2007 UTC revision 1.1.2.5, Wed Dec 19 00:09:27 2007 UTC
# Line 55  function createcontentblock_block($op = Line 55  function createcontentblock_block($op =
55  }  }
56    
57  function createcontentblock_form_init() {  function createcontentblock_form_init() {
58    $init = array();    $init = array('options' => 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();
# Line 73  function createcontentblock_form_init() Line 73  function createcontentblock_form_init()
73      $exempt = array();      $exempt = array();
74    }    }
75    
   $init['options'] = array();  
76    foreach (node_get_types() as $type) {    foreach (node_get_types() as $type) {
77      if (module_invoke(node_get_types('module', $type), 'access', 'create', $type)) {      if (module_invoke(node_get_types('module', $type), 'access', 'create', $type)) {
78        $name = $type->name;        $name = $type->name;
# Line 101  function createcontentblock_form_init() Line 100  function createcontentblock_form_init()
100    }    }
101    
102    if (count($init['options'])) {    if (count($init['options'])) {
103        $init['destination'] = theme('destination', $init);
104      return $init;      return $init;
105    }    }
106  }  }
107    
108  function createcontentblock_form($init) {  function createcontentblock_form($init) {
109    $form = array();    $form = array();
110      if ($init['destination']) {
111        $form['dest'] = array(
112          '#type' => 'hidden',
113          '#value' => $init['destination'],
114        );
115      }
116    if (isset($init['group_nid'])) {    if (isset($init['group_nid'])) {
117      $form['gid'] = array(      $form['gid'] = array(
118        '#type' => 'hidden',        '#type' => 'hidden',
# Line 134  function createcontentblock_form($init) Line 140  function createcontentblock_form($init)
140    return $form;    return $form;
141  }  }
142    
143    /**
144     * Use a theme overridable function so that the site developer can hook the
145     * this process and specify an alternate destination URL.
146     *
147     * The default behavior is to not set the destination.
148     */
149    function theme_destination($init) {
150    //return $_GET['q'];
151    }
152    
153  function createcontentblock_form_submit($form_id, &$form) {  function createcontentblock_form_submit($form_id, &$form) {
154      $fragment = array();
155      if (isset($form['dest'])) {
156        $fragment[] = 'destination='. $form['dest'];
157      }
158    if (!empty($form['type'])) {    if (!empty($form['type'])) {
159      if (empty($form['gid'])) {      if (empty($form['gid'])) {
160        drupal_goto('node/add/'. $form['type']);        drupal_goto('node/add/'. $form['type'], implode('&', $fragment));
161      }      }
162      else {      else {
163        drupal_goto('node/add/'. $form['type'], 'gids[]='. $form['gid']);        $fragment[] = 'gids[]='. $form['gid'];
164          drupal_goto('node/add/'. $form['type'], implode('&', $fragment));
165      }      }
166    }    }
167    elseif (isset($form['gid'])) {    elseif (isset($form['gid'])) {
168      drupal_goto('node/add-og', 'gids[]='. $form['gid']);      $fragment[] = 'gids[]='. $form['gid'];
169        drupal_goto('node/add-og', implode('&', $fragment));
170    }    }
171    else {    else {
172      drupal_goto('node/add');      drupal_goto('node/add', implode('&', $fragment));
173    }    }
174  }  }
175    

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

  ViewVC Help
Powered by ViewVC 1.1.2