Ejemplo n.º 1
0
 /**
  * @see PKPPlugin::manage()
  */
 function manage($verb, $args, &$message, &$messageParams, &$pluginModalContent = null)
 {
     $returner = true;
     $request = $this->getRequest();
     $journal = $request->getJournal();
     $this->addLocaleData();
     switch ($verb) {
         case 'settings':
             AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER);
             $templateMgr = TemplateManager::getManager($request);
             $templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
             $this->import('SettingsForm');
             $form = new SettingsForm($this, $journal->getId());
             if ($request->getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     $request->redirect(null, null, 'plugins');
                 } else {
                     $form->display();
                 }
             } else {
                 $form->initData();
                 $form->display();
             }
             break;
         case 'enable':
             $this->updateSetting($journal->getId(), 'enabled', true);
             $message = NOTIFICATION_TYPE_SWORD_ENABLED;
             $returner = false;
             break;
         case 'disable':
             $this->updateSetting($journal->getId(), 'enabled', false);
             $message = NOTIFICATION_TYPE_PLUGIN_DISABLED;
             $messageParams = array('pluginName' => $this->getDisplayName());
             $returner = false;
             break;
         case 'createDepositPoint':
         case 'editDepositPoint':
             $templateMgr = TemplateManager::getManager($request);
             $templateMgr->register_function('plugin_url', array($this, 'smartyPluginUrl'));
             $depositPointId = array_shift($args);
             if ($depositPointId == '') {
                 $depositPointId = null;
             } else {
                 $depositPointId = (int) $depositPointId;
             }
             $this->import('DepositPointForm');
             $form = new DepositPointForm($this, $journal->getId(), $depositPointId);
             if ($request->getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     $request->redirect(null, null, null, array('generic', $this->getName(), 'settings'));
                 } else {
                     $form->display();
                 }
             } else {
                 $form->initData();
                 $form->display();
             }
             break;
         case 'deleteDepositPoint':
             $journalId = $journal->getId();
             $depositPointId = (int) array_shift($args);
             $depositPoints = $this->getSetting($journalId, 'depositPoints');
             unset($depositPoints[$depositPointId]);
             $this->updateSetting($journalId, 'depositPoints', $depositPoints);
             $request->redirect(null, null, null, array('generic', 'SwordPlugin', 'settings'));
             break;
     }
     return $returner;
 }
Ejemplo n.º 2
0
 function manage($verb, $args, &$message)
 {
     $returner = true;
     $journal =& Request::getJournal();
     $this->addLocaleData();
     switch ($verb) {
         case 'settings':
             Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_MANAGER));
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
             $this->import('SettingsForm');
             $form = new SettingsForm($this, $journal->getId());
             if (Request::getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     Request::redirect(null, null, 'plugins');
                 } else {
                     $form->display();
                 }
             } else {
                 $form->initData();
                 $form->display();
             }
             break;
         case 'enable':
             $this->updateSetting($journal->getId(), 'enabled', true);
             $message = Locale::translate('plugins.generic.sword.enabled');
             $returner = false;
             break;
         case 'disable':
             $this->updateSetting($journal->getId(), 'enabled', false);
             $message = Locale::translate('plugins.generic.sword.disabled');
             $returner = false;
             break;
         case 'createDepositPoint':
         case 'editDepositPoint':
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl'));
             $depositPointId = array_shift($args);
             if ($depositPointId == '') {
                 $depositPointId = null;
             } else {
                 $depositPointId = (int) $depositPointId;
             }
             $this->import('DepositPointForm');
             $form = new DepositPointForm($this, $journal->getId(), $depositPointId);
             if (Request::getUserVar('save')) {
                 $form->readInputData();
                 if ($form->validate()) {
                     $form->execute();
                     Request::redirect(null, null, null, array('generic', $this->getName(), 'settings'));
                 } else {
                     $form->display();
                 }
             } else {
                 $form->initData();
                 $form->display();
             }
             break;
         case 'deleteDepositPoint':
             $journalId = $journal->getId();
             $depositPointId = (int) array_shift($args);
             $depositPoints = $this->getSetting($journalId, 'depositPoints');
             unset($depositPoints[$depositPointId]);
             $this->updateSetting($journalId, 'depositPoints', $depositPoints);
             Request::redirect(null, null, null, array('generic', 'SwordPlugin', 'settings'));
             break;
     }
     return $returner;
 }