array( 'title' => t('Author queue'), 'description' => t('Each user in the selected roles will be given a queue; nodequeue administrators can select nodes by that author for placement into that queue, allowing the site to easily hilight content by particular authors.'), )); } /** * Implementation of hook_nodequeue_form() */ function smartqueue_author_nodequeue_form($queue, &$form) { $roles = user_roles(TRUE); $form['placeholder']['rids'] = array( '#type' => 'checkboxes', '#title' => t('Roles'), '#description' => t('Select which roles a user must have to create a queue. If none are checked, all node authors will get a queue.'), '#options' => $roles, ); $form['subqueue_title'] = array( '#type' => 'textfield', '#title' => t('Subqueue title'), '#default_value' => $queue->subqueue_title, '#size' => 50, '#maxlength' => 64, '#description' => t('What to display for the subqueue title; use %subqueue to embed the actual subqueue title. This is used to distinguish multiple nodequeues with subqueues from each other, as internal subqueue title is filled automatically.'), ); if ($queue->qid && !empty($queue->reference)) { $form['placeholder']['rids']['#default_value'] = explode('-', $queue->reference); } } /** * Implementation of hook_nodequeue_form_validate() */ function smartqueue_author_nodequeue_form_validate($queue, &$form_state, &$form) { if (!isset($queue->qid)) { $rids = !empty($form_state['values']['rids']) ? array_keys(array_filter($form_state['values']['rids'])) : array(); // Convert this to our reference. form_set_value($form['reference'], implode('-', $rids)); } } /** * Implementation of hook_nodequeue_subqueues() */ function smartqueue_author_nodequeue_subqueues(&$queue, $node) { // Sorry, no anonymous nodes allowed. if (empty($node->uid)) { return; } $rids = !empty($queue->reference) ? explode('-', $queue->reference) : array(); $account = user_load(array('uid' => $node->uid)); if (!empty($rids) && !array_intersect($rids, array_keys($user->roles))) { return; } if (!nodequeue_load_subqueues_by_reference(array($queue->qid => array($node->uid)))) { nodequeue_add_subqueue($queue, $account->name, $node->uid); } return array($node->uid); } function smartqueue_author_nodequeue_subqueue_title($queue, $reference) { $account = user_load(array('uid' => $reference)); if ($account) { return $account->name; } } // TODO: // * Automatically delete subqueues when a user is deleted.