Beispiel #1
0
 function edit($id = 0)
 {
     $adminrole = new adminrole($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $adminrole->name = $this->input->post('name');
         $adminrole->level = $this->input->post('level');
         $menu = $this->input->post('checkmenu');
         $getmenu = new adminmenu();
         $getmenu->where_in('id', $menu);
         $getmenu->get();
         if ($adminrole->exists()) {
             $adminrole->delete($adminrole->adminmenu->all);
         }
         if ($adminrole->save($getmenu->all)) {
             redirect($this->admin . 'adminroles/edit/' . $adminrole->id);
         }
     }
     $adminmenu = new adminmenu();
     $adminmenu->order_by('position', 'asc');
     $adminmenu->get();
     $dis['adminmenu'] = $adminmenu;
     $dis['base_url'] = base_url();
     $dis['title'] = "Menu";
     $dis['menu_active'] = "adminrole";
     $dis['view'] = "adminrole/edit";
     $dis['object'] = $adminrole;
     $this->viewadmin($dis);
 }
Beispiel #2
0
 function index()
 {
     $id = $this->uri->segment(4);
     $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $id));
     $adminmenu = new adminmenu($id);
     if (!$adminmenu->exists()) {
         show_404();
     }
     $sub = $adminmenu->child->where_related_adminrole('id', $this->logged_in_user->adminrole->id)->order_by('position', 'asc')->get(1);
     redirect($this->admin . $sub->link);
 }
Beispiel #3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new adminmenu();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Beispiel #4
0
 function edit($id = 0)
 {
     $sitelanguage = new sitelanguage($id);
     if ($_SERVER['REQUEST_METHOD'] == "GET") {
     } else {
         $sitelanguage->name = $this->input->post('name');
         $sitelanguage->short = $this->input->post('short');
         $getmenu = new adminmenu();
         if ($sitelanguage->save()) {
             redirect($this->admin . 'sitelanguages/edit/' . $sitelanguage->id);
         }
     }
     $adminmenu = new adminmenu();
     $adminmenu->order_by('position', 'asc');
     $adminmenu->get();
     $dis['adminmenu'] = $adminmenu;
     $dis['base_url'] = base_url();
     $dis['title'] = "Add/Edit Language";
     $dis['menu_active'] = "Ngôn ngữ";
     $dis['view'] = "sitelanguage/edit";
     $dis['object'] = $sitelanguage;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}sitelanguages", "onclick" => ""));
     $this->viewadmin($dis);
 }
Beispiel #5
0
 function deleteall()
 {
     $menu = $this->input->post('checkinput');
     foreach ($menu as $row) {
         $adminmenu = new adminmenu($row);
         if (!$adminmenu->exists()) {
             continue;
         }
         if ($adminmenu->parentmenu_id == NULL) {
             $adminmenu->delete();
         } else {
             if ($adminmenu->child->count() > 0) {
                 flash_message('error', 'Vui lòng xóa hết menu con của ' . $adminmenu->name);
             } else {
                 // $this->firephp->log("sdf");
                 $adminmenu->delete();
             }
         }
     }
     redirect($this->admin . 'adminmenus/list_all');
 }
 public function display()
 {
     header('Content-Type:text/html;charset=utf-8');
     $filePath = hopedir . '/lib/Smarty/libs/Smarty.class.php';
     if (!class_exists('smarty')) {
         include_once $filePath;
     }
     $smarty = new Smarty();
     $smarty->cache_lifetime = 0;
     $smarty->caching = false;
     $smarty->template_dir = './templates';
     $smarty->compile_dir = './templates_c';
     $smarty->cache_dir = './smarty_cache';
     $smarty->left_delimiter = '<{';
     $smarty->right_delimiter = '}>';
     $smarty->assign('controlname', $this->ctrlId);
     $smarty->assign('urlshort', $this->ctrlId . '/' . $this->tplname);
     $templtepach = $this->module->config['sitetemp'] . '/' . $this->ctrlId . '/' . $this->tplname . '.html';
     if (!file_exists('templates/' . $templtepach)) {
         $this->error('模板文件不存在');
     }
     $smarty->registerPlugin('function', 'ofunc', 'FUNC_function');
     $smarty->registerPlugin('block', 'oblock', 'FUNC_block');
     $data = $this->getdata();
     foreach ($data as $key => $value) {
         $smarty->assign($key, $value);
     }
     if ($this->ctrlId == 'admin') {
         $menu = adminmenu::submenu($data['admininfo']['limit']);
         $smarty->assign('menu', $menu);
     }
     $smarty->display($templtepach);
 }