Example #1
0
 /**
  * Delete article
  * Delete all versions of an article
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function deleting($_post)
 {
     $msg = null;
     // check permissions on articles
     $mod = new Article_model();
     $artt = $mod->get_all_by_bid($_post['bid']);
     foreach ($artt as $i) {
         if (is_null($msg)) {
             $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $i->id, 4);
         }
     }
     // check permissions on pages
     $smod = new Section_model();
     $pp = $smod->get_pages_by_bid($_post['bid']);
     foreach ($pp as $i) {
         if (is_null($msg)) {
             $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $i->id, 3);
         }
     }
     if (is_null($msg)) {
         // do action
         $result = $mod->delete_by_bid($_post['bid']);
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // set what update
         if ($result[1]) {
             $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/index/' . $_post['id_area'] . '/' . $_post['lang'], 'title' => null);
         }
     }
     $this->response($msg);
 }
Example #2
0
 /**
  * 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);
 }