function notify_admin_users_submit in Notify 7
Same name and namespace in other branches
- 5.2 notify.module \notify_admin_users_submit()
- 5 notify.module \notify_admin_users_submit()
- 6 notify.module \notify_admin_users_submit()
Submit for the notify_admin_users form.
File
- ./
notify.admin.inc, line 805 - Administrative pages callbacks for the Notify module.
Code
function notify_admin_users_submit($form, &$form_state) {
unset($form);
$messages = 0;
if (isset($form_state['values']['import']) && 1 == $form_state['values']['import']) {
variable_set('notify_import', 1);
drupal_set_message(t('Will subscribe users when importing.'));
$messages++;
}
else {
if (variable_get('notify_import', 0)) {
variable_set('notify_import', 0);
drupal_set_message(t('Will no longer subscribe users when importing.'));
$messages++;
}
}
if (isset($form_state['values']['bulk']) && 1 == $form_state['values']['bulk']) {
$node = variable_get('notify_def_node', 1);
$comment = variable_get('notify_def_comment', 0);
$teasers = variable_get('notify_def_teasers', 0);
$result = db_query('SELECT u.uid, u.name FROM {users} u WHERE u.uid > 0 AND status = 1 AND u.uid NOT IN (SELECT n.uid FROM {notify} n)');
foreach ($result as $record) {
db_insert('notify')
->fields(array(
'uid' => $record->uid,
'status' => 1,
'node' => $node,
'comment' => $comment,
'teasers' => $teasers,
'attempts' => 0,
))
->execute();
}
}
elseif (!array_key_exists('users', $form_state['values'])) {
if (!$messages) {
drupal_set_message(t('No users have notifications enabled.'), 'warning');
}
return;
}
if (isset($form_state['values']['users']) && $form_state['values']['users']) {
foreach ($form_state['values']['users'] as $uid => $settings) {
db_update('notify')
->fields(array(
'node' => $settings['node'],
'teasers' => $settings['teasers'],
'comment' => $settings['comment'],
))
->condition('uid', $uid)
->execute();
}
}
drupal_set_message(t('Notify settings saved.'));
}