protected function _edit_category() { $category_id = Utils::pg('cid', 0); if (!empty($category_id)) { if (!$this->session()->checkPerm('edit-categories')) { $this->denyAccess(); } } else { if (!$this->session()->checkPerm('create-categories')) { $this->denyAccess(); } } $this->addScript("js/functions.js"); $this->addScript("js/behaviour.js"); $this->addScript("js/advajax.js"); $this->addScript("js/ajax.js"); $this->addScript("js/admin/ctree.js"); $this->addScript("js/admin/edit-category.js"); $this->addCSS('css/admin/ctree.css'); $category = new Category($category_id); $category_name = Utils::p("category_name", $category->dbdata('category_name')); $category_description = Utils::p("category_description", $category->dbdata('category_description')); $category_parent = Utils::p("category_parent", $category->dbdata('category_parent', null)); $this->setTemplateVar('category_id', $category_id); $this->setTemplateVar('frm_category_name', $category_name); $this->setTemplateVar('frm_category_description', $category_description); $this->setTemplateVar('frm_category_parent', $category_parent); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $category->setDBData('category_name', $category_name); $category->setDBData('category_description', $category_description); $category->setDBData('category_parent', $category_parent); $category->save(); $category_id = $category->cid(); $this->setTemplateVar('category_id', $category_id); $this->finishAction(_T("Kategoria została zapisana.")); } }