You are here

function signup_user in Signup 5

Same name and namespace in other branches
  1. 5.2 signup.module \signup_user()
  2. 6.2 signup.module \signup_user()
  3. 6 signup.module \signup_user()

Implementation of hook_user().

When viewing a user profile page, display their current signup schedule.

When a user is deleted, cancel all of that user's signups to remove all instances of that user from the {signup_log} table, free up space in events with signup limits, etc.

Related topics

File

./signup.module, line 244

Code

function signup_user($op, &$edit, &$user, $category = NULL) {
  switch ($op) {
    case 'view':

      // grab list of events the user signed up for.
      $signups = signup_list_user_signups($user->uid);
      if (count($signups)) {
        $output = '<h4>' . t('Current signups') . ' -- ' . l(t('view signup schedule'), "user/{$user->uid}/signups") . '</h4>' . theme_item_list($signups);
      }
      if (isset($output)) {
        return array(
          t('Signup information') => array(
            array(
              'value' => $output,
              'class' => 'user',
            ),
          ),
        );
      }
      break;
    case 'delete':
      $uids = array();
      if (is_array($edit['accounts'])) {

        // A multi-user delete from Admin > User management > Users.
        $uids = $edit['accounts'];
      }
      else {

        // A single-user delete from the edit tab on the user's profile.
        $uids[] = $edit['uid'];
      }
      foreach ($uids as $uid) {
        $nids = db_query("SELECT nid FROM {signup_log} WHERE uid = %d", $uid);
        while ($data = db_fetch_object($nids)) {
          signup_cancel_signup($uid, $data->nid);
        }
      }
      break;
  }
}