Conjunto 753e2f4 en sipp


Ignorar:
Fecha y hora:
30/05/2013 17:09:54 (hace 11 años)
Autor:
Luis Peña <lpena@…>
Branches:
master, drupal-7.x
Children:
76b2289
Parents:
a012c55
Mensaje:

Corrigiendo asignacion de roles al crear usuarios enlace y supervisor

Fichero:
1 editado

Leyenda

No modificado
Añadido
Eliminado
  • modules/ente_planificador_sipp/ente_planificador_sipp.module

    r8ec7804 r753e2f4  
    11<?php
    22  /**
    3   * Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana
     3  * Sistema de Planificación y Presupuesto - SIPP
    44  * @file ente_planificador_sipp.module
    55  * Drupal part Module to code ente planificador module
    6   * Copyright 2013 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL)
     6  * Copyright 2013 Sistema de Planificación y Presupuesto - SIPP
    77  *
    88  * This program is free software; you can redistribute it and/or modify
     
    1919  * along with this program; if not, write to the Free Software
    2020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    21   *
    22   * @author Cenditel Merida - Msc. Juan Vizcarrondo
     21  * 
    2322  * @author Cenditel Merida - Ing. Luis Gerardo Peña Camacho
    2423  * @date 2013-01-10 // (a&#241;o-mes-dia)
     
    3231function ente_planificador_sipp_form_alter(&$form, $form_state, $form_id) {
    3332  /*
    34   echo $form_id;
    35   print "<pre>";
    36   print_r($form);
    37   print "</pre>";
    38   */
     33   * Configuración del ente planificador SIPP
     34   * Creación del Rol para el Actor Enlace
     35   */ 
    3936  if ($form_id == 'ente_planificador_admin_settings') {
    40     //$iconsets = entes_planificadores_toolbar_get_iconsets();
    41     //foreach($iconsets as $id => $value) {
    42     //  $icons[$id] = $value->name;
    43            
    44    
    45     $form['ActorPlanificadorEnlace'] = $form['ActorPlanificadorMacro'];
     37    $form['ActorPlanificadorEnlace'] = $form['ActorPlanificadorMacro']; 
    4638    $form['ActorPlanificadorEnlace']['#default_value'] = variable_get('ActorPlanificadorEnlace', 2);
    4739    $form['ActorPlanificadorEnlace']['#title'] = 'Rol para el Actor Enlace';
    4840    $form['ActorPlanificadorEnlace']['#description'] = 'Seleccione el rol para el Actor Enlace';
    49     $form['buttons']['#weight'] = 10;
    50      
     41        $form['buttons']['#weight'] = 10;     
    5142  }
    5243 
    5344  /*
    54    Modificando el registro de usuarios presentando los roles disponibles
    55   */
    56   if ($form_id == 'user_register') {
    57         /*
    58         print "<pre>";
    59         print_r($form_id);
    60         //print_r($form);
    61         print_r(user_roles());
    62         print "</pre>";
    63         */
     45   * Modificando el Registro de Usuarios presentando los roles disponibles:
     46   *      Supervisor   
     47   *      Enlace
     48   */   
     49  if ($form_id == 'user_register') {       
    6450        $roles = user_roles();
    6551        $rolenlace = variable_get('ActorPlanificadorEnlace', 2);
    66         //print_r($rolenlace);
     52        $rolsupervisor = variable_get('ActorPlanificadorMicro', 2);
    6753        $ente_planificador = FALSE;       
    6854        if (arg(4) && is_numeric(arg(4))) {
     
    7157        if($ente_planificador->tipo && $ente_planificador->tipo == 2) {
    7258            if (isset($roles[$rolenlace])) {
    73                 $form['account']['roles']['#options'][$rolenlace] = $roles[$rolenlace];
     59              $form['account']['roles']['#default_value'] = array(2);
     60              $form['account']['roles']['#options'][$rolenlace] = $roles[$rolenlace];
    7461            }
    7562        }
    7663  }
    7764}
     65
     66/*
     67 * hook_user
     68 * Verificando que se inserte el Rol seleccionado en el Registro del usuario
     69 * Si el Rol es Enlace se elimina el Rol Supervisor(Micro) que viene por
     70 * defecto del modulo ente_planificador en la función: ente_planificador_user
     71*/
     72function ente_planificador_sipp_user($op, &$edit, &$user, $category = NULL) {
     73  switch ($op) {   
     74    case 'insert':
     75      if(array_key_exists('entes', $edit) && $edit['entes']) {
     76        $roles = user_roles();
     77        $ente_planificador = node_load($edit['entes']);       
     78        $rolenlace = variable_get('ActorPlanificadorEnlace', 2);
     79        $rolsupervisor = variable_get('ActorPlanificadorMicro', 2);
     80        //Si se han creado los roles
     81        if(isset($roles[$rolenlace]) && isset($roles[$rolsupervisor])){         
     82          if ($ente_planificador->tipo) {
     83            if($ente_planificador->tipo && $ente_planificador->tipo == 2) {             
     84              $edit['roles'][2] = $roles[2];
     85              // Si se selecciona el rol Enlace
     86              if(isset($edit['roles'][$rolenlace])){
     87                //Elimina el rol supervisor
     88                unset($edit['roles'][$rolsupervisor]);
     89              }
     90              /*
     91              if(isset($edit['roles'][$rolsupervisor])){             
     92                unset($edit['roles'][$rolenlace]);
     93              */
     94            }
     95          }
     96        }
     97      }     
     98    break;   
     99  }
     100}
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.