You are here

function notifications_user in Notifications 7

Same name and namespace in other branches
  1. 5 notifications.module \notifications_user()
  2. 6.4 notifications.module \notifications_user()
  3. 6 notifications.module \notifications_user()
  4. 6.2 notifications.module \notifications_user()
  5. 6.3 notifications.module \notifications_user()

Implementation of hook_user().

1 string reference to 'notifications_user'
NotificationsUserTestCase::setUp in notifications_user/notifications_user.test
Sets up a Drupal site for running functional and integration tests.

File

./notifications.module, line 665
Notifications module

Code

function notifications_user($type, $edit, $user, $category = NULL) {
  switch ($type) {
    case 'update':
      if (isset($edit['status'])) {
        if ($edit['status'] == 0) {

          // user is being blocked now
          // Delete pending notifications and block existing active subscriptions
          db_query('UPDATE {notifications_subscription} SET status = %d WHERE status = %d AND uid = %d', Notifications_Subscription::STATUS_BLOCKED, Notifications_Subscription::STATUS_ACTIVE, $user->uid);
          notifications_queue()
            ->queue_clean(array(
            'uid' => $user->uid,
          ));
        }
        else {

          // User may be being unblocked, unblock subscriptions if any
          db_query('UPDATE {notifications_subscription} SET status = %d WHERE status = %d AND uid = %d', Notifications_Subscription::STATUS_ACTIVE, Notifications_Subscription::STATUS_BLOCKED, $user->uid);
        }
      }
      break;
    case 'after_update':

      // Update language for all existing subscriptions
      if ($language = user_preferred_language($user)) {
        db_query("UPDATE {notifications_subscription} SET language = '%s' WHERE uid = %d", $language->language, $user->uid);
      }
      break;
  }
}