Ejemplo n.º 1
0
 /**
  * Save changes to an announcement type.
  * @param $args array
  * @param $request PKPRequest
  */
 function updateAnnouncementType($args, &$request)
 {
     // FIXME: Remove call to validate() when all ManagerHandler implementations
     // (across all apps) have been migrated to the authorize() authorization approach.
     $this->validate();
     $this->setupTemplate($request, true);
     $router =& $request->getRouter();
     import('classes.manager.form.AnnouncementTypeForm');
     $typeId = $request->getUserVar('typeId') == null ? null : (int) $request->getUserVar('typeId');
     $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
     if ($this->_announcementTypeIsValid($request, $typeId)) {
         $announcementTypeForm = new AnnouncementTypeForm($typeId);
         $announcementTypeForm->readInputData();
         if ($announcementTypeForm->validate()) {
             $announcementTypeForm->execute();
             if ($request->getUserVar('createAnother')) {
                 $request->redirectUrl($router->url($request, null, null, 'createAnnouncementType'));
             } else {
                 $request->redirectUrl($router->url($request, null, null, 'announcementTypes'));
             }
         } else {
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->append('pageHierarchy', array($request->url(null, null, 'manager', 'announcementTypes'), 'manager.announcementTypes'));
             if ($typeId == null) {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.createTitle');
             } else {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.editTitle');
             }
             $announcementTypeForm->display();
         }
     } else {
         $request->redirectUrl($router->url($request, null, null, 'announcementTypes'));
     }
 }
 /**
  * Save an edited/inserted announcement type.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function updateAnnouncementType($args, $request)
 {
     // Identify the announcement type id.
     $announcementTypeId = $request->getUserVar('announcementTypeId');
     $context = $request->getContext();
     $contextId = $context->getId();
     // Form handling.
     $announcementTypeForm = new AnnouncementTypeForm($contextId, $announcementTypeId);
     $announcementTypeForm->readInputData();
     if ($announcementTypeForm->validate()) {
         $announcementTypeForm->execute($request);
         if ($announcementTypeId) {
             // Successful edit of an existing announcement type.
             $notificationLocaleKey = 'notification.editedAnnouncementType';
         } else {
             // Successful added a new announcement type.
             $notificationLocaleKey = 'notification.addedAnnouncementType';
         }
         // Record the notification to user.
         $notificationManager = new NotificationManager();
         $user = $request->getUser();
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($notificationLocaleKey)));
         // Prepare the grid row data.
         return DAO::getDataChangedEvent($announcementTypeId);
     } else {
         return new JSONMessage(false);
     }
 }
Ejemplo n.º 3
0
 /**
  * Save changes to an announcement type.
  */
 function updateAnnouncementType()
 {
     $this->validate();
     $this->setupTemplate(true);
     import('manager.form.AnnouncementTypeForm');
     $typeId = Request::getUserVar('typeId') == null ? null : (int) Request::getUserVar('typeId');
     $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
     if ($this->_announcementTypeIsValid($typeId)) {
         $announcementTypeForm = new AnnouncementTypeForm($typeId);
         $announcementTypeForm->readInputData();
         if ($announcementTypeForm->validate()) {
             $announcementTypeForm->execute();
             if (Request::getUserVar('createAnother')) {
                 PKPRequest::redirect(null, null, 'createAnnouncementType');
             } else {
                 PKPRequest::redirect(null, null, 'announcementTypes');
             }
         } else {
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->append('pageHierarchy', array(Request::url(null, null, 'manager', 'announcementTypes'), 'manager.announcementTypes'));
             if ($typeId == null) {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.createTitle');
             } else {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.editTitle');
             }
             $announcementTypeForm->display();
         }
     } else {
         PKPRequest::redirect(null, null, 'announcementTypes');
     }
 }