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 * VariableCleanupRule.php
42 * This is a utility base class to provide further refinement when converting
43 * pre 5.x files to the new meta-data rules.
48 require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
50 class VariableCleanupRule extends BaseRule {
52 function VariableCleanupRule() {
56 function parsePanels($panels, $view) {
58 if($view == 'DetailView') {
59 foreach($panels as $name=>$panel) {
60 foreach($panel as $rowCount=>$row) {
61 foreach($row as $key=>$column) {
62 //This converts variable ended with "_c_checked" to just "_c" (for checkboxes in DetailView)
63 if(!is_array($column) && isset($column) && preg_match('/(.*?)_c_checked$/s', $column, $matches)) {
64 if(count($matches) == 2) {
65 $panels[$name][$rowCount][$key] = $matches[1] . "_c";
67 } else if($this->matches($column, '/^parent_id$/si')) {
68 $panels[$name][$rowCount][$key] = '';
69 } else if($this->matches($column, '/^assigned_user_id$/si')) {
70 $panels[$name][$rowCount][$key] = '';
76 } else if ($view == 'EditView') {
78 foreach($panels as $name=>$panel) {
79 foreach($panel as $rowCount=>$row) {
80 foreach($row as $key=>$column) {
81 if($this->matches($column, '/^(.*?)_c\[\]$/s')) {
82 //This converts multienum variables named with [] suffix back to normal and removes custom code
83 $val = $this->getMatch($column, '/^(.*?)_c\[\]$/s');
84 $panels[$name][$rowCount][$key] = $val[1] . '_c';
85 } else if($this->matches($column, '/^parent_id$/si')) {
86 //Remove parent_id field (replaced with parent_name from master copy)
87 $panels[$name][$rowCount][$key] = '';
88 } else if($this->matches($column, '/^assigned_user_id$/si')) {
89 //Remove assigned_user_id field (replaced with assigned_user_name from master copy)
90 $panels[$name][$rowCount][$key] = '';
91 } else if($this->matches($column, '/^RADIOOPTIONS_/si')) {
92 //This converts radioenum variables
93 $val = $this->getMatch($column, '/^RADIOOPTIONS_(.*)?$/si');
94 $panels[$name][$rowCount][$key] = $val[1];