/** * @see DataObjectRequiredPolicy::dataObjectEffect() */ function dataObjectEffect() { $issueId = (int) $this->getDataObjectId(); if (!$issueId) { return AUTHORIZATION_DENY; } // Make sure the issue belongs to the journal. $issueDao = DAORegistry::getDAO('IssueDAO'); if ($this->journal->getSetting('enablePublicIssueId')) { $issue = $issueDao->getByBestId($issueId, $this->journal->getId()); } else { $issue = $issueDao->getById((int) $issueId, null, true); } if (!is_a($issue, 'Issue')) { return AUTHORIZATION_DENY; } // The issue must be published, or we must have pre-publication // access to it. $userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES); if (!$issue->getPublished() && count(array_intersect($userRoles, array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SECTION_EDITOR, ROLE_ID_ASSISTANT))) == 0) { return AUTHORIZATION_DENY; } // Save the issue to the authorization context. $this->addAuthorizedContextObject(ASSOC_TYPE_ISSUE, $issue); return AUTHORIZATION_PERMIT; }
function testFind() { $content = "Today I walked the dog."; $date = date("Y-m-d"); $test_journal = new Journal($content, $date); $test_journal->save(); $content2 = "What is the meaning of life?"; $date2 = date("Y-m-d"); $test_journal2 = new Journal($content2, $date2); $test_journal2->save(); $result = Journal::find($test_journal->getId()); $this->assertEquals($test_journal, $result); }
/** * Save journal settings. */ function execute() { $journalDao =& DAORegistry::getDAO('JournalDAO'); if (isset($this->journalId)) { $journal =& $journalDao->getJournal($this->journalId); } if (!isset($journal)) { $journal = new Journal(); } $journal->setPath($this->getData('journalPath')); $journal->setEnabled($this->getData('enabled')); if ($journal->getId() != null) { $isNewJournal = false; $journalDao->updateJournal($journal); $section = null; } else { $isNewJournal = true; $site =& Request::getSite(); // Give it a default primary locale $journal->setPrimaryLocale($site->getPrimaryLocale()); $journalId = $journalDao->insertJournal($journal); $journalDao->resequenceJournals(); // Make the site administrator the journal manager of newly created journals $sessionManager =& SessionManager::getManager(); $userSession =& $sessionManager->getUserSession(); if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($journalId)) { $role = new Role(); $role->setJournalId($journalId); $role->setUserId($userSession->getUserId()); $role->setRoleId(ROLE_ID_JOURNAL_MANAGER); $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleDao->insertRole($role); } // Make the file directories for the journal import('lib.pkp.classes.file.FileManager'); FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId); FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles'); FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues'); FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId); // Install default journal settings $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $titles = $this->getData('title'); AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_DEFAULT, LOCALE_COMPONENT_APPLICATION_COMMON)); $journalSettingsDao->installSettings($journalId, 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $this->getData('journalPath'), 'primaryLocale' => $site->getPrimaryLocale(), 'journalName' => $titles[$site->getPrimaryLocale()])); // Install the default RT versions. import('classes.rt.ojs.JournalRTAdmin'); $journalRtAdmin = new JournalRTAdmin($journalId); $journalRtAdmin->restoreVersions(false); // Create a default "Articles" section $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section = new Section(); $section->setJournalId($journal->getId()); $section->setTitle(__('section.default.title'), $journal->getPrimaryLocale()); $section->setAbbrev(__('section.default.abbrev'), $journal->getPrimaryLocale()); $section->setMetaIndexed(true); $section->setMetaReviewed(true); $section->setPolicy(__('section.default.policy'), $journal->getPrimaryLocale()); $section->setEditorRestricted(false); $section->setHideTitle(false); $sectionDao->insertSection($section); } $journal->updateSetting('title', $this->getData('title'), 'string', true); $journal->updateSetting('description', $this->getData('description'), 'string', true); // Make sure all plugins are loaded for settings preload PluginRegistry::loadAllPlugins(); HookRegistry::call('JournalSiteSettingsForm::execute', array(&$this, &$journal, &$section, &$isNewJournal)); }
/** * Retrieves the CSS/style files associated with this HTML galley by looking at the submission_file genre. * @param ArticleGalley $galley * @param Journal $journal * @return array SubmissionFiles */ function _getStyleFiles($galley, $fileId, $journal) { $genreDao = DAORegistry::getDAO('GenreDAO'); $styleGenre = $genreDao->getByType('STYLE', $journal->getId()); $styleFiles = array(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $dependentFiles = $submissionFileDao->getLatestRevisionsByAssocId(ASSOC_TYPE_SUBMISSION_FILE, $fileId, $galley->getSubmissionId(), SUBMISSION_FILE_DEPENDENT); foreach ($dependentFiles as $file) { if ($file->getGenreId() == $styleGenre->getId()) { if ($file->getFileType() != 'text/css' && preg_match('/\\.css$/', $file->getOriginalFileName())) { $file->setFileType('text/css'); $submissionFileDao->updateObject($file); } $styleFiles[] = $file; } } return $styleFiles; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Journal $obj A Journal object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null JournalPeer::$instances[$key] = $obj; } }
/** * Declares an association between this object and a Journal object. * * @param Journal $v * @return JournalEntry The current object (for fluent API support) * @throws PropelException */ public function setJournal(Journal $v = null) { if ($v === null) { $this->setJournalId(NULL); } else { $this->setJournalId($v->getId()); } $this->aJournal = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Journal object, it will not be re-added. if ($v !== null) { $v->addJournalEntry($this); } return $this; }
/** * Exclude object from result * * @param Journal $journal Object to remove from the list of results * * @return JournalQuery The current query, for fluid interface */ public function prune($journal = null) { if ($journal) { $this->addUsingAlias(JournalPeer::ID, $journal->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related Journal object * * @param Journal|PropelObjectCollection $journal The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return JournalEntryQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByJournal($journal, $comparison = null) { if ($journal instanceof Journal) { return $this->addUsingAlias(JournalEntryPeer::JOURNAL_ID, $journal->getId(), $comparison); } elseif ($journal instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(JournalEntryPeer::JOURNAL_ID, $journal->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByJournal() only accepts arguments of type Journal or PropelCollection'); } }