You are here

function role_expire_write_record in Role Expire 6

Same name and namespace in other branches
  1. 7 role_expire.module \role_expire_write_record()

API function; Insert or update a record in the database.

Parameters

$rid: Role ID.

$uid: User ID.

$expiry_time: The expiration time string.

3 calls to role_expire_write_record()
role_expire_process_default_role_duration_for_user in ./role_expire.module
role_expire_rules_action_set_role_expire in ./role_expire.rules.inc
Action: Add expire time to role.
role_expire_user in ./role_expire.module
Implementation of hook_user().

File

./role_expire.module, line 86
Role Expire module

Code

function role_expire_write_record($uid, $rid, $expiry_timestamp) {
  $existing = db_result(db_query("SELECT expiry_timestamp FROM {role_expire} WHERE uid = %d AND rid = %d", $uid, $rid));
  if ($existing && $expiry_timestamp != $existing) {
    $result = db_query("UPDATE {role_expire} SET expiry_timestamp = %d WHERE uid = %d AND rid = %d", $expiry_timestamp, $uid, $rid);
  }
  elseif ($existing == FALSE) {
    db_query("INSERT INTO {role_expire} (uid, rid, expiry_timestamp) VALUES (%d, %d, %d)", $uid, $rid, $expiry_timestamp);
  }
}