]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Studio/TabGroups/TabGroupHelper.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Studio / TabGroups / TabGroupHelper.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39
40
41 require_once('modules/Administration/Common.php');
42 class TabGroupHelper{
43     var $modules = array();
44     function getAvailableModules($lang = ''){
45        static $availableModules = array();
46        if(!empty($availableModules))return $availableModules;
47        $specifyLanguageAppListStrings = $GLOBALS['app_list_strings'];
48        if(!empty($lang)){
49         $specifyLanguageAppListStrings = return_app_list_strings_language($lang);
50        }
51        foreach($GLOBALS['moduleList'] as $value){
52            $availableModules[$value] = array('label'=>$specifyLanguageAppListStrings['moduleList'][$value], 'value'=>$value);
53        }
54        foreach($GLOBALS['modInvisListActivities'] as $value){
55            $availableModules[$value] = array('label'=>$specifyLanguageAppListStrings['moduleList'][$value], 'value'=>$value);
56        }
57        
58        if(should_hide_iframes() && isset($availableModules['iFrames'])) {
59           unset($availableModules['iFrames']);
60        }
61        return $availableModules;
62     }
63     
64     /**
65      * Takes in the request params from a save request and processes 
66      * them for the save.
67      *
68      * @param REQUEST params  $params
69      */
70     function saveTabGroups($params){
71         //#30205 
72         global $sugar_config;
73
74         //Get the selected tab group language 
75         $grouptab_lang = (!empty($params['grouptab_lang'])?$params['grouptab_lang']:$_SESSION['authenticated_user_language']);  
76
77         $tabGroups = array();
78                 $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);          
79         $slot_count = $params['slot_count'];
80                 $completedIndexes = array();
81         for($count = 0; $count < $slot_count; $count++){
82                 if($params['delete_' . $count] == 1 || !isset($params['slot_' . $count])){
83                         continue;       
84                 }
85                 
86                 
87                 $index = $params['slot_' . $count];
88                 if (isset($completedIndexes[$index]))
89                    continue;
90                 
91                 $labelID = (!empty($params['tablabelid_' . $index]))?$params['tablabelid_' . $index]: 'LBL_GROUPTAB' . $count . '_'. time();
92                 $labelValue = $params['tablabel_' . $index];
93                 $app_strings = return_application_language($grouptab_lang);
94                 if(empty($app_strings[$labelID]) || $app_strings[$labelID] != $labelValue){
95                         $contents = return_custom_app_list_strings_file_contents($grouptab_lang);
96                         $new_contents = replace_or_add_app_string($labelID,$labelValue, $contents);
97                         save_custom_app_list_strings_contents($new_contents, $grouptab_lang);
98                         
99                         $languages = get_languages();
100                         foreach ($languages as $language => $langlabel) {
101                                 if($grouptab_lang == $language){
102                                         continue;
103                                 }
104                                         $app_strings = return_application_language($language);
105                                 if(!isset($app_strings[$labelID])){
106                                         $contents = return_custom_app_list_strings_file_contents($language);
107                                         $new_contents = replace_or_add_app_string($labelID,$labelValue, $contents);
108                                         save_custom_app_list_strings_contents($new_contents, $language);
109                                 }
110                         }
111                         
112                         $app_strings[$labelID] = $labelValue;
113                         
114                 }
115                 $tabGroups[$labelID] = array('label'=>$labelID);
116                 $tabGroups[$labelID]['modules']= array();
117                 for($subcount = 0; isset($params[$index.'_' . $subcount]); $subcount++){
118                         $tabGroups[$labelID]['modules'][] = $params[$index.'_' . $subcount];
119                 }
120                 
121                 $completedIndexes[$index] = true;
122                 
123         } 
124         // Force a rebuild of the app language
125         sugar_cache_clear('app_strings.'.$grouptab_lang);
126         $newFile = create_custom_directory('include/tabConfig.php');
127         write_array_to_file("GLOBALS['tabStructure']", $tabGroups, $newFile);
128                 $GLOBALS['tabStructure'] = $tabGroups; 
129    }
130     
131 }
132
133
134 ?>