示例#1
0
 function handle($args)
 {
     // @fixme move this to saveSettings and friends?
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         StatusNet::setApi(true);
         // short error pages :P
         $this->checkSessionToken();
         if ($this->subaction == 'change-apikey') {
             $form = new YammerApiKeyForm($this);
         } else {
             if ($this->subaction == 'apikey') {
                 if ($this->saveKeys()) {
                     $form = new YammerAuthInitForm($this, $this->runner);
                 } else {
                     $form = new YammerApiKeyForm($this);
                 }
             } else {
                 if ($this->subaction == 'authinit') {
                     // hack
                     if ($this->arg('change-apikey')) {
                         $form = new YammerApiKeyForm($this);
                     } else {
                         $url = $this->runner->requestAuth();
                         $form = new YammerAuthVerifyForm($this, $this->runner);
                     }
                 } else {
                     if ($this->subaction == 'authverify') {
                         $this->runner->saveAuthToken($this->trimmed('verify_token'));
                         // Haho! Now we can make THE FUN HAPPEN
                         $this->runner->startBackgroundImport();
                         $form = new YammerProgressForm($this, $this->runner);
                     } else {
                         if ($this->subaction == 'pause-import') {
                             // TRANS: Error message about an import job being paused from the admin panel.
                             $this->runner->recordError(_m('Paused from admin panel.'));
                             $form = $this->statusForm();
                         } else {
                             if ($this->subaction == 'continue-import') {
                                 $this->runner->clearError();
                                 $this->runner->startBackgroundImport();
                                 $form = $this->statusForm();
                             } else {
                                 if ($this->subaction == 'abort-import') {
                                     $this->runner->reset();
                                     $form = $this->statusForm();
                                 } else {
                                     if ($this->subaction == 'progress') {
                                         $form = $this->statusForm();
                                     } else {
                                         // TRANS: Client exception thrown when encountering an unhandled sub action.
                                         throw new ClientException(_m('Invalid POST'));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         return $this->showAjaxForm($form);
     }
     return parent::handle($args);
 }