tmgmt_local.rules.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @file
  4. * Rules integration.
  5. */
  6. /**
  7. * Implements hook_rules_action_info().
  8. */
  9. function tmgmt_local_rules_action_info() {
  10. $info['tmgmt_local_rules_task_assign'] = array(
  11. 'label' => t('Assign translation task'),
  12. 'group' => t('Translation Management'),
  13. 'parameter' => array(
  14. 'task' => array(
  15. 'type' => 'tmgmt_local_task',
  16. 'label' => t('Translation task'),
  17. 'description' => t('The translation task that should be assigned to the configured user.'),
  18. ),
  19. 'user' => array(
  20. 'type' => 'user',
  21. 'label' => t('user'),
  22. 'description' => t('The assigned user.'),
  23. ),
  24. ),
  25. );
  26. $info['tmgmt_local_rules_task_unassign'] = array(
  27. 'label' => t('Unassign translation task'),
  28. 'group' => t('Translation Management'),
  29. 'parameter' => array(
  30. 'task' => array(
  31. 'type' => 'tmgmt_local_task',
  32. 'label' => t('Translation task'),
  33. 'description' => t('The translation task which will be unassigned.'),
  34. ),
  35. ),
  36. 'access callback' => 'tmgmt_local_rules_task_access',
  37. );
  38. return $info;
  39. }
  40. /**
  41. * Rules callback to assign a translation task to translator.
  42. */
  43. function tmgmt_local_rules_task_assign(TMGMTLocalTask $task, stdClass $translator) {
  44. $task->assign($translator);
  45. $task->save();
  46. }
  47. /**
  48. * Rules callback to unassign a translation task.
  49. */
  50. function tmgmt_local_rules_task_unassign(TMGMTLocalTask $task) {
  51. $task->unassign();
  52. $task->save();
  53. }
  54. /**
  55. * Access callback to the unassign task rules action.
  56. */
  57. function tmgmt_local_rules_task_access() {
  58. return user_access('administer translation tasks') || user_access('provide translation services');
  59. }