/** * Update a footer category entry * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function updateFooterCategory($args, $request) { // Identify the footerLink entry to be updated $footerCategoryId = $request->getUserVar('footerCategoryId'); $context = $this->getContext(); $footerCategoryDao = DAORegistry::getDAO('FooterCategoryDAO'); $footerCategory = $footerCategoryDao->getById($footerCategoryId, $context->getId()); // Form handling $footerCategoryForm = new FooterCategoryForm($context->getId(), $footerCategory); $footerCategoryForm->readInputData(); if ($footerCategoryForm->validate()) { $footerCategoryId = $footerCategoryForm->execute($request); if (!isset($footerCategory)) { // This is a new entry $footerCategory = $footerCategoryDao->getById($footerCategoryId, $context->getId()); $notificationContent = __('notification.addedFooterCategory'); // Prepare the grid row data $row = $this->getRowInstance(); $row->setGridId($this->getId()); $row->setId($footerCategoryId); $row->setData($footerCategory); $row->initialize($request); } else { $notificationContent = __('notification.editedFooterCategory'); } // Create trivial notification. $currentUser = $request->getUser(); $notificationMgr = new NotificationManager(); $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => $notificationContent)); // Render the row into a JSON response return DAO::getDataChangedEvent($footerCategoryId); } else { $json = new JSONMessage(true, $footerCategoryForm->fetch($request)); return $json->getString(); } }