/** * create category */ public function newcatAction() { $this->checkCsrfToken(); if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADD)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } $cat = new Category(); $cat->getDataFromInput(); // submit button wasn't pressed -> category was chosen from dropdown // we now get the parent (security) category domains so we can inherit them if (!$this->request->request->get('category_submit', null)) { $newCat = $_POST['category']; $pcID = $newCat['parent_id']; $pCat = new Category(); $parentCat = $pCat->get($pcID); //$newCat['security_domain'] = $parentCat['security_domain']; //for ($i=1; $i<=5; $i++) { // $name = 'data' . $i . '_domain'; // $newCat[$name] = $parentCat[$name]; //} $_SESSION['newCategory'] = $newCat; return $this->redirect(ModUtil::url('Categories', 'admin', 'newcat') . '#top'); } if (!$cat->validate('admin')) { return $this->redirect(ModUtil::url('Categories', 'admin', 'newcat') . '#top'); } $attributes = array(); $values = $this->request->request->get('attribute_value', array()); foreach ($this->request->request->get('attribute_name', array()) as $index => $name) { if (!empty($name)) { $attributes[$name] = $values[$index]; } } if ($attributes) { $cat->setDataField('__ATTRIBUTES__', $attributes); } $cat->insert(); // since the original insert can't construct the ipath (since // the insert id is not known yet) we update the object here. $cat->update(); $msg = __f('Done! Inserted the %s category.', $cat->_objData['name']); LogUtil::registerStatus($msg); return $this->redirect(ModUtil::url('Categories', 'admin', 'view') . '#top'); }
/** * create category */ public function newcatAction() { $this->checkCsrfToken(); if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADD)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } $dr = (int) $this->request->request->get('dr', 0); $url = System::serverGetVar('HTTP_REFERER'); if (!$dr) { return LogUtil::registerError($this->__('Error! The document root is invalid.'), null, $url); } $cat = new Category(); $data = $cat->getDataFromInput(); if (!$cat->validate()) { return $this->redirect(ModUtil::url('Categories', 'user', 'edit', $_POST) . '#top'); } $cat->insert(); // since the original insert can't construct the ipath (since // the insert id is not known yet) we update the object here. $cat->update(); $msg = $this->__f('Done! Inserted the %s category.', $data['name']); LogUtil::registerStatus($msg); return $this->redirect($url); }