Esempio n. 1
0
 /**
  * Busca as opções a serem exibidas no menu lateral do sistema
  * @return array contendo menus e submenus
  */
 public function getSideBarMenus()
 {
     $menus = Menu::find(array('conditions' => 'menu_active = 1', 'hydration' => Resultset::HYDRATE_ARRAYS))->toArray();
     foreach ($menus as $id => $menu) {
         $menus[$id]['submenu'] = Submenu::find(array("conditions" => "menu_id = :menu_id:", "bind" => array("menu_id" => $menu["menu_id"]), "hydration" => Resultset::HYDRATE_ARRAYS))->toArray();
         if (!empty($menus[$id]['submenu'])) {
             $menus[$id]['submenu_div_name'] = str_replace("#", "", $menus[$id]['menu_href']);
         }
     }
     return $menus;
 }
 /**
  * Atualiza um plugin conforme dados recebidos via POST
  */
 public function updatePluginAction()
 {
     $this->view->disable();
     $plugin_name = $this->request->getPost("plugin_name");
     $id_menu = $this->request->getPost("menu_id");
     $menu_name = $this->request->getPost("exibition_name");
     $menu_icon = $this->request->getPost("icon");
     $menu_url = $this->request->getPost("url");
     $menu_level_permission = $this->request->getPost("level_permission");
     $menu_active = $this->request->getPost("menu_active") == 'on' ? true : false;
     $success = Menu::updateMenu($id_menu, $menu_icon, $menu_name, $menu_url, $menu_level_permission, $menu_active);
     $success = Plugin::updatePlugin($id_menu, $plugin_name);
     if (!empty($this->request->getPost("submenu1_name")) && $success) {
         $submenu_id = $this->request->getPost("submenu1_id");
         $submenu_name = $this->request->getPost("submenu1_name");
         $submenu_url = $this->request->getPost("submenu1_url");
         $submenu_icon = $this->request->getPost("submenu1_icon");
         if (empty($submenu_id)) {
             $success = Submenu::createSubmenu($id_menu, $submenu_icon, $submenu_name, $submenu_url, 1);
         } else {
             $success = Submenu::updateSubmenu($submenu_id, $submenu_icon, $submenu_name, $submenu_url, 1);
         }
     }
     if (!empty($this->request->getPost("submenu2_name")) && $success) {
         $submenu_id = $this->request->getPost("submenu2_id");
         $submenu_name = $this->request->getPost("submenu2_name");
         $submenu_url = $this->request->getPost("submenu2_url");
         $submenu_icon = $this->request->getPost("submenu2_icon");
         if (empty($submenu_id)) {
             $success = Submenu::createSubmenu($id_menu, $submenu_icon, $submenu_name, $submenu_url, 2);
         } else {
             $success = Submenu::updateSubmenu($submenu_id, $submenu_icon, $submenu_name, $submenu_url, 2);
         }
     }
     $data['success'] = $success;
     echo json_encode($data);
 }
Esempio n. 3
0
 /**
  * Cria os menus e submenus da sidebar no banco de dados
  * @return boolean true caso sucesso, false caso ocorra algum erro!
  */
 private function createMenus()
 {
     $id_menu = Menu::createMenu("fa fa-users", "Usuários", "#sub-users", 2, 0);
     if ($id_menu > 0) {
         $success = Submenu::createSubmenu($id_menu, "fa fa-user-plus", "Novo", "users/newUser", 1);
         $success = $success ? Submenu::createSubmenu($id_menu, "glyphicon glyphicon-edit", "Editar", "users/listUsers", 2) : false;
     } else {
         $success = false;
     }
     $id_menu = $success ? Menu::createMenu("glyphicon glyphicon-tags", "Posts", "#sub-posts", 4, 0) : false;
     if ($id_menu > 0) {
         $success = Submenu::createSubmenu($id_menu, "glyphicon glyphicon-plus", "Novo", "post/index", 1);
         $success = $success ? Submenu::createSubmenu($id_menu, "glyphicon glyphicon-edit", "Editar", "post/listPosts", 2) : false;
     } else {
         $success = false;
     }
     $id_menu = $success ? Menu::createMenu("fa fa-cogs", "Configurações", "settings/index", 2, 0) : false;
     $id_menu = $id_menu > 0 ? Menu::createMenu("fa fa-pie-chart", "Estatisticas", "statistics/index", 1, 0) : false;
     $success = $id_menu > 0 ? Menu::createMenu("glyphicon glyphicon-refresh", "Atualizações", "update/index", 2, true) : false;
     $id_menu = $success ? Menu::createMenu("fa fa-puzzle-piece", "Plugins", "#sub-plugins", 1, 0) : false;
     if ($id_menu > 0) {
         $success = Submenu::createSubmenu($id_menu, "glyphicon glyphicon-plus", "Novo", "plugin/index", 1);
         $success = $success ? Submenu::createSubmenu($id_menu, "glyphicon glyphicon-edit", "Editar", "plugin/listPlugins", 1) : false;
     }
     return $success;
 }