function privatemsg_list_form in Privatemsg 5
Same name and namespace in other branches
- 5.3 privatemsg.module \privatemsg_list_form()
1 string reference to 'privatemsg_list_form'
File
- ./
privatemsg.module, line 882
Code
function privatemsg_list_form($messages, $folders, $current_folder, $account) {
global $user;
$form['account'] = array(
'#type' => 'value',
'#value' => $account,
);
$form['messages'] = array(
'#theme' => 'privatemsg_message_table',
'#tree' => TRUE,
);
$form['messages']['current_folder'] = array(
'#type' => 'value',
'#value' => $current_folder,
);
foreach ($messages as $message) {
if ($current_folder != 1) {
$new = $message->newmsg;
$new_text = theme('mark');
}
else {
$new = variable_get('privatemsg_sent_status', 1) ? $message->newmsg : 0;
$new_text = ' <span class="marker">' . t('unread') . '</span>';
}
$form['messages'][$message->id]['message'] = array(
'#type' => 'value',
'#value' => $message,
);
$form['messages'][$message->id]['#new'] = $new;
$form['messages'][$message->id]['selected'] = array(
'#type' => 'checkbox',
);
$form['messages'][$message->id]['avatar'] = array(
'#value' => '<div class="pm-inbox-avatar">' . theme('privatemsg_user_picture', user_load(array(
'uid' => $message->uid,
))) . '</div>',
);
$form['messages'][$message->id]['user'] = array(
'#type' => 'value',
'#value' => '<div class="pm-username">' . theme('privatemsg_username', $message) . '</div>',
);
$form['messages'][$message->id]['subject'] = array(
'#type' => 'value',
'#value' => l($message->subject, 'privatemsg/view/' . $message->id, array(), NULL, 'message-' . $message->id) . ($new ? ' ' . $new_text : ''),
);
$form['messages'][$message->id]['date'] = array(
'#type' => 'value',
'#value' => format_date($message->timestamp, 'small'),
);
}
$form['pager'] = array(
'#value' => theme('pager', array(), variable_get('privatemsg_per_page', 10)),
);
if (count($messages) > 0) {
$js = array(
'deleteMessage' => t('Are you sure you want to delete these messages?'),
);
$del = variable_get('privatemsg_actions_loc', 1);
$form['selected'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#prefix' => '<div class="container-inline" id="privatemsg-action-buttons">',
'#suffix' => '</div>',
);
switch ($current_folder) {
case PRIVATEMSG_FOLDER_RECYCLE_BIN:
$actions['permanent'] = array(
'#type' => 'submit',
'#value' => t('Delete permanently'),
);
$actions['undelete'] = array(
'#type' => 'submit',
'#value' => t('Restore'),
);
$actions['empty'] = array(
'#type' => 'submit',
'#value' => t('Empty recycle bin'),
);
break;
default:
$actions['mark_read'] = array(
'#type' => 'submit',
'#value' => t('Mark as read'),
);
$actions['mark_unread'] = array(
'#type' => 'submit',
'#value' => t('Mark as unread'),
);
// deliberate no break.
case PRIVATEMSG_FOLDER_SENT:
$actions['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
}
if ($del == 1) {
$form['selected']['actions'] = $actions;
}
if (user_access('create new folder')) {
$extra_folders = array();
foreach ($folders as $folder) {
// Do not display the recycle bin in the move to folder drop down as the
// delete button is already available. Similarly, avoid displaying
// the sent items folder as it is for internal use only.
if ($folder['fid'] != PRIVATEMSG_FOLDER_SENT && $folder['fid'] != PRIVATEMSG_FOLDER_RECYCLE_BIN && $folder['fid'] != $current_folder) {
$extra_folders[$folder['fid']] = $folder['name'];
}
}
$extra_folders['new'] = t('New folder...');
// Control to move messages to a new folder. Display only for inbox and
// custom folders.
if ((arg(1) == NULL || arg(1) == 'list') && count($extra_folders) > 0 && $current_folder != PRIVATEMSG_FOLDER_RECYCLE_BIN && $current_folder != PRIVATEMSG_FOLDER_SENT) {
$form['selected']['folder'] = array(
'#prefix' => '<div class="pm-spacer">',
'#type' => 'select',
'#options' => $extra_folders,
);
$form['selected']['extra_folders'] = array(
'#type' => 'value',
'#value' => $extra_folders,
);
$form['selected']['move_messages'] = array(
'#type' => 'submit',
'#value' => t('Move to folder'),
'#suffix' => '</div>',
);
}
}
if ($del == 2) {
$form['selected']['actions'] = $actions;
}
}
$form['js_bypass'] = array(
'#type' => 'hidden',
'#value' => 0,
);
drupal_add_js(drupal_get_path('module', 'privatemsg') . '/privatemsg.js');
drupal_add_js(array(
'privatemsg' => $js,
), 'setting');
return $form;
}