Example #1
0
 function index()
 {
     $this->validate();
     PluginRegistry::loadCategory('oaiMetadataFormats', true);
     $oai = new JournalOAI(new OAIConfig(Request::getRequestUrl(), Config::getVar('oai', 'repository_id')));
     $oai->execute();
 }
Example #2
0
 /**
  * Constructor
  **/
 function CustomLocaleHandler($parentPluginName)
 {
     parent::Handler();
     $this->addCheck(new HandlerValidatorJournal($this));
     $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER)));
     $this->plugin = PluginRegistry::getPlugin('generic', $parentPluginName);
 }
Example #3
0
 /**
  * Constructor
  * @param $plugin MedraExportPlugin
  * @param $contextId integer
  */
 function MedraSettingsForm($plugin, $contextId)
 {
     $this->_contextId = $contextId;
     $this->_plugin = $plugin;
     parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
     // DOI plugin settings action link
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     if (isset($pubIdPlugins['doipubidplugin'])) {
         $application = PKPApplication::getApplication();
         $request = $application->getRequest();
         $dispatcher = $application->getDispatcher();
         import('lib.pkp.classes.linkAction.request.AjaxModal');
         $doiPluginSettingsLinkAction = new LinkAction('settings', new AjaxModal($dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.settings.plugins.SettingsPluginGridHandler', 'manage', null, array('plugin' => 'doipubidplugin', 'category' => 'pubIds')), __('plugins.importexport.common.settings.DOIPluginSettings')), __('plugins.importexport.common.settings.DOIPluginSettings'), null);
         $this->setData('doiPluginSettingsLinkAction', $doiPluginSettingsLinkAction);
     }
     // Add form validation checks.
     $this->addCheck(new FormValidator($this, 'registrantName', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.registrantNameRequired'));
     $this->addCheck(new FormValidator($this, 'fromCompany', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromCompanyRequired'));
     $this->addCheck(new FormValidator($this, 'fromName', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromNameRequired'));
     $this->addCheck(new FormValidatorEmail($this, 'fromEmail', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromEmailRequired'));
     $this->addCheck(new FormValidatorInSet($this, 'exportIssuesAs', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.exportIssuesAs', array(O4DOI_ISSUE_AS_WORK, O4DOI_ISSUE_AS_MANIFESTATION)));
     $this->addCheck(new FormValidatorInSet($this, 'publicationCountry', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.publicationCountry', array_keys($this->_getCountries())));
     // The username is used in HTTP basic authentication and according to RFC2617 it therefore may not contain a colon.
     $this->addCheck(new FormValidatorRegExp($this, 'username', FORM_VALIDATOR_OPTIONAL_VALUE, 'plugins.importexport.medra.settings.form.usernameRequired', '/^[^:]+$/'));
     $this->addCheck(new FormValidatorPost($this));
 }
 /**
  * Register the article's metadata with the SWORD deposit.
  */
 function setMetadata()
 {
     $this->package->setCustodian($this->journal->getSetting('contactName'));
     $this->package->setTitle(html_entity_decode($this->article->getTitle($this->journal->getPrimaryLocale()), ENT_QUOTES, 'UTF-8'));
     $this->package->setAbstract(html_entity_decode(strip_tags($this->article->getAbstract($this->journal->getPrimaryLocale())), ENT_QUOTES, 'UTF-8'));
     $this->package->setType($this->section->getIdentifyType($this->journal->getPrimaryLocale()));
     // The article can be published or not. Support either.
     if (is_a($this->article, 'PublishedArticle')) {
         $doi = $this->article->getPubId('doi');
         if ($doi !== null) {
             $this->package->setIdentifier($doi);
         }
     }
     foreach ($this->article->getAuthors() as $author) {
         $creator = $author->getFullName(true);
         $affiliation = $author->getAffiliation($this->journal->getPrimaryLocale());
         if (!empty($affiliation)) {
             $creator .= "; {$affiliation}";
         }
         $this->package->addCreator($creator);
     }
     // The article can be published or not. Support either.
     if (is_a($this->article, 'PublishedArticle')) {
         $plugin =& PluginRegistry::loadPlugin('citationFormats', 'bibtex');
         $this->package->setCitation(html_entity_decode(strip_tags($plugin->fetchCitation($this->article, $this->issue, $this->journal)), ENT_QUOTES, 'UTF-8'));
     }
 }
Example #5
0
 /**
  * Constructor.
  */
 function OAIDAO()
 {
     parent::DAO();
     $this->archiveDao =& DAORegistry::getDAO('ArchiveDAO');
     $this->recordDao =& DAORegistry::getDAO('RecordDAO');
     PluginRegistry::loadCategory('schemas');
 }
 /**
  * @copydoc Form::fetch()
  */
 function fetch($request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $this->getContextId());
     $templateMgr->assign(array('pubIdPlugins' => $pubIdPlugins, 'pubObject' => $this->getPubObject(), 'approval' => $this->getApproval(), 'confirmationText' => $this->getConfirmationText()));
     return parent::fetch($request);
 }
Example #7
0
 /**
  * Get a public ID for this galley.
  * @param $pubIdType string One of the NLM pub-id-type values or
  * 'other::something' if not part of the official NLM list
  * (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
  * @param $preview boolean If true, generate a non-persisted preview only.
  */
 function getPubId($pubIdType, $preview = false)
 {
     // FIXME: Move publisher-id to PID plug-in.
     if ($pubIdType === 'publisher-id') {
         $pubId = $this->getStoredPubId($pubIdType);
         return $pubId ? $pubId : null;
     }
     // Retrieve the article.
     $articleDao = DAORegistry::getDAO('ArticleDAO');
     /* @var $articleDao ArticleDAO */
     $article = $articleDao->getById($this->getArticleId(), null, true);
     if (!$article) {
         return null;
     }
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $article->getJournalId());
     foreach ($pubIdPlugins as $pubIdPlugin) {
         if ($pubIdPlugin->getPubIdType() == $pubIdType) {
             // If we already have an assigned ID, use it.
             $storedId = $this->getStoredPubId($pubIdType);
             if (!empty($storedId)) {
                 return $storedId;
             }
             return $pubIdPlugin->getPubId($this, $preview);
         }
     }
     return null;
 }
 /**
  * Perform plugin-specific management functions.
  * @param $args array
  * @param $request object
  */
 function plugin($args, &$request)
 {
     $category = array_shift($args);
     $plugin = array_shift($args);
     $verb = array_shift($args);
     $this->validate();
     $this->setupTemplate(true);
     $plugins =& PluginRegistry::loadCategory($category);
     $message = $messageParams = null;
     $pluginObject = null;
     if (isset($plugins[$plugin])) {
         $pluginObject = $plugins[$plugin];
     }
     if (is_null($pluginObject)) {
         $request->redirect(null, null, 'plugins', array($category));
     }
     if (!$pluginObject->manage($verb, $args, $message, $messageParams, $request)) {
         HookRegistry::call('PluginHandler::plugin', array($verb, $args, $message, $messageParams, $pluginObject));
         if ($message) {
             $user =& $request->getUser();
             import('classes.notification.NotificationManager');
             $notificationManager = new NotificationManager();
             $notificationManager->createTrivialNotification($user->getId(), $message, $messageParams);
         }
         $request->redirect(null, null, 'plugins', array($category));
     }
 }
 /**
  * Fetch the HTML contents of the form.
  * @param $request PKPRequest
  * return string
  */
 function fetch($request)
 {
     $monograph = $this->getMonograph();
     $press = $request->getPress();
     $templateMgr = TemplateManager::getManager($request);
     $templateMgr->assign('submissionId', $monograph->getId());
     $templateMgr->assign('representationId', (int) $this->getPublicationFormatId());
     $templateMgr->assign('isPhysicalFormat', (bool) $this->getPhysicalFormat());
     // included to load format-specific template
     $templateMgr->assign('stageId', $this->getStageId());
     $templateMgr->assign('formParams', $this->getFormParams());
     $templateMgr->assign('submissionApproved', $monograph->getDatePublished());
     $onixCodelistItemDao = DAORegistry::getDAO('ONIXCodelistItemDAO');
     // Check if e-commerce is available
     import('classes.payment.omp.OMPPaymentManager');
     $ompPaymentManager = new OMPPaymentManager($request);
     if ($ompPaymentManager->isConfigured()) {
         $templateMgr->assign('paymentConfigured', true);
         $templateMgr->assign('currency', $press->getSetting('currency'));
     }
     // get the lists associated with the select elements on these publication format forms.
     $codes = array('productCompositionCodes' => 'List2', 'measurementUnitCodes' => 'List50', 'weightUnitCodes' => 'List95', 'measurementTypeCodes' => 'List48', 'productFormDetailCodes' => 'List175', 'productAvailabilityCodes' => 'List65', 'technicalProtectionCodes' => 'List144', 'returnableIndicatorCodes' => 'List66', 'countriesIncludedCodes' => 'List91');
     foreach ($codes as $templateVarName => $list) {
         $templateMgr->assign_by_ref($templateVarName, $onixCodelistItemDao->getCodes($list));
     }
     // consider public identifiers
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     $templateMgr->assign('pubIdPlugins', $pubIdPlugins);
     // Notification options.
     $notificationRequestOptions = array(NOTIFICATION_LEVEL_NORMAL => array(NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD => array(ASSOC_TYPE_PRESS, $press->getId()), NOTIFICATION_TYPE_FORMAT_NEEDS_APPROVED_SUBMISSION => array(ASSOC_TYPE_MONOGRAPH, $monograph->getId())), NOTIFICATION_LEVEL_TRIVIAL => array());
     $templateMgr->assign('notificationRequestOptions', $notificationRequestOptions);
     return parent::fetch($request);
 }
 function index($args, $request)
 {
     $this->validate();
     PluginRegistry::loadCategory('oaiMetadataFormats', true);
     $oai = new JournalOAI(new OAIConfig($request->url(null, 'oai'), Config::getVar('oai', 'repository_id')));
     $oai->execute();
 }
Example #11
0
 /**
  * For 2.3 upgrade:  Add initial plugin data to versions table
  * @return boolean
  */
 function addPluginVersions()
 {
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     import('site.VersionCheck');
     $categories = PluginRegistry::getCategories();
     foreach ($categories as $category) {
         PluginRegistry::loadCategory($category, true);
         $plugins = PluginRegistry::getPlugins($category);
         foreach ($plugins as $plugin) {
             $versionFile = $plugin->getPluginPath() . '/version.xml';
             if (FileManager::fileExists($versionFile)) {
                 $versionInfo =& VersionCheck::parseVersionXML($versionFile);
                 $pluginVersion = $versionInfo['version'];
                 $pluginVersion->setCurrent(1);
                 $versionDao->insertVersion($pluginVersion);
             } else {
                 $pluginVersion = new Version();
                 $pluginVersion->setMajor(1);
                 $pluginVersion->setMinor(0);
                 $pluginVersion->setRevision(0);
                 $pluginVersion->setBuild(0);
                 $pluginVersion->setDateInstalled(Core::getCurrentDate());
                 $pluginVersion->setCurrent(1);
                 $pluginVersion->setProductType('plugins.' . $category);
                 $pluginVersion->setProduct(basename($plugin->getPluginPath()));
                 $versionDao->insertVersion($pluginVersion);
             }
         }
     }
 }
Example #12
0
 /**
  * Test locales.
  */
 function execute()
 {
     // Flush the file cache just to be certain we're using
     // the most recent stuff
     import('cache.CacheManager');
     $cacheManager =& CacheManager::getManager();
     $cacheManager->flush('locale');
     // Load plugins so that their locale data is included too
     $plugins = array();
     foreach (PluginRegistry::getCategories() as $category) {
         echo "Loading plugin category \"{$category}\"...\n";
         $morePlugins = PluginRegistry::loadCategory($category);
         if (is_array($morePlugins)) {
             $plugins += $morePlugins;
         }
     }
     foreach (Locale::getAllLocales() as $locale => $name) {
         if (!empty($this->locales) && !in_array($locale, $this->locales)) {
             continue;
         }
         if ($locale != MASTER_LOCALE) {
             echo "Testing locale \"{$name}\" ({$locale}) against reference locale " . MASTER_LOCALE . ".\n";
             $this->testLocale($locale, MASTER_LOCALE, $plugins);
             $this->testEmails($locale, MASTER_LOCALE);
         }
     }
 }
 /**
  * Harvest archives.
  *
  * NB: This handler method is meant to be called by the parallel
  * processing framework (see ProcessDAO::spawnProcesses()). Executing
  * this handler in parallel will significantly improve harvesting
  * performance.
  *
  * The 'harvesting_checking_max_processes' config parameter limits
  * the number of parallel processes that can be started in parallel.
  *
  * @param $args array
  * @param $request PKPRequest
  */
 function harvest($args, $request)
 {
     // This is potentially a long running request. So
     // give us unlimited execution time.
     ini_set('max_execution_time', 0);
     // Get the process id.
     $processId = $args['authToken'];
     // Run until all archives have been harvested.
     $processDao = DAORegistry::getDAO('ProcessDAO');
     $archiveDao = DAORegistry::getDAO('ArchiveDAO');
     $plugins = PluginRegistry::loadCategory('harvesters');
     do {
         // Check that the process lease has not expired.
         $continue = $processDao->canContinue($processId);
         if ($continue) {
             $process = $processDao->getObjectById($processId);
             $archive = $archiveDao->getNextFlaggedArchive($request, $processId);
             if (!$archive) {
                 $continue = false;
             } else {
                 $plugin = $plugins[$archive->getHarvesterPluginName()];
                 $plugin->updateIndex($archive, $process->getAdditionalData());
             }
         }
     } while ($continue);
     // Free the process slot.
     $processDao->deleteObjectById($processId);
     // This request returns just a (private) status message.
     return 'Done!';
 }
 /**
  * Logs in to the system
  *
  * @param $username string The username
  * @param $password strint The password
  * @return string
  */
 public function login($username, $password)
 {
     @session_destroy();
     @session_start();
     $password = md5($password);
     $msg = "";
     $pru = PluginRegistry::getInstance();
     $login = $pru->getPlugin("Login Plugin");
     $result = $login->SOAPLogin($username, $password);
     return session_id();
     switch ($result) {
         case 200:
             $msg = "Logged in successfully";
             break;
         case 402:
             $msg = "There was an error while trying to login; your username is blocked";
             break;
         case 403:
             $msg = "Incorrect username/password combination";
             break;
         case 500:
             $msg = "There was an error on the server, please try later";
             break;
         default:
             $msg = "Incorrect username/password combination";
             break;
     }
     return $msg;
 }
Example #15
0
 function index()
 {
     $this->validate();
     PluginRegistry::loadCategory('schemas');
     $oai = new ArchiveOAI(new OAIConfig(Request::getRequestUrl(), Config::getVar('oai', 'repository_id')));
     $oai->execute();
 }
 /**
  * Executes the metadata plug-in test.
  * @param $pluginDir string
  * @param $pluginName string
  * @param $filterGroups array
  * @param $controlledVocabs array
  */
 protected function executeMetadataPluginTest($pluginDir, $pluginName, $filterGroups, $controlledVocabs)
 {
     // Make sure that the vocab xml configuration is valid.
     $controlledVocabFile = 'plugins/metadata/' . $pluginDir . '/schema/' . METADATA_PLUGIN_VOCAB_DATAFILE;
     $this->validateXmlConfig(array('./' . $controlledVocabFile, './lib/pkp/' . $controlledVocabFile));
     // Delete vocab data so that we can re-install it.
     $controlledVocabDao = DAORegistry::getDAO('ControlledVocabDAO');
     /* @var $controlledVocabDao ControlledVocabDAO */
     foreach ($controlledVocabs as $controlledVocabSymbolic) {
         $controlledVocab = $controlledVocabDao->getBySymbolic($controlledVocabSymbolic, 0, 0);
         if ($controlledVocab) {
             $controlledVocabDao->deleteObject($controlledVocab);
         }
     }
     // Reset the plug-in setting indicating that vocabs have already been installed.
     $pluginSettingsDao = DAORegistry::getDAO('PluginSettingsDAO');
     /* @var $pluginSettingsDao PluginSettingsDAO */
     $pluginSettingsDao->updateSetting(0, $pluginName, METADATA_PLUGIN_VOCAB_INSTALLED_SETTING, false);
     // Unregister the plug-in so that we're sure it will be registered again.
     $plugins =& PluginRegistry::getPlugins();
     unset($plugins['metadata'][$pluginName]);
     $this->executePluginTest('metadata', $pluginDir, $pluginName, $filterGroups);
     // Test whether the controlled vocabs have been installed.
     foreach ($controlledVocabs as $controlledVocab) {
         self::assertInstanceOf('ControlledVocab', $controlledVocabDao->getBySymbolic($controlledVocab, 0, 0));
     }
 }
 /**
  * @copydoc MultipleListsListbuilderHandler::setListsData()
  */
 function setListsData($request, $filter)
 {
     $leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
     $plugins =& PluginRegistry::loadCategory('blocks');
     foreach ($plugins as $key => $junk) {
         if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
             if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) {
                 $disabledBlockPlugins[$key] =& $plugins[$key];
             }
         } else {
             switch ($plugins[$key]->getBlockContext()) {
                 case BLOCK_CONTEXT_LEFT_SIDEBAR:
                     $leftBlockPlugins[$key] =& $plugins[$key];
                     break;
                 case BLOCK_CONTEXT_RIGHT_SIDEBAR:
                     $rightBlockPlugins[$key] =& $plugins[$key];
                     break;
             }
         }
     }
     $lists =& $this->getLists();
     $lists['leftContext']->setData($leftBlockPlugins);
     $lists['rightContext']->setData($rightBlockPlugins);
     $lists['unselected']->setData($disabledBlockPlugins);
 }
 /**
  * @see MetadataDataObjectAdapter::extractMetadataFromDataObject()
  * @param $monograph Monograph
  * @return MetadataDescription
  */
 function extractMetadataFromDataObject($monograph)
 {
     assert(is_a($monograph, 'Monograph'));
     AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
     // Retrieve data that belongs to the publication format.
     $oaiDao = DAORegistry::getDAO('OAIDAO');
     /* @var $oaiDao OAIDAO */
     $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
     $chapterDao = DAORegistry::getDAO('ChapterDAO');
     $monograph = $publishedMonographDao->getById($monograph->getId());
     $press = $oaiDao->getPress($monograph->getPressId());
     $description = $this->instantiateMetadataDescription();
     // Update status
     // Is communicated via an attribute, so property value is empty
     $description->addStatement('administrative_data/delivery/update_status[@type="urn_new"]', "");
     $urn = "";
     $scheme = "";
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds');
     if (isset($pubIdPlugins) && array_key_exists('URNDNBPubIdPlugin', $pubIdPlugins) && $pubIdPlugins['URNDNBPubIdPlugin']->getEnabled() == true) {
         $urn = $pubIdPlugins['URNDNBPubIdPlugin']->getPubId($monograph);
         $namespaces = explode(':', $urn);
         $numberOfNamespaces = min(sizeof($namespaces), 3);
         $scheme = implode(":", array_slice($namespaces, 0, $numberOfNamespaces));
     }
     // URN
     $description->addStatement('record/identifier', $urn . ' [@scheme="' . $scheme . '"]');
     // URL
     $url = Request::url($press->getPath(), 'catalog', 'book', array($monograph->getId()));
     $description->addStatement('record/resource/identifier[@scheme="url", @type="frontpage", @role="primary"]', $url);
     // URL Mime type
     $description->addStatement('record/resource/format[@scheme="imt"]', "text/html");
     return $description;
 }
Example #19
0
 /**
  * @see PKPTestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     // Instantiate the plug-in for testing.
     $this->mockRequest();
     PluginRegistry::loadCategory('generic', true, 0);
     $this->lucenePlugin = PluginRegistry::getPlugin('generic', 'luceneplugin');
 }
 /**
  * Constructor
  */
 function CustomLocaleHandler()
 {
     parent::Handler();
     $this->addCheck(new HandlerValidatorConference($this));
     $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SITE_ADMIN, ROLE_ID_CONFERENCE_MANAGER)));
     $plugin =& PluginRegistry::getPlugin('generic', 'CustomLocalePlugin');
     $this->plugin =& $plugin;
 }
Example #21
0
 /**
  * Display status of deposit(s)
  * @param array $args
  * @param Request $request
  */
 function status($args = array(), &$request)
 {
     $journal =& $request->getJournal();
     $plnPlugin =& PluginRegistry::getPlugin('generic', PLN_PLUGIN_NAME);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('pageHierarchy', array(array($router->url($request, null, 'about'), 'about.aboutTheJournal')));
     $templateMgr->display($plnPlugin->getTemplatePath() . DIRECTORY_SEPARATOR . 'status.tpl');
 }
Example #22
0
 function isTinyMCEInstalled()
 {
     $tinyMCEPlugin =& PluginRegistry::getPlugin('generic', 'TinyMCEPlugin');
     if ($tinyMCEPlugin) {
         return $tinyMCEPlugin->getEnabled();
     }
     return false;
 }
 /**
  * Constructor
  */
 function PayMethodSettingsForm()
 {
     parent::Form('payments/payMethodSettingsForm.tpl');
     // Load the plugins.
     $this->plugins =& PluginRegistry::loadCategory('paymethod');
     // Add form checks
     $this->addCheck(new FormValidatorInSet($this, 'paymentMethodPluginName', 'optional', 'manager.payment.paymentPluginInvalid', array_keys($this->plugins)));
 }
Example #24
0
 /**
  * Authenticate user credentials and mark the user as logged in in the current session.
  * @param $username string
  * @param $password string unencrypted password
  * @param $reason string reference to string to receive the reason an account was disabled; null otherwise
  * @param $remember boolean remember a user's session past the current browser session
  * @return User the User associated with the login credentials, or false if the credentials are invalid
  */
 static function login($username, $password, &$reason, $remember = false)
 {
     $implicitAuth = Config::getVar('security', 'implicit_auth');
     $reason = null;
     if ($implicitAuth) {
         // Implicit auth
         if (!Validation::isLoggedIn()) {
             PluginRegistry::loadCategory('implicitAuth');
             // Call the implicitAuth hook. It will set $user.
             HookRegistry::call('ImplicitAuthPlugin::implicitAuth', array(&$user));
             $valid = true;
         } else {
             $valid = false;
         }
     } else {
         // Regular Auth
         $userDao = DAORegistry::getDAO('UserDAO');
         $user = $userDao->getByUsername($username, true);
         if (!isset($user)) {
             // User does not exist
             return false;
         }
         if ($user->getAuthId()) {
             $authDao = DAORegistry::getDAO('AuthSourceDAO');
             $auth = $authDao->getPlugin($user->getAuthId());
         } else {
             $auth = null;
         }
         if ($auth) {
             // Validate against remote authentication source
             $valid = $auth->authenticate($username, $password);
             if ($valid) {
                 $oldEmail = $user->getEmail();
                 $auth->doGetUserInfo($user);
                 if ($user->getEmail() != $oldEmail) {
                     // FIXME requires email addresses to be unique; if changed email already exists, ignore
                     if ($userDao->userExistsByEmail($user->getEmail())) {
                         $user->setEmail($oldEmail);
                     }
                 }
             }
         } else {
             // Validate against user database
             $rehash = null;
             $valid = Validation::verifyPassword($username, $password, $user->getPassword(), $rehash);
             if ($valid && !empty($rehash)) {
                 // update to new hashing algorithm
                 $user->setPassword($rehash);
             }
         }
     }
     if (!$valid) {
         // Login credentials are invalid
         return false;
     } else {
         return self::registerUserSession($user, $reason, $remember);
     }
 }
 /**
  * @copydoc Form::fetch()
  */
 function fetch($request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $templateMgr->assign(array('pubIdPlugins' => PluginRegistry::loadCategory('pubIds', true, $this->getContextId()), 'pubObject' => $this->getPubObject(), 'stageId' => $this->getStageId(), 'formParams' => $this->getFormParams()));
     // consider JavaScripts
     $pubIdPluginHelper = new PKPPubIdPluginHelper();
     $pubIdPluginHelper->addJavaScripts($this->getContextId(), $request, $templateMgr);
     return parent::fetch($request);
 }
Example #26
0
 function &getPlugin()
 {
     $plugins =& PluginRegistry::loadCategory('schemas');
     $returner = null;
     if (isset($plugins[$this->getPluginName()])) {
         $returner =& $plugins[$this->getPluginName()];
     }
     return $returner;
 }
Example #27
0
 public static function initBindings()
 {
     $NativeBinding = new NativeBinding();
     self::$Bindings = array($NativeBinding);
     self::$BindingsByName[$NativeBinding->getName()] = $NativeBinding;
     PluginRegistry::ForEachBinding(function ($PluginInstance) {
         UserProxy::registerInstance($PluginInstance);
     });
 }
 /**
  * @see ScheduledTask::executeActions()
  */
 function executeActions()
 {
     $ofrPlugin =& PluginRegistry::getPlugin('generic', 'objectsforreviewplugin');
     if ($ofrPlugin) {
         $ofrPluginName = $ofrPlugin->getName();
         // Get all journals
         $journalDao =& DAORegistry::getDAO('JournalDAO');
         $journals =& $journalDao->getJournals(true);
         // Register the plugin DAOs and get the others
         $ofrPlugin->registerDAOs();
         $pluginSettingsDao =& DAORegistry::getDAO('PluginSettingsDAO');
         $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO');
         // For all journals
         while ($journal =& $journals->next()) {
             $journalId = $journal->getId();
             // If the plugin is enabled
             $pluginEnabled = $pluginSettingsDao->getSetting($journalId, $ofrPluginName, 'enabled');
             if ($pluginEnabled) {
                 // Get plugin reminder settings
                 $enableDueReminderBefore = $pluginSettingsDao->getSetting($journalId, $ofrPluginName, 'enableDueReminderBefore');
                 $enableDueReminderAfter = $pluginSettingsDao->getSetting($journalId, $ofrPluginName, 'enableDueReminderAfter');
                 $beforeDays = $pluginSettingsDao->getSetting($journalId, $ofrPluginName, 'numDaysBeforeDueReminder');
                 $afterDays = $pluginSettingsDao->getSetting($journalId, $ofrPluginName, 'numDaysAfterDueReminder');
                 // If a reminder is set
                 if ($enableDueReminderBefore && $beforeDays > 0 || $enableDueReminderAfter && $afterDays > 0) {
                     // Retrieve all incomplete object for review assignments
                     $incompleteAssignments =& $ofrAssignmentDao->getIncompleteAssignmentsByContextId($journalId);
                     foreach ($incompleteAssignments as $incompleteAssignment) {
                         if ($incompleteAssignment->getDateDue() != null) {
                             $dueDate = strtotime($incompleteAssignment->getDateDue());
                             // Remind before:
                             // If there hasn't been any such reminder, this option is set and due date is in the future
                             if ($incompleteAssignment->getDateRemindedBefore() == null && $enableDueReminderBefore == 1 && time() < $dueDate) {
                                 $nowToDueDate = $dueDate - time();
                                 if ($nowToDueDate < 60 * 60 * 24 * $beforeDays) {
                                     $this->sendReminder($incompleteAssignment, $journal, 'OFR_REVIEW_REMINDER');
                                 }
                             }
                             // Remind after:
                             // If there hasn't been any such reminder, this option is set and due date is in the past
                             if ($incompleteAssignment->getDateRemindedAfter() == null && $enableDueReminderAfter == 1 && time() > $dueDate) {
                                 $dueDateToNow = time() - $dueDate;
                                 if ($dueDateToNow > 60 * 60 * 24 * $afterDays) {
                                     $this->sendReminder($incompleteAssignment, $journal, 'OFR_REVIEW_REMINDER_LATE');
                                 }
                             }
                         }
                     }
                 }
             }
             unset($journal);
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * Register this plugin for all the appropriate hooks.
  */
 function register($category, $path)
 {
     $success = parent::register($category, $path);
     if ($success) {
         // Make sure postprocessors are loaded.
         PluginRegistry::loadCategory('postprocessors');
         HookRegistry::register('OAI::metadataFormats', array(&$this, 'callback_formatRequest'));
     }
     return $success;
 }
Example #30
0
 /**
  * tries to include the requested plugin and returns the plugin class name, or false if plugin not found.
  * @param string $pluginName name of the plugin
  * @return string class name or false if not found
  */
 protected function _load($pluginName, $section)
 {
     $cleanName = FileUtils::sanitize($pluginName);
     $className = strtolower("Plugins_{$cleanName}_{$section}");
     if (M::resolve_class($className, 'plugins', function () use($cleanName) {
         PluginRegistry::initPlugin($cleanName);
     })) {
         return $className;
     }
 }