Example #1
0
         $padre['checked'] = false;
     }
 } else {
     $padre['checked'] = false;
 }
 $padre['children'] = array();
 if ($permisos = seguridad_permission::listPermissionsFor($m)) {
     foreach ($permisos as $p) {
         $permiso = array();
         $permiso['leaf'] = false;
         $permiso['expanded'] = true;
         $permiso['id'] = "p_" . $p->get("permission");
         $permiso['text'] = $p->get("nicename");
         $permiso['children'] = array();
         $permiso['iconCls'] = 'Clspermiso';
         if ($acciones = seguridad_action::listActionsFor($p, ALL_MENU)) {
             foreach ($acciones as $a) {
                 $accion = array();
                 $accion['leaf'] = true;
                 $accion['id'] = "a_" . $a->get("action");
                 $accion['text'] = $a->get("nicename");
                 $accion['iconCls'] = 'Clsaccion';
                 if (seguridad_action::exists($a, $role)) {
                     $accion['checked'] = true;
                 } else {
                     $accion['checked'] = false;
                 }
                 $permiso['children'][] = $accion;
             }
         }
         $padre['children'][] = $permiso;
Example #2
0
 /** returns the module admin menu */
 public function adminMenu()
 {
     global $ari;
     if ($ari->get('user') == false || is_a($ari->module, 'OOB_module') == false) {
         return false;
     }
     $menu = "";
     $array_menu = array();
     // loads localized array
     @(include $this->admindir() . DIRECTORY_SEPARATOR . 'menu' . DIRECTORY_SEPARATOR . $ari->agent->getLang() . '.php');
     // cache del menu para cada modulo en cada usuario
     // Set a id for this cache
     $id = 'menu__' . $ari->agent->getLang() . '__' . $ari->user->get('user') . '-' . $this->name() . '.php';
     //Set cache options
     $options = array('cacheDir' => $ari->cachedir . DIRECTORY_SEPARATOR, 'lifeTime' => SQL_CACHE, 'fileNameProtection' => false, 'automaticSerialization' => true);
     // Create a Cache_Lite object
     $Cache_Lite = new Cache_Lite($options);
     // Test if thereis a valide cache for this id
     if ($menu = $Cache_Lite->get($id)) {
         return $menu;
     } else {
         // No valid cache found
         if ($permissions = seguridad_permission::listPermissionsFor($this)) {
             $menu = array();
             $i = 0;
             foreach ($permissions as $p) {
                 if ($actions = seguridad_action::listActionsFor($p, IN_MENU)) {
                     foreach ($actions as $a) {
                         if (seguridad::isAllowed($a, $ari->perspective)) {
                             if (!count($array_menu) == 0) {
                                 $menu[$i]['name'] = $array_menu[$p->get("name") . $a->get("name")];
                             } else {
                                 $menu[$i]['name'] = $a->get("nicename");
                             }
                             $menu[$i]['link'] = $this->name() . "/" . $p->get("name") . "/" . $a->get("name");
                             $i++;
                         }
                     }
                     //end foreach $actions
                 }
             }
             //end foreach $permissions
         }
         if (count($menu) == 0) {
             $menu = false;
         }
         $Cache_Lite->save($menu);
         return $menu;
     }
     // end cache
 }