/** * Display form to edit a group. * @param $args array optional, first parameter is the ID of the group to edit */ function editGroup($args = array()) { $groupId = isset($args[0]) ? (int) $args[0] : null; $this->validate($groupId); $press =& $this->press; if ($groupId !== null) { $groupDao =& DAORegistry::getDAO('GroupDAO'); $group =& $groupDao->getGroup($groupId, ASSOC_TYPE_PRESS, $press->getId()); if (!$group) { Request::redirect(null, null, 'groups'); } } else { $group = null; } $this->setupTemplate($group, true); import('classes.manager.form.GroupForm'); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageTitle', $group === null ? 'manager.groups.createTitle' : 'manager.groups.editTitle'); $groupForm = new GroupForm($group); if ($groupForm->isLocaleResubmit()) { $groupForm->readInputData(); } else { $groupForm->initData(); } $groupForm->display(); }
/** * Action to edit a group * @param $args array, first parameter is the ID of the group to edit * @param $request PKPRequest * @return string Serialized JSON object */ function editGroup($args, &$request) { $groupId = isset($args['rowId']) ? $args['rowId'] : null; $router =& $request->getRouter(); $press =& $router->getContext($request); if ($groupId !== null) { $groupDao =& DAORegistry::getDAO('GroupDAO'); $group =& $groupDao->getById($groupId, ASSOC_TYPE_PRESS, $press->getId()); if (!$group) { $json = new JSON(false); return $json->getString(); } } else { $group = null; } import('controllers.grid.settings.masthead.form.GroupForm'); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageTitle', $group === null ? 'manager.groups.createTitle' : 'manager.groups.editTitle'); $groupForm = new GroupForm($group); if ($groupForm->isLocaleResubmit()) { $groupForm->readInputData(); } else { $groupForm->initData(); } $json = new JSON(true, $groupForm->fetch($request)); return $json->getString(); }