Example #1
0
 /**	Sincroniza las tablas de acciones
  */
 public static function synchronizeActions($arrayModules = false)
 {
     global $ari;
     $clause = "";
     if ($arrayModules) {
         if (!is_array($arrayModules)) {
             //es un solo modulo
             $moduleName = $ari->db->qMagic($arrayModules);
             $clause = " AND p_origen.modulename = {$moduleName} ";
         } else {
             //es un array con los nombres de los modulos de los permisos a sincronizar
             $first = true;
             $lista = false;
             foreach ($arrayModules as $moduleName) {
                 $moduleName = $ari->db->qMagic($moduleName);
                 if ($first) {
                     $lista = $moduleName;
                     $first = false;
                 } else {
                     $lista = $lista . "," . $moduleName;
                 }
             }
             if ($lista) {
                 $clause = " AND p_origen.modulename IN ({$lista}) ";
             }
         }
     }
     //security_permission:  ID, ModuleName, Name, NiceName
     //security_action: 		ID, PermissionID, Name, NiceName, inMenu
     $sql = "SELECT a_origen.Name AS aName, a_origen.NiceName AS aNiceName, a_origen.inMenu AS aInMenu,\n\t\t\t\t\t   p_origen.Name AS pName, p_origen.ModuleName AS pModuleName \n\t\t\t\tFROM security_permission_other p_origen, security_action_other a_origen\n\t\t\t\tWHERE p_origen.ID = a_origen.PermissionID\n\t\t\t\t{$clause}\n\t\t\t\tAND NOT EXISTS\n\t\t\t\t\t\t\t\t(\tSELECT 1\n\t\t\t\t\t\t\t\t\tFROM security_permission p_destino, security_action a_destino\n\t\t\t\t\t\t\t\t\tWHERE p_destino.ID = a_destino.PermissionID\n\t\t\t\t\t\t\t\t\tAND p_destino.name = p_origen.name \n\t\t\t\t\t\t\t\t\tAND p_destino.modulename = p_origen.modulename\n\t\t\t\t\t\t\t\t\tAND a_destino.name = a_origen.name\n\t\t\t\t\t\t\t\t)\n\t\t\t\t";
     //echo $sql;
     //exit;
     $savem = $ari->db->SetFetchMode(ADODB_FETCH_ASSOC);
     $rs = $ari->db->Execute($sql);
     $ari->db->SetFetchMode($savem);
     if ($rs && !$rs->EOF) {
         while (!$rs->EOF) {
             $permission = self::nameConstructor($rs->fields["pName"], $rs->fields["pModuleName"]);
             //var_dump();exit;
             $action = new seguridad_action(ID_UNDEFINED);
             $action->set('name', $rs->fields["aName"]);
             $action->set('nicename', $rs->fields["aNiceName"]);
             $action->set('inmenu', $rs->fields["aInMenu"]);
             $action->set('permission', $permission);
             $action->store();
             $rs->MoveNext();
         }
         //end while
         $rs->Close();
     }
 }
Example #2
0
     for ($i = 0; $i < count($_POST['modulo']); $i++) {
         $accion = new seguridad_action();
         if (isset($_POST['accion'][$i])) {
             $accion->set('name', $_POST['accion'][$i]);
         }
         if (isset($_POST['nicename'][$i])) {
             $accion->set('nicename', $_POST['nicename'][$i]);
         }
         if (isset($_POST['permiso'][$i])) {
             $permiso = new seguridad_permission($_POST['permiso'][$i]);
             $accion->set('permission', $permiso);
         }
         if (isset($_POST['inmenu'][$i])) {
             $accion->set('inmenu', $_POST['inmenu'][$i]);
         }
         if (!$accion->store()) {
             $storeOk = false;
         }
     }
     //end for
 }
 if ($storeOk) {
     header("Location: " . $ari->get("adminaddress") . '/seguridad/role/list');
     exit;
 } else {
     $array_values['modules'] = $modules;
     refrescar($array_values);
     $ari->t->assign("form", true);
     $ari->t->assign("error", true);
     if ($errores = $ari->error->getErrorsfor("seguridad_action")) {
         foreach ($errores as $error) {