array( 'type' => 'node', 'label' => t('Request translations'), 'configurable' => false, 'aggregate' => true ) ); } /** * Action to do multistep checkout for translations. * * @param array $nodes * Array of Drupal nodes. * @param $info * Action info - not used. * */ function tmgmt_node_ui_checkout_multiple_action($nodes, $info) { $jobs = array(); $source_lang_registry = array(); // Loop through entities and create individual jobs for each source language. foreach ($nodes as $node) { try { // For given source lang no job exists yet. if (!isset($source_lang_registry[$node->language])) { // Create new job. $job = tmgmt_job_create($node->language, NULL, $GLOBALS['user']->uid); // Add initial job item. $job->addItem('node', 'node', $node->nid); // Add job identifier into registry $source_lang_registry[$node->language] = $job->tjid; // Add newly created job into jobs queue. $jobs[$job->tjid] = $job; } // We have a job for given source lang, so just add new job item for the // existing job. else { $jobs[$source_lang_registry[$node->language]]->addItem('node', 'node', $node->nid); } } catch (TMGMTException $e) { watchdog_exception('tmgmt', $e); drupal_set_message(t('Unable to add job item for node %name. Make sure the source content is not empty.', array('%name' => $node->title)), 'error'); } } // If necessary, do a redirect. $redirects = tmgmt_ui_job_checkout_multiple($jobs); if ($redirects) { tmgmt_ui_redirect_queue_set($redirects, current_path()); drupal_set_message(format_plural(count($redirects), t('One job needs to be checked out.'), t('@count jobs need to be checked out.'))); drupal_goto(tmgmt_ui_redirect_queue_dequeue()); } }