2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
40 * func: query_module_access
43 * returns 1 if user has access to a module, else returns 0
47 $modules_exempt_from_availability_check['Activities']='Activities';
48 $modules_exempt_from_availability_check['History']='History';
49 $modules_exempt_from_availability_check['Calls']='Calls';
50 $modules_exempt_from_availability_check['Meetings']='Meetings';
51 $modules_exempt_from_availability_check['Tasks']='Tasks';
52 $modules_exempt_from_availability_check['Notes']='Notes';
53 $modules_exempt_from_availability_check['CampaignLog']='CampaignLog';
54 $modules_exempt_from_availability_check['CampaignTrackers']='CampaignTrackers';
55 $modules_exempt_from_availability_check['Prospects']='Prospects';
56 $modules_exempt_from_availability_check['ProspectLists']='ProspectLists';
57 $modules_exempt_from_availability_check['EmailMarketing']='EmailMarketing';
58 $modules_exempt_from_availability_check['EmailMan']='EmailMan';
59 $modules_exempt_from_availability_check['ProjectTask']='ProjectTask';
60 $modules_exempt_from_availability_check['Users']='Users';
61 $modules_exempt_from_availability_check['Teams']='Teams';
62 $modules_exempt_from_availability_check['SchedulersJobs']='SchedulersJobs';
63 $modules_exempt_from_availability_check['DocumentRevisions']='DocumentRevisions';
64 function query_module_access_list(&$user)
66 require_once('modules/MySettings/TabController.php');
67 $controller = new TabController();
68 $tabArray = $controller->get_tabs($user);
74 function query_user_has_roles($user_id)
80 return $role->check_user_role_count($user_id);
83 function get_user_allowed_modules($user_id)
89 $allowed = $role->query_user_allowed_modules($user_id);
93 function get_user_disallowed_modules($user_id, &$allowed)
98 $disallowed = $role->query_user_disallowed_modules($user_id, $allowed);
101 // grabs client ip address and returns its value
102 function query_client_ip()
106 if(!empty($GLOBALS['sugar_config']['ip_variable']) && !empty($_SERVER[$GLOBALS['sugar_config']['ip_variable']])){
107 $clientIP = $_SERVER[$GLOBALS['sugar_config']['ip_variable']];
108 }else if(isset($_SERVER['HTTP_CLIENT_IP']))
110 $clientIP = $_SERVER['HTTP_CLIENT_IP'];
112 elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))
114 // check for internal ips by looking at the first octet
115 foreach($matches[0] AS $ip)
117 if(!preg_match("#^(10|172\.16|192\.168)\.#", $ip))
125 elseif(isset($_SERVER['HTTP_FROM']))
127 $clientIP = $_SERVER['HTTP_FROM'];
131 $clientIP = $_SERVER['REMOTE_ADDR'];
136 // sets value to key value
137 function get_val_array($arr){
140 foreach($arr as $key=>$val){