/** * Register page's composition * Use _POST data * * @param integer item id (if 0 then is a new item) * @param array _POST array * @return void */ public function compositing() { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $_POST['id_page'], 3); if (is_null($msg)) { // handle _POST $sections = array(); $post = array('id_area' => $_POST['id_area'], 'id_page' => $_POST['id_page'], 'xon' => 1); // handle _POST for each section for ($i = 1; $i <= $_POST['snum']; $i++) { $post['progressive'] = $i; // delete first comma $articles = substr($_POST['sort' . $i], 0, 1) == ',' ? substr($_POST['sort' . $i], 1) : $_POST['sort' . $i]; $post['articles'] = str_replace(',', '|', $articles); $sections[] = $post; } // register composition $mod = new Section_model(); $result = $mod->compose($sections); APC && apc_delete(SITE . 'sections' . $post['id_page']); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); // add permissions on new sections if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'sections/compose/' . $post['id_page'], 'title' => null); if (is_array($result[0]) && !empty($result[0])) { $perm = new Permission_model(); $array = array(); foreach ($result[0] as $i) { $array[] = array('action' => 'insert', 'id_what' => $i, 'id_user' => $_SESSION['xuid'], 'level' => 4); } $result = $perm->pexec('sections', $array, $_POST['id_area']); } } } $this->response($msg); }