function notifications_ui_form_alter in Notifications 6.2
Same name and namespace in other branches
- 5 notifications_ui/notifications_ui.module \notifications_ui_form_alter()
- 6.4 notifications_ui/notifications_ui.module \notifications_ui_form_alter()
- 6 notifications_ui/notifications_ui.module \notifications_ui_form_alter()
- 6.3 notifications_ui/notifications_ui.module \notifications_ui_form_alter()
- 7 notifications_ui/notifications_ui.module \notifications_ui_form_alter()
Implementation of hook_form_alter()
File
- notifications_ui/
notifications_ui.module, line 170 - User Interface for subscriptions modules
Code
function notifications_ui_form_alter(&$form, $form_state, $form_id) {
global $user;
// Content type settings
switch ($form_id) {
case 'node_type_form':
if (isset($form['identity']['type'])) {
// Just in case we want to add more settings here
$form['notifications']['notifications_node_ui'] = array(
'#type' => 'checkboxes',
'#title' => t('Subscriptions UI'),
'#default_value' => notifications_ui_node_options($form['#node_type']->type),
'#options' => _notifications_ui_node_options(),
'#description' => t('Enable different display options for subscriptions to this content type.'),
);
if (!variable_get('notifications_ui_per_type', 0)) {
$form['notifications']['notifications_node_ui']['#disabled'] = TRUE;
$form['notifications']['notifications_node_ui']['#description'] .= ' <strong>' . t('To enable these options check the <a href="@notifications-ui-settings">Notifications UI settings</a>', array(
'@notifications-ui-settings' => url('admin/messaging/notifications/ui'),
)) . '</strong>';
}
}
break;
case 'comment_form':
// Add to comment forms.
$node = node_load($form['nid']['#value']);
if ($user->uid && notifications_ui_node_options($node->type, 'comment')) {
$form[] = notifications_ui_node_subform($node);
}
break;
case 'notifications_user_overview':
// Create new subscription
$account = $form['account']['#value'];
foreach (notifications_ui_subscription_types() as $key => $type) {
if (notifications_ui_subscription_type($key) && notifications_ui_user_options('create') && notifications_access_user_add($account, $key)) {
$create[] = l($type['title'], "user/{$account->uid}/notifications/add/{$key}");
}
}
if (!empty($create)) {
// $output .= theme('item_list', $create, t('or create a new subscription'));
$form['create'] = array(
'#type' => 'item',
'#weight' => 30,
'#title' => t('or create a new subscription'),
'#value' => theme('item_list', $create),
);
}
break;
default:
if (isset($form['type']['#value']) && $form['type']['#value'] . '_node_form' == $form_id && notifications_ui_node_options($form['type']['#value'], 'form')) {
// Add node forms.
$node = $form['#node'];
$form[] = notifications_ui_node_subform($node);
}
}
}