| 1 |
<?php |
<?php |
| 2 |
// $Id: createcontentblock.module,v 1.1.2.1 2007/11/03 20:18:08 douggreen Exp $ |
// $Id: createcontentblock.module,v 1.1.2.2 2007/11/08 22:45:03 douggreen Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 47 |
break; |
break; |
| 48 |
|
|
| 49 |
case 'view': |
case 'view': |
| 50 |
return array( |
if ($init = createcontentblock_form_init()) { |
| 51 |
'content' => drupal_get_form('createcontentblock_form'), |
return array('content' => drupal_get_form('createcontentblock_form', $init)); |
| 52 |
); |
} |
| 53 |
|
break; |
| 54 |
} |
} |
| 55 |
} |
} |
| 56 |
|
|
| 57 |
function createcontentblock_form() { |
function createcontentblock_form_init() { |
|
$form = array(); |
|
|
|
|
| 58 |
$subscribe = FALSE; |
$subscribe = FALSE; |
| 59 |
if ($og = module_exists('og')) { |
if ($og = module_exists('og')) { |
| 60 |
$group_node = og_get_group_context(); |
$group_node = og_get_group_context(); |
| 62 |
if (isset($user->og_groups[$group_node->nid])) { |
if (isset($user->og_groups[$group_node->nid])) { |
| 63 |
// add only OG groups we have access to |
// add only OG groups we have access to |
| 64 |
$group_nid = $group_node->nid; |
$group_nid = $group_node->nid; |
|
$form['gid'] = array( |
|
|
'#type' => 'hidden', |
|
|
'#value' => $group_nid, |
|
|
); |
|
| 65 |
} |
} |
| 66 |
else { |
else { |
| 67 |
$subscribe = $group_node->nid; |
$subscribe = $group_node->nid; |
| 72 |
$exempt = array(); |
$exempt = array(); |
| 73 |
} |
} |
| 74 |
|
|
| 75 |
$options[] = t('-- Select One --'); |
$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; |
| 98 |
} |
} |
| 99 |
} |
} |
| 100 |
} |
} |
| 101 |
if ($subscribe) { |
|
| 102 |
|
if (count($options)) { |
| 103 |
|
return array('options' => $options, 'group_nid' => $group_nid, 'subscribe' => $subscribe); |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
function createcontentblock_form($init) { |
| 108 |
|
$form = array(); |
| 109 |
|
if (isset($init['group_nid'])) { |
| 110 |
|
$form['gid'] = array( |
| 111 |
|
'#type' => 'hidden', |
| 112 |
|
'#value' => $init['group_nid'], |
| 113 |
|
); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
$options[] = t('-- Select One --'); |
| 117 |
|
$options += $init['options']; |
| 118 |
|
if ($init['subscribe']) { |
| 119 |
$form['subscribe'] = array( |
$form['subscribe'] = array( |
| 120 |
'#value' => l(t('Subscribe to Add Content to this Group'), 'og/subscribe/'. $subscribe, array(), 'destination=node/'. $subscribe), |
'#value' => l(t('Subscribe to Add Content to this Group'), 'og/subscribe/'. $init['subscribe'], array(), 'destination=node/'. $init['subscribe']), |
| 121 |
); |
); |
| 122 |
} |
} |
| 123 |
$form['type'] = array( |
$form['type'] = array( |
| 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()); |
| 134 |
|
$empty = (count($options) <= 1); |
| 135 |
return $form; |
return $form; |
| 136 |
} |
} |
| 137 |
|
|