' . t('The subqueue !title is empty.', array('!title' => $subqueue->title)) . ''; } /** * Print the privacy setting. */ function theme_smartqueue_users_privacy($privacy) { if ($privacy == SMARTQUEUE_USERS_PRIVACY_PUBLIC) { return '' . t('Public') . ''; } else if ($privacy == SMARTQUEUE_USERS_PRIVACY_PRIVATE) { return '' . t('Private') . ''; } else { return ''; } } /** * Preprocess the smartqueue users profile page. */ function smartqueue_users_preprocess_smartqueue_users_profile_page(&$vars) { $uid = $vars['account']->uid; // Check if the current user can manipulate this account's queues. $vars['can_manipulate'] = smartqueue_users_can_manipulate($vars['account']); $vars['viewable_subqueues'] = FALSE; foreach ($vars['queues'] as $qid => $queue) { // Set the headers for the table $header = array(t('Subqueue')); // Set the table's caption and attributes $caption = check_plain($queue->title); $attributes = array('class' => "smartqueue-users-queue smartqueue-users-queue-$qid"); if (!$vars['can_manipulate']) { // Users that can't manipulate might not be able to view every subqueue, so filter those out $vars['subqueues'][$qid] = smartqueue_users_subqueue_filter_viewable($vars['user'], $queue, $vars['subqueues'][$qid]); } else { // Manipulators can see more columns $header[] = t('Privacy'); $header[] = t('Operations'); } // Create a row for each subqueue $rows = array(); foreach ($vars['subqueues'][$qid] as $sqid => $subqueue) { // Basic information - the title of the subqueue (as a link to view it) $row = array( array( 'data' => l($subqueue->title, "user/$uid/queue/$qid/view/$sqid"), 'class' => "smartqueue-users-subqueue-title smartqueue-users-subqueue-title-$sqid", ), ); // Manipulators get more columns - Add privacy information and subqueue operations if ($vars['can_manipulate']) { $row[] = array( 'data' => theme('smartqueue_users_privacy', $subqueue->privacy), 'class' => "smartqueue-users-subqueue-privacy smartqueue-users-subqueue-privacy-$sqid", ); $row[] = array( 'data' => l(t('Edit'), "user/$uid/queue/$qid/edit/$sqid") . ' ' . l(t('Delete'), "user/$uid/queue/$qid/delete/$sqid"), 'class' => "smartqueue-users-subqueue-operations smartqueue-users-subqueue-operations-$sqid", ); } // Add the new row to the rows object $rows[] = $row; } // Decide whether a user can add a subqueue to this queue $vars['queues'][$qid]->can_add_subqueue = ($vars['can_manipulate'] && !smartqueue_users_reached_subqueue_limit($vars['account']->uid, $queue->qid)); // Add a row to add a new subqueue at the end of the table for privileged users if ($vars['queues'][$qid]->can_add_subqueue) { $rows[] = array( array( 'data' => l(t('Add a new subqueue'), "user/$uid/queue/$qid/add"), 'class' => 'smartqueue-users-subqueue-add', 'colspan' => 3, ), ); } if (!empty($rows)) { // Invoke hook_nodequeue_table()s. foreach (module_implements('nodequeue_table') as $module) { $implementation = $module.'_nodequeue_table'; $implementation('smartqueue_users_profile', $header, $rows, $attributes, $caption, $queue, $vars['subqueues'][$qid]); } $vars['queues'][$qid]->output = theme('table', $header, $rows, $attributes, $caption); } else { $vars['queues'][$qid]->output = ''; } // If the subqueue is not empty then we mark that there are some viewable subqueues if (!empty($rows)) { $vars['viewable_subqueues'] = TRUE; } } }