]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Studio/TabGroups/TabGroupHelper.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Studio / TabGroups / TabGroupHelper.php
1 <?php
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-2012 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
55        if(should_hide_iframes() && isset($availableModules['iFrames'])) {
56           unset($availableModules['iFrames']);
57        }
58        return $availableModules;
59     }
60
61     /**
62      * Takes in the request params from a save request and processes
63      * them for the save.
64      *
65      * @param REQUEST params  $params
66      */
67     function saveTabGroups($params){
68         //#30205
69         global $sugar_config;
70
71         //Get the selected tab group language
72         $grouptab_lang = (!empty($params['grouptab_lang'])?$params['grouptab_lang']:$_SESSION['authenticated_user_language']);
73
74         $tabGroups = array();
75                 $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);
76         $slot_count = $params['slot_count'];
77                 $completedIndexes = array();
78         for($count = 0; $count < $slot_count; $count++){
79                 if($params['delete_' . $count] == 1 || !isset($params['slot_' . $count])){
80                         continue;
81                 }
82
83
84                 $index = $params['slot_' . $count];
85                 if (isset($completedIndexes[$index]))
86                    continue;
87
88                 $labelID = (!empty($params['tablabelid_' . $index]))?$params['tablabelid_' . $index]: 'LBL_GROUPTAB' . $count . '_'. time();
89                 $labelValue = SugarCleaner::stripTags(from_html($params['tablabel_' . $index]), false);
90                 $app_strings = return_application_language($grouptab_lang);
91                 if(empty($app_strings[$labelID]) || $app_strings[$labelID] != $labelValue){
92                         $contents = return_custom_app_list_strings_file_contents($grouptab_lang);
93                         $new_contents = replace_or_add_app_string($labelID,$labelValue, $contents);
94                         save_custom_app_list_strings_contents($new_contents, $grouptab_lang);
95
96                         $languages = get_languages();
97                         foreach ($languages as $language => $langlabel) {
98                                 if($grouptab_lang == $language){
99                                         continue;
100                                 }
101                                         $app_strings = return_application_language($language);
102                                 if(!isset($app_strings[$labelID])){
103                                         $contents = return_custom_app_list_strings_file_contents($language);
104                                         $new_contents = replace_or_add_app_string($labelID,$labelValue, $contents);
105                                         save_custom_app_list_strings_contents($new_contents, $language);
106                                 }
107                         }
108
109                         $app_strings[$labelID] = $labelValue;
110
111                 }
112                 $tabGroups[$labelID] = array('label'=>$labelID);
113                 $tabGroups[$labelID]['modules']= array();
114                 for($subcount = 0; isset($params[$index.'_' . $subcount]); $subcount++){
115                         $tabGroups[$labelID]['modules'][] = $params[$index.'_' . $subcount];
116                 }
117
118                 $completedIndexes[$index] = true;
119
120         }
121
122         // Force a rebuild of the app language
123         global $current_user;
124         include(get_custom_file_if_exists('modules/Administration/RebuildJSLang.php'));
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 ?>