I just installed tmgmt_mygengo in addition to tmgmt_oht. Both plugins are configured and ready to be used.

When I click the "Poll translations" button on an in-progress OHT translation, I get a WSOD with the following error message in the php error log file:

[Mon Dec 03 18:07:00 2012] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined method TMGMTOhtPluginController::mapGengoJobs() in [...]/sites/all/modules/tmgmt_mygengo/tmgmt_mygengo.module on line 78, referer: [...]/admin/config/regional/tmgmt/jobs/3

Comments

miro_dietiker’s picture

Project: BLEND Localization » TMGMT Translator Gengo
Assigned: Unassigned » blueminds

This bug is not from the OHT module.
It seems, the mygengo module adds this button without checking if it is owning the job.

We need to fix this.

berdir’s picture

Hm, is it adding that poll button through hook_form_alter()? It should probably use checkoutInfo() for that, then TMGMT itself makes sure that it's only called for it's own jobs.

miro_dietiker’s picture

Priority: Normal » Major

Yes. We're lacking at least conditions here...
Note in the current status it is quite common that people have multiple translators enabled. This leads to severe user issues.

  43 /**
  44  * Implements hook_form_ID_alter().
  45  *
  46  * Adds poll action button into job checkout page.
  47  */
  48 function tmgmt_mygengo_form_tmgmt_job_form_alter(&$form, &$form_state) {
  49   /**
  50    * @var TMGMTJob $job
  51    */
  52   $job = $form_state['tmgmt_job'];
  53 
  54   if (!empty($job) && $job->isActive()) {
  55     $form['actions']['poll'] = array(
  56       '#type' => 'submit',
  57       '#value' => t('Poll translations'),
  58       '#submit' => array('_tmgmt_mygengo_poll_submit'),
  59       '#weight' => -10,
  60     );
  61   }
  62 }
 157 /**
 158  * Implements hook_form_ID_alter().
 159  *
 160  * Attaches javascript needed for gengo form.
 161  */
 162 function tmgmt_mygengo_form_tmgmt_translator_form_alter(&$form, &$form_state) {
 163   $form['#attached']['js'][] = drupal_get_path('module', 'tmgmt_mygengo') . '/js/tmgmt_mygengo.toggle_auto_approve.js';
 164 }

Both need at least to check if a translator is assigned to the gengo plugin.

blueminds’s picture

Status: Active » Needs review

Fixed.

I kept the form alter solution as it is not possible to add action button via checkoutInfo() to the others. I think it would be just fine to have that button in the checkoutInfo() form, for now I kept it where it was before... we might change it in the future.

berdir’s picture

Fixed or needs review*? ;)

I'm positive that it is possible add form buttons via checkoutInfo() :) See http://drupalcode.org/project/tmgmt_nativy.git/blob/refs/heads/7.x-1.x:/...

* I'd prefer needs review with a patch instead of just commiting, at least in issues where we can actually expect that someone tests it :)

miro_dietiker’s picture

Status: Needs review » Needs work

OK, needs work then.

blueminds’s picture

StatusFileSize
new2.72 KB

Sure it is possible to add form buttons, they just cannot be placed by the form actions buttons (save...). See attached patch. BTW, I like it this way more as well.

blueminds’s picture

Status: Needs work » Needs review
berdir’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/tmgmt_mygengo.ui.incundefined
@@ -158,4 +160,22 @@ class TMGMTMyGengoTranslatorUIController extends TMGMTDefaultTranslatorUIControl
+    if ($job->isActive()) {
+      $form['actions']['poll'] = array(
+        '#type' => 'submit',
+        '#value' => t('Poll translations'),
+        '#submit' => array('_tmgmt_mygengo_poll_submit'),
+        '#weight' => -10,
+      );
+    }

Yes, I like that much better :)

Also, we need to get those tests working again ;)

Have a look at http://drupal.org/node/698932, that should allow us to add a rules dependency. Note that it might not get picked up unless we do a new release, but we can do that once the currently open bugs are fixed.

There's no need to make the submit callback private function with a _ prefix. But looks good to me other than that.

bforchhammer’s picture

Cool, I haven't tested it yet, but this looks a lot cleaner :-)

+++ b/tmgmt_mygengo.ui.inc
@@ -23,6 +23,8 @@ class TMGMTMyGengoTranslatorUIController extends TMGMTDefaultTranslatorUIControl
+    $form['#attached']['js'][] = drupal_get_path('module', 'tmgmt_mygengo') . '/js/tmgmt_mygengo.toggle_auto_approve.js';

Separate issue, but I think the javascript code could actually be replaced by using the states api on the respective FAPI fields.

miro_dietiker’s picture

Haha, looking forward to that separate issue then. :-)

blueminds’s picture

Status: Reviewed & tested by the community » Fixed

Pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.