2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2013 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';
54 $modules_exempt_from_availability_check['CampaignLog']='CampaignLog';
55 $modules_exempt_from_availability_check['CampaignTrackers']='CampaignTrackers';
56 $modules_exempt_from_availability_check['Prospects']='Prospects';
57 $modules_exempt_from_availability_check['ProspectLists']='ProspectLists';
58 $modules_exempt_from_availability_check['EmailMarketing']='EmailMarketing';
59 $modules_exempt_from_availability_check['EmailMan']='EmailMan';
60 $modules_exempt_from_availability_check['ProjectTask']='ProjectTask';
61 $modules_exempt_from_availability_check['Users']='Users';
62 $modules_exempt_from_availability_check['Teams']='Teams';
63 $modules_exempt_from_availability_check['SchedulersJobs']='SchedulersJobs';
64 $modules_exempt_from_availability_check['DocumentRevisions']='DocumentRevisions';
65 function query_module_access_list(&$user)
67 require_once('modules/MySettings/TabController.php');
68 $controller = new TabController();
69 $tabArray = $controller->get_tabs($user);
75 function query_user_has_roles($user_id)
81 return $role->check_user_role_count($user_id);
84 function get_user_allowed_modules($user_id)
90 $allowed = $role->query_user_allowed_modules($user_id);
94 function get_user_disallowed_modules($user_id, &$allowed)
99 $disallowed = $role->query_user_disallowed_modules($user_id, $allowed);
102 // grabs client ip address and returns its value
103 function query_client_ip()
107 if(!empty($GLOBALS['sugar_config']['ip_variable']) && !empty($_SERVER[$GLOBALS['sugar_config']['ip_variable']])){
108 $clientIP = $_SERVER[$GLOBALS['sugar_config']['ip_variable']];
109 }else if(isset($_SERVER['HTTP_CLIENT_IP']))
111 $clientIP = $_SERVER['HTTP_CLIENT_IP'];
113 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))
115 // check for internal ips by looking at the first octet
116 foreach($matches[0] AS $ip)
118 if(!preg_match("#^(10|172\.16|192\.168)\.#", $ip))
126 elseif(isset($_SERVER['HTTP_FROM']))
128 $clientIP = $_SERVER['HTTP_FROM'];
132 $clientIP = $_SERVER['REMOTE_ADDR'];
137 // sets value to key value
138 function get_val_array($arr){
141 foreach($arr as $key=>$val){