/** * Register Edit / New Category form data * * @access private * @param integer $id item ID (if 0 then is a new item) * @param array $_post _POST array * @return void */ private function editing($id, $_post) { $msg = null; // check permission $msg = $id ? AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'categories', $_post['id'], 3) : AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_category_creation', 0, 4); if (is_null($msg)) { // handle _post $post = array('id_area' => $_post['id_area'], 'lang' => $_post['lang'], 'title' => $_post['title'], 'name' => X4Utils_helper::unspace($_post['title']), 'tag' => X4Utils_helper::unspace($_post['tag'])); $mod = new Category_model(); // check if category already exists $check = $mod->exists($post, $id); if ($check) { $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_CATEGORY_ALREADY_EXISTS', 'msg')); } else { // update or insert if ($id) { $result = $mod->update($_post['id'], $post); } else { $result = $mod->insert($post); // create permissions if ($result[1]) { $perm = new Permission_model(); $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('categories', $array, $_post['id_area']); } } // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'categories/index/' . $post['id_area'] . '/' . $post['lang'] . '/' . $post['tag'], 'title' => null); } } } $this->response($msg); }