function _privatemsg_assemble_query in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.module \_privatemsg_assemble_query()
- 6 privatemsg.module \_privatemsg_assemble_query()
- 7.2 privatemsg.module \_privatemsg_assemble_query()
Generates a query based on a query id.
Parameters
$query: Either be a string ('some_id') or an array('group_name', 'query_id'), if a string is supplied, group_name defaults to 'privatemsg'.
Return value
SelectQuery Array with the keys query and count. count can be used to count the elements which would be returned by query. count can be used together with pager_query().
Related topics
15 calls to _privatemsg_assemble_query()
- privatemsg_cron in ./
privatemsg.module - Implements hook_cron().
- privatemsg_filter_form in privatemsg_filter/
privatemsg_filter.module - Form to show and allow modification of tagging information for a conversation.
- privatemsg_filter_form_privatemsg_list_alter in privatemsg_filter/
privatemsg_filter.module - Implements hook_form_FORM_ID_alter() to add a filter widget to the message listing pages.
- privatemsg_filter_show_tags in privatemsg_filter/
privatemsg_filter.module - privatemsg_filter_tags_autocomplete in privatemsg_filter/
privatemsg_filter.pages.inc - Return autocomplete results for tags.
File
- ./
privatemsg.module, line 2039 - Allows users to send private messages to other users.
Code
function _privatemsg_assemble_query($query) {
// Modules will be allowed to choose the prefix for the query builder,
// but if there is not one supplied, 'privatemsg' will be taken by default.
if (is_array($query)) {
$query_id = $query[0];
$query_group = $query[1];
}
else {
$query_id = $query;
$query_group = 'privatemsg';
}
/**
* Begin: dynamic arguments
*/
$args = func_get_args();
unset($args[0]);
// We do the merge because we call call_user_func_array and not drupal_alter.
// This is necessary because otherwise we would not be able to use $args
// correctly (otherwise it doesn't unfold).
$query_function = $query_group . '_sql_' . $query_id;
if (!function_exists($query_function)) {
drupal_set_message(t('Query function %function does not exist', array(
'%function' => $query_function,
)), 'error');
return FALSE;
}
$query = call_user_func_array($query_function, $args);
// Add a tag to make it alterable.
$query
->addTag($query_group . '_' . $query_id);
// Add arguments as metadata.
foreach ($args as $id => $arg) {
$query
->addMetaData('arg_' . $id, $arg);
}
return $query;
}