function user_relationships_pending_requests_page in User Relationships 7
Same name and namespace in other branches
- 6 user_relationships_ui/user_relationships_ui.pages.inc \user_relationships_pending_requests_page()
List of pending requests from other users
1 string reference to 'user_relationships_pending_requests_page'
- user_relationships_ui_menu in user_relationships_ui/
user_relationships_ui.module - Implements hook_menu().
File
- user_relationships_ui/
user_relationships_ui.pages.inc, line 92 - Various user relationships admin and user pages
Code
function user_relationships_pending_requests_page($column, $account = NULL) {
global $user;
if (!$account) {
$account = $user;
}
if (!is_object($account) || !$account->uid) {
return MENU_NOT_FOUND;
}
if ($column == 'requester_id') {
$permission = 'request';
if ($account->uid == $user->uid) {
$msg = t('My relationships (sent requests)');
$empty = t('You have not sent any relationship requests that are currently pending.');
}
else {
$msg = t("%username's relationships (sent requests)", array(
'%username' => format_username($account),
));
$empty = t('%username has not sent any relationship requests that are currently pending.', array(
'%username' => format_username($account),
));
}
}
else {
$permission = 'approve';
if ($account->uid == $user->uid) {
$msg = t('My relationships (received requests)');
$empty = t('You have not received any relationship requests that are currently pending.');
}
else {
$msg = t("%username's relationships (received requests)", array(
'%username' => format_username($account),
));
$empty = t('%username has not received any relationship requests that are currently pending.', array(
'%username' => format_username($account),
));
}
}
drupal_set_title($msg, PASS_THROUGH);
$options = array(
'include_user_info' => TRUE,
'paging' => variable_get('user_relationships_relationships_per_page', 16),
);
$header = user_relationships_ui_get_table_header(user_relationships_ui_check_access($permission, $account));
$relationships = user_relationships_load(array(
$column => $account->uid,
'approved' => FALSE,
), $options);
$rows = array();
foreach ($relationships as $relationship) {
$rows[$relationship->rid] = user_relationships_ui_get_table_row($relationship, $account);
if (count($rows[$relationship->rid]) < count($header)) {
// Add an empty space to the operations table row.
$rows[$relationship->rid][] = ' ';
}
}
$output['list'] = array(
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
'#empty' => $empty,
'attributes' => array(
'class' => array(
'user-relationships-pending-listing-table',
),
),
);
$output['pager'] = array(
'#markup' => theme('pager'),
);
return $output;
}