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 * VariableSubstitutionRule.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. This rule substitutes the current
44 * definitions will the standard meta-data ones.
49 require_once('include/SugarFields/Parsers/Rules/BaseRule.php');
51 class VariableSubstitutionRule extends BaseRule {
53 function VariableSubstitutionRule() {
57 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 if($this->matches($column, '/^date_entered$/') || $this->matches($column, '/^created_by$/')) {
63 $panels[$name][$rowCount][$key] = array (
64 'name' => 'date_entered',
65 'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}',
66 'label' => 'LBL_DATE_ENTERED',
68 } else if($this->matches($column, '/^team.*?(_name)?$/s')) {
69 $panels[$name][$rowCount][$key] = 'team_name';
70 } else if($this->matches($column, '/^date_modified$/') || $this->matches($column, '/^modified_by$/')) {
71 $panels[$name][$rowCount][$key] = array (
72 'name' => 'date_modified',
73 'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}',
74 'label' => 'LBL_DATE_MODIFIED',
76 } else if($this->matches($column, '/^assigned.*?(_to|_name|_link)$/s')) {
77 //Remove "assigned_to" variable... this will be replaced with "assigned_to"
78 $panels[$name][$rowCount][$key] = 'assigned_user_name';
79 } else if($this->matches($column, '/^vcard_link$/')) {
80 $panels[$name][$rowCount][$key] = array (
81 'name' => 'full_name',
82 'customCode' => '{$fields.full_name.value} <input type="button" class="button" name="vCardButton" value="{$MOD.LBL_VCARD}" onClick="document.vcard.submit();">',
83 'label' => 'LBL_NAME',
85 } else if($this->matches($column, '/^parent_type$/si')) {
86 $panels[$name][$rowCount][$key] = 'parent_name';
87 } else if($this->matches($column, '/^account_id$/')) {
88 $panels[$name][$rowCount][$key] = 'account_name';
89 } else if($this->matches($column, '/^contact_id$/')) {
90 $panels[$name][$rowCount][$key] = 'contact_name';
91 } else if($this->matches($column, '/^reports_to_id$/')) {
92 $panels[$name][$rowCount][$key] = 'report_to_name';
93 } else if($this->matches($column, '/^reminder_time$/')) {
94 $panels[$name][$rowCount][$key] = array(
95 'name'=>'reminder_checked',
96 'fields'=>array('reminder_checked', 'reminder_time')
98 } else if($this->matches($column, '/^currency(_name)*$/')) {
99 $panels[$name][$rowCount][$key] = 'currency_id';
100 } else if($this->matches($column, '/^quote_id$/')) {
101 $panels[$name][$rowCount][$key] = 'quote_name';
106 } else if($view == 'EditView') {
107 foreach($panels as $name=>$panel) {
108 foreach($panel as $rowCount=>$row) {
109 foreach($row as $key=>$column) {
111 if($this->matches($column, '/^salutation$/si') && is_array($column) && isset($column['fields']) && count($column['fields']) == 2) {
112 //Change salutation field to salutation + first_name'
113 $panels[$name][$rowCount][$key] = array (
114 'name' => 'first_name',
115 'customCode' => '{html_options name="salutation" options=$fields.salutation.options selected=$fields.salutation.value} <input name="first_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
117 } else if($this->matches($column, '/^parent_type$/si')) {
118 $panels[$name][$rowCount][$key] = 'parent_name';
119 } else if($this->matches($column, '/^currency(_name)$/')) {
120 $panels[$name][$rowCount][$key] = 'currency_id';
121 } else if($this->matches($column, '/^quote_id$/')) {
122 $panels[$name][$rowCount][$key] = 'quote_name';
123 } else if($this->matches($column, '/^account_id$/')) {
124 $panels[$name][$rowCount][$key] = 'account_name';
125 } else if($this->matches($column, '/^contact_id$/')) {
126 $panels[$name][$rowCount][$key] = 'contact_name';