コード例 #1
0
ファイル: menus_controller.php プロジェクト: paolocerto/x3cms
 /**
  * Register Edit / New Menu form data
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function editing($id, $_post)
 {
     $msg = null;
     // check permission
     if ($_post['id']) {
         $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'menus', $_post['id'], 2);
     } else {
         $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_menu_creation', 0, 4);
     }
     if (is_null($msg)) {
         // handle _post
         $post = array('id_theme' => $_post['id_theme'], 'name' => $_post['name'], 'description' => $_post['description']);
         $mod = new Menu_model();
         // update or insert
         if ($_post['id']) {
             $result = $mod->update($_post['id'], $post);
         } else {
             $result = $mod->insert($post);
             // add pemission
             if ($result[1]) {
                 $perm = new Permission_model();
                 $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
                 $result = $perm->pexec('menus', $array, 1);
             }
         }
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         if ($result[1]) {
             $theme = $mod->get_var($post['id_theme'], 'themes', 'name');
             $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'menus/index/' . $post['id_theme'] . '/' . $theme, 'title' => null);
         }
     }
     $this->response($msg);
 }