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-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 require_once('modules/Administration/Common.php');
42 var $modules = array();
43 function getDropDownModules(){
44 $dir = dir('modules');
45 while($entry = $dir->read()){
46 if(file_exists('modules/'. $entry . '/EditView.php')){
47 $this->scanForDropDowns('modules/'. $entry . '/EditView.php', $entry);
53 function scanForDropDowns($filepath, $module){
54 $contents = file_get_contents($filepath);
56 preg_match_all('/app_list_strings\s*\[\s*[\'\"]([^\]]*)[\'\"]\s*]/', $contents, $matches);
57 if(!empty($matches[1])){
59 foreach($matches[1] as $match){
60 $this->modules[$module][$match] = $match;
68 * Allow for certain dropdowns to be filtered when edited by pre 5.0 studio (eg. Rename Tabs)
71 * @param array dropdown
72 * @return array Filtered dropdown list
74 function filterDropDown($name,$dropdown)
79 //When renaming tabs ensure that the modList dropdown is filtered properly.
81 $hiddenModList = array_flip($GLOBALS['modInvisList']);
82 $moduleList = array_flip($GLOBALS['moduleList']);
84 foreach ($dropdown as $k => $v)
86 if( isset($moduleList[$k]) && !$hiddenModList[$k])
90 default: //By default perform no filtering
100 * Takes in the request params from a save request and processes
103 * @param REQUEST params $params
105 function saveDropDown($params){
108 $dropdown_name = $params['dropdown_name'];
109 $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']);
110 $my_list_strings = return_app_list_strings_language($selected_lang);
111 while(isset($params['slot_' . $count])){
113 $index = $params['slot_' . $count];
114 $key = (isset($params['key_' . $index]))?$params['key_' . $index]: 'BLANK';
115 $value = (isset($params['value_' . $index]))?$params['value_' . $index]: '';
121 $value = trim($value);
122 if(empty($params['delete_' . $index])){
123 $dropdown[$key] = $value;
128 if($selected_lang == $GLOBALS['current_language']){
130 $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown;
132 $contents = return_custom_app_list_strings_file_contents($selected_lang);
136 //get rid of closing tags they are not needed and are just trouble
137 $contents = str_replace("?>", '', $contents);
138 if(empty($contents))$contents = "<?php";
139 //add new drop down to the bottom
140 if(!empty($params['use_push'])){
141 //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed
142 foreach($dropdown as $key=>$value){
143 //only if the value has changed or does not exist do we want to add it this way
144 if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){
145 //clear out the old value
146 $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism';
147 $contents = preg_replace($pattern_match, "\n", $contents);
149 $contents .= "\n\$app_list_strings['$dropdown_name']['$key']=" . var_export_helper($value) . ";";
153 //clear out the old value
154 $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\s*=\s*array\s*\([^\)]*\)\s*;\s*/ism';
155 $contents = preg_replace($pattern_match, "\n", $contents);
157 $contents .= "\n\$app_list_strings['$dropdown_name']=" . var_export_helper($dropdown) . ";";
160 // 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
161 if($contents != "<?php"){
162 save_custom_app_list_strings_contents($contents, $selected_lang);