function role_expire_write_record in Role Expire 7
Same name and namespace in other branches
- 6 role_expire.module \role_expire_write_record()
API function; Insert or update a record in the database.
Parameters
$uid: User ID.
$rid: Role ID.
$expiry_time: The expiration timestamp.
6 calls to role_expire_write_record()
- role_expire_process_default_role_duration_for_user in ./
role_expire.module - Sets the default role duration for the current user/role combination.
- role_expire_rules_action_extend_role_expire in ./
role_expire.rules.inc - Action: Extend expire time for role. Defaults to the current time.
- role_expire_rules_action_set_role_expire in ./
role_expire.rules.inc - Action: Add expire time to role.
- role_expire_rules_action_set_role_expire_to_longest in ./
role_expire.rules.inc - Action: Set expire time for role to longest attached to this user. Defaults to the current time.
- role_expire_user_insert in ./
role_expire.module - Implements hook_user_insert().
File
- ./
role_expire.module, line 104 - Role Expire module
Code
function role_expire_write_record($uid, $rid, $expiry_timestamp) {
$existing = db_query("SELECT expiry_timestamp FROM {role_expire} WHERE uid = :uid AND rid = :rid", array(
':uid' => $uid,
':rid' => $rid,
))
->fetchField();
if ($existing && $expiry_timestamp != $existing) {
$result = db_update('role_expire')
->fields(array(
'expiry_timestamp' => $expiry_timestamp,
))
->condition('uid', $uid)
->condition('rid', $rid)
->execute();
}
elseif ($existing == FALSE) {
$id = db_insert('role_expire')
->fields(array(
'uid' => $uid,
'rid' => $rid,
'expiry_timestamp' => $expiry_timestamp,
))
->execute();
}
}