Ejemplo n.º 1
0
 public function multiple_action()
 {
     $ids = $this->input->post('ids');
     $action = $this->input->post('action');
     $id_page = $this->input->post('id_page');
     $returned_ids = array();
     if (!empty($ids)) {
         switch ($action) {
             case 'delete':
                 foreach ($ids as $id_article) {
                     $nb = $this->article_model->delete($id_article);
                     if ($nb > 0) {
                         $returned_ids[] = $id_article;
                     }
                 }
                 break;
             case 'unlink':
                 foreach ($ids as $id_article) {
                     $nb = $this->article_model->unlink($id_article, $id_page);
                     if ($nb > 0) {
                         $returned_ids[] = $id_article;
                     }
                 }
                 break;
             case 'offline':
                 foreach ($ids as $id_article) {
                     $this->article_model->switch_online($id_page, $id_article, 0);
                 }
                 $returned_ids = $ids;
                 break;
             case 'online':
                 foreach ($ids as $id_article) {
                     $this->article_model->switch_online($id_page, $id_article, 1);
                 }
                 $returned_ids = $ids;
                 break;
         }
         $this->url_model->clean_table();
         $this->xhr_output(array('action' => $action, 'id_page' => $id_page, 'ids' => $returned_ids));
     } else {
         $this->error(lang('ionize_message_operation_nok'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Delete article's version
  *
  * @access	private
  * @param   integer $id article ID
  * @param   string 	$bid BID code
  * @return  void
  */
 private function deleting_version($id)
 {
     $msg = null;
     // check permissions
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $id, 4);
     if (is_null($msg)) {
         // do action
         $mod = new Article_model();
         $obj = $mod->get_by_id($id, 'articles', 'id_area, lang, bid');
         $result = $mod->delete($id);
         // clear useless permissions
         if ($result[1]) {
             $perm = new Permission_model();
             $perm->deleting_by_what('articles', $id);
         }
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // set what update
         if ($result[1]) {
             $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/history/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->bid, 'title' => null);
         }
     }
     $this->response($msg);
 }