Commit 43d70bd4 authored by dealancer's avatar dealancer

#973882 by dealancer: updating randome handlers

parent 61fe1150
......@@ -18,6 +18,17 @@ class menu_token_node_random implements menu_token_handler {
}
function object_load($options) {
// Nothing to do here.
$nid = db_select('node', 'n')
->fields('n', array('nid'))
->orderRandom()
->range(0, 1)
->execute()
->fetchField(0);
if ($nid) {
return node_load($nid);
}
return FALSE;
}
}
......@@ -18,6 +18,17 @@ class menu_token_term_random implements menu_token_handler {
}
function object_load($options) {
// Nothing to do here.
$tid = db_select('taxonomy_term_data', 't')
->fields('t', array('tid'))
->orderRandom()
->range(0, 1)
->execute()
->fetchField(0);
if ($tid) {
return taxonomy_term_load($tid);
}
return FALSE;
}
}
......@@ -18,6 +18,18 @@ class menu_token_user_random implements menu_token_handler {
}
function object_load($options) {
// Nothing to do here.
$uid = db_select('users', 'u')
->fields('u', array('uid'))
->condition('uid', 0, '!=')
->orderRandom()
->range(0, 1)
->execute()
->fetchField(0);
if ($uid) {
return user_load($uid);
}
return FALSE;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment