/** * Remotely set a user setting. * @param $args array * @param $request PKPRequest * @return string a JSON message */ function setUserSetting($args, &$request) { // Retrieve the user from the session. $user =& $request->getUser(); assert(is_a($user, 'User')); // Exit with an error if request parameters are missing. if (!isset($args['setting-name']) && isset($args['setting-value'])) { $json = new JSON('false', 'Required request parameter "setting-name" or "setting-value" missing!'); return $json->getString(); } // Validate the setting. $settingName = $args['setting-name']; $settingValue = $args['setting-value']; $settingType = $this->_settingType($settingName); switch ($settingType) { case 'bool': if (!($settingValue === 'false' || $settingValue === 'true')) { $json = new JSON('false', 'Invalid setting value! Must be "true" or "false".'); return $json->getString(); } $settingValue = $settingValue === 'true' ? true : false; break; default: // Exit with a fatal error when an unknown setting is found. $json = new JSON('false', 'Unknown setting!'); return $json->getString(); } // Persist the validated setting. $userSettingsDAO =& DAORegistry::getDAO('UserSettingsDAO'); $userSettingsDAO->updateSetting($user->getId(), $settingName, $settingValue, $settingType); // Return a success message. $json = new JSON('true'); return $json->getString(); }
/** * Delete a file or revision * @param $args array * @param $request Request * @return string a serialized JSON object */ function deleteFile($args, &$request) { // FIXME: authorize! $fileId = (int) $request->getUserVar('fileId'); $success = false; if ($fileId) { // Delete all revisions or only one? $revision = $request->getUserVar('revision') ? (int) $request->getUserVar('revision') : null; // Delete the file/revision but only when it belongs to the authorized monograph // and to the right file stage. $monograph =& $this->getMonograph(); $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ if ($revision) { $success = (bool) $submissionFileDao->deleteRevisionById($fileId, $revision, $this->getFileStage(), $monograph->getId()); } else { $success = (bool) $submissionFileDao->deleteAllRevisionsById($fileId, $this->getFileStage(), $monograph->getId()); } } if ($success) { return DAO::getDataChangedEvent($fileId); } else { $json = new JSON(false); return $json->getString(); } }
/** * Show the form to allow the user to select review files * (bring in/take out files from submission stage to review stage) * * FIXME: Move to it's own handler so that it can be re-used among grids. * * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function selectFiles($args, &$request) { $monograph =& $this->getMonograph(); import('controllers.grid.files.review.form.ManageReviewFilesForm'); $manageReviewFilesForm = new ManageReviewFilesForm($monograph->getId(), $this->getRequestArg('reviewType'), $this->getRequestArg('round')); $manageReviewFilesForm->initData($args, $request); $json = new JSON(true, $manageReviewFilesForm->fetch($request)); return $json->getString(); }
/** * Get keywords for reviewer interests autocomplete. * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function getInterests($args, &$request) { // Get the input text used to filter on $filter = $request->getUserVar('term'); import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interests = $interestManager->getAllInterests($filter); import('lib.pkp.classes.core.JSON'); $json = new JSON(true, $interests); return $json->getString(); }
/** * Display the submission participants grid * @param $args array * @param $request PKPRequest * @return string Serialized JSON object * @see Form::fetch() */ function fetch($args, &$request) { // Identify the submission Id $monographId = $request->getUserVar('monographId'); // Form handling import('controllers.modals.submissionParticipants.form.SubmissionParticipantsForm'); $submissionParticipantsForm = new SubmissionParticipantsForm($monographId); $submissionParticipantsForm->initData($args, $request); $json = new JSON('true', $submissionParticipantsForm->fetch($request)); return $json->getString(); }
/** * Display the submission's metadata * @param $args array * @param $request PKPRequest * @return string Serialized JSON object * @see Form::fetch() */ function fetch($args, &$request) { // Identify the submission Id $monographId = $request->getUserVar('monographId'); Locale::requireComponents(array(LOCALE_COMPONENT_OMP_SUBMISSION)); // Form handling import('controllers.modals.submissionMetadata.form.SubmissionMetadataForm'); $submissionMetadataForm = new SubmissionMetadataForm($monographId); $submissionMetadataForm->initData($args, $request); $json = new JSON('true', $submissionMetadataForm->fetch($request)); return $json->getString(); }
/** * Display the submission's metadata * @return string Serialized JSON object * @see Form::fetch() * @param $args array * @param $request PKPRequest */ function fetch($args, &$request) { // Identify the press Id $pressId = $request->getUserVar('pressId'); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); // Form handling import('controllers.modals.competingInterests.form.CompetingInterestsForm'); $competingInterestsForm = new CompetingInterestsForm($pressId); $competingInterestsForm->initData($args, $request); $json = new JSON(true, $competingInterestsForm->fetch($request)); return $json->getString(); }
/** * Save 'manage review files' form * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function updateReviewFiles($args, &$request) { $monograph =& $this->getMonograph(); import('controllers.grid.files.review.form.ManageReviewFilesForm'); $manageReviewFilesForm = new ManageReviewFilesForm($monograph->getId(), $this->getRequestArg('reviewType'), $this->getRequestArg('round')); $manageReviewFilesForm->readInputData(); if ($manageReviewFilesForm->validate()) { $manageReviewFilesForm->execute($args, $request); // Let the calling grid reload itself return DAO::getDataChangedEvent(); } else { $json = new JSON(false); return $json->getString(); } }
/** * Display the information page for the press.. */ function index($args) { $this->validate(); $this->setupTemplate(); $press = Request::getPress(); $contentOnly = Request::getUserVar('contentOnly'); if ($press == null) { Request::redirect('index'); return; } switch (isset($args[0]) ? $args[0] : null) { case 'readers': $content = $press->getLocalizedSetting('readerInformation'); $pageTitle = 'navigation.infoForReaders.long'; $pageCrumbTitle = 'navigation.infoForReaders'; break; case 'authors': $content = $press->getLocalizedSetting('authorInformation'); $pageTitle = 'navigation.infoForAuthors.long'; $pageCrumbTitle = 'navigation.infoForAuthors'; break; case 'librarians': $content = $press->getLocalizedSetting('librarianInformation'); $pageTitle = 'navigation.infoForLibrarians.long'; $pageCrumbTitle = 'navigation.infoForLibrarians'; break; case 'competingInterestGuidelines': $content = $press->getLocalizedSetting('competingInterestGuidelines'); $pageTitle = $pageCrumbTitle = 'navigation.competingInterestGuidelines'; break; case 'sampleCopyrightWording': $content = Locale::translate('manager.setup.authorCopyrightNotice.sample'); $pageTitle = $pageCrumbTitle = 'manager.setup.copyrightNotice'; break; default: Request::redirect($press->getPath()); return; } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageCrumbTitle', $pageCrumbTitle); $templateMgr->assign('pageTitle', $pageTitle); $templateMgr->assign('content', $content); $templateMgr->assign('contentOnly', $contentOnly); // Hide the header and footer code import('lib.pkp.classes.core.JSON'); $json = new JSON('true', $templateMgr->fetch('information/information.tpl')); return $json->getString(); }
/** * Display the reviewer filtering form * @param $args array * @param $request PKPRequest */ function fetchForm($args, &$request) { // Get the monograph $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH); $interestDao =& DAORegistry::getDAO('InterestDAO'); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('monograph', $monograph->getId()); $templateMgr->assign('existingInterests', $interestDao->getAllUniqueInterests()); Locale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // Form handling import('controllers.reviewerSelector.form.ReviewerSelectorForm'); $reviewerSelectorForm = new ReviewerSelectorForm($monograph->getId()); $reviewerSelectorForm->initData(); $json = new JSON('true', $reviewerSelectorForm->fetch($request)); return $json->getString(); }
/** * Render the entire grid controller and send * it to the client. * @return string the grid HTML */ function fetchGrid($args, &$request) { // Prepare the template to render the grid $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('grid', $this); // Add columns to the view $columns =& $this->getColumns(); $templateMgr->assign_by_ref('columns', $columns); $templateMgr->assign('numColumns', count($columns)); // Render the body elements (category groupings + rows inside a <tbody>) $gridBodyParts = $this->_renderCategoriesInternally($request); $templateMgr->assign_by_ref('gridBodyParts', $gridBodyParts); // Let the view render the grid $json = new JSON('true', $templateMgr->fetch($this->getTemplate())); return $json->getString(); }
/** * Delete a submission * FIXME: Either delete this operation or add it as a row action, see #6396. * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function deleteSubmission($args, &$request) { $monographId = $request->getUserVar('monographId'); $this->validate($monographId); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission = $authorSubmissionDao->getAuthorSubmission($monographId); // If the submission is incomplete, allow the author to delete it. if ($authorSubmission->getSubmissionProgress() != 0) { $monographDao =& DAORegistry::getDAO('MonographDAO'); /* @var $monographDao MonographDAO */ $monographDao->deleteMonographById($monographId); $json = new JSON(true); } else { $json = new JSON(false, Locale::translate('settings.setup.errorDeletingItem')); } return $json->getString(); }
/** * Delete a user's signoff * @param $args array * @param $request PKPRequest * @return string */ function deleteUser($args, &$request) { $signoffId = (int) $request->getUserVar('signoffId'); if ($signoffId) { // Remove the signoff $signoffDao =& DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $signoffDao->deleteObjectById($signoffId); $json = new JSON(true); } else { $json = new JSON(false, 'manager.setup.errorDeletingItem'); } return $json->getString(); }
/** * Delete a contributor * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function deleteContributor($args, &$request) { $contributorId = isset($args['rowId']) ? $args['rowId'] : null; $router =& $request->getRouter(); $press =& $router->getContext($request); $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO'); // get all of the contributors $contributors = $pressSettingsDao->getSetting($press->getId(), 'contributors'); if (isset($contributors[$contributorId])) { unset($contributors[$contributorId]); $pressSettingsDao->updateSetting($press->getId(), 'contributors', $contributors, 'object'); $json = new JSON('true'); } else { $json = new JSON('false', Locale::translate('manager.setup.errorDeletingItem')); } return $json->getString(); }
/** * Display the Listbuilder */ function fetch(&$args, &$request, $additionalVars = null) { // FIXME: User validation $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(); $router =& $request->getRouter(); if (isset($additionalVars)) { foreach ($additionalVars as $key => $value) { $templateMgr->assign($key, $value); } } else { $templateMgr->assign('addUrl', $router->url($request, array(), null, 'addItem')); $templateMgr->assign('deleteUrl', $router->url($request, array(), null, 'deleteItems')); } // Translate modal submit/cancel buttons $okButton = Locale::translate('common.ok'); $warning = Locale::translate('common.warning'); $templateMgr->assign('localizedButtons', "{$okButton}, {$warning}"); // initialize to create the columns $columns =& $this->getColumns(); $templateMgr->assign_by_ref('columns', $columns); $templateMgr->assign('numColumns', count($columns)); // Render the rows $nullVar = null; // Kludge $rows = $this->_renderRowsInternally($request, $nullVar); $templateMgr->assign_by_ref('rows', $rows); $templateMgr->assign('listbuilder', $this); $json = new JSON('true', $templateMgr->fetch($this->getTemplate())); return $json->getString(); }
/** * Delete a file * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function deleteFile($args, &$request) { $fileId = isset($args['fileId']) ? $args['fileId'] : null; $router =& $request->getRouter(); $press =& $router->getContext($request); if ($fileId) { import('classes.file.LibraryFileManager'); $libraryFileManager = new LibraryFileManager($press->getId()); $libraryFileManager->deleteFile($fileId); return DAO::getDataChangedEvent($fileId); } $json = new JSON(false); return $json->getString(); }
/** * Delete a file * @param $args array * @param $request PKPRequest * @return string */ function deleteFile($args, &$request) { $fileId = $request->getUserVar('rowId'); if ($fileId) { $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $submissionFileDao->deleteAllRevisionsById($fileId); $json = new JSON('true'); } else { $json = new JSON('false'); } return $json->getString(); }
/** * @see PKPRouter::handleAuthorizationFailure() */ function handleAuthorizationFailure($request, $authorizationMessage) { // Translate the authorization error message. if (defined('LOCALE_COMPONENT_APPLICATION_COMMON')) { Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); } Locale::requireComponents(array(LOCALE_COMPONENT_PKP_USER)); $translatedAuthorizationMessage = Locale::translate($authorizationMessage); // Add the router name and operation. $url = $request->getRequestUrl(); $queryString = $request->getQueryString(); if ($queryString) { $queryString = '?' . $queryString; } $translatedAuthorizationMessage .= ' [' . $url . $queryString . ']'; // Return a JSON error message. import('lib.pkp.classes.core.JSON'); $json = new JSON('false', $translatedAuthorizationMessage); return $json->getString(); }
/** * Return a grid row with for the submission grid * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function returnFileRow($args, &$request) { $fileId = isset($args['fileId']) ? $args['fileId'] : null; $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $monographFile =& $submissionFileDao->getLatestRevision($fileId); $monographId = $monographFile->getMonographId(); if ($monographFile) { import('controllers.grid.files.reviewFiles.ReviewFilesGridHandler'); $reviewFilesGridHandler =& new ReviewFilesGridHandler(); $reviewFilesGridHandler->initialize($request); $row =& $reviewFilesGridHandler->getRowInstance(); $row->setId($monographFile->getFileId()); $row->setData($monographFile); $row->initialize($request); $json = new JSON('true', $reviewFilesGridHandler->_renderRowInternally($request, $row)); } else { $json = new JSON('false', Locale::translate("There was an error with trying to fetch the file")); } return $json->getString(); }
/** * Render a cell and send it to the client * @param $args array * @param $request Request * @return string the serialized cell JSON message */ function fetchCell(&$args, &$request) { // Check the requested column if (!isset($args['columnId'])) { fatalError('Missing column id!'); } if (!$this->hasColumn($args['columnId'])) { fatalError('Invalid column id!'); } $column =& $this->getColumn($args['columnId']); // Instantiate the requested row $row =& $this->getRequestedRow($request, $args); // Render the cell $json = new JSON('true', $this->_renderCellInternally($request, $row, $column)); return $json->getString(); }
/** * Update user group data on database and grid. * @param $args array * @param $request PKPRequest */ function updateUserGroup($args, &$request) { $userGroupForm = $this->_getUserGroupForm($request); $userGroupForm->readInputData(); if ($userGroupForm->validate()) { $userGroupForm->execute($request); return DAO::getDataChangedEvent($userGroupForm->getUserGroupId()); } else { $json = new JSON(false); return $json->getString(); } }
/** * Delete a filter * @param $args array * @param $request PKPRequest * @return string */ function deleteFilter(&$args, &$request) { // Identify the filter to be deleted $filter =& $this->getFilterFromArgs($args); $filterDAO = DAORegistry::getDAO('FilterDAO'); $result = $filterDAO->deleteObject($filter); if ($result) { $json = new JSON('true'); } else { $json = new JSON('false', Locale::translate('manager.setup.filter.grid.errorDeletingFilter')); } return $json->getString(); }
function deleteItems($args, &$request) { $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO'); foreach ($args as $publicationFormatId) { $publicationFormatDao->deleteById($publicationFormatId); } $json = new JSON(true); return $json->getString(); }
/** * Delete a note. * @param $args array * @param $request PKPRequest */ function deleteNote($args, &$request) { $noteId = (int) $request->getUserVar('noteId'); $noteDao =& DAORegistry::getDAO('NoteDAO'); $note =& $noteDao->getById($noteId); assert($note && $note->getAssocType() == $this->_getAssocType() && $note->getAssocId() == $this->_getAssocId()); $noteDao->deleteById($noteId); $additionalAttributes = array('script' => "\$('#note-{$noteId}').hide('slow')"); $json = new JSON(true, '', true, null, $additionalAttributes); return $json->getString(); }
function deleteItems(&$args, &$request) { $json = new JSON(true); return $json->getString(); }
/** * Consolidates all editor decision form calls into one function * @param $args array * @param $request PKPRequest * @param $formName string Name of form to call * @return string Serialized JSON object */ function _editorDecision($args, &$request, $formName) { // Retrieve the authorized monograph. $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH); // FIXME: Need to validate the decision (Does it combine with the // requested operation? Is it a valid decision? Is the user authorized // to take that decision? See #6199. $decision =& $request->getUserVar('decision'); // Form handling import("controllers.modals.editorDecision.form.{$formName}"); $editorDecisionForm = new $formName($monograph, $decision); $editorDecisionForm->initData($args, $request); $json = new JSON('true', $editorDecisionForm->fetch($request)); return $json->getString(); }
function deleteItems($args, &$request) { $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO'); $divisionDao =& DAORegistry::getDAO('DivisionDAO'); $press =& $request->getPress(); foreach ($args as $item) { $divisionDao->deleteById($item, $press->getId()); } $json = new JSON('true'); return $json->getString(); }
/** * Save the metadata of the latest revision of * the requested submission file * @param $args array * @param $request Request * @return string a serialized JSON object */ function saveMetadata($args, &$request) { $metadataForm =& $this->_getMetadataForm($request); $metadataForm->readInputData(); if ($metadataForm->validate()) { $metadataForm->execute($args, $request); $submissionFile = $metadataForm->getSubmissionFile(); return DAO::getDataChangedEvent($submissionFile->getFileId()); } else { $json = new JSON(false, $metadataForm->fetch($request)); } return $json->getString(); }
function deleteItems($args, &$request) { $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO'); $press =& $request->getPress(); $formats = $pressSettingsDao->getSetting($press->getId(), 'cataloguingMetadata'); foreach ($args as $item) { for ($i = 0; $i < count($formats); $i++) { if ($formats[$i]['name'] == $item) { array_splice($formats, $i, 1); } } } $pressSettingsDao->updateSetting($press->getId(), 'cataloguingMetadata', $formats, 'object'); $json = new JSON('true'); return $json->getString(); }
/** * @see ListbuilderHandler::deleteItems() */ function deleteItems($args, &$request) { $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $signoffIds = $this->getDeletedItemIds($request, $args, 2); foreach ($signoffIds as $signoffId) { $signoffDao->deleteObjectById((int) $signoffId); } $json = new JSON(true); return $json->getString(); }