/**
  * Page callback; Displays the subqueue add form.
  */
 public function subqueue_add_page($js, $input, EntityQueue $queue)
 {
     global $user;
     drupal_set_title(t('Add subqueue to %queue', array('%queue' => $queue->label)), PASS_THROUGH);
     ctools_include('plugins');
     $plugins = ctools_get_plugins('entityqueue', 'handler');
     $subqueue = entityqueue_subqueue_create(array('queue' => $queue->name, 'module' => $plugins[$queue->handler]['module'], 'uid' => $user->uid));
     return drupal_get_form('entityqueue_subqueue_edit_form', $queue, $subqueue);
 }
 /**
  * Makes sure that every simple queue has a subqueue.
  */
 protected function ensureSubqueue()
 {
     global $user;
     static $queues = array();
     if (!isset($queues[$this->queue->name])) {
         $queues[$this->queue->name] = TRUE;
         $transaction = db_transaction();
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'entityqueue_subqueue')->entityCondition('bundle', $this->queue->name);
         $result = $query->execute();
         // If we don't have a subqueue already, create one now.
         if (empty($result['entityqueue_subqueue'])) {
             $subqueue = entityqueue_subqueue_create();
             $subqueue->queue = $this->queue->name;
             $subqueue->name = $this->queue->name;
             $subqueue->label = $this->getSubqueueLabel($subqueue);
             $subqueue->module = 'entityqueue';
             $subqueue->uid = $user->uid;
             entity_get_controller('entityqueue_subqueue')->save($subqueue, $transaction);
         }
     }
 }