function privatemsg_list in Privatemsg 6
Same name and namespace in other branches
- 5.3 privatemsg.module \privatemsg_list()
- 5 privatemsg.module \privatemsg_list()
- 6.2 privatemsg.pages.inc \privatemsg_list()
- 7.2 privatemsg.pages.inc \privatemsg_list()
- 7 privatemsg.pages.inc \privatemsg_list()
List messages.
Parameters
$form_state: Form state array
$argument: An argument to pass through to the query builder.
$uid: User id messages of another user should be displayed
Return value
Form array
3 string references to 'privatemsg_list'
- privatemsg_filter_menu in privatemsg_filter/
privatemsg_filter.module - Implements hook_menu().
- privatemsg_filter_menu_alter in privatemsg_filter/
privatemsg_filter.module - Implements hook_menu_alter().
- privatemsg_menu in ./
privatemsg.module - Implements hook_menu().
File
- ./
privatemsg.module, line 653 - Allows users to send private messages to other users.
Code
function privatemsg_list(&$form_state, $argument = 'list', $uid = NULL) {
global $user;
// Setting default behavior...
$account = $user;
// Because uid is submitted by the menu system, it's a string not a integer.
if ((int) $uid > 0 && $uid != $user->uid) {
// Trying to view someone else's messages...
if (!privatemsg_user_access('read all private messages')) {
drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning');
}
elseif ($account_check = user_load(array(
'uid' => $uid,
))) {
// Has rights and user_load return an array so user does exist
$account = $account_check;
}
}
// By this point we have figured out for which user we are listing messages and now it is safe to use $account->uid in the listing query.
$query = _privatemsg_assemble_query('list', $account, $argument);
$result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']);
$threads = array();
$form['#data'] = array();
while ($row = db_fetch_array($result)) {
// Store the raw row data.
$form['#data'][$row['thread_id']] = $row;
// store thread id for the checkboxes array
$threads[$row['thread_id']] = '';
}
if (!empty($form['#data'])) {
$form['actions'] = _privatemsg_action_form();
}
// Save the currently active account, used for actions.
$form['account'] = array(
'#type' => 'value',
'#value' => $account,
);
// Define checkboxes, pager and theme
$form['threads'] = array(
'#type' => 'checkboxes',
'#options' => $threads,
);
$form['pager'] = array(
'#value' => theme('pager'),
'#weight' => 20,
);
$form['#theme'] = 'privatemsg_list';
// Store the account for which the threads are displayed.
$form['#account'] = $account;
return $form;
}