/**
  * 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 '';
     }
 }
 /**
  * Delete Article form (use Ajax)
  * Delete all versions of an article
  *
  * @param   $bid string, unique ID for articles
  * @return  void
  */
 public function delete($bid)
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'articles'));
     // get object
     $mod = new Article_model();
     $obj = $mod->get_by_bid($bid);
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $bid, 'name' => 'bid');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $obj->id_area, 'name' => 'id_area');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $obj->lang, 'name' => 'lang');
     // if submitted
     if (X4Route_core::$post) {
         $this->deleting($_POST);
         die;
     }
     // contents
     $view = new X4View_core('delete');
     $view->title = _DELETE_ARTICLE;
     $view->item = $obj->name;
     // form builder
     $view->form = X4Form_helper::doform('delete', $_SERVER["REQUEST_URI"], $fields, array(null, _YES, 'buttons'), 'post', '', 'onclick="setForm(\'delete\');"');
     $view->render(TRUE);
 }