示例#1
0
 /**
  * Check if a context name already exists in the admin dictionary
  * If not then insert it
  *
  * @param   array 	$array Associative array ('lang' => 'language code', 'name' => 'context name')
  * @param   integer	$xon Context status
  * @return  void
  */
 public function check_dictionary($array, $xon = 0)
 {
     // prepare post array
     $post = array('area' => 'admin', 'lang' => $array['lang'], 'what' => 'articles', 'xkey' => '_CONTEXT_' . strtoupper($array['name']), 'xval' => ucfirst($array['name']), 'xon' => $xon);
     // check if context exists
     $dict = new Dictionary_model();
     $check = $dict->exists($post);
     // insert
     if (!$check) {
         $dict->insert($post);
     }
 }
 /**
  * Register New dictionary word form data
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function adding($_post)
 {
     $msg = null;
     // check permission
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_word_creation', 0, 4);
     if (is_null($msg)) {
         // handle _post
         $post = array('lang' => $_post['lang'], 'area' => $_post['area'], 'what' => X4Utils_helper::unspace($_post['what']), 'xkey' => strtoupper(trim($_post['xkey'])), 'xval' => nl2br(trim($_post['xval'])));
         $dict = new Dictionary_model();
         // check if words already exists
         $check = $dict->exists($post);
         if ($check) {
             $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_XKEY_ALREADY_EXISTS', 'msg'));
         } else {
             // insert
             $result = $dict->insert($post);
             // set message
             $msg = AdmUtils_helper::set_msg($result);
             // add permission
             if ($result[1]) {
                 $amod = new Area_model();
                 $id_area = $amod->get_area_id($_post['area']);
                 $perm = new Permission_model();
                 $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
                 $result = $perm->pexec('dictionary', $array, $id_area);
                 $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'dictionary/keys/' . $post['lang'] . '/' . $post['area'] . '/' . $post['what'], 'title' => null);
             }
         }
     }
     $this->response($msg);
 }