/** * Update an existing press. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateContext($args, $request) { // Identify the press Id. $pressId = $request->getUserVar('contextId'); // Form handling. $settingsForm = new PressSiteSettingsForm($pressId); $settingsForm->readInputData(); if ($settingsForm->validate()) { PluginRegistry::loadCategory('blocks'); // The press settings form will return a press path in two cases: // 1 - if a new press was created; // 2 - if a press path of an existing press was edited. $newPressPath = $settingsForm->execute($request); // Create the notification. $notificationMgr = new NotificationManager(); $user = $request->getUser(); $notificationMgr->createTrivialNotification($user->getId()); // Check for the two cases above. if ($newPressPath) { $context = $request->getContext(); if (is_null($pressId)) { // CASE 1: new press created. // Create notification related to payment method configuration. $pressDao = DAORegistry::getDAO('PressDAO'); $newPress =& $pressDao->getByPath($newPressPath); $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $newPress->getId(), ASSOC_TYPE_PRESS, $newPress->getId(), NOTIFICATION_LEVEL_NORMAL); // redirect and set the parameter to open the press // setting wizard modal after redirection. return $this->_getRedirectEvent($request, $newPressPath, true); } else { // CASE 2: check if user is in the context of // the press being edited. if ($context->getId() == $pressId) { return $this->_getRedirectEvent($request, $newPressPath, false); } } } return DAO::getDataChangedEvent($pressId); } else { return new JSONMessage(false); } }
/** * Save changes to a press' settings. */ function updatePress() { $this->validate(); $this->setupTemplate(true); import('classes.admin.form.PressSiteSettingsForm'); if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor $settingsForm = new PressSiteSettingsForm(Request::getUserVar('pressId')); } else { $settingsForm =& new PressSiteSettingsForm(Request::getUserVar('pressId')); } $settingsForm->readInputData(); if ($settingsForm->validate()) { PluginRegistry::loadCategory('blocks'); $settingsForm->execute(); import('lib.pkp.classes.notification.NotificationManager'); $notificationManager =& new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved'); Request::redirect(null, null, 'presses'); } else { $settingsForm->display(); } }