function lingotek_page_mark_phases_complete in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.2 includes/lingotek.ajax.inc \lingotek_page_mark_phases_complete()
- 7.3 includes/lingotek.ajax.inc \lingotek_page_mark_phases_complete()
- 7.4 includes/lingotek.ajax.inc \lingotek_page_mark_phases_complete()
- 7.5 includes/lingotek.ajax.inc \lingotek_page_mark_phases_complete()
- 7.6 includes/lingotek.ajax.inc \lingotek_page_mark_phases_complete()
Page handler for completing the current phases of remote Lingotek documents.
Parameters
object $node: The node whose targets should have phases marked as complete.
Return value
string JSON-encoded return data.
1 string reference to 'lingotek_page_mark_phases_complete'
- lingotek_menu in ./
lingotek.module - Implements hook_menu().
File
- includes/
lingotek.ajax.inc, line 17 - Page handlers and supporting routines for Ajax callbacks.
Code
function lingotek_page_mark_phases_complete($node) {
$output = array(
'success' => TRUE,
);
if (!empty($_POST['token']) && drupal_valid_token($_POST['token'])) {
if (!empty($_POST['targets']) && is_array($_POST['targets'])) {
$languages = language_list();
if ($lingotek_document_id = lingotek_keystore('node', $node->nid, 'document_id')) {
$targets = LingotekDocument::load($lingotek_document_id)
->translationTargets();
$api = LingotekApi::instance();
foreach ($_POST['targets'] as $target) {
$target = filter_xss($target);
if ($remote_target = $api
->getTranslationTarget($targets[$target]->id)) {
$current_phase_id = lingotek_current_phase($remote_target->phases);
if ($api
->markPhaseComplete($current_phase_id)) {
drupal_set_message(t('Marked phase complete for @language', array(
'@language' => $languages[$target]->name,
)));
}
else {
drupal_set_message(t('Unable to mark the current phase as complete for @language.', array(
'@language' => $languages[$target]->name,
)), 'error');
}
}
else {
drupal_set_message(t('Unable to mark the current phase as complete for @language.', array(
'@language' => $languages[$target]->name,
)), 'error');
}
}
}
else {
drupal_set_message(t('Unable to location Lingotek Document. No phases were marked as complete.'), 'error');
LingotekLog::error('Unable to locate Lingotek Document for node @node_id.', array(
'@node_id' => $node->nid,
));
}
}
else {
drupal_set_message(t('No target langauges were selected.'), 'error');
}
}
return drupal_json_output($output);
}