[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/include/utils/ -> GetUserGroups.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9  *
  10   ********************************************************************************/
  11  
  12  /** Class to retreive all the Parent Groups of the specified Group
  13   *
  14   */
  15  require_once ('include/utils/UserInfoUtil.php');
  16  require_once ('include/utils/GetParentGroups.php');
  17  
  18  class GetUserGroups { 
  19  
  20      var $user_groups=Array();
  21      //var $userRole='';
  22  
  23      /** to get all the parent vtiger_groups of the specified group
  24       * @params $groupId --> Group Id :: Type Integer
  25           * @returns updates the parent group in the varibale $parent_groups of the class
  26           */
  27  	function getAllUserGroups($userid)
  28      {
  29          global $adb,$log;
  30          $log->debug("Entering getAllUserGroups(".$userid.") method...");
  31          //Retreiving from the user2grouptable
  32          $query="select * from vtiger_users2group where userid=".$userid;
  33          $result = $adb->query($query);
  34          $num_rows=$adb->num_rows($result);
  35          for($i=0;$i<$num_rows;$i++)
  36          {
  37              $now_group_id=$adb->query_result($result,$i,'groupid');
  38              if(! in_array($now_group_id,$this->user_groups))
  39              {
  40                  $this->user_groups[]=$now_group_id;
  41                      
  42              }
  43          }
  44  
  45          //Setting the User Role
  46          $userRole = fetchUserRole($userid);
  47          //Retreiving from the vtiger_user2role
  48          $query="select * from vtiger_group2role where roleid='".$userRole."'";
  49                  $result = $adb->query($query);
  50                  $num_rows=$adb->num_rows($result);
  51                  for($i=0;$i<$num_rows;$i++)
  52                  {
  53                          $now_group_id=$adb->query_result($result,$i,'groupid');
  54              if(! in_array($now_group_id,$this->user_groups))
  55              {
  56                  $this->user_groups[]=$now_group_id;
  57                      
  58              }
  59                  }
  60  
  61          //Retreiving from the user2rs
  62          $parentRoles=getParentRole($userRole);
  63          $parentRolelist="(";
  64          foreach($parentRoles as $par_rol_id)
  65          {
  66              $parentRolelist .= "'".$par_rol_id."',";        
  67          }
  68          $parentRolelist .= "'".$userRole."')";
  69          $query="select * from vtiger_group2rs where roleandsubid in".$parentRolelist;
  70                  $result = $adb->query($query);
  71                  $num_rows=$adb->num_rows($result);
  72                  for($i=0;$i<$num_rows;$i++)
  73                  {
  74                          $now_group_id=$adb->query_result($result,$i,'groupid');
  75   
  76              if(! in_array($now_group_id,$this->user_groups))
  77              {
  78                  $this->user_groups[]=$now_group_id;
  79                      
  80              }
  81                  }
  82          foreach($this->user_groups as $grp_id)
  83          {
  84              $focus = new GetParentGroups();
  85              $focus->getAllParentGroups($grp_id);
  86              
  87              foreach($focus->parent_groups as $par_grp_id)
  88              {
  89                  if(! in_array($par_grp_id,$this->user_groups))
  90                  {
  91                      $this->user_groups[]=$par_grp_id;
  92                      
  93                  }    
  94              }
  95                                  
  96          } 
  97          $log->debug("Exiting getAllUserGroups method...");    
  98      
  99      }
 100  
 101      
 102  }
 103  
 104  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7