/**
  * Save article
  *
  * @param   string	$bid
  * @return  void
  */
 public function update($bid)
 {
     // load dictionaries
     $this->dict->get_words();
     // get article id
     $mod = new Article_model();
     $item = $mod->get_by_bid($bid);
     // check permission
     AdmUtils_helper::chklevel($_SESSION['xuid'], 'articles', $item->id, 2);
     // only if there are differences
     if ($item->content != $_POST['content']) {
         // tinymce
         $post = array('bid' => $bid, 'id_area' => $item->id_area, 'lang' => $item->lang, 'code_context' => $item->code_context, 'id_page' => $item->id_page, 'date_in' => time(), 'xkeys' => $item->xkeys, 'name' => $item->name, 'content' => $_POST['content'], 'excerpt' => 0, 'author' => $_SESSION['mail'], 'module' => $item->module, 'param' => $item->param, 'id_editor' => $_SESSION['xuid'], 'xon' => AUTOREFRESH);
         // insert new article's version
         $result = $mod->insert($post);
         if ($result[1]) {
             // add permission
             $perm = new Permission_model();
             // privs permissions
             $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
             $res = $perm->pexec('articles', $array, $item->id_area);
         }
         // set message
         X4Utils_helper::set_msg($result);
         echo $_SESSION['msg'];
         unset($_SESSION['msg']);
     } else {
         echo '';
     }
 }
 /**
  * Register New / Edit article data
  *
  * @access	private
  * @param   object $item Article
  * @param   array	$_post _POST array
  * @return  void
  */
 private function editing($item, $_post)
 {
     $msg = null;
     // check permission
     if ($item->id) {
         $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $item->id, 2);
     }
     if (is_null($msg)) {
         // handle _post
         $post = array('bid' => $_post['bid'], 'id_area' => $_post['id_area'], 'lang' => $_post['lang'], 'code_context' => $_post['code_context'], 'category' => $_post['category'], 'id_page' => isset($_post['id_page']) ? $_post['id_page'] : 0, 'date_out' => empty($_post['date_out']) ? 0 : intval(strtotime($_post['date_out'])), 'xkeys' => strtolower($_post['xkeys']), 'name' => $_post['name'], 'content' => $_post['content'], 'js' => html_entity_decode($_post['js']), 'excerpt' => strstr($_post['content'], '<!--pagebreak-->') !== false ? 1 : 0, 'tags' => str_replace(', ', ',', $_post['tags']), 'author' => $_post['author'], 'module' => $_post['module'], 'param' => $_post['param'], 'id_editor' => $_SESSION['xuid'], 'show_author' => intval(isset($_post['show_author'])), 'show_date' => intval(isset($_post['show_date'])), 'show_tags' => intval(isset($_post['show_tags'])), 'show_actions' => intval(isset($_post['show_actions'])), 'xon' => AUTOREFRESH);
         // adjust date_in value in case of set or update
         if ($item->id == 0 || $_post['date_in'] != date('Y-m-d', $_post['old_date_in'])) {
             $post['date_in'] = strtotime($_post['date_in']) + (date('G') * 60 + date('i')) * 60 + date('s');
         } else {
             $post['date_in'] = $_post['old_date_in'];
         }
         // insert article
         $mod = new Article_model();
         // check for context
         // if the code_context is changed we assign a new bid to the article
         // if the id page is changed we assign a new bid
         if ($_post['old_context'] > -1 && $_post['old_context'] != $_post['code_context'] || isset($_post['id_page']) && $item->id_page != $_post['id_page']) {
             $post['bid'] = $mod->get_new_bid();
         }
         $result = $mod->insert($post);
         if (APC) {
             apc_delete(SITE . 'abid' . $post['id_area'] . $_post['lang'] . $_post['bid']);
             if (!empty($post['old_module'])) {
                 apc_delete(SITE . 'pageto' . $post['id_area'] . $_post['lang'] . $_post['old_module'] . $_post['old_param']);
             }
             if (!empty($post['module'])) {
                 apc_delete(SITE . 'pageto' . $post['id_area'] . $_post['lang'] . $post['module'] . $post['param']);
             }
         }
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // add permission
         if ($result[1]) {
             $perm = new Permission_model();
             $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
             $res = $perm->pexec('articles', $array, $_post['id_area']);
             if (!empty($_post['from'])) {
                 $msg->update[] = array('element' => 'topic', 'url' => urldecode($_post['from']), 'title' => null);
             }
         }
     }
     $this->response($msg);
 }