[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/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=?";
  33          $result = $adb->pquery($query, array($userid));
  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=?";
  49                  $result = $adb->pquery($query, array($userRole));
  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= array();
  64          foreach($parentRoles as $par_rol_id)
  65          {
  66              array_push($parentRolelist, $par_rol_id);        
  67          }
  68          array_push($parentRolelist, $userRole);
  69          $query="select * from vtiger_group2rs where roleandsubid in (". generateQuestionMarks($parentRolelist) .")";
  70          $result = $adb->pquery($query, array($parentRolelist));
  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          foreach($this->user_groups as $grp_id)
  82          {
  83              $focus = new GetParentGroups();
  84              $focus->getAllParentGroups($grp_id);
  85              
  86              foreach($focus->parent_groups as $par_grp_id)
  87              {
  88                  if(! in_array($par_grp_id,$this->user_groups))
  89                  {
  90                      $this->user_groups[]=$par_grp_id;
  91                      
  92                  }    
  93              }
  94                                  
  95          } 
  96          $log->debug("Exiting getAllUserGroups method...");    
  97      
  98      }
  99  
 100      
 101  }
 102  
 103  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1