You are here

function apply_for_role_deny_apply in Apply for role 7

Same name and namespace in other branches
  1. 5 apply_for_role.module \apply_for_role_deny_apply()
  2. 6 apply_for_role.module \apply_for_role_deny_apply()
  3. 7.2 apply_for_role.module \apply_for_role_deny_apply()

Deny a role application.

Parameters

$user: A user object.

$rid: A role ID.

Return value

A boolean indicating success.

1 call to apply_for_role_deny_apply()
apply_for_role_deny_form_submit in ./apply_for_role.admin.inc

File

./apply_for_role.module, line 537
Allows users to apply for roles.

Code

function apply_for_role_deny_apply($user, $rid) {
  $uid = $user->uid;
  if ($apply = db_query("SELECT * FROM {users_roles_apply} WHERE uid = :uid AND rid = :rid AND approved <> :approved", array(
    ':uid' => $uid,
    ':rid' => $rid,
    ':approved' => APPLY_FOR_ROLE_DENIED,
  ))
    ->fetchObject()) {
    apply_for_role_delete_role($uid, $rid);
    $apply->approve_date = REQUEST_TIME;
    $apply->approved = APPLY_FOR_ROLE_DENIED;
    drupal_write_record('users_roles_apply', $apply, array(
      'uid',
      'rid',
    ));
    module_invoke_all('apply_for_role', 'deny', $apply);
    return TRUE;
  }
  return FALSE;
}