function user_relationships_api_cron in User Relationships 5.3
Same name and namespace in other branches
- 6 user_relationships_api/user_relationships_api.module \user_relationships_api_cron()
Implementation of hook_cron().
File
- user_relationships_api/
user_relationships_api.module, line 190
Code
function user_relationships_api_cron() {
$now = time();
// only expire relationships once a day
$last_cron = variable_get('user_relationships_last_expire', 0);
if ($now > $last_cron + 24 * 60 * 60) {
return FALSE;
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query(" DELETE ur\n FROM user_relationships ur \n INNER JOIN user_relationship_types urt USING ( rtid )\n WHERE ur.approved = 0 \n AND urt.expires_val > 0 \n AND %d > (ur.updated_at + (urt.expires_val * 24 * 60 *60))", $now);
break;
}
// remember when we last expired relationships
variable_set('user_relationships_last_expire', $now);
return TRUE;
}