From 585c7f35ca5141d85a8d2f20e9b62a99cbf03f4e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 27 Sep 2010 13:34:35 -0700 Subject: [PATCH] Yammer import (work run via background queues) now can be started from the admin panel! :DDDD Still requires that the app be registered on your network manually first. --- plugins/YammerImport/YammerImportPlugin.php | 3 ++- .../YammerImport/actions/yammeradminpanel.php | 4 ++++ .../YammerImport/lib/yammerauthverifyform.php | 19 ++++++++++++++----- .../YammerImport/lib/yammerqueuehandler.php | 3 +-- plugins/YammerImport/lib/yammerrunner.php | 9 +++++++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/plugins/YammerImport/YammerImportPlugin.php b/plugins/YammerImport/YammerImportPlugin.php index bb1e976186..547870936b 100644 --- a/plugins/YammerImport/YammerImportPlugin.php +++ b/plugins/YammerImport/YammerImportPlugin.php @@ -48,7 +48,7 @@ class YammerImportPlugin extends Plugin */ function onEndInitializeQueueManager(QueueManager $qm) { - $qm->connect('importym', 'ImportYmQueueHandler'); + $qm->connect('yammer', 'YammerQueueHandler'); return true; } @@ -122,6 +122,7 @@ class YammerImportPlugin extends Plugin case 'yammerauthinitform': case 'yammerauthverifyform': case 'yammerprogressform': + case 'yammerqueuehandler': require_once "$base/lib/$lower.php"; return false; case 'yammeradminpanelaction': diff --git a/plugins/YammerImport/actions/yammeradminpanel.php b/plugins/YammerImport/actions/yammeradminpanel.php index fdf7a084f4..04ef26d512 100644 --- a/plugins/YammerImport/actions/yammeradminpanel.php +++ b/plugins/YammerImport/actions/yammeradminpanel.php @@ -76,6 +76,10 @@ class YammeradminpanelAction extends AdminPanelAction return $this->showAjaxForm($form); } else if ($this->verify_token) { $this->runner->saveAuthToken($this->verify_token); + + // Haho! Now we can make THE FUN HAPPEN + $this->runner->startBackgroundImport(); + $form = new YammerProgressForm($this, $this->runner); return $this->showAjaxForm($form); } else { diff --git a/plugins/YammerImport/lib/yammerauthverifyform.php b/plugins/YammerImport/lib/yammerauthverifyform.php index 96decea102..2b3efbcb1a 100644 --- a/plugins/YammerImport/lib/yammerauthverifyform.php +++ b/plugins/YammerImport/lib/yammerauthverifyform.php @@ -64,7 +64,20 @@ class YammerAuthVerifyForm extends Form function formData() { - $this->out->input('verify_token', _m('Verification code:'), '', _m("Click through and paste the code it gives you below...")); + $this->out->elementStart('p'); + $this->out->text(_m('Follow this link to confirm authorization at Yammer; you will be prompted to log in if necessary:')); + $this->out->elementEnd('p'); + + $this->out->elementStart('blockquote'); + $this->out->element('a', + array('href' => $this->runner->getAuthUrl(), + 'target' => '_blank'), + _m('Open Yammer authentication window')); + $this->out->elementEnd('blockquote'); + + $this->out->element('p', array(), _m('Copy the verification code you are given into the form below:')); + + $this->out->input('verify_token', _m('Verification code:')); // iframe would be nice to avoid leaving -- since they don't seem to have callback url O_O /* @@ -72,10 +85,6 @@ class YammerAuthVerifyForm extends Form 'src' => $this->runner->getAuthUrl())); */ // yeah, it ignores the callback_url - $this->out->element('a', - array('href' => $this->runner->getAuthUrl(), - 'target' => '_blank'), - 'clicky click'); } /** diff --git a/plugins/YammerImport/lib/yammerqueuehandler.php b/plugins/YammerImport/lib/yammerqueuehandler.php index 5fc3777835..acc8073115 100644 --- a/plugins/YammerImport/lib/yammerqueuehandler.php +++ b/plugins/YammerImport/lib/yammerqueuehandler.php @@ -41,8 +41,7 @@ class YammerQueueHandler extends QueueHandler if ($runner->iterate()) { if ($runner->hasWork()) { // More to do? Shove us back on the queue... - $qm = QueueManager::get(); - $qm->enqueue('YammerImport', 'yammer'); + $runner->startBackgroundImport(); } return true; } else { diff --git a/plugins/YammerImport/lib/yammerrunner.php b/plugins/YammerImport/lib/yammerrunner.php index aee6b17e15..e0aec0d166 100644 --- a/plugins/YammerImport/lib/yammerrunner.php +++ b/plugins/YammerImport/lib/yammerrunner.php @@ -386,4 +386,13 @@ class YammerRunner return $map->count(); } + /** + * Start running import work in the background queues... + */ + public function startBackgroundImport() + { + $qm = QueueManager::get(); + $qm->enqueue('YammerImport', 'yammer'); + } + } -- 2.39.5