This repository has been archived by the owner on Dec 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmgmt_oht.module
63 lines (59 loc) · 1.62 KB
/
tmgmt_oht.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @file
* Module file of the translation management OHT module.
*
* http://onehourtranslation.com/
*
* Implemented by Artem Berdishev, AMgrade
*/
/**
* Implements hook_tmgmt_translator_plugin_info().
*/
function tmgmt_oht_tmgmt_translator_plugin_info() {
return array(
'oht' => array(
'label' => t('OHT translator'),
'description' => t('A OneHourTranslation translator service.'),
'plugin controller class' => 'TMGMTOhtPluginController',
'ui controller class' => 'TMGMTOhtTranslatorUIController',
),
);
}
/**
* Implements hook_menu().
*/
function tmgmt_oht_menu() {
return array(
'tmgmt_oht_callback' => array(
'title' => 'TMGMT OHT Callback',
'description' => '',
'page callback' => 'tmgmt_oht_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
),
);
}
/**
* Callback for OHT requests.
*/
function tmgmt_oht_callback() {
// if translation submitted - handle it
if ($_POST['type'] == 'translation_submitted') {
$job = tmgmt_job_load($_POST['custom0']);
$oht = $job->getTranslator()->getController();
$oht->receiveTranslation($job, $_POST['translated_content']);
}
// otherwise - add message about status changing
elseif($_POST['type'] == 'status_change') {
$job = tmgmt_job_load(check_plain($_POST['custom0']));
$job->addMessage('Status for project @project changed to "@status". Estimated finish: @finish',
array(
'@project' => $_POST['project_id'],
'@status' => $_POST['project_status'],
'@finish' => format_date($_POST['estimate_finish']),
)
);
}
exit('');
}