function notifications_manage_subscriptions_form in Notifications 6
Same name and namespace in other branches
- 6.4 notifications.manage.inc \notifications_manage_subscriptions_form()
- 6.2 notifications.manage.inc \notifications_manage_subscriptions_form()
- 6.3 notifications.manage.inc \notifications_manage_subscriptions_form()
- 7 notifications.manage.inc \notifications_manage_subscriptions_form()
Administer user subscriptions
2 calls to notifications_manage_subscriptions_form()
- notifications_manage_admin_subscriptions in ./
notifications.manage.inc - Menu callback: subscriptions administration.
- notifications_manage_user_subscriptions in ./
notifications.manage.inc - Menu callback: user subscriptions management
File
- ./
notifications.manage.inc, line 64 - Common functions for bulk management of subscriptions
Code
function notifications_manage_subscriptions_form($account = NULL, $full = TRUE) {
$filter = notifications_subscriptions_build_filter_query($account);
if ($account) {
$result = pager_query('SELECT n.* FROM {notifications} n ' . $filter['join'] . $filter['where'] . ' ORDER BY n.sid DESC', 50, 0, NULL, $filter['args']);
}
else {
$result = pager_query('SELECT n.*, u.name FROM {notifications} n ' . $filter['join'] . ' INNER JOIN {users} u ON n.uid = u.uid ' . $filter['where'] . ' ORDER BY n.sid DESC', 50, 0, NULL, $filter['args']);
}
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array();
foreach (notifications_subscriptions_operations($account) as $operation => $array) {
if (!empty($array['parent'])) {
$options[$array['parent']][$operation] = $array['label'];
}
else {
$options[$operation] = $array['label'];
}
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'approve',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#validate' => array(
'notifications_manage_subscriptions_form_validate',
),
'#submit' => array(
'notifications_manage_subscriptions_form_submit',
),
);
$destination = drupal_get_destination();
$subscriptions = array();
$status = _notifications_subscription_status();
$send_methods = messaging_method_info(NULL, 'name');
$send_intervals = _notifications_send_intervals();
while ($sub = db_fetch_object($result)) {
if ($full) {
$sub = notifications_load_subscription($sub);
}
$subscriptions[$sub->sid] = '';
$name = notifications_subscription_types($sub->type, 'title');
$form['type'][$sub->sid] = array(
'#value' => $name ? $name : $sub->type,
);
// Build description using field formatters
if ($full) {
$description = array();
foreach ($sub->fields as $type => $value) {
$format = notifications_format_subscription_field($type, $value, TRUE);
$description[] = $format['value'];
}
}
$form['description'][$sub->sid] = array(
'#value' => implode(', ', $description),
);
if (!$account) {
$form['username'][$sub->sid] = array(
'#value' => theme('username', $sub),
);
}
$form['send_method'][$sub->sid] = array(
'#value' => !empty($send_methods[$sub->send_method]) ? $send_methods[$sub->send_method] : $sub->send_method,
);
$form['send_interval'][$sub->sid] = array(
'#value' => !empty($send_intervals[$sub->send_interval]) ? $send_intervals[$sub->send_interval] : $sub->send_interval,
);
$form['status'][$sub->sid] = array(
'#value' => $status[$sub->status],
);
$operations = array(
l(t('edit'), 'notifications/subscription/' . $sub->sid, array(
'query' => $destination,
)),
l(t('drop'), 'notifications/unsubscribe/' . $sub->sid, array(
'query' => $destination,
)),
);
$form['operations'][$sub->sid] = array(
'#value' => implode(', ', $operations),
);
}
$form['subscriptions'] = array(
'#type' => 'checkboxes',
'#options' => $subscriptions,
);
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
$form['#theme'] = 'notifications_manage_subscriptions';
return $form;
}