function notifications_manage_subscriptions_form in Notifications 6.2
Same name and namespace in other branches
- 6.4 notifications.manage.inc \notifications_manage_subscriptions_form()
- 6 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 65 - 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)) {
$subscriptions[$sub->sid] = '';
// Naming for this specific subscription, formatted strings
$form['type'][$sub->sid] = array(
'#value' => notifications_subscription_types($sub->type, 'title'),
);
// If full loading, load full subscription and add description
if ($full) {
$sub = notifications_load_subscription($sub);
$format = notifications_format_subscription($sub, 'array');
$form['description'][$sub->sid] = array(
'#value' => $format['name'],
);
}
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],
);
// These links will be different depending on whether we are under admin or user account
if ($account) {
$operations = array(
l(t('edit'), 'user/' . $account->uid . '/notifications/subscriptions/edit/' . $sub->sid, array(
'query' => $destination,
)),
l(t('drop'), 'user/' . $account->uid . '/notifications/subscriptions/delete/' . $sub->sid, array(
'query' => $destination,
)),
);
}
else {
$operations = array(
l(t('edit'), 'notifications/subscription/' . $sub->sid, array(
'query' => $destination,
)),
l(t('drop'), 'notifications/unsubscribe/sid/' . $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;
}