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.
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 require_once('modules/Administration/Common.php');
41 require_once('modules/Administration/QuickRepairAndRebuild.php');
43 var $modules = array();
44 function getDropDownModules(){
45 $dir = dir('modules');
46 while($entry = $dir->read()){
47 if(file_exists('modules/'. $entry . '/EditView.php')){
48 $this->scanForDropDowns('modules/'. $entry . '/EditView.php', $entry);
54 function scanForDropDowns($filepath, $module){
55 $contents = file_get_contents($filepath);
57 preg_match_all('/app_list_strings\s*\[\s*[\'\"]([^\]]*)[\'\"]\s*]/', $contents, $matches);
58 if(!empty($matches[1])){
60 foreach($matches[1] as $match){
61 $this->modules[$module][$match] = $match;
69 * Allow for certain dropdowns to be filtered when edited by pre 5.0 studio (eg. Rename Tabs)
72 * @param array dropdown
73 * @return array Filtered dropdown list
75 function filterDropDown($name,$dropdown)
80 //When renaming tabs ensure that the modList dropdown is filtered properly.
82 $hiddenModList = array_flip($GLOBALS['modInvisList']);
83 $moduleList = array_flip($GLOBALS['moduleList']);
85 foreach ($dropdown as $k => $v)
87 if( isset($moduleList[$k]) ) // && !$hiddenModList[$k])
91 default: //By default perform no filtering
101 * Takes in the request params from a save request and processes
104 * @param REQUEST params $params
106 function saveDropDown($params){
109 $dropdown_name = $params['dropdown_name'];
110 $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);
111 $my_list_strings = return_app_list_strings_language($selected_lang);
112 while(isset($params['slot_' . $count])){
114 $index = $params['slot_' . $count];
115 $key = (isset($params['key_' . $index]))?to_html(remove_xss(from_html($params['key_' . $index]))): 'BLANK';
116 $value = (isset($params['value_' . $index]))?to_html(remove_xss(from_html($params['value_' . $index]))): '';
122 $value = trim($value);
123 if(empty($params['delete_' . $index])){
124 $dropdown[$key] = $value;
129 if($selected_lang == $GLOBALS['current_language']){
131 $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown;
133 $contents = return_custom_app_list_strings_file_contents($selected_lang);
137 //get rid of closing tags they are not needed and are just trouble
138 $contents = str_replace("?>", '', $contents);
139 if(empty($contents))$contents = "<?php";
140 //add new drop down to the bottom
141 if(!empty($params['use_push'])){
142 //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed
143 foreach($dropdown as $key=>$value){
144 //only if the value has changed or does not exist do we want to add it this way
145 if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){
146 //clear out the old value
147 $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism';
148 $contents = preg_replace($pattern_match, "\n", $contents);
150 $contents .= "\n\$app_list_strings['$dropdown_name']['$key']=" . var_export_helper($value) . ";";
154 //clear out the old value
155 $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\s*=\s*array\s*\([^\)]*\)\s*;\s*/ism';
156 $contents = preg_replace($pattern_match, "\n", $contents);
158 $contents .= "\n\$app_list_strings['$dropdown_name']=" . var_export_helper($dropdown) . ";";
161 // Bug 40234 - If we have no contents, we don't write the file. Checking for "<?php" because above it's set to that if empty
162 if($contents != "<?php"){
163 save_custom_app_list_strings_contents($contents, $selected_lang);
167 $repairAndClear = new RepairAndClear();
168 $repairAndClear->module_list = array(translate('LBL_ALL_MODULES'));
169 $repairAndClear->show_output = false;
170 $repairAndClear->clearJsLangFiles();