You are here

function uc_roles_delete in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_roles/uc_roles.module \uc_roles_delete()

Deletes an expiration using user id or user id and rid.

This function deletes expirations associated with users and roles. If no role ID is passed, the function deletes all role expirations associated with the given user. Otherwise, the function only deletes expirations whose user and role IDs match. If any roles were actually deleted, the function notifies the user. The menu cache is then flushed, as privileges to view menu items may have been lost in the process.

Parameters

$account: A Drupal user object.

int $rid: A Drupal role ID.

bool $silent: When set to TRUE will suppress any Drupal messages from this function.

7 calls to uc_roles_delete()
uc_roles_cron in uc_roles/uc_roles.module
Implements hook_cron().
uc_roles_deletion_form_submit in uc_roles/uc_roles.admin.inc
Submission handler for uc_roles_deletion_form().
uc_roles_grant in uc_roles/uc_roles.module
Grants a role to a given user.
uc_roles_renew in uc_roles/uc_roles.module
Renews a given role on a user.
uc_roles_revoke in uc_roles/uc_roles.module
Revokes a role on a given user.

... See full list

File

uc_roles/uc_roles.module, line 991
Grants roles upon accepted payment of products.

Code

function uc_roles_delete($account, $rid = NULL, $silent = FALSE) {
  global $user;
  $query = db_delete('uc_roles_expirations')
    ->condition('uid', $account->uid);
  if ($rid) {
    $query
      ->condition('rid', $rid);
  }

  // Echo the deletion only if something was actually deleted.
  if ($query
    ->execute() && !$silent) {
    if ($user->uid == $account->uid) {
      drupal_set_message(t('The expiration of your %role_name role has been deleted.', array(
        '%role_name' => _uc_roles_get_name($rid),
      )));
    }
    else {
      drupal_set_message(t('The expiration of %role_name role for the user !user has been deleted.', array(
        '!user' => theme('username', array(
          'account' => $account,
          'name' => check_plain(format_username($account)),
          'link_path' => 'user/' . $account->uid,
        )),
        '%role_name' => _uc_roles_get_name($rid),
      )));
    }
  }

  // Flush visible menu items, since our permissions could've changed.
  _uc_roles_flush_menu_cache($account);
}