Passed
Push — scrutinizer-code-quality ( 27193c...09f5a1 )
by Adam
51:28
created
modules/AOR_Reports/metadata/listviewdefs.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /**
4 4
  * Advanced OpenReports, SugarCRM Reporting.
5 5
  * @package Advanced OpenReports for SugarCRM
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 $listViewDefs ['AOR_Reports'] =
28
-array (
28
+array(
29 29
   'NAME' => 
30
-  array (
30
+  array(
31 31
     'width' => '15%',
32 32
     'label' => 'LBL_NAME',
33 33
     'default' => true,
34 34
     'link' => true,
35 35
   ),
36 36
   'REPORT_MODULE' => 
37
-  array (
37
+  array(
38 38
     'type' => 'enum',
39 39
     'default' => true,
40 40
     'studio' => 'visible',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     'width' => '15%',
43 43
   ),
44 44
   'ASSIGNED_USER_NAME' => 
45
-  array (
45
+  array(
46 46
     'width' => '15%',
47 47
     'label' => 'LBL_ASSIGNED_TO_NAME',
48 48
     'module' => 'Employees',
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
     'default' => true,
51 51
   ),
52 52
   'DATE_ENTERED' => 
53
-  array (
53
+  array(
54 54
     'type' => 'datetime',
55 55
     'label' => 'LBL_DATE_ENTERED',
56 56
     'width' => '15%',
57 57
     'default' => true,
58 58
   ),
59 59
   'DATE_MODIFIED' => 
60
-  array (
60
+  array(
61 61
     'type' => 'datetime',
62 62
     'label' => 'LBL_DATE_MODIFIED',
63 63
     'width' => '15%',
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,42 +26,42 @@
 block discarded – undo
26 26
 
27 27
 $listViewDefs ['AOR_Reports'] =
28 28
 array (
29
-  'NAME' => 
30
-  array (
29
+    'NAME' => 
30
+    array (
31 31
     'width' => '15%',
32 32
     'label' => 'LBL_NAME',
33 33
     'default' => true,
34 34
     'link' => true,
35
-  ),
36
-  'REPORT_MODULE' => 
37
-  array (
35
+    ),
36
+    'REPORT_MODULE' => 
37
+    array (
38 38
     'type' => 'enum',
39 39
     'default' => true,
40 40
     'studio' => 'visible',
41 41
     'label' => 'LBL_REPORT_MODULE',
42 42
     'width' => '15%',
43
-  ),
44
-  'ASSIGNED_USER_NAME' => 
45
-  array (
43
+    ),
44
+    'ASSIGNED_USER_NAME' => 
45
+    array (
46 46
     'width' => '15%',
47 47
     'label' => 'LBL_ASSIGNED_TO_NAME',
48 48
     'module' => 'Employees',
49 49
     'id' => 'ASSIGNED_USER_ID',
50 50
     'default' => true,
51
-  ),
52
-  'DATE_ENTERED' => 
53
-  array (
51
+    ),
52
+    'DATE_ENTERED' => 
53
+    array (
54 54
     'type' => 'datetime',
55 55
     'label' => 'LBL_DATE_ENTERED',
56 56
     'width' => '15%',
57 57
     'default' => true,
58
-  ),
59
-  'DATE_MODIFIED' => 
60
-  array (
58
+    ),
59
+    'DATE_MODIFIED' => 
60
+    array (
61 61
     'type' => 'datetime',
62 62
     'label' => 'LBL_DATE_MODIFIED',
63 63
     'width' => '15%',
64 64
     'default' => true,
65
-  ),
65
+    ),
66 66
 );
67 67
 ?>
Please login to merge, or discard this patch.
modules/AOR_Reports/views/view.edit.php 4 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
         //readfile('modules/AOR_Reports/css/edit.css');
39 39
         readfile('modules/AOR_Reports/js/jqtree/jqtree.css');
40 40
         echo "</style>";
41
-        if (!is_file('cache/jsLanguage/AOR_Fields/' . $GLOBALS['current_language'] . '.js')) {
41
+        if (!is_file('cache/jsLanguage/AOR_Fields/'.$GLOBALS['current_language'].'.js')) {
42 42
             require_once ('include/language/jsLanguage.php');
43 43
             jsLanguage::createModuleStringsCache('AOR_Fields', $GLOBALS['current_language']);
44 44
         }
45
-        echo '<script src="cache/jsLanguage/AOR_Fields/'. $GLOBALS['current_language'] . '.js"></script>';
45
+        echo '<script src="cache/jsLanguage/AOR_Fields/'.$GLOBALS['current_language'].'.js"></script>';
46 46
 
47
-        if (!is_file('cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js')) {
47
+        if (!is_file('cache/jsLanguage/AOR_Conditions/'.$GLOBALS['current_language'].'.js')) {
48 48
             require_once ('include/language/jsLanguage.php');
49 49
             jsLanguage::createModuleStringsCache('AOR_Conditions', $GLOBALS['current_language']);
50 50
         }
51
-        echo '<script src="cache/jsLanguage/AOR_Conditions/'. $GLOBALS['current_language'] . '.js"></script>';
51
+        echo '<script src="cache/jsLanguage/AOR_Conditions/'.$GLOBALS['current_language'].'.js"></script>';
52 52
         echo '<script src="include/javascript/yui3/build/yui/yui-min.js"></script>';
53 53
 
54 54
         echo "<script>";
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
         parent::preDisplay();
70 70
     }
71 71
 
72
-    private function getConditionLines(){
73
-        if(!$this->bean->id){
72
+    private function getConditionLines() {
73
+        if (!$this->bean->id) {
74 74
             return array();
75 75
         }
76 76
         $sql = "SELECT id FROM aor_conditions WHERE aor_report_id = '".$this->bean->id."' AND deleted = 0 ORDER BY condition_order ASC";
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
         while ($row = $this->bean->db->fetchByAssoc($result)) {
80 80
             $condition_name = new AOR_Condition();
81 81
             $condition_name->retrieve($row['id']);
82
-            if(!$condition_name->parenthesis) {
82
+            if (!$condition_name->parenthesis) {
83 83
                 $condition_name->module_path = implode(":", unserialize(base64_decode($condition_name->module_path)));
84 84
             }
85
-            if($condition_name->value_type == 'Date'){
85
+            if ($condition_name->value_type == 'Date') {
86 86
                 $condition_name->value = unserialize(base64_decode($condition_name->value));
87 87
             }
88 88
             $condition_item = $condition_name->toArray();
89 89
 
90
-            if(!$condition_name->parenthesis) {
90
+            if (!$condition_name->parenthesis) {
91 91
                 $display = getDisplayForField($condition_name->module_path, $condition_name->field, $this->bean->report_module);
92 92
                 $condition_item['module_path_display'] = $display['module'];
93 93
                 $condition_item['field_label'] = $display['field'];
94 94
             }
95
-            if(isset($conditions[$condition_item['condition_order']])) {
95
+            if (isset($conditions[$condition_item['condition_order']])) {
96 96
                 $conditions[] = $condition_item;
97 97
             }
98 98
             else {
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
         return $conditions;
103 103
     }
104 104
 
105
-    private function getFieldLines(){
106
-        if(!$this->bean->id){
105
+    private function getFieldLines() {
106
+        if (!$this->bean->id) {
107 107
             return array();
108 108
         }
109 109
         $sql = "SELECT id FROM aor_fields WHERE aor_report_id = '".$this->bean->id."' AND deleted = 0 ORDER BY field_order ASC";
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
         while ($row = $this->bean->db->fetchByAssoc($result)) {
114 114
             $field_name = new AOR_Field();
115 115
             $field_name->retrieve($row['id']);
116
-            $field_name->module_path = implode(":",unserialize(base64_decode($field_name->module_path)));
116
+            $field_name->module_path = implode(":", unserialize(base64_decode($field_name->module_path)));
117 117
             $arr = $field_name->toArray();
118 118
 
119
-            $arr['field_type'] = $this->getDisplayForField($field_name->module_path, $field_name->field  , $this->bean->report_module);
119
+            $arr['field_type'] = $this->getDisplayForField($field_name->module_path, $field_name->field, $this->bean->report_module);
120 120
 
121 121
             $display = getDisplayForField($field_name->module_path, $field_name->field, $this->bean->report_module);
122 122
 
@@ -127,42 +127,42 @@  discard block
 block discarded – undo
127 127
         return $fields;
128 128
     }
129 129
 
130
-    private function getChartLines(){
130
+    private function getChartLines() {
131 131
         $charts = array();
132
-        if(!$this->bean->id){
132
+        if (!$this->bean->id) {
133 133
             return array();
134 134
         }
135
-        foreach($this->bean->get_linked_beans('aor_charts','AOR_Charts') as $chart){
135
+        foreach ($this->bean->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
136 136
             $charts[] = $chart->toArray();
137 137
         }
138 138
         return $charts;
139 139
     }
140 140
 
141
-    public function getDisplayForField($modulePath, $field, $reportModule){
141
+    public function getDisplayForField($modulePath, $field, $reportModule) {
142 142
         $modulePathDisplay = array();
143 143
         $currentBean = BeanFactory::getBean($reportModule);
144 144
         $modulePathDisplay[] = $currentBean->module_name;
145
-        if(is_array($modulePath)) {
145
+        if (is_array($modulePath)) {
146 146
             $split = $modulePath;
147
-        }else{
147
+        } else {
148 148
             $split = explode(':', $modulePath);
149 149
         }
150 150
         if ($split && $split[0] == $currentBean->module_dir) {
151 151
             array_shift($split);
152 152
         }
153
-        foreach($split as $relName){
154
-            if(empty($relName)){
153
+        foreach ($split as $relName) {
154
+            if (empty($relName)) {
155 155
                 continue;
156 156
             }
157
-            if(!empty($currentBean->field_name_map[$relName]['vname'])){
158
-                $moduleLabel = trim(translate($currentBean->field_name_map[$relName]['vname'],$currentBean->module_dir),':');
157
+            if (!empty($currentBean->field_name_map[$relName]['vname'])) {
158
+                $moduleLabel = trim(translate($currentBean->field_name_map[$relName]['vname'], $currentBean->module_dir), ':');
159 159
             }
160 160
             $thisModule = getRelatedModule($currentBean->module_dir, $relName);
161 161
             $currentBean = BeanFactory::getBean($thisModule);
162 162
 
163
-            if(!empty($moduleLabel)){
163
+            if (!empty($moduleLabel)) {
164 164
                 $modulePathDisplay[] = $moduleLabel;
165
-            }else {
165
+            } else {
166 166
                 $modulePathDisplay[] = $currentBean->module_name;
167 167
             }
168 168
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
             }
95 95
             if(isset($conditions[$condition_item['condition_order']])) {
96 96
                 $conditions[] = $condition_item;
97
-            }
98
-            else {
97
+            } else {
99 98
                 $conditions[$condition_item['condition_order']] = $condition_item;
100 99
             }
101 100
         }
@@ -144,7 +143,7 @@  discard block
 block discarded – undo
144 143
         $modulePathDisplay[] = $currentBean->module_name;
145 144
         if(is_array($modulePath)) {
146 145
             $split = $modulePath;
147
-        }else{
146
+        } else{
148 147
             $split = explode(':', $modulePath);
149 148
         }
150 149
         if ($split && $split[0] == $currentBean->module_dir) {
@@ -162,7 +161,7 @@  discard block
 block discarded – undo
162 161
 
163 162
             if(!empty($moduleLabel)){
164 163
                 $modulePathDisplay[] = $moduleLabel;
165
-            }else {
164
+            } else {
166 165
                 $modulePathDisplay[] = $currentBean->module_name;
167 166
             }
168 167
         }
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -138,6 +138,10 @@
 block discarded – undo
138 138
         return $charts;
139 139
     }
140 140
 
141
+    /**
142
+     * @param string $modulePath
143
+     * @param string $field
144
+     */
141 145
     public function getDisplayForField($modulePath, $field, $reportModule){
142 146
         $modulePathDisplay = array();
143 147
         $currentBean = BeanFactory::getBean($reportModule);
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
- /**
3
- *
4
- *
5
- * @package
6
- * @copyright SalesAgility Ltd http://www.salesagility.com
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
- * the Free Software Foundation; either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
- * along with this program; if not, see http://www.gnu.org/licenses
20
- * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
- * Fifth Floor, Boston, MA 02110-1301  USA
22
- *
23
- * @author Salesagility Ltd <[email protected]>
24
- */
2
+    /**
3
+     *
4
+     *
5
+     * @package
6
+     * @copyright SalesAgility Ltd http://www.salesagility.com
7
+     *
8
+     * This program is free software; you can redistribute it and/or modify
9
+     * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
+     * the Free Software Foundation; either version 3 of the License, or
11
+     * (at your option) any later version.
12
+     *
13
+     * This program is distributed in the hope that it will be useful,
14
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+     * GNU General Public License for more details.
17
+     *
18
+     * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
+     * along with this program; if not, see http://www.gnu.org/licenses
20
+     * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
+     * Fifth Floor, Boston, MA 02110-1301  USA
22
+     *
23
+     * @author Salesagility Ltd <[email protected]>
24
+     */
25 25
 class AOD_LogicHooks{
26 26
 
27 27
     function saveModuleChanges(SugarBean $bean, $event, $arguments){
Please login to merge, or discard this patch.
modules/AOR_Reports/views/view.detail.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
     public function __construct() {
30 30
         parent::ViewDetail();
31 31
     }
32
-    private function getReportParameters(){
33
-        if(!$this->bean->id){
32
+    private function getReportParameters() {
33
+        if (!$this->bean->id) {
34 34
             return array();
35 35
         }
36
-        $conditions = $this->bean->get_linked_beans('aor_conditions','AOR_Conditions', 'condition_order');
36
+        $conditions = $this->bean->get_linked_beans('aor_conditions', 'AOR_Conditions', 'condition_order');
37 37
         $parameters = array();
38
-        foreach($conditions as $condition){
39
-            if(!$condition->parameter){
38
+        foreach ($conditions as $condition) {
39
+            if (!$condition->parameter) {
40 40
                 continue;
41 41
             }
42
-            $condition->module_path = implode(":",unserialize(base64_decode($condition->module_path)));
43
-            if($condition->value_type == 'Date'){
42
+            $condition->module_path = implode(":", unserialize(base64_decode($condition->module_path)));
43
+            if ($condition->value_type == 'Date') {
44 44
                 $condition->value = unserialize(base64_decode($condition->value));
45 45
             }
46 46
             $condition_item = $condition->toArray();
47 47
             $display = getDisplayForField($condition->module_path, $condition->field, $this->bean->report_module);
48 48
             $condition_item['module_path_display'] = $display['module'];
49 49
             $condition_item['field_label'] = $display['field'];
50
-            if(!empty($this->bean->user_parameters[$condition->id])){
50
+            if (!empty($this->bean->user_parameters[$condition->id])) {
51 51
                 $param = $this->bean->user_parameters[$condition->id];
52 52
                 $condition_item['operator'] = $param['operator'];
53 53
                 $condition_item['value_type'] = $param['type'];
54 54
                 $condition_item['value'] = $param['value'];
55 55
             }
56
-            if(isset($parameters[$condition_item['condition_order']])) {
56
+            if (isset($parameters[$condition_item['condition_order']])) {
57 57
                 $parameters[] = $condition_item;
58 58
             }
59 59
             else {
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
     public function preDisplay() {
67 67
         global $app_list_strings;
68 68
         parent::preDisplay();
69
-        $this->ss->assign('report_module',$this->bean->report_module);
69
+        $this->ss->assign('report_module', $this->bean->report_module);
70 70
 
71 71
 
72 72
 
73 73
         $this->bean->user_parameters = requestToUserParameters();
74 74
 
75 75
         //$reportHTML = $this->bean->build_group_report(0,true);
76
-        $reportHTML = $this->bean->buildMultiGroupReport(0,true);
76
+        $reportHTML = $this->bean->buildMultiGroupReport(0, true);
77 77
 
78 78
         $chartsHTML = $this->bean->build_report_chart(null, AOR_Report::CHART_TYPE_RGRAPH);
79 79
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
         $this->ss->assign('report_content', $reportHTML);
85 85
 
86 86
         echo "<input type='hidden' name='report_module' id='report_module' value='{$this->bean->report_module}'>";
87
-        if (!is_file('cache/jsLanguage/AOR_Conditions/' . $GLOBALS['current_language'] . '.js')) {
87
+        if (!is_file('cache/jsLanguage/AOR_Conditions/'.$GLOBALS['current_language'].'.js')) {
88 88
             require_once ('include/language/jsLanguage.php');
89 89
             jsLanguage::createModuleStringsCache('AOR_Conditions', $GLOBALS['current_language']);
90 90
         }
91
-        echo '<script src="cache/jsLanguage/AOR_Conditions/'. $GLOBALS['current_language'] . '.js"></script>';
91
+        echo '<script src="cache/jsLanguage/AOR_Conditions/'.$GLOBALS['current_language'].'.js"></script>';
92 92
 
93 93
         $params = $this->getReportParameters();
94 94
         echo "<script>var reportParameters = ".json_encode($params).";</script>";
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@
 block discarded – undo
55 55
             }
56 56
             if(isset($parameters[$condition_item['condition_order']])) {
57 57
                 $parameters[] = $condition_item;
58
-            }
59
-            else {
58
+            } else {
60 59
                 $parameters[$condition_item['condition_order']] = $condition_item;
61 60
             }
62 61
         }
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
- /**
3
- * 
4
- * 
5
- * @package 
6
- * @copyright SalesAgility Ltd http://www.salesagility.com
7
- * 
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
- * the Free Software Foundation; either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
- * along with this program; if not, see http://www.gnu.org/licenses
20
- * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
- * Fifth Floor, Boston, MA 02110-1301  USA
22
- *
23
- * @author Salesagility Ltd <[email protected]>
24
- */
2
+    /**
3
+     * 
4
+     * 
5
+     * @package 
6
+     * @copyright SalesAgility Ltd http://www.salesagility.com
7
+     * 
8
+     * This program is free software; you can redistribute it and/or modify
9
+     * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
10
+     * the Free Software Foundation; either version 3 of the License, or
11
+     * (at your option) any later version.
12
+     *
13
+     * This program is distributed in the hope that it will be useful,
14
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+     * GNU General Public License for more details.
17
+     *
18
+     * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
19
+     * along with this program; if not, see http://www.gnu.org/licenses
20
+     * or write to the Free Software Foundation,Inc., 51 Franklin Street,
21
+     * Fifth Floor, Boston, MA 02110-1301  USA
22
+     *
23
+     * @author Salesagility Ltd <[email protected]>
24
+     */
25 25
 require_once 'modules/InboundEmail/InboundEmail.php';
26 26
 require_once 'include/clean.php';
27 27
 class AOPInboundEmail extends InboundEmail {
Please login to merge, or discard this patch.
modules/AOR_Reports/controller.php 2 patches
Braces   +110 added lines, -51 removed lines patch added patch discarded remove patch
@@ -191,10 +191,11 @@  discard block
 block discarded – undo
191 191
 
192 192
             for($x =0; $x < $countOfCharts; $x++)
193 193
             {
194
-                if(is_null($itemsWithModulus) ||  $x < $itemsWithModulus)
195
-                    $graphHtml.="<img src='.$graphs[$x].' style='width:$width%;' />";
196
-                else
197
-                    $graphHtml.="<img src='.$graphs[$x].' style='width:$modulusWidth%;' />";
194
+                if(is_null($itemsWithModulus) ||  $x < $itemsWithModulus) {
195
+                                    $graphHtml.="<img src='.$graphs[$x].' style='width:$width%;' />";
196
+                } else {
197
+                                    $graphHtml.="<img src='.$graphs[$x].' style='width:$modulusWidth%;' />";
198
+                }
198 199
             }
199 200
 
200 201
 /*            foreach($graphs as $g)
@@ -241,7 +242,7 @@  discard block
 block discarded – undo
241 242
             $pdf->WriteHTML($printable,3);
242 243
             $pdf->Output($this->bean->name.'.pdf', "D");
243 244
 
244
-        }catch(mPDF_exception $e){
245
+        } catch(mPDF_exception $e){
245 246
             echo $e;
246 247
         }
247 248
 
@@ -259,7 +260,7 @@  discard block
 block discarded – undo
259 260
 
260 261
         if($view == 'EditView'){
261 262
             echo "<select type='text' style='width:100px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_function_list'], $value) ."</select>";
262
-        }else{
263
+        } else{
263 264
             echo $app_list_strings['aor_function_list'][$value];
264 265
         }
265 266
         die;
@@ -278,11 +279,17 @@  discard block
 block discarded – undo
278 279
         $fieldname = $_REQUEST['aor_fieldname'];
279 280
         $aor_field = $_REQUEST['aor_newfieldname'];
280 281
 
281
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
282
-        else $view= 'EditView';
282
+        if(isset($_REQUEST['view'])) {
283
+            $view = $_REQUEST['view'];
284
+        } else {
285
+            $view= 'EditView';
286
+        }
283 287
 
284
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
285
-        else $value = '';
288
+        if(isset($_REQUEST['aor_value'])) {
289
+            $value = $_REQUEST['aor_value'];
290
+        } else {
291
+            $value = '';
292
+        }
286 293
 
287 294
 
288 295
         require_once($beanFiles[$beanList[$module]]);
@@ -329,7 +336,7 @@  discard block
 block discarded – undo
329 336
         $app_list_strings['aor_operator_list'];
330 337
         if($view == 'EditView'){
331 338
             echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_operator_list'], $value) ."</select>";
332
-        }else{
339
+        } else{
333 340
             echo $app_list_strings['aor_operator_list'][$value];
334 341
         }
335 342
         die;
@@ -348,11 +355,17 @@  discard block
 block discarded – undo
348 355
         $fieldname = $_REQUEST['aor_fieldname'];
349 356
         $aor_field = $_REQUEST['aor_newfieldname'];
350 357
 
351
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
352
-        else $view= 'EditView';
358
+        if(isset($_REQUEST['view'])) {
359
+            $view = $_REQUEST['view'];
360
+        } else {
361
+            $view= 'EditView';
362
+        }
353 363
 
354
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
355
-        else $value = '';
364
+        if(isset($_REQUEST['aor_value'])) {
365
+            $value = $_REQUEST['aor_value'];
366
+        } else {
367
+            $value = '';
368
+        }
356 369
 
357 370
 
358 371
         require_once($beanFiles[$beanList[$module]]);
@@ -403,7 +416,7 @@  discard block
 block discarded – undo
403 416
 
404 417
         if($view == 'EditView'){
405 418
             echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_condition_type_list'], $value) ."</select>";
406
-        }else{
419
+        } else{
407 420
             echo $app_list_strings['aor_condition_type_list'][$value];
408 421
         }
409 422
         die;
@@ -423,11 +436,17 @@  discard block
 block discarded – undo
423 436
         $fieldname = $_REQUEST['aor_fieldname'];
424 437
         $aor_field = $_REQUEST['aor_newfieldname'];
425 438
 
426
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
427
-        else $view= 'EditView';
439
+        if(isset($_REQUEST['view'])) {
440
+            $view = $_REQUEST['view'];
441
+        } else {
442
+            $view= 'EditView';
443
+        }
428 444
 
429
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
430
-        else $value = '';
445
+        if(isset($_REQUEST['aor_value'])) {
446
+            $value = $_REQUEST['aor_value'];
447
+        } else {
448
+            $value = '';
449
+        }
431 450
 
432 451
 
433 452
         require_once($beanFiles[$beanList[$module]]);
@@ -460,7 +479,9 @@  discard block
 block discarded – undo
460 479
                 break;
461 480
             case 'relate':
462 481
                 $valid_opp = array('Value','Field');
463
-                if($vardef['module'] == 'Users') $valid_opp = array('Value','Field','Round_Robin','Least_Busy','Random');
482
+                if($vardef['module'] == 'Users') {
483
+                    $valid_opp = array('Value','Field','Round_Robin','Least_Busy','Random');
484
+                }
464 485
                 break;
465 486
             default:
466 487
                 $valid_opp = array('Value','Field');
@@ -475,7 +496,7 @@  discard block
 block discarded – undo
475 496
 
476 497
         if($view == 'EditView'){
477 498
             echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_action_type_list'], $value) ."</select>";
478
-        }else{
499
+        } else{
479 500
             echo $app_list_strings['aor_action_type_list'][$value];
480 501
         }
481 502
         die;
@@ -494,18 +515,26 @@  discard block
 block discarded – undo
494 515
         $fieldname = $_REQUEST['aor_fieldname'];
495 516
         $aor_field = $_REQUEST['aor_newfieldname'];
496 517
 
497
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
498
-        else $view= 'EditView';
518
+        if(isset($_REQUEST['view'])) {
519
+            $view = $_REQUEST['view'];
520
+        } else {
521
+            $view= 'EditView';
522
+        }
499 523
 
500
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
501
-        else $value = '';
524
+        if(isset($_REQUEST['aor_value'])) {
525
+            $value = $_REQUEST['aor_value'];
526
+        } else {
527
+            $value = '';
528
+        }
502 529
 
503 530
         switch($_REQUEST['aor_type']) {
504 531
             case 'Field':
505
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
532
+                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
533
+                    $module = $_REQUEST['alt_module'];
534
+                }
506 535
                 if($view == 'EditView'){
507 536
                     echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
508
-                }else{
537
+                } else{
509 538
                     echo getModuleFields($module, $view, $value);
510 539
                 }
511 540
                 break;
@@ -518,7 +547,7 @@  discard block
 block discarded – undo
518 547
             case 'Period':
519 548
                 if($view == 'EditView'){
520 549
                     echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getDropdownList('date_time_period_list',$_REQUEST['aor_value']) ."</select>";
521
-                }else{
550
+                } else{
522 551
                     echo getDropdownList('date_time_period_list',$_REQUEST['aor_value']);
523 552
                 }
524 553
 
@@ -540,23 +569,33 @@  discard block
 block discarded – undo
540 569
         $fieldname = $_REQUEST['aor_fieldname'];
541 570
         $aor_field = $_REQUEST['aor_newfieldname'];
542 571
 
543
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
544
-        else $view= 'EditView';
572
+        if(isset($_REQUEST['view'])) {
573
+            $view = $_REQUEST['view'];
574
+        } else {
575
+            $view= 'EditView';
576
+        }
545 577
 
546
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
547
-        else $value = '';
578
+        if(isset($_REQUEST['aor_value'])) {
579
+            $value = $_REQUEST['aor_value'];
580
+        } else {
581
+            $value = '';
582
+        }
548 583
 
549 584
         switch($_REQUEST['aor_type']) {
550 585
             case 'Field':
551
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
586
+                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
587
+                    $module = $_REQUEST['alt_module'];
588
+                }
552 589
                 if($view == 'EditView'){
553 590
                     echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
554
-                }else{
591
+                } else{
555 592
                     echo getModuleFields($module, $view, $value);
556 593
                 }
557 594
                 break;
558 595
             case 'Date':
559
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
596
+                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
597
+                    $module = $_REQUEST['alt_module'];
598
+                }
560 599
                 echo getDateField($module, $aor_field, $view, $value);
561 600
                 break;
562 601
             Case 'Round_Robin';
@@ -575,11 +614,17 @@  discard block
 block discarded – undo
575 614
 
576 615
     protected function action_getModuleField()
577 616
     {
578
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
579
-        else $view= 'EditView';
617
+        if(isset($_REQUEST['view'])) {
618
+            $view = $_REQUEST['view'];
619
+        } else {
620
+            $view= 'EditView';
621
+        }
580 622
 
581
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
582
-        else $value = '';
623
+        if(isset($_REQUEST['aor_value'])) {
624
+            $value = $_REQUEST['aor_value'];
625
+        } else {
626
+            $value = '';
627
+        }
583 628
 
584 629
         echo getModuleField($_REQUEST['aor_module'],$_REQUEST['aor_fieldname'], $_REQUEST['aor_newfieldname'], $view, $value );
585 630
         die;
@@ -591,18 +636,26 @@  discard block
 block discarded – undo
591 636
         $fieldname = $_REQUEST['aor_fieldname'];
592 637
         $aor_field = $_REQUEST['aor_newfieldname'];
593 638
 
594
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
595
-        else $view= 'EditView';
639
+        if(isset($_REQUEST['view'])) {
640
+            $view = $_REQUEST['view'];
641
+        } else {
642
+            $view= 'EditView';
643
+        }
596 644
 
597
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
598
-        else $value = '';
645
+        if(isset($_REQUEST['aor_value'])) {
646
+            $value = $_REQUEST['aor_value'];
647
+        } else {
648
+            $value = '';
649
+        }
599 650
 
600 651
         switch($_REQUEST['aor_type']) {
601 652
             case 'Field':
602
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
653
+                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') {
654
+                    $module = $_REQUEST['alt_module'];
655
+                }
603 656
                 if($view == 'EditView'){
604 657
                     echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
605
-                }else{
658
+                } else{
606 659
                     echo getModuleFields($module, $view, $value);
607 660
                 }
608 661
                 break;
@@ -624,11 +677,17 @@  discard block
 block discarded – undo
624 677
         $fieldname = $_REQUEST['aor_fieldname'];
625 678
         $aor_field = $_REQUEST['aor_newfieldname'];
626 679
 
627
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
628
-        else $view= 'EditView';
680
+        if(isset($_REQUEST['view'])) {
681
+            $view = $_REQUEST['view'];
682
+        } else {
683
+            $view= 'EditView';
684
+        }
629 685
 
630
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
631
-        else $value = '';
686
+        if(isset($_REQUEST['aor_value'])) {
687
+            $value = $_REQUEST['aor_value'];
688
+        } else {
689
+            $value = '';
690
+        }
632 691
 
633 692
 
634 693
         require_once($beanFiles[$beanList[$module]]);
@@ -652,7 +711,7 @@  discard block
 block discarded – undo
652 711
 
653 712
         if($view == 'EditView'){
654 713
             echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_rel_action_type_list'], $value) ."</select>";
655
-        }else{
714
+        } else{
656 715
             echo $app_list_strings['aor_rel_action_type_list'][$value];
657 716
         }
658 717
         die;
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
     protected function action_getModuleFields()
32 32
     {
33 33
         if (!empty($_REQUEST['aor_module']) && $_REQUEST['aor_module'] != '') {
34
-            if(isset($_REQUEST['rel_field']) &&  $_REQUEST['rel_field'] != ''){
35
-                $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']);
34
+            if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
35
+                $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']);
36 36
             } else {
37 37
                 $module = $_REQUEST['aor_module'];
38 38
             }
39 39
             $val = !empty($_REQUEST['aor_value']) ? $_REQUEST['aor_value'] : '';
40
-            echo getModuleFields($module,$_REQUEST['view'],$val);
40
+            echo getModuleFields($module, $_REQUEST['view'], $val);
41 41
         }
42 42
         die;
43 43
 
44 44
     }
45
-    function action_getVarDefs(){
46
-        if($_REQUEST['aor_module']){
45
+    function action_getVarDefs() {
46
+        if ($_REQUEST['aor_module']) {
47 47
             $bean = BeanFactory::getBean($_REQUEST['aor_module']);
48 48
             echo json_encode((array)$bean->field_defs[$_REQUEST['aor_request']]);
49 49
             die();
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         die;
70 70
     }
71 71
 
72
-    protected function action_changeReportPage(){
72
+    protected function action_changeReportPage() {
73 73
         $tableId = !empty($_REQUEST['table_id']) ? $_REQUEST['table_id'] : '';
74 74
         $group = !empty($_REQUEST['group']) ? $_REQUEST['group'] : '';
75 75
         $offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
76
-        if(!empty($this->bean->id)){
76
+        if (!empty($this->bean->id)) {
77 77
             $this->bean->user_parameters = requestToUserParameters();
78 78
             //echo $this->bean->build_report_html($offset, true,$group,$tableId);
79 79
             echo $this->bean->build_group_report($offset, true);
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
         die();
83 83
     }
84 84
 
85
-    protected function action_getParametersForReport(){
86
-        if(empty($_REQUEST['record'])){
85
+    protected function action_getParametersForReport() {
86
+        if (empty($_REQUEST['record'])) {
87 87
             echo json_encode(array());
88 88
             return;
89 89
         }
90
-        $report = BeanFactory::getBean('AOR_Reports',$_REQUEST['record']);
91
-        if(!$report){
90
+        $report = BeanFactory::getBean('AOR_Reports', $_REQUEST['record']);
91
+        if (!$report) {
92 92
             echo json_encode(array());
93 93
             return;
94 94
         }
95
-        if(empty($report->id)) {
95
+        if (empty($report->id)) {
96 96
             echo json_encode(array());
97 97
             return;
98 98
         }
@@ -100,24 +100,24 @@  discard block
 block discarded – undo
100 100
         echo json_encode($conditions);
101 101
     }
102 102
 
103
-    protected function action_getChartsForReport(){
104
-        if(empty($_REQUEST['record'])){
103
+    protected function action_getChartsForReport() {
104
+        if (empty($_REQUEST['record'])) {
105 105
             echo json_encode(array());
106 106
             return;
107 107
         }
108
-        $report = BeanFactory::getBean('AOR_Reports',$_REQUEST['record']);
109
-        if(!$report){
108
+        $report = BeanFactory::getBean('AOR_Reports', $_REQUEST['record']);
109
+        if (!$report) {
110 110
             echo json_encode(array());
111 111
             return;
112 112
         }
113 113
         $charts = array();
114
-        foreach($report->get_linked_beans('aor_charts','AOR_Charts') as $chart){
114
+        foreach ($report->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
115 115
             $charts[$chart->id] = $chart->name;
116 116
         }
117 117
         echo json_encode($charts);
118 118
     }
119 119
 
120
-    protected function action_addToProspectList(){
120
+    protected function action_addToProspectList() {
121 121
         global $beanList;
122 122
 
123 123
         require_once('modules/Relationships/Relationship.php');
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
             $result = $this->bean->db->query($sql);
136 136
             $beans = array();
137 137
             while ($row = $this->bean->db->fetchByAssoc($result)) {
138
-                if (isset($row[$module->table_name.'_id'])){
138
+                if (isset($row[$module->table_name.'_id'])) {
139 139
                     $beans[] = $row[$module->table_name.'_id'];
140 140
                 }
141 141
             }
142
-            if(!empty($beans)){
143
-                foreach($prospectList->field_defs as $field=>$def){
144
-                    if($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key){
142
+            if (!empty($beans)) {
143
+                foreach ($prospectList->field_defs as $field=>$def) {
144
+                    if ($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key) {
145 145
                         $prospectList->load_relationship($field);
146 146
                         $prospectList->$field->add($beans);
147 147
                     }
@@ -170,41 +170,41 @@  discard block
 block discarded – undo
170 170
         error_reporting(0);
171 171
         require_once('modules/AOS_PDF_Templates/PDF_Lib/mpdf.php');
172 172
 
173
-        $d_image = explode('?',SugarThemeRegistry::current()->getImageURL('company_logo.png'));
173
+        $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
174 174
         $graphs = $_POST["graphsForPDF"];
175 175
         $graphHtml = "<div class='reportGraphs' style='width:100%; text-align:center;'>";
176 176
 
177 177
         $chartsPerRow = $this->bean->graphs_per_row;
178 178
         $countOfCharts = count($graphs);
179
-        if($countOfCharts > 0)
179
+        if ($countOfCharts > 0)
180 180
         {
181
-            $width = ((int)100/$chartsPerRow);
181
+            $width = ((int)100 / $chartsPerRow);
182 182
 
183 183
             $modulusRemainder = $countOfCharts % $chartsPerRow;
184 184
 
185
-            if($modulusRemainder > 0)
185
+            if ($modulusRemainder > 0)
186 186
             {
187
-                $modulusWidth = ((int)100/$modulusRemainder);
187
+                $modulusWidth = ((int)100 / $modulusRemainder);
188 188
                 $itemsWithModulus = $countOfCharts - $modulusRemainder;
189 189
             }
190 190
 
191 191
 
192
-            for($x =0; $x < $countOfCharts; $x++)
192
+            for ($x = 0; $x < $countOfCharts; $x++)
193 193
             {
194
-                if(is_null($itemsWithModulus) ||  $x < $itemsWithModulus)
195
-                    $graphHtml.="<img src='.$graphs[$x].' style='width:$width%;' />";
194
+                if (is_null($itemsWithModulus) || $x < $itemsWithModulus)
195
+                    $graphHtml .= "<img src='.$graphs[$x].' style='width:$width%;' />";
196 196
                 else
197
-                    $graphHtml.="<img src='.$graphs[$x].' style='width:$modulusWidth%;' />";
197
+                    $graphHtml .= "<img src='.$graphs[$x].' style='width:$modulusWidth%;' />";
198 198
             }
199 199
 
200 200
 /*            foreach($graphs as $g)
201 201
             {
202 202
                 $graphHtml.="<img src='.$g.' style='width:$width%;' />";
203 203
             }*/
204
-            $graphHtml.="</div>";
204
+            $graphHtml .= "</div>";
205 205
         }
206 206
 
207
-        $head =  '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
207
+        $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
208 208
                 <tbody style="text-align: left;">
209 209
                 <tr style="text-align: left;">
210 210
                 <td style="text-align: left;">
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
 
230 230
         $this->bean->user_parameters = requestToUserParameters();
231 231
 
232
-        $printable = $this->bean->build_group_report(-1,false);
233
-        $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css',false));
232
+        $printable = $this->bean->build_group_report(-1, false);
233
+        $stylesheet = file_get_contents(SugarThemeRegistry::current()->getCSSURL('style.css', false));
234 234
         ob_clean();
235
-        try{
236
-            $pdf=new mPDF('en','A4','','DejaVuSansCondensed');
235
+        try {
236
+            $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed');
237 237
             $pdf->setAutoFont();
238
-            $pdf->WriteHTML($stylesheet,1);
239
-            $pdf->WriteHTML($head,2);
240
-            $pdf->WriteHTML($printable,3);
238
+            $pdf->WriteHTML($stylesheet, 1);
239
+            $pdf->WriteHTML($head, 2);
240
+            $pdf->WriteHTML($printable, 3);
241 241
             $pdf->Output($this->bean->name.'.pdf', "D");
242 242
 
243
-        }catch(mPDF_exception $e){
243
+        }catch (mPDF_exception $e) {
244 244
             echo $e;
245 245
         }
246 246
 
247 247
         die;
248 248
     }
249 249
 
250
-    protected function action_getModuleFunctionField(){
250
+    protected function action_getModuleFunctionField() {
251 251
         global $app_list_strings;
252 252
 
253 253
         $view = $_REQUEST['view'];
@@ -256,31 +256,31 @@  discard block
 block discarded – undo
256 256
         $fieldname = $_REQUEST['aor_fieldname'];
257 257
         $aor_field = $_REQUEST['aor_newfieldname'];
258 258
 
259
-        if($view == 'EditView'){
260
-            echo "<select type='text' style='width:100px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_function_list'], $value) ."</select>";
261
-        }else{
259
+        if ($view == 'EditView') {
260
+            echo "<select type='text' style='width:100px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_function_list'], $value)."</select>";
261
+        } else {
262 262
             echo $app_list_strings['aor_function_list'][$value];
263 263
         }
264 264
         die;
265 265
     }
266 266
 
267 267
 
268
-    protected function action_getModuleOperatorField(){
268
+    protected function action_getModuleOperatorField() {
269 269
 
270 270
         global $app_list_strings, $beanFiles, $beanList;
271 271
 
272
-        if(isset($_REQUEST['rel_field']) &&  $_REQUEST['rel_field'] != ''){
273
-            $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']);
272
+        if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
273
+            $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']);
274 274
         } else {
275 275
             $module = $_REQUEST['aor_module'];
276 276
         }
277 277
         $fieldname = $_REQUEST['aor_fieldname'];
278 278
         $aor_field = $_REQUEST['aor_newfieldname'];
279 279
 
280
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
281
-        else $view= 'EditView';
280
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
281
+        else $view = 'EditView';
282 282
 
283
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
283
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
284 284
         else $value = '';
285 285
 
286 286
 
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
         $focus = new $beanList[$module];
289 289
         $vardef = $focus->getFieldDefinition($fieldname);
290 290
 
291
-        switch($vardef['type']) {
291
+        switch ($vardef['type']) {
292 292
             case 'double':
293 293
             case 'decimal':
294 294
             case 'float':
295 295
             case 'currency':
296
-                $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To');
296
+                $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To');
297 297
                 break;
298 298
             case 'uint':
299 299
             case 'ulong':
@@ -301,24 +301,24 @@  discard block
 block discarded – undo
301 301
             case 'short':
302 302
             case 'tinyint':
303 303
             case 'int':
304
-                $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To');
304
+                $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To');
305 305
                 break;
306 306
             case 'date':
307 307
             case 'datetime':
308 308
             case 'datetimecombo':
309
-                $valid_opp = array('Equal_To','Not_Equal_To','Greater_Than','Less_Than','Greater_Than_or_Equal_To','Less_Than_or_Equal_To');
309
+                $valid_opp = array('Equal_To', 'Not_Equal_To', 'Greater_Than', 'Less_Than', 'Greater_Than_or_Equal_To', 'Less_Than_or_Equal_To');
310 310
                 break;
311 311
             case 'enum':
312 312
             case 'multienum':
313
-                $valid_opp = array('Equal_To','Not_Equal_To');
313
+                $valid_opp = array('Equal_To', 'Not_Equal_To');
314 314
                 break;
315 315
             default:
316
-                $valid_opp = array('Equal_To','Not_Equal_To','Contains', 'Starts_With', 'Ends_With',);
316
+                $valid_opp = array('Equal_To', 'Not_Equal_To', 'Contains', 'Starts_With', 'Ends_With',);
317 317
                 break;
318 318
         }
319 319
 
320
-        foreach($app_list_strings['aor_operator_list'] as $key => $keyValue){
321
-            if(!in_array($key, $valid_opp)){
320
+        foreach ($app_list_strings['aor_operator_list'] as $key => $keyValue) {
321
+            if (!in_array($key, $valid_opp)) {
322 322
                 unset($app_list_strings['aor_operator_list'][$key]);
323 323
             }
324 324
         }
@@ -326,31 +326,31 @@  discard block
 block discarded – undo
326 326
 
327 327
 
328 328
         $app_list_strings['aor_operator_list'];
329
-        if($view == 'EditView'){
330
-            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_operator_list'], $value) ."</select>";
331
-        }else{
329
+        if ($view == 'EditView') {
330
+            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_operator_list'], $value)."</select>";
331
+        } else {
332 332
             echo $app_list_strings['aor_operator_list'][$value];
333 333
         }
334 334
         die;
335 335
 
336 336
     }
337 337
 
338
-    protected function action_getFieldTypeOptions(){
338
+    protected function action_getFieldTypeOptions() {
339 339
 
340 340
         global $app_list_strings, $beanFiles, $beanList;
341 341
 
342
-        if(isset($_REQUEST['rel_field']) &&  $_REQUEST['rel_field'] != ''){
343
-            $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']);
342
+        if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
343
+            $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']);
344 344
         } else {
345 345
             $module = $_REQUEST['aor_module'];
346 346
         }
347 347
         $fieldname = $_REQUEST['aor_fieldname'];
348 348
         $aor_field = $_REQUEST['aor_newfieldname'];
349 349
 
350
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
351
-        else $view= 'EditView';
350
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
351
+        else $view = 'EditView';
352 352
 
353
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
353
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
354 354
         else $value = '';
355 355
 
356 356
 
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         $focus = new $beanList[$module];
359 359
         $vardef = $focus->getFieldDefinition($fieldname);
360 360
 
361
-        switch($vardef['type']) {
361
+        switch ($vardef['type']) {
362 362
             case 'double':
363 363
             case 'decimal':
364 364
             case 'float':
365 365
             case 'currency':
366
-                $valid_opp = array('Value','Field');
366
+                $valid_opp = array('Value', 'Field');
367 367
                 break;
368 368
             case 'uint':
369 369
             case 'ulong':
@@ -371,50 +371,50 @@  discard block
 block discarded – undo
371 371
             case 'short':
372 372
             case 'tinyint':
373 373
             case 'int':
374
-                $valid_opp = array('Value','Field');
374
+                $valid_opp = array('Value', 'Field');
375 375
                 break;
376 376
             case 'date':
377 377
             case 'datetime':
378 378
             case 'datetimecombo':
379
-                $valid_opp = array('Value','Field', 'Date', 'Period');
379
+                $valid_opp = array('Value', 'Field', 'Date', 'Period');
380 380
                 break;
381 381
             case 'enum':
382 382
             case 'dynamicenum':
383 383
             case 'multienum':
384
-                $valid_opp = array('Value','Field', 'Multi');
384
+                $valid_opp = array('Value', 'Field', 'Multi');
385 385
                 break;
386 386
             default:
387 387
                 // Added to compare fields like assinged to with the current user
388
-                if( (isset($vardef['module']) && $vardef['module'] == "Users") || $vardef['name'] = 'id') {
389
-                    $valid_opp = array('Value','Field', 'CurrentUserID');
388
+                if ((isset($vardef['module']) && $vardef['module'] == "Users") || $vardef['name'] = 'id') {
389
+                    $valid_opp = array('Value', 'Field', 'CurrentUserID');
390 390
                 } else {
391
-                    $valid_opp = array('Value','Field');
391
+                    $valid_opp = array('Value', 'Field');
392 392
                 }
393 393
 
394 394
                 break;
395 395
         }
396 396
 
397
-        foreach($app_list_strings['aor_condition_type_list'] as $key => $keyValue){
398
-            if(!in_array($key, $valid_opp)){
397
+        foreach ($app_list_strings['aor_condition_type_list'] as $key => $keyValue) {
398
+            if (!in_array($key, $valid_opp)) {
399 399
                 unset($app_list_strings['aor_condition_type_list'][$key]);
400 400
             }
401 401
         }
402 402
 
403
-        if($view == 'EditView'){
404
-            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_condition_type_list'], $value) ."</select>";
405
-        }else{
403
+        if ($view == 'EditView') {
404
+            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_condition_type_list'], $value)."</select>";
405
+        } else {
406 406
             echo $app_list_strings['aor_condition_type_list'][$value];
407 407
         }
408 408
         die;
409 409
 
410 410
     }
411 411
 
412
-    protected function action_getActionFieldTypeOptions(){
412
+    protected function action_getActionFieldTypeOptions() {
413 413
 
414 414
         global $app_list_strings, $beanFiles, $beanList;
415 415
 
416
-        if(isset($_REQUEST['rel_field']) &&  $_REQUEST['rel_field'] != ''){
417
-            $module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']);
416
+        if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
417
+            $module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']);
418 418
         } else {
419 419
             $module = $_REQUEST['aor_module'];
420 420
         }
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
         $fieldname = $_REQUEST['aor_fieldname'];
423 423
         $aor_field = $_REQUEST['aor_newfieldname'];
424 424
 
425
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
426
-        else $view= 'EditView';
425
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
426
+        else $view = 'EditView';
427 427
 
428
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
428
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
429 429
         else $value = '';
430 430
 
431 431
 
@@ -433,12 +433,12 @@  discard block
 block discarded – undo
433 433
         $focus = new $beanList[$module];
434 434
         $vardef = $focus->getFieldDefinition($fieldname);
435 435
 
436
-        switch($vardef['type']) {
436
+        switch ($vardef['type']) {
437 437
             case 'double':
438 438
             case 'decimal':
439 439
             case 'float':
440 440
             case 'currency':
441
-                $valid_opp = array('Value','Field');
441
+                $valid_opp = array('Value', 'Field');
442 442
                 break;
443 443
             case 'uint':
444 444
             case 'ulong':
@@ -446,35 +446,35 @@  discard block
 block discarded – undo
446 446
             case 'short':
447 447
             case 'tinyint':
448 448
             case 'int':
449
-                $valid_opp = array('Value','Field');
449
+                $valid_opp = array('Value', 'Field');
450 450
                 break;
451 451
             case 'date':
452 452
             case 'datetime':
453 453
             case 'datetimecombo':
454
-                $valid_opp = array('Value','Field', 'Date');
454
+                $valid_opp = array('Value', 'Field', 'Date');
455 455
                 break;
456 456
             case 'enum':
457 457
             case 'multienum':
458
-                $valid_opp = array('Value','Field');
458
+                $valid_opp = array('Value', 'Field');
459 459
                 break;
460 460
             case 'relate':
461
-                $valid_opp = array('Value','Field');
462
-                if($vardef['module'] == 'Users') $valid_opp = array('Value','Field','Round_Robin','Least_Busy','Random');
461
+                $valid_opp = array('Value', 'Field');
462
+                if ($vardef['module'] == 'Users') $valid_opp = array('Value', 'Field', 'Round_Robin', 'Least_Busy', 'Random');
463 463
                 break;
464 464
             default:
465
-                $valid_opp = array('Value','Field');
465
+                $valid_opp = array('Value', 'Field');
466 466
                 break;
467 467
         }
468 468
 
469
-        foreach($app_list_strings['aor_action_type_list'] as $key => $keyValue){
470
-            if(!in_array($key, $valid_opp)){
469
+        foreach ($app_list_strings['aor_action_type_list'] as $key => $keyValue) {
470
+            if (!in_array($key, $valid_opp)) {
471 471
                 unset($app_list_strings['aor_action_type_list'][$key]);
472 472
             }
473 473
         }
474 474
 
475
-        if($view == 'EditView'){
476
-            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_action_type_list'], $value) ."</select>";
477
-        }else{
475
+        if ($view == 'EditView') {
476
+            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_action_type_list'], $value)."</select>";
477
+        } else {
478 478
             echo $app_list_strings['aor_action_type_list'][$value];
479 479
         }
480 480
         die;
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
 
484 484
     protected function action_getModuleFieldType()
485 485
     {
486
-        if(isset($_REQUEST['rel_field']) &&  $_REQUEST['rel_field'] != ''){
487
-            $rel_module = getRelatedModule($_REQUEST['aor_module'],$_REQUEST['rel_field']);
486
+        if (isset($_REQUEST['rel_field']) && $_REQUEST['rel_field'] != '') {
487
+            $rel_module = getRelatedModule($_REQUEST['aor_module'], $_REQUEST['rel_field']);
488 488
         } else {
489 489
             $rel_module = $_REQUEST['aor_module'];
490 490
         }
@@ -493,18 +493,18 @@  discard block
 block discarded – undo
493 493
         $fieldname = $_REQUEST['aor_fieldname'];
494 494
         $aor_field = $_REQUEST['aor_newfieldname'];
495 495
 
496
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
497
-        else $view= 'EditView';
496
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
497
+        else $view = 'EditView';
498 498
 
499
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
499
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
500 500
         else $value = '';
501 501
 
502
-        switch($_REQUEST['aor_type']) {
502
+        switch ($_REQUEST['aor_type']) {
503 503
             case 'Field':
504
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
505
-                if($view == 'EditView'){
506
-                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
507
-                }else{
504
+                if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
505
+                if ($view == 'EditView') {
506
+                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>";
507
+                } else {
508 508
                     echo getModuleFields($module, $view, $value);
509 509
                 }
510 510
                 break;
@@ -512,13 +512,13 @@  discard block
 block discarded – undo
512 512
                 echo getDateField($module, $aor_field, $view, $value, false);
513 513
                 break;
514 514
             case 'Multi':
515
-                echo getModuleField($rel_module,$fieldname, $aor_field, $view, $value,'multienum');
515
+                echo getModuleField($rel_module, $fieldname, $aor_field, $view, $value, 'multienum');
516 516
                 break;
517 517
             case 'Period':
518
-                if($view == 'EditView'){
519
-                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getDropdownList('date_time_period_list',$_REQUEST['aor_value']) ."</select>";
520
-                }else{
521
-                    echo getDropdownList('date_time_period_list',$_REQUEST['aor_value']);
518
+                if ($view == 'EditView') {
519
+                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getDropdownList('date_time_period_list', $_REQUEST['aor_value'])."</select>";
520
+                } else {
521
+                    echo getDropdownList('date_time_period_list', $_REQUEST['aor_value']);
522 522
                 }
523 523
 
524 524
                 break;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                 break;
527 527
             case 'Value':
528 528
             default:
529
-                echo getModuleField($rel_module,$fieldname, $aor_field, $view, $value );
529
+                echo getModuleField($rel_module, $fieldname, $aor_field, $view, $value);
530 530
                 break;
531 531
         }
532 532
         die;
@@ -539,23 +539,23 @@  discard block
 block discarded – undo
539 539
         $fieldname = $_REQUEST['aor_fieldname'];
540 540
         $aor_field = $_REQUEST['aor_newfieldname'];
541 541
 
542
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
543
-        else $view= 'EditView';
542
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
543
+        else $view = 'EditView';
544 544
 
545
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
545
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
546 546
         else $value = '';
547 547
 
548
-        switch($_REQUEST['aor_type']) {
548
+        switch ($_REQUEST['aor_type']) {
549 549
             case 'Field':
550
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
551
-                if($view == 'EditView'){
552
-                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
553
-                }else{
550
+                if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
551
+                if ($view == 'EditView') {
552
+                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>";
553
+                } else {
554 554
                     echo getModuleFields($module, $view, $value);
555 555
                 }
556 556
                 break;
557 557
             case 'Date':
558
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
558
+                if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
559 559
                 echo getDateField($module, $aor_field, $view, $value);
560 560
                 break;
561 561
             Case 'Round_Robin';
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
                 break;
566 566
             case 'Value':
567 567
             default:
568
-                echo getModuleField($module,$fieldname, $aor_field, $view, $value );
568
+                echo getModuleField($module, $fieldname, $aor_field, $view, $value);
569 569
                 break;
570 570
         }
571 571
         die;
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 
575 575
     protected function action_getModuleField()
576 576
     {
577
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
578
-        else $view= 'EditView';
577
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
578
+        else $view = 'EditView';
579 579
 
580
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
580
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
581 581
         else $value = '';
582 582
 
583
-        echo getModuleField($_REQUEST['aor_module'],$_REQUEST['aor_fieldname'], $_REQUEST['aor_newfieldname'], $view, $value );
583
+        echo getModuleField($_REQUEST['aor_module'], $_REQUEST['aor_fieldname'], $_REQUEST['aor_newfieldname'], $view, $value);
584 584
         die;
585 585
     }
586 586
 
@@ -590,31 +590,31 @@  discard block
 block discarded – undo
590 590
         $fieldname = $_REQUEST['aor_fieldname'];
591 591
         $aor_field = $_REQUEST['aor_newfieldname'];
592 592
 
593
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
594
-        else $view= 'EditView';
593
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
594
+        else $view = 'EditView';
595 595
 
596
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
596
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
597 597
         else $value = '';
598 598
 
599
-        switch($_REQUEST['aor_type']) {
599
+        switch ($_REQUEST['aor_type']) {
600 600
             case 'Field':
601
-                if(isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
602
-                if($view == 'EditView'){
603
-                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". getModuleFields($module, $view, $value) ."</select>";
604
-                }else{
601
+                if (isset($_REQUEST['alt_module']) && $_REQUEST['alt_module'] != '') $module = $_REQUEST['alt_module'];
602
+                if ($view == 'EditView') {
603
+                    echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".getModuleFields($module, $view, $value)."</select>";
604
+                } else {
605 605
                     echo getModuleFields($module, $view, $value);
606 606
                 }
607 607
                 break;
608 608
             case 'Value':
609 609
             default:
610
-                echo getModuleField($module,$fieldname, $aor_field, $view, $value );
610
+                echo getModuleField($module, $fieldname, $aor_field, $view, $value);
611 611
                 break;
612 612
         }
613 613
         die;
614 614
 
615 615
     }
616 616
 
617
-    protected function action_getRelActionFieldTypeOptions(){
617
+    protected function action_getRelActionFieldTypeOptions() {
618 618
 
619 619
         global $app_list_strings, $beanFiles, $beanList;
620 620
 
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
         $fieldname = $_REQUEST['aor_fieldname'];
624 624
         $aor_field = $_REQUEST['aor_newfieldname'];
625 625
 
626
-        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
627
-        else $view= 'EditView';
626
+        if (isset($_REQUEST['view'])) $view = $_REQUEST['view'];
627
+        else $view = 'EditView';
628 628
 
629
-        if(isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
629
+        if (isset($_REQUEST['aor_value'])) $value = $_REQUEST['aor_value'];
630 630
         else $value = '';
631 631
 
632 632
 
@@ -643,15 +643,15 @@  discard block
 block discarded – undo
643 643
         }*/
644 644
         $valid_opp = array('Value');
645 645
 
646
-        foreach($app_list_strings['aor_rel_action_type_list'] as $key => $keyValue){
647
-            if(!in_array($key, $valid_opp)){
646
+        foreach ($app_list_strings['aor_rel_action_type_list'] as $key => $keyValue) {
647
+            if (!in_array($key, $valid_opp)) {
648 648
                 unset($app_list_strings['aor_rel_action_type_list'][$key]);
649 649
             }
650 650
         }
651 651
 
652
-        if($view == 'EditView'){
653
-            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aor_rel_action_type_list'], $value) ."</select>";
654
-        }else{
652
+        if ($view == 'EditView') {
653
+            echo "<select type='text' style='width:178px;' name='$aor_field' id='$aor_field' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aor_rel_action_type_list'], $value)."</select>";
654
+        } else {
655 655
             echo $app_list_strings['aor_rel_action_type_list'][$value];
656 656
         }
657 657
         die;
Please login to merge, or discard this patch.
modules/AOR_Reports/Dashlets/AORReportsDashlet/AORReportsDashlet.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     var $onlyCharts;
13 13
 
14 14
     function AORReportsDashlet($id, $def = array()) {
15
-		global $current_user, $app_strings;
15
+        global $current_user, $app_strings;
16 16
 
17 17
         parent::Dashlet($id);
18 18
         $this->isConfigurable = true;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         }
69 69
     }
70 70
 
71
-	function process() {
71
+    function process() {
72 72
     }
73 73
 
74 74
     public function displayOptions() {
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 
4 4
 
5 5
 require_once('include/Dashlets/Dashlet.php');
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
         parent::Dashlet($id);
18 18
         $this->isConfigurable = true;
19 19
         $this->def = $def;
20
-        if(empty($def['dashletTitle'])) {
20
+        if (empty($def['dashletTitle'])) {
21 21
             $this->title = translate('LBL_AOR_REPORTS_DASHLET', 'AOR_Reports');
22
-        } else{
22
+        } else {
23 23
             $this->title = $def['dashletTitle'];
24 24
         }
25 25
 
26 26
         $this->params = array();
27
-        if(!empty($def['parameter_id'])) {
27
+        if (!empty($def['parameter_id'])) {
28 28
             foreach ($def['parameter_id'] as $key => $parameterId) {
29 29
                 $this->params[$parameterId] = array(
30 30
                     'id' => $parameterId,
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                     'value' => $def['parameter_value'][$key]);
34 34
             }
35 35
         }
36
-        if(!empty($def['aor_report_id'])) {
36
+        if (!empty($def['aor_report_id'])) {
37 37
             $this->report = BeanFactory::getBean('AOR_Reports', $def['aor_report_id']);
38 38
             $this->report->user_parameters = $this->params;
39 39
         }
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
         $mod_strings = return_module_language($current_language, 'AOR_Reports');
47 47
         $dashletSmarty = new Sugar_Smarty();
48 48
         $dashletTemplate = get_custom_file_if_exists('modules/AOR_Reports/Dashlets/AORReportsDashlet/dashlet.tpl');
49
-        $dashletSmarty->assign('MOD',$mod_strings);
50
-        $dashletSmarty->assign('dashlet_id',$this->id);
51
-        $dashletSmarty->assign('report_id',$this->report->id);
52
-        $dashletSmarty->assign('chartHTML',$this->getChartHTML());
49
+        $dashletSmarty->assign('MOD', $mod_strings);
50
+        $dashletSmarty->assign('dashlet_id', $this->id);
51
+        $dashletSmarty->assign('report_id', $this->report->id);
52
+        $dashletSmarty->assign('chartHTML', $this->getChartHTML());
53 53
         $dashletSmarty->assign('onlyCharts', $this->onlyCharts);
54
-        $dashletSmarty->assign('parameters',json_encode(array(
54
+        $dashletSmarty->assign('parameters', json_encode(array(
55 55
                                             'ids' => $this->def['parameter_id'],
56 56
                                             'operators' => $this->def['parameter_operator'],
57 57
                                             'types' => $this->def['parameter_type'],
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
         return $dashletSmarty->fetch($dashletTemplate);
60 60
     }
61 61
 
62
-    function getChartHTML(){
63
-        if(!empty($this->report->id)) {
62
+    function getChartHTML() {
63
+        if (!empty($this->report->id)) {
64 64
             //return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_CHARTJS);
65 65
             return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_RGRAPH);
66
-        }else{
66
+        } else {
67 67
             return '';
68 68
         }
69 69
     }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         global $current_language, $app_list_strings, $datetime;
77 77
         $mod_strings = return_module_language($current_language, 'AOR_Reports');
78 78
         $optionsSmarty = new Sugar_Smarty();
79
-        $optionsSmarty->assign('MOD',$mod_strings);
79
+        $optionsSmarty->assign('MOD', $mod_strings);
80 80
         $optionsSmarty->assign('id', $this->id);
81 81
         $optionsSmarty->assign('dashletTitle', $this->title);
82 82
         $optionsSmarty->assign('aor_report_id', $this->report->id);
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
         $optionsSmarty->assign('date_time_period_list', $app_list_strings['date_time_period_list']);
90 90
 
91 91
         $charts = array();
92
-        if(!empty($this->report->id)){
93
-            foreach($this->report->get_linked_beans('aor_charts','AOR_Charts') as $chart){
92
+        if (!empty($this->report->id)) {
93
+            foreach ($this->report->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
94 94
                 $charts[$chart->id] = $chart->name;
95 95
             }
96 96
         }
97 97
         $conditions = getConditionsAsParameters($this->report, $this->params);
98 98
         $i = 0;
99
-        foreach($conditions as $condition) {
100
-            if($condition["value_type"] == "Date"){
101
-                if($condition["additionalConditions"][0] == "now") {
99
+        foreach ($conditions as $condition) {
100
+            if ($condition["value_type"] == "Date") {
101
+                if ($condition["additionalConditions"][0] == "now") {
102 102
                     $conditions[$i]["value"] = date("d/m/Y");
103 103
                 }
104 104
             }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             $i++;
107 107
         }
108 108
         $optionsSmarty->assign('parameters', $conditions);
109
-        $chartOptions = get_select_options_with_id($charts,$this->charts);
109
+        $chartOptions = get_select_options_with_id($charts, $this->charts);
110 110
         $optionsSmarty->assign('chartOptions', $chartOptions);
111 111
         $optionsTemplate = get_custom_file_if_exists('modules/AOR_Reports/Dashlets/AORReportsDashlet/dashletConfigure.tpl');
112 112
         ob_clean();
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 //            $req['parameter_value'][0] = $secondValue;
120 120
 //            $req['parameter_value'][1] = $firstValue;
121 121
 //        }
122
-        $allowedKeys = array_flip(array('aor_report_id','dashletTitle','charts','onlyCharts','parameter_id','parameter_value','parameter_type','parameter_operator'));
123
-        $intersected = array_intersect_key($req,$allowedKeys);
122
+        $allowedKeys = array_flip(array('aor_report_id', 'dashletTitle', 'charts', 'onlyCharts', 'parameter_id', 'parameter_value', 'parameter_type', 'parameter_operator'));
123
+        $intersected = array_intersect_key($req, $allowedKeys);
124 124
         return $intersected;
125 125
     }
126 126
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 
4 6
 
5 7
 require_once('include/Dashlets/Dashlet.php');
@@ -63,7 +65,7 @@  discard block
 block discarded – undo
63 65
         if(!empty($this->report->id)) {
64 66
             //return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_CHARTJS);
65 67
             return $this->report->build_report_chart($this->charts, AOR_Report::CHART_TYPE_RGRAPH);
66
-        }else{
68
+        } else{
67 69
             return '';
68 70
         }
69 71
     }
Please login to merge, or discard this patch.
modules/AOR_Reports/Dashlets/AORReportsDashlet/AORReportsDashlet.meta.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,6 +3,6 @@
 block discarded – undo
3 3
 global $app_strings;
4 4
 
5 5
 $dashletMeta['AORReportsDashlet'] = array('module'		=> 'AOR_Reports',
6
-										  'title'       => translate('LBL_AOR_REPORTS_DASHLET', 'AOR_Reports'),
7
-                                          'description' => 'Displays Reports',
8
-                                          'category'    => 'Module Views');
6
+                                            'title'       => translate('LBL_AOR_REPORTS_DASHLET', 'AOR_Reports'),
7
+                                            'description' => 'Displays Reports',
8
+                                            'category'    => 'Module Views');
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
modules/DynamicFields/DynamicField.php 4 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $this->base_path = "custom/Extension/modules/{$this->module}/Ext/Vardefs";
52 52
     }
53 53
 
54
-   function getModuleName()
54
+    function getModuleName()
55 55
     {
56 56
         return $this->module ;
57 57
     }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 
70 70
 
71 71
     /**
72
-    * This will add the bean as a reference in this object as well as building the custom field cache if it has not been built
73
-    * LOADS THE BEAN IF THE BEAN IS NOT BEING PASSED ALONG IN SETUP IT SHOULD BE SET PRIOR TO SETUP
74
-    *
75
-    * @param SUGARBEAN $bean
76
-    */
72
+     * This will add the bean as a reference in this object as well as building the custom field cache if it has not been built
73
+     * LOADS THE BEAN IF THE BEAN IS NOT BEING PASSED ALONG IN SETUP IT SHOULD BE SET PRIOR TO SETUP
74
+     *
75
+     * @param SUGARBEAN $bean
76
+     */
77 77
     function setup($bean = null) {
78 78
         if ($bean) {
79 79
             $this->bean = $bean;
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
     /**
98
-    * Builds the cache for custom fields based on the vardefs
99
-    *
100
-    * @param STRING $module
101
-    * @param boolean saveCache Boolean value indicating whether or not to pass saveCache value to saveToVardef, defaults to true
102
-    * @return unknown
103
-    */
98
+     * Builds the cache for custom fields based on the vardefs
99
+     *
100
+     * @param STRING $module
101
+     * @param boolean saveCache Boolean value indicating whether or not to pass saveCache value to saveToVardef, defaults to true
102
+     * @return unknown
103
+     */
104 104
     function buildCache($module = false, $saveCache=true) {
105 105
         //We can't build the cache while installing as the required database tables may not exist.
106 106
         if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db']))
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
     }
162 162
 
163 163
     /**
164
-    * Returns the widget for a custom field from the fields_meta_data table.
165
-    */
164
+     * Returns the widget for a custom field from the fields_meta_data table.
165
+     */
166 166
     function getFieldWidget($module, $fieldName) {
167 167
         if (empty($module) || empty($fieldName)){
168 168
             sugar_die("Unable to load widget for '$module' : '$fieldName'");
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
     /**
182
-    * Updates the cached vardefs with the custom field information stored in result
183
-    *
184
-    * @param string $module
185
-    * @param array $result
186
-    * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true
187
-    */
182
+     * Updates the cached vardefs with the custom field information stored in result
183
+     *
184
+     * @param string $module
185
+     * @param array $result
186
+     * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true
187
+     */
188 188
     function saveToVardef($module,$result,$saveCache=true) {
189 189
 
190 190
 
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
     }
249 249
 
250 250
     /**
251
-    * returns either false or an array containing the select and join parameter for a query using custom fields
252
-    * @param $expandedList boolean	If true, return a list of all fields with source=custom_fields in the select instead of the standard _cstm.*
253
-    *     This is required for any downstream construction of a SQL statement where we need to manipulate the select list,
254
-    *     for example, listviews with custom relate fields where the value comes from join rather than from the custom table
255
-    *
256
-    * @return array select=>select columns, join=>prebuilt join statement
257
-    */
258
-  function getJOIN( $expandedList = false , $includeRelates = false, &$where = false){
251
+     * returns either false or an array containing the select and join parameter for a query using custom fields
252
+     * @param $expandedList boolean	If true, return a list of all fields with source=custom_fields in the select instead of the standard _cstm.*
253
+     *     This is required for any downstream construction of a SQL statement where we need to manipulate the select list,
254
+     *     for example, listviews with custom relate fields where the value comes from join rather than from the custom table
255
+     *
256
+     * @return array select=>select columns, join=>prebuilt join statement
257
+     */
258
+    function getJOIN( $expandedList = false , $includeRelates = false, &$where = false){
259 259
         if(!$this->bean->hasCustomFields()){
260 260
             return array(
261 261
                 'select' => '',
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
     }
310 310
 
311
-   function getRelateJoin($field_def, $joinTableAlias, $withIdName = true) {
311
+    function getRelateJoin($field_def, $joinTableAlias, $withIdName = true) {
312 312
         if (empty($field_def['type']) || $field_def['type'] != "relate") {
313 313
             return false;
314 314
         }
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
         $ret_array['from'] = " LEFT JOIN $rel_table $joinTableAlias ON $tableName.$relID = $joinTableAlias.id"
347 347
                             . " AND $joinTableAlias.deleted=0 ";
348 348
         return $ret_array;
349
-   }
349
+    }
350 350
 
351
-   /**
352
-    * Fills in all the custom fields of type relate relationships for an object
353
-    *
354
-    */
355
-   function fill_relationships(){
351
+    /**
352
+     * Fills in all the custom fields of type relate relationships for an object
353
+     *
354
+     */
355
+    function fill_relationships(){
356 356
         global $beanList, $beanFiles;
357 357
         if(!empty($this->bean->relDepth)) {
358 358
             if($this->bean->relDepth > 1)return;
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
      *
388 388
      * @param boolean $isUpdate
389 389
      */
390
-     function save($isUpdate){
390
+        function save($isUpdate){
391 391
 
392 392
         if($this->bean->hasCustomFields() && isset($this->bean->id)){
393 393
 
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
                     }
423 423
 
424 424
                     $val = $this->bean->$name;
425
-					if(($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name )|| $this->bean->$name == '1900-01-01')){
426
-                    	$quote = '';
425
+                    if(($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name )|| $this->bean->$name == '1900-01-01')){
426
+                        $quote = '';
427 427
                         $val = 'NULL';
428 428
                         $this->bean->$name = ''; // do not set it to string 'NULL'
429 429
                     }
@@ -571,11 +571,11 @@  discard block
 block discarded – undo
571 571
         if($field){
572 572
             if(!$is_update){
573 573
                 //Do two SQL calls here in this case
574
-            	//The first is to create the column in the custom table without the default value
575
-            	//The second is to modify the column created in the custom table to set the default value
576
-            	//We do this so that the existing entries in the custom table don't have the default value set
577
-            	$field->default = '';
578
-            	$field->default_value = '';
574
+                //The first is to create the column in the custom table without the default value
575
+                //The second is to modify the column created in the custom table to set the default value
576
+                //We do this so that the existing entries in the custom table don't have the default value set
577
+                $field->default = '';
578
+                $field->default_value = '';
579 579
                 // resetting default and default_value does not work for multienum and causes trouble for mssql
580 580
                 // so using a temporary variable here to indicate that we don't want default for this query
581 581
                 $field->no_default = 1;
@@ -583,19 +583,19 @@  discard block
 block discarded – undo
583 583
                 // unsetting temporary member variable
584 584
                 unset($field->no_default);
585 585
                 if(!empty($query)){
586
-                	$GLOBALS['db']->query($query, true, "Cannot create column");
587
-	                $field->default = $fmd->default_value;
588
-	                $field->default_value = $fmd->default_value;
589
-	                $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
590
-	                if(!empty($query)){
591
-	                	$GLOBALS['db']->query($query, true, "Cannot set default");
592
-	            	}
586
+                    $GLOBALS['db']->query($query, true, "Cannot create column");
587
+                    $field->default = $fmd->default_value;
588
+                    $field->default_value = $fmd->default_value;
589
+                    $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
590
+                    if(!empty($query)){
591
+                        $GLOBALS['db']->query($query, true, "Cannot set default");
592
+                    }
593 593
                 }
594 594
             }else{
595 595
                 $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
596 596
                 if(!empty($query)){
597
-                	$GLOBALS['db']->query($query, true, "Cannot modify field");
598
-            	}
597
+                    $GLOBALS['db']->query($query, true, "Cannot modify field");
598
+                }
599 599
             }
600 600
             $fmd->save();
601 601
             $this->buildCache($this->module);
@@ -761,12 +761,12 @@  discard block
 block discarded – undo
761 761
                 )
762 762
             );
763 763
             $ididx = array(
764
-       			'id'=>array(
765
-       				'name' =>$this->bean->table_name."_cstm_pk",
766
-       				'type' =>'primary',
767
-       				'fields'=>array('id_c')
764
+                    'id'=>array(
765
+                        'name' =>$this->bean->table_name."_cstm_pk",
766
+                        'type' =>'primary',
767
+                        'fields'=>array('id_c')
768 768
                 ),
769
-           );
769
+            );
770 770
 
771 771
             $query = $GLOBALS['db']->createTableSQLParams($this->bean->table_name."_cstm", $iddef, $ididx);
772 772
             if(!$GLOBALS['db']->supports("inline_keys")) {
@@ -798,14 +798,14 @@  discard block
 block discarded – undo
798 798
      *
799 799
      */
800 800
     function add_existing_custom_fields($execute = true){
801
-    	$out = "";
801
+        $out = "";
802 802
         if($this->bean->hasCustomFields()){
803
-	        foreach($this->bean->field_defs as $name=>$data){
804
-	        	if(empty($data['source']) || $data['source'] != 'custom_fields')
803
+            foreach($this->bean->field_defs as $name=>$data){
804
+                if(empty($data['source']) || $data['source'] != 'custom_fields')
805 805
                     continue;
806
-	            $out .= $this->add_existing_custom_field($data, $execute);
807
-	        }
808
-    	}
806
+                $out .= $this->add_existing_custom_field($data, $execute);
807
+            }
808
+        }
809 809
         return $out;
810 810
     }
811 811
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 
960 960
     }
961 961
 
962
-   function populateXTPL($xtpl, $view) {
962
+    function populateXTPL($xtpl, $view) {
963 963
 
964 964
         if($this->bean->hasCustomFields()){
965 965
             $results = $this->getAllFieldsView($view, 'xtpl');
@@ -984,12 +984,12 @@  discard block
 block discarded – undo
984 984
     }
985 985
 
986 986
     function getAllFieldsView($view, $type){
987
-         require_once ('modules/DynamicFields/FieldCases.php');
988
-         $results = array();
989
-         foreach($this->bean->field_defs as $name=>$data){
987
+            require_once ('modules/DynamicFields/FieldCases.php');
988
+            $results = array();
989
+            foreach($this->bean->field_defs as $name=>$data){
990 990
             if(empty($data['source']) || $data['source'] != 'custom_fields')
991 991
             {
992
-            	continue;
992
+                continue;
993 993
             }
994 994
             $field = get_widget ( $data ['type'] );
995 995
             $field->populateFromRow($data);
Please login to merge, or discard this patch.
Spacing   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3
-    die ( 'Not A Valid Entry Point' ) ;
2
+if (!defined('sugarEntry') || !sugarEntry)
3
+    die ('Not A Valid Entry Point');
4 4
 
5 5
 /*********************************************************************************
6 6
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
     var $base_path = "";
48 48
 
49 49
     function DynamicField($module = '') {
50
-        $this->module = (! empty ( $module )) ? $module :( (isset($_REQUEST['module']) && ! empty($_REQUEST['module'])) ? $_REQUEST ['module'] : '');
50
+        $this->module = (!empty ($module)) ? $module : ((isset($_REQUEST['module']) && !empty($_REQUEST['module'])) ? $_REQUEST ['module'] : '');
51 51
         $this->base_path = "custom/Extension/modules/{$this->module}/Ext/Vardefs";
52 52
     }
53 53
 
54 54
    function getModuleName()
55 55
     {
56
-        return $this->module ;
56
+        return $this->module;
57 57
     }
58 58
 
59 59
     /*
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
      */
62 62
     function getPackageName()
63 63
     {
64
-        return null ;
64
+        return null;
65 65
     }
66 66
 
67
-    function deleteCache(){
67
+    function deleteCache() {
68 68
     }
69 69
 
70 70
 
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         if ($bean) {
79 79
             $this->bean = $bean;
80 80
         }
81
-        if (isset ( $this->bean->module_dir )) {
81
+        if (isset ($this->bean->module_dir)) {
82 82
             $this->module = $this->bean->module_dir;
83 83
         }
84
-        if(!isset($GLOBALS['dictionary'][$this->bean->object_name]['custom_fields'])){
85
-            $this->buildCache ( $this->module );
84
+        if (!isset($GLOBALS['dictionary'][$this->bean->object_name]['custom_fields'])) {
85
+            $this->buildCache($this->module);
86 86
         }
87 87
     }
88 88
 
89
-    function setLabel( $language='en_us' , $key , $value )
89
+    function setLabel($language = 'en_us', $key, $value)
90 90
     {
91
-        $params [ "label_" . $key ] = $value;
92
-        require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
93
-        $parser = new ParserLabel ( $this->module ) ;
94
-        $parser->handleSave( $params , $language);
91
+        $params ["label_".$key] = $value;
92
+        require_once 'modules/ModuleBuilder/parsers/parser.label.php';
93
+        $parser = new ParserLabel($this->module);
94
+        $parser->handleSave($params, $language);
95 95
     }
96 96
 
97 97
     /**
@@ -101,58 +101,58 @@  discard block
 block discarded – undo
101 101
     * @param boolean saveCache Boolean value indicating whether or not to pass saveCache value to saveToVardef, defaults to true
102 102
     * @return unknown
103 103
     */
104
-    function buildCache($module = false, $saveCache=true) {
104
+    function buildCache($module = false, $saveCache = true) {
105 105
         //We can't build the cache while installing as the required database tables may not exist.
106
-        if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db']))
106
+        if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true || empty($GLOBALS['db']))
107 107
             return false;
108
-        if($module == '../data')return false;
108
+        if ($module == '../data')return false;
109 109
 
110
-        static $results = array ( ) ;
110
+        static $results = array( );
111 111
 
112 112
         $where = '';
113
-        if (! empty ( $module )) {
113
+        if (!empty ($module)) {
114 114
             $where .= " custom_module='$module' AND ";
115
-            unset( $results[ $module ] ) ; // clear out any old results for the module as $results is declared static
115
+            unset($results[$module]); // clear out any old results for the module as $results is declared static
116 116
         }
117 117
         else
118 118
         {
119
-            $results = array ( ) ; // clear out results - if we remove a module we don't want to have its old vardefs hanging around
119
+            $results = array( ); // clear out results - if we remove a module we don't want to have its old vardefs hanging around
120 120
         }
121 121
 
122
-        $GLOBALS['log']->debug('rebuilding cache for ' . $module);
122
+        $GLOBALS['log']->debug('rebuilding cache for '.$module);
123 123
         $query = "SELECT * FROM fields_meta_data WHERE $where deleted = 0";
124 124
 
125
-        $result = $GLOBALS['db']->query ( $query );
125
+        $result = $GLOBALS['db']->query($query);
126 126
         require_once ('modules/DynamicFields/FieldCases.php');
127 127
 
128 128
         // retrieve the field definition from the fields_meta_data table
129 129
         // using 'encode'=false to fetchByAssoc to prevent any pre-formatting of the base metadata
130 130
         // for immediate use in HTML. This metadata will be further massaged by get_field_def() and so should not be pre-formatted
131
-        while ( $row = $GLOBALS['db']->fetchByAssoc ( $result, false ) ) {
132
-            $field = get_widget ( $row ['type'] );
131
+        while ($row = $GLOBALS['db']->fetchByAssoc($result, false)) {
132
+            $field = get_widget($row ['type']);
133 133
 
134
-            foreach ( $row as $key => $value ) {
134
+            foreach ($row as $key => $value) {
135 135
                 $field->$key = $value;
136 136
             }
137 137
             $field->default = $field->default_value;
138
-            $vardef = $field->get_field_def ();
138
+            $vardef = $field->get_field_def();
139 139
             $vardef ['id'] = $row ['id'];
140 140
             $vardef ['custom_module'] = $row ['custom_module'];
141
-            if (empty ( $vardef ['source'] ))
141
+            if (empty ($vardef ['source']))
142 142
                 $vardef ['source'] = 'custom_fields';
143
-            if (empty ( $results [$row ['custom_module']] ))
144
-                $results [$row ['custom_module']] = array ( );
143
+            if (empty ($results [$row ['custom_module']]))
144
+                $results [$row ['custom_module']] = array( );
145 145
             $results [$row ['custom_module']] [$row ['name']] = $vardef;
146 146
         }
147
-        if (empty ( $module )) {
148
-            foreach ( $results as $module => $result ) {
149
-                $this->saveToVardef ( $module, $result, $saveCache);
147
+        if (empty ($module)) {
148
+            foreach ($results as $module => $result) {
149
+                $this->saveToVardef($module, $result, $saveCache);
150 150
             }
151 151
         } else {
152
-            if (! empty ( $results [$module] )) {
153
-                $this->saveToVardef ( $module, $results [$module], $saveCache);
154
-            }else{
155
-                $this->saveToVardef ( $module, false, $saveCache);
152
+            if (!empty ($results [$module])) {
153
+                $this->saveToVardef($module, $results [$module], $saveCache);
154
+            } else {
155
+                $this->saveToVardef($module, false, $saveCache);
156 156
             }
157 157
         }
158 158
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
     * Returns the widget for a custom field from the fields_meta_data table.
165 165
     */
166 166
     function getFieldWidget($module, $fieldName) {
167
-        if (empty($module) || empty($fieldName)){
167
+        if (empty($module) || empty($fieldName)) {
168 168
             sugar_die("Unable to load widget for '$module' : '$fieldName'");
169 169
         }
170 170
         $query = "SELECT * FROM fields_meta_data WHERE custom_module='$module' AND name='$fieldName' AND deleted = 0";
171
-        $result = $GLOBALS['db']->query ( $query );
171
+        $result = $GLOBALS['db']->query($query);
172 172
         require_once ('modules/DynamicFields/FieldCases.php');
173
-        if ( $row = $GLOBALS['db']->fetchByAssoc ( $result ) ) {
174
-            $field = get_widget ( $row ['type'] );
173
+        if ($row = $GLOBALS['db']->fetchByAssoc($result)) {
174
+            $field = get_widget($row ['type']);
175 175
             $field->populateFromRow($row);
176 176
             return $field;
177 177
         }
@@ -185,41 +185,41 @@  discard block
 block discarded – undo
185 185
     * @param array $result
186 186
     * @param boolean saveCache Boolean value indicating whether or not to call VardefManager::saveCache, defaults to true
187 187
     */
188
-    function saveToVardef($module,$result,$saveCache=true) {
188
+    function saveToVardef($module, $result, $saveCache = true) {
189 189
 
190 190
 
191 191
         global $beanList;
192
-        if (! empty ( $beanList [$module] )) {
192
+        if (!empty ($beanList [$module])) {
193 193
             $object = BeanFactory::getObjectName($module);
194 194
 
195
-            if(empty($GLOBALS['dictionary'][$object]['fields'])){
195
+            if (empty($GLOBALS['dictionary'][$object]['fields'])) {
196 196
                 //if the vardef isn't loaded let's try loading it.
197
-                VardefManager::refreshVardefs($module,$object, null, false);
197
+                VardefManager::refreshVardefs($module, $object, null, false);
198 198
                 //if it's still not loaded we really don't have anything useful to cache
199
-                if(empty($GLOBALS['dictionary'][$object]['fields']))return;
199
+                if (empty($GLOBALS['dictionary'][$object]['fields']))return;
200 200
             }
201 201
             if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) {
202 202
                 $GLOBALS['dictionary'][$object]['custom_fields'] = false;
203 203
             }
204
-            if (! empty ( $GLOBALS ['dictionary'] [$object] )) {
205
-                if (! empty ( $result )) {
204
+            if (!empty ($GLOBALS ['dictionary'] [$object])) {
205
+                if (!empty ($result)) {
206 206
                     // First loop to add
207 207
 
208
-                foreach ( $result as $field ) {
209
-                    foreach($field as $k=>$v){
208
+                foreach ($result as $field) {
209
+                    foreach ($field as $k=>$v) {
210 210
                         //allows values for custom fields to be defined outside of the scope of studio
211
-                        if(!isset($GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k])){
211
+                        if (!isset($GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k])) {
212 212
                             $GLOBALS ['dictionary'] [$object] ['fields'] [$field ['name']][$k] = $v;
213 213
                         }
214 214
                     }
215 215
                 }
216 216
 
217 217
                     // Second loop to remove
218
-                    foreach ( $GLOBALS ['dictionary'] [$object] ['fields'] as $name => $fieldDef ) {
218
+                    foreach ($GLOBALS ['dictionary'] [$object] ['fields'] as $name => $fieldDef) {
219 219
 
220
-                        if (isset ( $fieldDef ['custom_module'] )) {
221
-                            if (! isset ( $result [$name] )) {
222
-                                unset ( $GLOBALS ['dictionary'] [$object] ['fields'] [$name] );
220
+                        if (isset ($fieldDef ['custom_module'])) {
221
+                            if (!isset ($result [$name])) {
222
+                                unset ($GLOBALS ['dictionary'] [$object] ['fields'] [$name]);
223 223
                             } else {
224 224
                                 $GLOBALS ['dictionary'] [$object] ['custom_fields'] = true;
225 225
                             }
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
             }
231 231
 
232 232
             $manager = new VardefManager();
233
-            if($saveCache)
233
+            if ($saveCache)
234 234
             {
235
-                $manager->saveCache ($this->module, $object);
235
+                $manager->saveCache($this->module, $object);
236 236
             }
237 237
 
238 238
             // Everything works off of vardefs, so let's have it save the users vardefs
@@ -255,38 +255,38 @@  discard block
 block discarded – undo
255 255
     *
256 256
     * @return array select=>select columns, join=>prebuilt join statement
257 257
     */
258
-  function getJOIN( $expandedList = false , $includeRelates = false, &$where = false){
259
-        if(!$this->bean->hasCustomFields()){
258
+  function getJOIN($expandedList = false, $includeRelates = false, &$where = false) {
259
+        if (!$this->bean->hasCustomFields()) {
260 260
             return array(
261 261
                 'select' => '',
262 262
                 'join' => ''
263 263
             );
264 264
         }
265 265
 
266
-        if (empty($expandedList) )
266
+        if (empty($expandedList))
267 267
         {
268
-            $select = ",{$this->bean->table_name}_cstm.*" ;
268
+            $select = ",{$this->bean->table_name}_cstm.*";
269 269
         }
270 270
         else
271 271
         {
272 272
             $select = '';
273 273
             $isList = is_array($expandedList);
274
-            foreach($this->bean->field_defs as $name=>$field)
274
+            foreach ($this->bean->field_defs as $name=>$field)
275 275
             {
276
-                if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))){
276
+                if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))) {
277 277
                     // assumption: that the column name in _cstm is the same as the field name. Currently true.
278 278
                     // however, two types of dynamic fields do not have columns in the custom table - html fields (they're readonly) and flex relates (parent_name doesn't exist)
279
-                    if ( $field['type'] != 'html' && $name != 'parent_name')
280
-                        $select .= ",{$this->bean->table_name}_cstm.{$name}" ;
279
+                    if ($field['type'] != 'html' && $name != 'parent_name')
280
+                        $select .= ",{$this->bean->table_name}_cstm.{$name}";
281 281
                 }
282 282
             }
283 283
         }
284
-        $join = " LEFT JOIN " .$this->bean->table_name. "_cstm ON " .$this->bean->table_name. ".id = ". $this->bean->table_name. "_cstm.id_c ";
284
+        $join = " LEFT JOIN ".$this->bean->table_name."_cstm ON ".$this->bean->table_name.".id = ".$this->bean->table_name."_cstm.id_c ";
285 285
 
286 286
         if ($includeRelates) {
287 287
             $jtAlias = "relJoin";
288 288
             $jtCount = 1;
289
-            foreach($this->bean->field_defs as $name=>$field)
289
+            foreach ($this->bean->field_defs as $name=>$field)
290 290
             {
291 291
                 if ($field['type'] == 'relate' && isset($field['custom_module'])) {
292 292
                     $relateJoinInfo = $this->getRelateJoin($field, $jtAlias.$jtCount);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                     {
298 298
                         $pattern = '/'.$field['name'].'\slike/i';
299 299
                         $replacement = $relateJoinInfo['name_field'].' like';
300
-                        $where = preg_replace($pattern,$replacement,$where);
300
+                        $where = preg_replace($pattern, $replacement, $where);
301 301
                     }
302 302
                     $jtCount++;
303 303
                 }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         }
315 315
         global $beanFiles, $beanList, $module;
316 316
         $rel_module = $field_def['module'];
317
-        if(empty($beanFiles[$beanList[$rel_module]])) {
317
+        if (empty($beanFiles[$beanList[$rel_module]])) {
318 318
             return false;
319 319
         }
320 320
 
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
         if (isset($rel_mod->field_defs['name']))
325 325
         {
326 326
             $name_field_def = $rel_mod->field_defs['name'];
327
-            if(isset($name_field_def['db_concat_fields']))
327
+            if (isset($name_field_def['db_concat_fields']))
328 328
             {
329 329
                 $name_field = db_concat($joinTableAlias, $name_field_def['db_concat_fields']);
330 330
             }
331 331
             //If the name field is non-db, we need to find another field to display
332
-            else if(!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname']))
332
+            else if (!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname']))
333 333
             {
334
-                $name_field = "$joinTableAlias." . $field_def['rname'];
334
+                $name_field = "$joinTableAlias.".$field_def['rname'];
335 335
             }
336 336
             else
337 337
             {
338 338
                 $name_field = "$joinTableAlias.name";
339 339
             }
340 340
         }
341
-        $tableName = isset($field_def['custom_module']) ? "{$this->bean->table_name}_cstm" : $this->bean->table_name ;
341
+        $tableName = isset($field_def['custom_module']) ? "{$this->bean->table_name}_cstm" : $this->bean->table_name;
342 342
         $relID = $field_def['id_name'];
343 343
         $ret_array['rel_table'] = $rel_table;
344 344
         $ret_array['name_field'] = $name_field;
345
-        $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : "") . ", {$name_field} {$field_def['name']} ";
345
+        $ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : "").", {$name_field} {$field_def['name']} ";
346 346
         $ret_array['from'] = " LEFT JOIN $rel_table $joinTableAlias ON $tableName.$relID = $joinTableAlias.id"
347 347
                             . " AND $joinTableAlias.deleted=0 ";
348 348
         return $ret_array;
@@ -352,24 +352,24 @@  discard block
 block discarded – undo
352 352
     * Fills in all the custom fields of type relate relationships for an object
353 353
     *
354 354
     */
355
-   function fill_relationships(){
355
+   function fill_relationships() {
356 356
         global $beanList, $beanFiles;
357
-        if(!empty($this->bean->relDepth)) {
358
-            if($this->bean->relDepth > 1)return;
359
-        }else{
357
+        if (!empty($this->bean->relDepth)) {
358
+            if ($this->bean->relDepth > 1)return;
359
+        } else {
360 360
             $this->bean->relDepth = 0;
361 361
         }
362
-        foreach($this->bean->field_defs as $field){
363
-            if(empty($field['source']) || $field['source'] != 'custom_fields')continue;
364
-            if($field['type'] == 'relate'){
365
-                $related_module =$field['ext2'];
362
+        foreach ($this->bean->field_defs as $field) {
363
+            if (empty($field['source']) || $field['source'] != 'custom_fields')continue;
364
+            if ($field['type'] == 'relate') {
365
+                $related_module = $field['ext2'];
366 366
                 $name = $field['name'];
367 367
                 if (empty($this->bean->$name)) { //Don't load the relationship twice
368 368
                     $id_name = $field['id_name'];
369
-                    if(isset($beanList[ $related_module])){
369
+                    if (isset($beanList[$related_module])) {
370 370
                         $class = $beanList[$related_module];
371 371
 
372
-                        if(file_exists($beanFiles[$class]) && isset($this->bean->$name)){
372
+                        if (file_exists($beanFiles[$class]) && isset($this->bean->$name)) {
373 373
                             require_once($beanFiles[$class]);
374 374
                             $mod = new $class();
375 375
                             $mod->relDepth = $this->bean->relDepth + 1;
@@ -387,72 +387,72 @@  discard block
 block discarded – undo
387 387
      *
388 388
      * @param boolean $isUpdate
389 389
      */
390
-     function save($isUpdate){
390
+     function save($isUpdate) {
391 391
 
392
-        if($this->bean->hasCustomFields() && isset($this->bean->id)){
392
+        if ($this->bean->hasCustomFields() && isset($this->bean->id)) {
393 393
 
394
-            if($isUpdate){
395
-                $query = "UPDATE ". $this->bean->table_name. "_cstm SET ";
394
+            if ($isUpdate) {
395
+                $query = "UPDATE ".$this->bean->table_name."_cstm SET ";
396 396
             }
397
-            $queryInsert = "INSERT INTO ". $this->bean->table_name. "_cstm (id_c";
397
+            $queryInsert = "INSERT INTO ".$this->bean->table_name."_cstm (id_c";
398 398
             $values = "('".$this->bean->id."'";
399 399
             $first = true;
400
-            foreach($this->bean->field_defs as $name=>$field){
400
+            foreach ($this->bean->field_defs as $name=>$field) {
401 401
 
402
-                if(empty($field['source']) || $field['source'] != 'custom_fields')continue;
403
-                if($field['type'] == 'html' || $field['type'] == 'parent')continue;
404
-                if(isset($this->bean->$name)){
402
+                if (empty($field['source']) || $field['source'] != 'custom_fields')continue;
403
+                if ($field['type'] == 'html' || $field['type'] == 'parent')continue;
404
+                if (isset($this->bean->$name)) {
405 405
                     $quote = "'";
406 406
 
407
-                    if(in_array($field['type'], array('int', 'float', 'double', 'uint', 'ulong', 'long', 'short', 'tinyint', 'currency', 'decimal'))) {
407
+                    if (in_array($field['type'], array('int', 'float', 'double', 'uint', 'ulong', 'long', 'short', 'tinyint', 'currency', 'decimal'))) {
408 408
                         $quote = '';
409
-                        if(!isset($this->bean->$name) || !is_numeric($this->bean->$name) ){
410
-                            if($field['required']){
409
+                        if (!isset($this->bean->$name) || !is_numeric($this->bean->$name)) {
410
+                            if ($field['required']) {
411 411
                                 $this->bean->$name = 0;
412
-                            }else{
412
+                            } else {
413 413
                                 $this->bean->$name = 'NULL';
414 414
                             }
415 415
                         }
416 416
                     }
417
-                    if ( $field['type'] == 'bool' ) {
418
-                        if ( $this->bean->$name === FALSE )
417
+                    if ($field['type'] == 'bool') {
418
+                        if ($this->bean->$name === FALSE)
419 419
                             $this->bean->$name = '0';
420
-                        elseif ( $this->bean->$name === TRUE )
420
+                        elseif ($this->bean->$name === TRUE)
421 421
                             $this->bean->$name = '1';
422 422
                     }
423 423
 
424 424
                     $val = $this->bean->$name;
425
-					if(($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name )|| $this->bean->$name == '1900-01-01')){
425
+					if (($field['type'] == 'date' || $field['type'] == 'datetimecombo') && (empty($this->bean->$name) || $this->bean->$name == '1900-01-01')) {
426 426
                     	$quote = '';
427 427
                         $val = 'NULL';
428 428
                         $this->bean->$name = ''; // do not set it to string 'NULL'
429 429
                     }
430
-                    if($isUpdate){
431
-                        if($first){
430
+                    if ($isUpdate) {
431
+                        if ($first) {
432 432
                             $query .= " $name=$quote".$GLOBALS['db']->quote($val)."$quote";
433 433
 
434
-                        }else{
434
+                        } else {
435 435
                             $query .= " ,$name=$quote".$GLOBALS['db']->quote($val)."$quote";
436 436
                         }
437 437
                     }
438 438
                     $first = false;
439 439
                     $queryInsert .= " ,$name";
440
-                    $values .= " ,$quote". $GLOBALS['db']->quote($val). "$quote";
440
+                    $values .= " ,$quote".$GLOBALS['db']->quote($val)."$quote";
441 441
                 }
442 442
             }
443
-            if($isUpdate){
444
-                $query.= " WHERE id_c='" . $this->bean->id ."'";
443
+            if ($isUpdate) {
444
+                $query .= " WHERE id_c='".$this->bean->id."'";
445 445
 
446 446
             }
447 447
 
448 448
             $queryInsert .= " ) VALUES $values )";
449 449
 
450
-            if(!$first){
451
-                if(!$isUpdate){
450
+            if (!$first) {
451
+                if (!$isUpdate) {
452 452
                     $GLOBALS['db']->query($queryInsert);
453
-                }else{
453
+                } else {
454 454
                     $checkquery = "SELECT id_c FROM {$this->bean->table_name}_cstm WHERE id_c = '{$this->bean->id}'";
455
-                    if ( $GLOBALS['db']->getOne($checkquery) ) {
455
+                    if ($GLOBALS['db']->getOne($checkquery)) {
456 456
                         $result = $GLOBALS['db']->query($query);
457 457
                     } else {
458 458
                         $GLOBALS['db']->query($queryInsert);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      * Use the widgets get_db_modify_alter_table() method to get the table sql - some widgets do not need any custom table modifications
468 468
      * @param STRING $name - field name
469 469
      */
470
-    function deleteField($widget){
470
+    function deleteField($widget) {
471 471
         require_once('modules/DynamicFields/templates/Fields/TemplateField.php');
472 472
         global $beanList;
473 473
         if (!($widget instanceof TemplateField)) {
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
             $object_name = $newName != false ? $newName : $object_name;
484 484
         }
485 485
 
486
-        $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'");
487
-        $sql = $widget->get_db_delete_alter_table( $this->bean->table_name . "_cstm" ) ;
488
-        if (! empty( $sql ) )
489
-            $GLOBALS['db']->query( $sql );
486
+        $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='".$this->module.$widget->name."'");
487
+        $sql = $widget->get_db_delete_alter_table($this->bean->table_name."_cstm");
488
+        if (!empty($sql))
489
+            $GLOBALS['db']->query($sql);
490 490
 
491 491
         $this->removeVardefExtension($widget);
492 492
         VardefManager::clearVardef();
@@ -498,25 +498,25 @@  discard block
 block discarded – undo
498 498
      * Method required by the TemplateRelatedTextField->save() method
499 499
      * Taken from MBModule's implementation
500 500
      */
501
-    function fieldExists($name = '', $type = ''){
501
+    function fieldExists($name = '', $type = '') {
502 502
         // must get the vardefs from the GLOBAL array as $bean->field_defs does not contain the values from the cache at this point
503 503
         // TODO: fix this - saveToVardefs() updates GLOBAL['dictionary'] correctly, obtaining its information directly from the fields_meta_data table via buildCache()...
504 504
         $name = $this->getDBName($name);
505 505
         $vardefs = $GLOBALS['dictionary'][$this->bean->object_name]['fields'];
506
-        if(!empty($vardefs)){
507
-            if(empty($type) && empty($name))
506
+        if (!empty($vardefs)) {
507
+            if (empty($type) && empty($name))
508 508
                 return false;
509
-            else if(empty($type))
509
+            else if (empty($type))
510 510
                 return !empty($vardefs[$name]);
511
-            else if(empty($name)){
512
-                foreach($vardefs as $def){
513
-                    if(!empty($def['type']) && $def['type'] == $type)
511
+            else if (empty($name)) {
512
+                foreach ($vardefs as $def) {
513
+                    if (!empty($def['type']) && $def['type'] == $type)
514 514
                         return true;
515 515
                 }
516 516
                 return false;
517
-            }else
517
+            } else
518 518
                 return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type));
519
-        }else{
519
+        } else {
520 520
             return false;
521 521
         }
522 522
     }
@@ -528,24 +528,24 @@  discard block
 block discarded – undo
528 528
      * @param Field Object $field
529 529
      * @return boolean
530 530
      */
531
-    function addFieldObject(&$field){
531
+    function addFieldObject(&$field) {
532 532
         $GLOBALS['log']->debug('adding field');
533 533
         $object_name = $this->module;
534 534
         $db_name = $field->name;
535 535
 
536 536
         $fmd = new FieldsMetaData();
537
-        $id =  $fmd->retrieve($object_name.$db_name,true, false);
537
+        $id = $fmd->retrieve($object_name.$db_name, true, false);
538 538
         $is_update = false;
539
-        $label = strtoupper( $field->label );
540
-        if(!empty($id)){
539
+        $label = strtoupper($field->label);
540
+        if (!empty($id)) {
541 541
             $is_update = true;
542
-        }else{
542
+        } else {
543 543
             $db_name = $this->getDBName($field->name);
544 544
             $field->name = $db_name;
545 545
         }
546 546
         $this->createCustomTable();
547 547
         $fmd->id = $object_name.$db_name;
548
-        $fmd->custom_module= $object_name;
548
+        $fmd->custom_module = $object_name;
549 549
         $fmd->name = $db_name;
550 550
         $fmd->vname = $label;
551 551
         $fmd->type = $field->type;
@@ -560,16 +560,16 @@  discard block
 block discarded – undo
560 560
         $fmd->ext4 = (isset($field->ext4) ? $field->ext4 : '');
561 561
         $fmd->comments = $field->comment;
562 562
         $fmd->massupdate = $field->massupdate;
563
-        $fmd->importable = ( isset ( $field->importable ) ) ? $field->importable : null ;
563
+        $fmd->importable = (isset ($field->importable)) ? $field->importable : null;
564 564
         $fmd->duplicate_merge = $field->duplicate_merge;
565
-        $fmd->audited =$field->audited;
565
+        $fmd->audited = $field->audited;
566 566
         $fmd->inline_edit = $field->inline_edit;
567 567
         $fmd->reportable = ($field->reportable ? 1 : 0);
568
-        if(!$is_update){
569
-            $fmd->new_with_id=true;
568
+        if (!$is_update) {
569
+            $fmd->new_with_id = true;
570 570
         }
571
-        if($field){
572
-            if(!$is_update){
571
+        if ($field) {
572
+            if (!$is_update) {
573 573
                 //Do two SQL calls here in this case
574 574
             	//The first is to create the column in the custom table without the default value
575 575
             	//The second is to modify the column created in the custom table to set the default value
@@ -579,21 +579,21 @@  discard block
 block discarded – undo
579 579
                 // resetting default and default_value does not work for multienum and causes trouble for mssql
580 580
                 // so using a temporary variable here to indicate that we don't want default for this query
581 581
                 $field->no_default = 1;
582
-                $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
582
+                $query = $field->get_db_add_alter_table($this->bean->table_name.'_cstm');
583 583
                 // unsetting temporary member variable
584 584
                 unset($field->no_default);
585
-                if(!empty($query)){
585
+                if (!empty($query)) {
586 586
                 	$GLOBALS['db']->query($query, true, "Cannot create column");
587 587
 	                $field->default = $fmd->default_value;
588 588
 	                $field->default_value = $fmd->default_value;
589
-	                $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
590
-	                if(!empty($query)){
589
+	                $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm');
590
+	                if (!empty($query)) {
591 591
 	                	$GLOBALS['db']->query($query, true, "Cannot set default");
592 592
 	            	}
593 593
                 }
594
-            }else{
595
-                $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
596
-                if(!empty($query)){
594
+            } else {
595
+                $query = $field->get_db_modify_alter_table($this->bean->table_name.'_cstm');
596
+                if (!empty($query)) {
597 597
                 	$GLOBALS['db']->query($query, true, "Cannot modify field");
598 598
             	}
599 599
             }
@@ -607,18 +607,18 @@  discard block
 block discarded – undo
607 607
 
608 608
     function saveExtendedAttributes($field, $column_fields)
609 609
     {
610
-            require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
611
-            require_once ('modules/DynamicFields/FieldCases.php') ;
610
+            require_once ('modules/ModuleBuilder/parsers/StandardField.php');
611
+            require_once ('modules/DynamicFields/FieldCases.php');
612 612
             global $beanList;
613 613
 
614 614
             $to_save = array();
615
-            $base_field = get_widget ( $field->type) ;
616
-        foreach ($field->vardef_map as $property => $fmd_col){
615
+            $base_field = get_widget($field->type);
616
+        foreach ($field->vardef_map as $property => $fmd_col) {
617 617
             //Skip over attribes that are either the default or part of the normal attributes stored in the DB
618 618
             if (!isset($field->$property) || in_array($fmd_col, $column_fields) || in_array($property, $column_fields)
619 619
                 || $this->isDefaultValue($property, $field->$property, $base_field)
620 620
                 || $property == "action" || $property == "label_value" || $property == "label"
621
-                || (substr($property, 0,3) == 'ext' && strlen($property) == 4))
621
+                || (substr($property, 0, 3) == 'ext' && strlen($property) == 4))
622 622
             {
623 623
                 continue;
624 624
             }
@@ -634,19 +634,19 @@  discard block
 block discarded – undo
634 634
     {
635 635
         switch ($property) {
636 636
             case "importable":
637
-                return ( $value === 'true' || $value === '1' || $value === true || $value === 1 ); break;
637
+                return ($value === 'true' || $value === '1' || $value === true || $value === 1); break;
638 638
             case "required":
639 639
             case "audited":
640 640
             case "inline_edit":
641 641
             case "massupdate":
642
-                return ( $value === 'false' || $value === '0' || $value === false || $value === 0); break;
642
+                return ($value === 'false' || $value === '0' || $value === false || $value === 0); break;
643 643
             case "default_value":
644 644
             case "default":
645 645
             case "help":
646 646
             case "comments":
647 647
                 return ($value == "");
648 648
             case "duplicate_merge":
649
-                return ( $value === 'false' || $value === '0' || $value === false || $value === 0 || $value === "disabled"); break;
649
+                return ($value === 'false' || $value === '0' || $value === false || $value === 0 || $value === "disabled"); break;
650 650
         }
651 651
 
652 652
         if (isset($baseField->$property))
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
         $vBean = $bean_name == "aCase" ? "Case" : $bean_name;
664 664
         $file_loc = "$this->base_path/sugarfield_{$field->name}.php";
665 665
 
666
-        $out =  "<?php\n // created: " . date('Y-m-d H:i:s') . "\n";
666
+        $out = "<?php\n // created: ".date('Y-m-d H:i:s')."\n";
667 667
         foreach ($def_override as $property => $val)
668 668
         {
669
-            $out .= override_value_to_string_recursive(array($vBean, "fields", $field->name, $property), "dictionary", $val) . "\n";
669
+            $out .= override_value_to_string_recursive(array($vBean, "fields", $field->name, $property), "dictionary", $val)."\n";
670 670
         }
671 671
 
672 672
         $out .= "\n ?>";
@@ -674,15 +674,15 @@  discard block
 block discarded – undo
674 674
         if (!file_exists($this->base_path))
675 675
             mkdir_recursive($this->base_path);
676 676
 
677
-        if( $fh = @sugar_fopen( $file_loc, 'w' ) )
677
+        if ($fh = @sugar_fopen($file_loc, 'w'))
678 678
         {
679
-            fputs( $fh, $out);
680
-            fclose( $fh );
681
-            return true ;
679
+            fputs($fh, $out);
680
+            fclose($fh);
681
+            return true;
682 682
         }
683 683
         else
684 684
         {
685
-            return false ;
685
+            return false;
686 686
         }
687 687
     }
688 688
 
@@ -719,11 +719,11 @@  discard block
 block discarded – undo
719 719
      * @param unknown_type $comment
720 720
      * @return boolean
721 721
      */
722
-    function addField($name,$label='', $type='Text',$max_size='255',$required_option='optional', $default_value='', $ext1='', $ext2='', $ext3='',$audited=0, $inline_edit = 1, $mass_update = 0 , $ext4='', $help='',$duplicate_merge=0, $comment=''){
722
+    function addField($name, $label = '', $type = 'Text', $max_size = '255', $required_option = 'optional', $default_value = '', $ext1 = '', $ext2 = '', $ext3 = '', $audited = 0, $inline_edit = 1, $mass_update = 0, $ext4 = '', $help = '', $duplicate_merge = 0, $comment = '') {
723 723
         require_once('modules/DynamicFields/templates/Fields/TemplateField.php');
724 724
         $field = new TemplateField();
725 725
         $field->label = $label;
726
-        if(empty($field->label)){
726
+        if (empty($field->label)) {
727 727
             $field->label = $name;
728 728
         }
729 729
         $field->name = $name;
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
      * Creates the custom table with an id of id_c
750 750
      *
751 751
      */
752
-    function createCustomTable($execute = true){
752
+    function createCustomTable($execute = true) {
753 753
         $out = "";
754 754
         if (!$GLOBALS['db']->tableExists($this->bean->table_name."_cstm")) {
755
-            $GLOBALS['log']->debug('creating custom table for '. $this->bean->table_name);
755
+            $GLOBALS['log']->debug('creating custom table for '.$this->bean->table_name);
756 756
             $iddef = array(
757 757
                 "id_c" => array(
758 758
                     "name" => "id_c",
@@ -769,21 +769,21 @@  discard block
 block discarded – undo
769 769
            );
770 770
 
771 771
             $query = $GLOBALS['db']->createTableSQLParams($this->bean->table_name."_cstm", $iddef, $ididx);
772
-            if(!$GLOBALS['db']->supports("inline_keys")) {
772
+            if (!$GLOBALS['db']->supports("inline_keys")) {
773 773
                 $indicesArr = $GLOBALS['db']->getConstraintSql($ididx, $this->bean->table_name."_cstm");
774 774
             } else {
775 775
                 $indicesArr = array();
776 776
             }
777
-            if($execute) {
777
+            if ($execute) {
778 778
                 $GLOBALS['db']->query($query);
779
-                if(!empty($indicesArr)) {
780
-                    foreach($indicesArr as $idxq) {
779
+                if (!empty($indicesArr)) {
780
+                    foreach ($indicesArr as $idxq) {
781 781
                         $GLOBALS['db']->query($idxq);
782 782
                     }
783 783
                 }
784 784
             }
785
-            $out = $query . "\n";
786
-            if(!empty($indicesArr)) {
785
+            $out = $query."\n";
786
+            if (!empty($indicesArr)) {
787 787
                 $out .= join("\n", $indicesArr)."\n";
788 788
             }
789 789
 
@@ -797,11 +797,11 @@  discard block
 block discarded – undo
797 797
      * Updates the db schema and adds any custom fields we have used if the custom table was dropped
798 798
      *
799 799
      */
800
-    function add_existing_custom_fields($execute = true){
800
+    function add_existing_custom_fields($execute = true) {
801 801
     	$out = "";
802
-        if($this->bean->hasCustomFields()){
803
-	        foreach($this->bean->field_defs as $name=>$data){
804
-	        	if(empty($data['source']) || $data['source'] != 'custom_fields')
802
+        if ($this->bean->hasCustomFields()) {
803
+	        foreach ($this->bean->field_defs as $name=>$data) {
804
+	        	if (empty($data['source']) || $data['source'] != 'custom_fields')
805 805
                     continue;
806 806
 	            $out .= $this->add_existing_custom_field($data, $execute);
807 807
 	        }
@@ -812,11 +812,11 @@  discard block
 block discarded – undo
812 812
     function add_existing_custom_field($data, $execute = true)
813 813
     {
814 814
 
815
-        $field = get_widget ( $data ['type'] );
815
+        $field = get_widget($data ['type']);
816 816
         $field->populateFromRow($data);
817 817
         $query = "/*MISSING IN DATABASE - {$data['name']} -  ROW*/\n"
818
-                . $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
819
-        $out = $query . "\n";
818
+                . $field->get_db_add_alter_table($this->bean->table_name.'_cstm');
819
+        $out = $query."\n";
820 820
         if ($execute)
821 821
             $GLOBALS['db']->query($query);
822 822
 
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
         $db = $GLOBALS['db'];
835 835
         $tablename = $this->bean->table_name."_cstm";
836 836
         $compareFieldDefs = $db->get_columns($tablename);
837
-        foreach($this->bean->field_defs as $name=>$data){
838
-            if(empty($data['source']) || $data['source'] != 'custom_fields')
837
+        foreach ($this->bean->field_defs as $name=>$data) {
838
+            if (empty($data['source']) || $data['source'] != 'custom_fields')
839 839
                 continue;
840 840
             /**
841 841
              * @bug 43471
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
              * force the name to be lower as it needs to be lower since that is how it's put into the key
846 846
              * in the get_columns() call above.
847 847
              */
848
-            if(!empty($compareFieldDefs[strtolower($name)])) {
848
+            if (!empty($compareFieldDefs[strtolower($name)])) {
849 849
                 continue;
850 850
             }
851 851
             $out .= $this->add_existing_custom_field($data, $execute);
@@ -864,24 +864,24 @@  discard block
 block discarded – undo
864 864
      * @return string The core of the system label name - returns currency_id5 for example, when the full label would then be LBL_CURRENCY_ID5
865 865
      * TODO: Only the core is returned for historical reasons - switch to return the real system label
866 866
      */
867
-    function addLabel ( $displayLabel )
867
+    function addLabel($displayLabel)
868 868
     {
869
-        $mod_strings = return_module_language($GLOBALS[ 'current_language' ], $this->module);
869
+        $mod_strings = return_module_language($GLOBALS['current_language'], $this->module);
870 870
         $limit = 10;
871 871
         $count = 0;
872 872
         $field_key = $this->getDBName($displayLabel, false);
873 873
         $systemLabel = $field_key;
874
-        if(!$this->use_existing_labels){ // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php
875
-            while( isset( $mod_strings [ $systemLabel ] ) && $count <= $limit )
874
+        if (!$this->use_existing_labels) { // use_existing_labels defaults to false in this module; as of today, only set to true by ModuleInstaller.php
875
+            while (isset($mod_strings [$systemLabel]) && $count <= $limit)
876 876
             {
877
-                $systemLabel = $field_key. "_$count";
877
+                $systemLabel = $field_key."_$count";
878 878
                 $count++;
879 879
             }
880 880
         }
881 881
         $selMod = (!empty($_REQUEST['view_module'])) ? $_REQUEST['view_module'] : $this->module;
882
-        require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
883
-        $parser = new ParserLabel ( $selMod , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
884
-        $parser->handleSave ( array('label_'. $systemLabel => $displayLabel ) , $GLOBALS [ 'current_language' ] ) ;
882
+        require_once 'modules/ModuleBuilder/parsers/parser.label.php';
883
+        $parser = new ParserLabel($selMod, isset ($_REQUEST ['view_package']) ? $_REQUEST ['view_package'] : null);
884
+        $parser->handleSave(array('label_'.$systemLabel => $displayLabel), $GLOBALS ['current_language']);
885 885
 
886 886
         return $systemLabel;
887 887
     }
@@ -893,27 +893,27 @@  discard block
 block discarded – undo
893 893
      * @param BOOLEAN $_C do we append _c to the name
894 894
      * @return STRING
895 895
      */
896
-    function getDBName($name, $_C= true){
896
+    function getDBName($name, $_C = true) {
897 897
         static $cached_results = array();
898
-        if(!empty($cached_results[$name]))
898
+        if (!empty($cached_results[$name]))
899 899
         {
900 900
             return $cached_results[$name];
901 901
         }
902 902
         $exclusions = array('parent_type', 'parent_id', 'currency_id', 'parent_name');
903 903
         // Remove any non-db friendly characters
904
-        $return_value = preg_replace("/[^\w]+/","_",$name);
905
-        if($_C == true && !in_array($return_value, $exclusions) && substr($return_value, -2) != '_c'){
904
+        $return_value = preg_replace("/[^\w]+/", "_", $name);
905
+        if ($_C == true && !in_array($return_value, $exclusions) && substr($return_value, -2) != '_c') {
906 906
             $return_value .= '_c';
907 907
         }
908 908
         $cached_results[$name] = $return_value;
909 909
         return $return_value;
910 910
     }
911 911
 
912
-    function setWhereClauses(&$where_clauses){
912
+    function setWhereClauses(&$where_clauses) {
913 913
         if (isset($this->avail_fields)) {
914
-            foreach($this->avail_fields as $name=>$value){
915
-                if(!empty($_REQUEST[$name])){
916
-                    $where_clauses[] = $this->bean->table_name . "_cstm.$name LIKE '". $GLOBALS['db']->quote($_REQUEST[$name]). "%'";
914
+            foreach ($this->avail_fields as $name=>$value) {
915
+                if (!empty($_REQUEST[$name])) {
916
+                    $where_clauses[] = $this->bean->table_name."_cstm.$name LIKE '".$GLOBALS['db']->quote($_REQUEST[$name])."%'";
917 917
                 }
918 918
             }
919 919
         }
@@ -933,12 +933,12 @@  discard block
 block discarded – undo
933 933
 
934 934
     function retrieve()
935 935
     {
936
-        if(!isset($this->bean)){
936
+        if (!isset($this->bean)) {
937 937
             $GLOBALS['log']->fatal("DynamicField retrieve, bean not instantiated: ".var_export(debug_print_backtrace(), true));
938 938
             return false;
939 939
         }
940 940
 
941
-        if(!$this->bean->hasCustomFields()){
941
+        if (!$this->bean->hasCustomFields()) {
942 942
             return false;
943 943
         }
944 944
 
@@ -946,9 +946,9 @@  discard block
 block discarded – undo
946 946
         $result = $GLOBALS['db']->query($query);
947 947
         $row = $GLOBALS['db']->fetchByAssoc($result);
948 948
 
949
-        if($row)
949
+        if ($row)
950 950
         {
951
-            foreach($row as $name=>$value)
951
+            foreach ($row as $name=>$value)
952 952
             {
953 953
                 // originally in pre-r30895 we checked if this field was in avail_fields i.e., in fields_meta_data and not deleted
954 954
                 // with the removal of avail_fields post-r30895 we have simplified this - we now retrieve every custom field even if previously deleted
@@ -961,12 +961,12 @@  discard block
 block discarded – undo
961 961
 
962 962
    function populateXTPL($xtpl, $view) {
963 963
 
964
-        if($this->bean->hasCustomFields()){
964
+        if ($this->bean->hasCustomFields()) {
965 965
             $results = $this->getAllFieldsView($view, 'xtpl');
966
-            foreach($results as $name=>$value){
967
-                if(is_array($value['xtpl']))
966
+            foreach ($results as $name=>$value) {
967
+                if (is_array($value['xtpl']))
968 968
                 {
969
-                    foreach($value['xtpl'] as $xName=>$xValue)
969
+                    foreach ($value['xtpl'] as $xName=>$xValue)
970 970
                     {
971 971
                         $xtpl->assign(strtoupper($xName), $xValue);
972 972
                     }
@@ -978,24 +978,24 @@  discard block
 block discarded – undo
978 978
 
979 979
     }
980 980
 
981
-    function populateAllXTPL($xtpl, $view){
981
+    function populateAllXTPL($xtpl, $view) {
982 982
         $this->populateXTPL($xtpl, $view);
983 983
 
984 984
     }
985 985
 
986
-    function getAllFieldsView($view, $type){
986
+    function getAllFieldsView($view, $type) {
987 987
          require_once ('modules/DynamicFields/FieldCases.php');
988 988
          $results = array();
989
-         foreach($this->bean->field_defs as $name=>$data){
990
-            if(empty($data['source']) || $data['source'] != 'custom_fields')
989
+         foreach ($this->bean->field_defs as $name=>$data) {
990
+            if (empty($data['source']) || $data['source'] != 'custom_fields')
991 991
             {
992 992
             	continue;
993 993
             }
994
-            $field = get_widget ( $data ['type'] );
994
+            $field = get_widget($data ['type']);
995 995
             $field->populateFromRow($data);
996 996
             $field->view = $view;
997 997
             $field->bean = $this->bean;
998
-            switch(strtolower($type))
998
+            switch (strtolower($type))
999 999
             {
1000 1000
                 case 'xtpl':
1001 1001
                     $results[$name] = array('xtpl'=>$field->get_xtpl());
Please login to merge, or discard this patch.
Braces   +84 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined ( 'sugarEntry' ) || ! sugarEntry)
2
+if (! defined ( 'sugarEntry' ) || ! sugarEntry) {
3 3
     die ( 'Not A Valid Entry Point' ) ;
4
+}
4 5
 
5 6
 /*********************************************************************************
6 7
  * SugarCRM Community Edition is a customer relationship management program developed by
@@ -103,9 +104,12 @@  discard block
 block discarded – undo
103 104
     */
104 105
     function buildCache($module = false, $saveCache=true) {
105 106
         //We can't build the cache while installing as the required database tables may not exist.
106
-        if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db']))
107
+        if (!empty($GLOBALS['installing']) && $GLOBALS['installing'] == true|| empty($GLOBALS['db'])) {
108
+                    return false;
109
+        }
110
+        if($module == '../data') {
107 111
             return false;
108
-        if($module == '../data')return false;
112
+        }
109 113
 
110 114
         static $results = array ( ) ;
111 115
 
@@ -113,8 +117,7 @@  discard block
 block discarded – undo
113 117
         if (! empty ( $module )) {
114 118
             $where .= " custom_module='$module' AND ";
115 119
             unset( $results[ $module ] ) ; // clear out any old results for the module as $results is declared static
116
-        }
117
-        else
120
+        } else
118 121
         {
119 122
             $results = array ( ) ; // clear out results - if we remove a module we don't want to have its old vardefs hanging around
120 123
         }
@@ -138,10 +141,12 @@  discard block
 block discarded – undo
138 141
             $vardef = $field->get_field_def ();
139 142
             $vardef ['id'] = $row ['id'];
140 143
             $vardef ['custom_module'] = $row ['custom_module'];
141
-            if (empty ( $vardef ['source'] ))
142
-                $vardef ['source'] = 'custom_fields';
143
-            if (empty ( $results [$row ['custom_module']] ))
144
-                $results [$row ['custom_module']] = array ( );
144
+            if (empty ( $vardef ['source'] )) {
145
+                            $vardef ['source'] = 'custom_fields';
146
+            }
147
+            if (empty ( $results [$row ['custom_module']] )) {
148
+                            $results [$row ['custom_module']] = array ( );
149
+            }
145 150
             $results [$row ['custom_module']] [$row ['name']] = $vardef;
146 151
         }
147 152
         if (empty ( $module )) {
@@ -151,7 +156,7 @@  discard block
 block discarded – undo
151 156
         } else {
152 157
             if (! empty ( $results [$module] )) {
153 158
                 $this->saveToVardef ( $module, $results [$module], $saveCache);
154
-            }else{
159
+            } else{
155 160
                 $this->saveToVardef ( $module, false, $saveCache);
156 161
             }
157 162
         }
@@ -196,7 +201,9 @@  discard block
 block discarded – undo
196 201
                 //if the vardef isn't loaded let's try loading it.
197 202
                 VardefManager::refreshVardefs($module,$object, null, false);
198 203
                 //if it's still not loaded we really don't have anything useful to cache
199
-                if(empty($GLOBALS['dictionary'][$object]['fields']))return;
204
+                if(empty($GLOBALS['dictionary'][$object]['fields'])) {
205
+                    return;
206
+                }
200 207
             }
201 208
             if (!isset($GLOBALS['dictionary'][$object]['custom_fields'])) {
202 209
                 $GLOBALS['dictionary'][$object]['custom_fields'] = false;
@@ -266,8 +273,7 @@  discard block
 block discarded – undo
266 273
         if (empty($expandedList) )
267 274
         {
268 275
             $select = ",{$this->bean->table_name}_cstm.*" ;
269
-        }
270
-        else
276
+        } else
271 277
         {
272 278
             $select = '';
273 279
             $isList = is_array($expandedList);
@@ -276,8 +282,9 @@  discard block
 block discarded – undo
276 282
                 if (!empty($field['source']) && $field['source'] == 'custom_fields' && (!$isList || !empty($expandedList[$name]))){
277 283
                     // assumption: that the column name in _cstm is the same as the field name. Currently true.
278 284
                     // however, two types of dynamic fields do not have columns in the custom table - html fields (they're readonly) and flex relates (parent_name doesn't exist)
279
-                    if ( $field['type'] != 'html' && $name != 'parent_name')
280
-                        $select .= ",{$this->bean->table_name}_cstm.{$name}" ;
285
+                    if ( $field['type'] != 'html' && $name != 'parent_name') {
286
+                                            $select .= ",{$this->bean->table_name}_cstm.{$name}" ;
287
+                    }
281 288
                 }
282 289
             }
283 290
         }
@@ -332,8 +339,7 @@  discard block
 block discarded – undo
332 339
             else if(!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == "non-db" && !empty($field_def['rname']))
333 340
             {
334 341
                 $name_field = "$joinTableAlias." . $field_def['rname'];
335
-            }
336
-            else
342
+            } else
337 343
             {
338 344
                 $name_field = "$joinTableAlias.name";
339 345
             }
@@ -355,12 +361,16 @@  discard block
 block discarded – undo
355 361
    function fill_relationships(){
356 362
         global $beanList, $beanFiles;
357 363
         if(!empty($this->bean->relDepth)) {
358
-            if($this->bean->relDepth > 1)return;
359
-        }else{
364
+            if($this->bean->relDepth > 1) {
365
+                return;
366
+            }
367
+        } else{
360 368
             $this->bean->relDepth = 0;
361 369
         }
362 370
         foreach($this->bean->field_defs as $field){
363
-            if(empty($field['source']) || $field['source'] != 'custom_fields')continue;
371
+            if(empty($field['source']) || $field['source'] != 'custom_fields') {
372
+                continue;
373
+            }
364 374
             if($field['type'] == 'relate'){
365 375
                 $related_module =$field['ext2'];
366 376
                 $name = $field['name'];
@@ -399,8 +409,12 @@  discard block
 block discarded – undo
399 409
             $first = true;
400 410
             foreach($this->bean->field_defs as $name=>$field){
401 411
 
402
-                if(empty($field['source']) || $field['source'] != 'custom_fields')continue;
403
-                if($field['type'] == 'html' || $field['type'] == 'parent')continue;
412
+                if(empty($field['source']) || $field['source'] != 'custom_fields') {
413
+                    continue;
414
+                }
415
+                if($field['type'] == 'html' || $field['type'] == 'parent') {
416
+                    continue;
417
+                }
404 418
                 if(isset($this->bean->$name)){
405 419
                     $quote = "'";
406 420
 
@@ -409,16 +423,17 @@  discard block
 block discarded – undo
409 423
                         if(!isset($this->bean->$name) || !is_numeric($this->bean->$name) ){
410 424
                             if($field['required']){
411 425
                                 $this->bean->$name = 0;
412
-                            }else{
426
+                            } else{
413 427
                                 $this->bean->$name = 'NULL';
414 428
                             }
415 429
                         }
416 430
                     }
417 431
                     if ( $field['type'] == 'bool' ) {
418
-                        if ( $this->bean->$name === FALSE )
419
-                            $this->bean->$name = '0';
420
-                        elseif ( $this->bean->$name === TRUE )
421
-                            $this->bean->$name = '1';
432
+                        if ( $this->bean->$name === FALSE ) {
433
+                                                    $this->bean->$name = '0';
434
+                        } elseif ( $this->bean->$name === TRUE ) {
435
+                                                    $this->bean->$name = '1';
436
+                        }
422 437
                     }
423 438
 
424 439
                     $val = $this->bean->$name;
@@ -431,7 +446,7 @@  discard block
 block discarded – undo
431 446
                         if($first){
432 447
                             $query .= " $name=$quote".$GLOBALS['db']->quote($val)."$quote";
433 448
 
434
-                        }else{
449
+                        } else{
435 450
                             $query .= " ,$name=$quote".$GLOBALS['db']->quote($val)."$quote";
436 451
                         }
437 452
                     }
@@ -450,7 +465,7 @@  discard block
 block discarded – undo
450 465
             if(!$first){
451 466
                 if(!$isUpdate){
452 467
                     $GLOBALS['db']->query($queryInsert);
453
-                }else{
468
+                } else{
454 469
                     $checkquery = "SELECT id_c FROM {$this->bean->table_name}_cstm WHERE id_c = '{$this->bean->id}'";
455 470
                     if ( $GLOBALS['db']->getOne($checkquery) ) {
456 471
                         $result = $GLOBALS['db']->query($query);
@@ -485,8 +500,9 @@  discard block
 block discarded – undo
485 500
 
486 501
         $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='" . $this->module . $widget->name . "'");
487 502
         $sql = $widget->get_db_delete_alter_table( $this->bean->table_name . "_cstm" ) ;
488
-        if (! empty( $sql ) )
489
-            $GLOBALS['db']->query( $sql );
503
+        if (! empty( $sql ) ) {
504
+                    $GLOBALS['db']->query( $sql );
505
+        }
490 506
 
491 507
         $this->removeVardefExtension($widget);
492 508
         VardefManager::clearVardef();
@@ -504,19 +520,21 @@  discard block
 block discarded – undo
504 520
         $name = $this->getDBName($name);
505 521
         $vardefs = $GLOBALS['dictionary'][$this->bean->object_name]['fields'];
506 522
         if(!empty($vardefs)){
507
-            if(empty($type) && empty($name))
508
-                return false;
509
-            else if(empty($type))
510
-                return !empty($vardefs[$name]);
511
-            else if(empty($name)){
523
+            if(empty($type) && empty($name)) {
524
+                            return false;
525
+            } else if(empty($type)) {
526
+                            return !empty($vardefs[$name]);
527
+            } else if(empty($name)){
512 528
                 foreach($vardefs as $def){
513
-                    if(!empty($def['type']) && $def['type'] == $type)
514
-                        return true;
529
+                    if(!empty($def['type']) && $def['type'] == $type) {
530
+                                            return true;
531
+                    }
515 532
                 }
516 533
                 return false;
517
-            }else
518
-                return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type));
519
-        }else{
534
+            } else {
535
+                            return (!empty($vardefs[$name]) && ($vardefs[$name]['type'] == $type));
536
+            }
537
+        } else{
520 538
             return false;
521 539
         }
522 540
     }
@@ -539,7 +557,7 @@  discard block
 block discarded – undo
539 557
         $label = strtoupper( $field->label );
540 558
         if(!empty($id)){
541 559
             $is_update = true;
542
-        }else{
560
+        } else{
543 561
             $db_name = $this->getDBName($field->name);
544 562
             $field->name = $db_name;
545 563
         }
@@ -550,8 +568,10 @@  discard block
 block discarded – undo
550 568
         $fmd->vname = $label;
551 569
         $fmd->type = $field->type;
552 570
         $fmd->help = $field->help;
553
-        if (!empty($field->len))
554
-            $fmd->len = $field->len; // tyoung bug 15407 - was being set to $field->size so changes weren't being saved
571
+        if (!empty($field->len)) {
572
+                    $fmd->len = $field->len;
573
+        }
574
+        // tyoung bug 15407 - was being set to $field->size so changes weren't being saved
555 575
         $fmd->required = ($field->required ? 1 : 0);
556 576
         $fmd->default_value = $field->default;
557 577
         $fmd->ext1 = $field->ext1;
@@ -591,7 +611,7 @@  discard block
 block discarded – undo
591 611
 	                	$GLOBALS['db']->query($query, true, "Cannot set default");
592 612
 	            	}
593 613
                 }
594
-            }else{
614
+            } else{
595 615
                 $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
596 616
                 if(!empty($query)){
597 617
                 	$GLOBALS['db']->query($query, true, "Cannot modify field");
@@ -671,16 +691,16 @@  discard block
 block discarded – undo
671 691
 
672 692
         $out .= "\n ?>";
673 693
 
674
-        if (!file_exists($this->base_path))
675
-            mkdir_recursive($this->base_path);
694
+        if (!file_exists($this->base_path)) {
695
+                    mkdir_recursive($this->base_path);
696
+        }
676 697
 
677 698
         if( $fh = @sugar_fopen( $file_loc, 'w' ) )
678 699
         {
679 700
             fputs( $fh, $out);
680 701
             fclose( $fh );
681 702
             return true ;
682
-        }
683
-        else
703
+        } else
684 704
         {
685 705
             return false ;
686 706
         }
@@ -801,8 +821,9 @@  discard block
 block discarded – undo
801 821
     	$out = "";
802 822
         if($this->bean->hasCustomFields()){
803 823
 	        foreach($this->bean->field_defs as $name=>$data){
804
-	        	if(empty($data['source']) || $data['source'] != 'custom_fields')
805
-                    continue;
824
+	        	if(empty($data['source']) || $data['source'] != 'custom_fields') {
825
+	        	                    continue;
826
+	        	}
806 827
 	            $out .= $this->add_existing_custom_field($data, $execute);
807 828
 	        }
808 829
     	}
@@ -817,8 +838,9 @@  discard block
 block discarded – undo
817 838
         $query = "/*MISSING IN DATABASE - {$data['name']} -  ROW*/\n"
818 839
                 . $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
819 840
         $out = $query . "\n";
820
-        if ($execute)
821
-            $GLOBALS['db']->query($query);
841
+        if ($execute) {
842
+                    $GLOBALS['db']->query($query);
843
+        }
822 844
 
823 845
         return $out;
824 846
     }
@@ -827,16 +849,18 @@  discard block
 block discarded – undo
827 849
     {
828 850
         $out = $this->createCustomTable($execute);
829 851
         //If the table didn't exist, createCustomTable will have returned all the SQL to create and populate it
830
-        if (!empty($out))
831
-            return "/*Checking Custom Fields for module : {$this->module} */\n$out";
852
+        if (!empty($out)) {
853
+                    return "/*Checking Custom Fields for module : {$this->module} */\n$out";
854
+        }
832 855
         //Otherwise make sure all the custom fields defined in the vardefs exist in the custom table.
833 856
         //We aren't checking for data types, just that the column exists.
834 857
         $db = $GLOBALS['db'];
835 858
         $tablename = $this->bean->table_name."_cstm";
836 859
         $compareFieldDefs = $db->get_columns($tablename);
837 860
         foreach($this->bean->field_defs as $name=>$data){
838
-            if(empty($data['source']) || $data['source'] != 'custom_fields')
839
-                continue;
861
+            if(empty($data['source']) || $data['source'] != 'custom_fields') {
862
+                            continue;
863
+            }
840 864
             /**
841 865
              * @bug 43471
842 866
              * @issue 43471
@@ -850,8 +874,9 @@  discard block
 block discarded – undo
850 874
             }
851 875
             $out .= $this->add_existing_custom_field($data, $execute);
852 876
         }
853
-        if (!empty($out))
854
-            $out = "/*Checking Custom Fields for module : {$this->module} */\n$out";
877
+        if (!empty($out)) {
878
+                    $out = "/*Checking Custom Fields for module : {$this->module} */\n$out";
879
+        }
855 880
 
856 881
         return $out;
857 882
     }
Please login to merge, or discard this patch.
Doc Comments   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     *
100 100
     * @param STRING $module
101 101
     * @param boolean saveCache Boolean value indicating whether or not to pass saveCache value to saveToVardef, defaults to true
102
-    * @return unknown
102
+    * @return boolean
103 103
     */
104 104
     function buildCache($module = false, $saveCache=true) {
105 105
         //We can't build the cache while installing as the required database tables may not exist.
@@ -308,6 +308,9 @@  discard block
 block discarded – undo
308 308
 
309 309
     }
310 310
 
311
+   /**
312
+    * @param string $joinTableAlias
313
+    */
311 314
    function getRelateJoin($field_def, $joinTableAlias, $withIdName = true) {
312 315
         if (empty($field_def['type']) || $field_def['type'] != "relate") {
313 316
             return false;
@@ -465,7 +468,6 @@  discard block
 block discarded – undo
465 468
     /**
466 469
      * Deletes the field from fields_meta_data and drops the database column then it rebuilds the cache
467 470
      * Use the widgets get_db_modify_alter_table() method to get the table sql - some widgets do not need any custom table modifications
468
-     * @param STRING $name - field name
469 471
      */
470 472
     function deleteField($widget){
471 473
         require_once('modules/DynamicFields/templates/Fields/TemplateField.php');
@@ -525,7 +527,7 @@  discard block
 block discarded – undo
525 527
     /**
526 528
      * Adds a custom field using a field object
527 529
      *
528
-     * @param Field Object $field
530
+     * @param Field TemplateField $field
529 531
      * @return boolean
530 532
      */
531 533
     function addFieldObject(&$field){
@@ -605,6 +607,9 @@  discard block
 block discarded – undo
605 607
         return true;
606 608
     }
607 609
 
610
+    /**
611
+     * @param string[] $column_fields
612
+     */
608 613
     function saveExtendedAttributes($field, $column_fields)
609 614
     {
610 615
             require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
@@ -686,6 +691,9 @@  discard block
 block discarded – undo
686 691
         }
687 692
     }
688 693
 
694
+    /**
695
+     * @param TemplateField $field
696
+     */
689 697
     protected function removeVardefExtension($field)
690 698
     {
691 699
         $file_loc = "$this->base_path/sugarfield_{$field->name}.php";
@@ -710,12 +718,12 @@  discard block
 block discarded – undo
710 718
      * @param unknown_type $ext1
711 719
      * @param unknown_type $ext2
712 720
      * @param unknown_type $ext3
713
-     * @param unknown_type $audited
714
-     * @param unknown_type $inline_edit
715
-     * @param unknown_type $mass_update
721
+     * @param integer $audited
722
+     * @param integer $inline_edit
723
+     * @param integer $mass_update
716 724
      * @param unknown_type $ext4
717 725
      * @param unknown_type $help
718
-     * @param unknown_type $duplicate_merge
726
+     * @param integer $duplicate_merge
719 727
      * @param unknown_type $comment
720 728
      * @return boolean
721 729
      */
@@ -983,6 +991,9 @@  discard block
 block discarded – undo
983 991
 
984 992
     }
985 993
 
994
+    /**
995
+     * @param string $type
996
+     */
986 997
     function getAllFieldsView($view, $type){
987 998
          require_once ('modules/DynamicFields/FieldCases.php');
988 999
          $results = array();
Please login to merge, or discard this patch.
modules/DynamicFields/FieldsMetaData.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	var $inline_edit;
69 69
     var $duplicate_merge;
70 70
     var $reportable;
71
-	var $required_fields =  array("name"=>1, "date_start"=>2, "time_start"=>3,);
71
+	var $required_fields = array("name"=>1, "date_start"=>2, "time_start"=>3,);
72 72
 
73 73
 	var $table_name = 'fields_meta_data';
74 74
 	var $object_name = 'FieldsMetaData';
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 	function mark_deleted($id)
125 125
 	{
126 126
 		$query = "DELETE FROM $this->table_name WHERE  id='$id'";
127
-		$this->db->query($query, true,"Error deleting record: ");
127
+		$this->db->query($query, true, "Error deleting record: ");
128 128
 		$this->mark_relationships_deleted($id);
129 129
 
130 130
 	}
131 131
 	
132
-	function get_list_view_data(){
132
+	function get_list_view_data() {
133 133
 	    $data = parent::get_list_view_data();
134 134
 	    $data['VNAME'] = translate($this->vname, $this->custom_module);
135
-	    $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '">&nbsp;&nbsp;<a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >';
135
+	    $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="'.$this->id.'">&nbsp;&nbsp;<a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record='.$this->id.'" >';
136 136
 	    return $data;
137 137
 	}
138 138
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -51,95 +51,95 @@
 block discarded – undo
51 51
 
52 52
 
53 53
 class FieldsMetaData extends SugarBean {
54
-	// database table columns
55
-	var $id;
56
-	var $name;
57
-	var $vname;
58
-  	var $custom_module;
59
-  	var $type;
60
-  	var $len;
61
-  	var $required;
62
-  	var $default_value;
63
-  	var $deleted;
64
-  	var $ext1;
65
-  	var $ext2;
66
-  	var $ext3;
67
-	var $audited;
68
-	var $inline_edit;
54
+    // database table columns
55
+    var $id;
56
+    var $name;
57
+    var $vname;
58
+        var $custom_module;
59
+        var $type;
60
+        var $len;
61
+        var $required;
62
+        var $default_value;
63
+        var $deleted;
64
+        var $ext1;
65
+        var $ext2;
66
+        var $ext3;
67
+    var $audited;
68
+    var $inline_edit;
69 69
     var $duplicate_merge;
70 70
     var $reportable;
71
-	var $required_fields =  array("name"=>1, "date_start"=>2, "time_start"=>3,);
72
-
73
-	var $table_name = 'fields_meta_data';
74
-	var $object_name = 'FieldsMetaData';
75
-	var $module_dir = 'DynamicFields';
76
-	var $column_fields = array(
77
-		'id',
78
-		'name',
79
-		'vname',
80
-		'custom_module',
81
-		'type',
82
-		'len',
83
-		'required',
84
-		'default_value',
85
-		'deleted',
86
-		'ext1',
87
-		'ext2',
88
-		'ext3',
89
-		'audited',
90
-		'inline_edit',
91
-		'massupdate',
71
+    var $required_fields =  array("name"=>1, "date_start"=>2, "time_start"=>3,);
72
+
73
+    var $table_name = 'fields_meta_data';
74
+    var $object_name = 'FieldsMetaData';
75
+    var $module_dir = 'DynamicFields';
76
+    var $column_fields = array(
77
+        'id',
78
+        'name',
79
+        'vname',
80
+        'custom_module',
81
+        'type',
82
+        'len',
83
+        'required',
84
+        'default_value',
85
+        'deleted',
86
+        'ext1',
87
+        'ext2',
88
+        'ext3',
89
+        'audited',
90
+        'inline_edit',
91
+        'massupdate',
92 92
         'duplicate_merge',
93 93
         'reportable',
94
-	);
95
-
96
-	var $list_fields = array(
97
-		'id',
98
-		'name',
99
-		'vname',
100
-		'type',
101
-		'len',
102
-		'required',
103
-		'default_value',
104
-		'audited',
94
+    );
95
+
96
+    var $list_fields = array(
97
+        'id',
98
+        'name',
99
+        'vname',
100
+        'type',
101
+        'len',
102
+        'required',
103
+        'default_value',
104
+        'audited',
105 105
         'inline_edit',
106
-		'massupdate',
106
+        'massupdate',
107 107
         'duplicate_merge',
108 108
         'reportable',
109
-	);
109
+    );
110 110
 
111
-	var $field_name_map;
112
-	var $new_schema = true;
111
+    var $field_name_map;
112
+    var $new_schema = true;
113 113
 
114
-	//////////////////////////////////////////////////////////////////
115
-	// METHODS
116
-	//////////////////////////////////////////////////////////////////
114
+    //////////////////////////////////////////////////////////////////
115
+    // METHODS
116
+    //////////////////////////////////////////////////////////////////
117 117
 
118 118
     public function __construct()
119
-	{
120
-		parent::__construct();
121
-		$this->disable_row_level_security = true;
122
-	}
123
-
124
-	function mark_deleted($id)
125
-	{
126
-		$query = "DELETE FROM $this->table_name WHERE  id='$id'";
127
-		$this->db->query($query, true,"Error deleting record: ");
128
-		$this->mark_relationships_deleted($id);
129
-
130
-	}
131
-
132
-	function get_list_view_data(){
133
-	    $data = parent::get_list_view_data();
134
-	    $data['VNAME'] = translate($this->vname, $this->custom_module);
135
-	    $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '">&nbsp;&nbsp;<a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >';
136
-	    return $data;
137
-	}
138
-
139
-
140
-	function get_summary_text()
141
-	{
142
-		return $this->name;
143
-	}
119
+    {
120
+        parent::__construct();
121
+        $this->disable_row_level_security = true;
122
+    }
123
+
124
+    function mark_deleted($id)
125
+    {
126
+        $query = "DELETE FROM $this->table_name WHERE  id='$id'";
127
+        $this->db->query($query, true,"Error deleting record: ");
128
+        $this->mark_relationships_deleted($id);
129
+
130
+    }
131
+
132
+    function get_list_view_data(){
133
+        $data = parent::get_list_view_data();
134
+        $data['VNAME'] = translate($this->vname, $this->custom_module);
135
+        $data['NAMELINK'] = '<input class="checkbox" type="checkbox" name="remove[]" value="' . $this->id . '">&nbsp;&nbsp;<a href="index.php?module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=EditCustomField&record=' . $this->id . '" >';
136
+        return $data;
137
+    }
138
+
139
+
140
+    function get_summary_text()
141
+    {
142
+        return $this->name;
143
+    }
144 144
 }
145 145
 ?>
Please login to merge, or discard this patch.
modules/DynamicFields/UpgradeFields.php 3 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -40,95 +40,95 @@  discard block
 block discarded – undo
40 40
 
41 41
 require_once('modules/DynamicFields/FieldCases.php');
42 42
 require_once('modules/DynamicFields/DynamicField.php');
43
- global $db;
44
- if(!isset($db)){
45
- 	$db = DBManagerFactory::getInstance();
46
- }
47
- $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module');
48
- $modules = array();
49
- /*
43
+    global $db;
44
+    if(!isset($db)){
45
+        $db = DBManagerFactory::getInstance();
46
+    }
47
+    $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module');
48
+    $modules = array();
49
+    /*
50 50
   * get the real field_meta_data
51 51
   */
52
- while($row = $db->fetchByAssoc($result)){
53
- 	$the_modules = $row['custom_module'];
54
- 	if(!isset($modules[$the_modules])){
55
- 		$modules[$the_modules] = array();	
56
- 	}
57
- 	$modules[$the_modules][$row['name']] = $row['name'];
58
- }
52
+    while($row = $db->fetchByAssoc($result)){
53
+        $the_modules = $row['custom_module'];
54
+        if(!isset($modules[$the_modules])){
55
+            $modules[$the_modules] = array();	
56
+        }
57
+        $modules[$the_modules][$row['name']] = $row['name'];
58
+    }
59 59
  	
60
- $simulate = false;
61
- if(!isset($_REQUEST['run'])){
62
- 	$simulate = true;
63
- 	echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE";
64
- }	
60
+    $simulate = false;
61
+    if(!isset($_REQUEST['run'])){
62
+        $simulate = true;
63
+        echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE";
64
+    }	
65 65
 
66
- foreach($modules as $the_module=>$fields){
67
-         if(isset($beanList[$the_module]))
68
-         {
69
- 	$class_name = $beanList[$the_module];
70
- 	echo "<br><br>Scanning $the_module <br>";
66
+    foreach($modules as $the_module=>$fields){
67
+            if(isset($beanList[$the_module]))
68
+            {
69
+        $class_name = $beanList[$the_module];
70
+        echo "<br><br>Scanning $the_module <br>";
71 71
 		
72
-		require_once($beanFiles[$class_name]);
73
-		$mod = new $class_name();
74
-		if(!$db->tableExists($mod->table_name . "_cstm")){
75
-			$mod->custom_fields = new DynamicField();
76
-			$mod->custom_fields->setup($mod);
77
-		$mod->custom_fields->createCustomTable();
78
-		}
72
+        require_once($beanFiles[$class_name]);
73
+        $mod = new $class_name();
74
+        if(!$db->tableExists($mod->table_name . "_cstm")){
75
+            $mod->custom_fields = new DynamicField();
76
+            $mod->custom_fields->setup($mod);
77
+        $mod->custom_fields->createCustomTable();
78
+        }
79 79
 
80
-		$result = $db->query("DESCRIBE $mod->table_name" . "_cstm");
80
+        $result = $db->query("DESCRIBE $mod->table_name" . "_cstm");
81 81
 		
82
-		while($row = $db->fetchByAssoc($result)){
82
+        while($row = $db->fetchByAssoc($result)){
83 83
 			
84 84
 			
85
-			$col = $row['Field'];
86
-			$type = $row['Type'];
87
-			$fieldDef = $mod->getFieldDefinition($col);
88
-			$the_field = get_widget($fieldDef['type']);
89
-			$the_field->set($fieldDef);
85
+            $col = $row['Field'];
86
+            $type = $row['Type'];
87
+            $fieldDef = $mod->getFieldDefinition($col);
88
+            $the_field = get_widget($fieldDef['type']);
89
+            $the_field->set($fieldDef);
90 90
 				
91
-				if(!isset($fields[$col]) && $col != 'id_c'){
92
-					if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col");
93
-					unset($fields[$col]);
94
-					echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>";
95
-				}	else{
96
-					if($col != 'id_c'){
97
-					if(trim($the_field->get_db_type()) != trim($type)){
91
+                if(!isset($fields[$col]) && $col != 'id_c'){
92
+                    if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col");
93
+                    unset($fields[$col]);
94
+                    echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>";
95
+                }	else{
96
+                    if($col != 'id_c'){
97
+                    if(trim($the_field->get_db_type()) != trim($type)){
98 98
 						
99
-					echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>";
100
-					if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));		
101
-					}
102
-					}
99
+                    echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>";
100
+                    if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));		
101
+                    }
102
+                    }
103 103
 					
104
-					unset($fields[$col]);
105
-				}
104
+                    unset($fields[$col]);
105
+                }
106 106
 			
107
-		}
107
+        }
108 108
 			
109
-			echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>";
110
-			foreach($fields as $field){
111
-				echo "Adding Column $field to $mod->table_name" . "_cstm<br>";
112
-				if(!$simulate){
113
-					$the_field = $mod->getFieldDefinition($field);
114
-					$field = get_widget($the_field['type']);
115
-					$field->set($the_field);
116
-					$query = $field->get_db_add_alter_table($mod->table_name . '_cstm');
117
-					echo $query;
118
-            		if(!empty($query)){
119
-                		$mod->db->query($query);
120
-            		}
121
-				}
122
-			}
123
-         }
124
-	}
109
+            echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>";
110
+            foreach($fields as $field){
111
+                echo "Adding Column $field to $mod->table_name" . "_cstm<br>";
112
+                if(!$simulate){
113
+                    $the_field = $mod->getFieldDefinition($field);
114
+                    $field = get_widget($the_field['type']);
115
+                    $field->set($the_field);
116
+                    $query = $field->get_db_add_alter_table($mod->table_name . '_cstm');
117
+                    echo $query;
118
+                    if(!empty($query)){
119
+                        $mod->db->query($query);
120
+                    }
121
+                }
122
+            }
123
+            }
124
+    }
125 125
 	
126 126
 	
127
-	DynamicField::deleteCache();	
128
-	echo '<br>Done<br>';
129
-	if($simulate){
130
-		echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';	
131
-	}
127
+    DynamicField::deleteCache();	
128
+    echo '<br>Done<br>';
129
+    if($simulate){
130
+        echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';	
131
+    }
132 132
 		
133 133
 		
134 134
  
@@ -137,4 +137,4 @@  discard block
 block discarded – undo
137 137
  
138 138
  
139 139
  
140
- ?>
141 140
\ No newline at end of file
141
+    ?>
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
2
+if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
3 3
 /*********************************************************************************
4 4
  * SugarCRM Community Edition is a customer relationship management program developed by
5 5
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -41,45 +41,45 @@  discard block
 block discarded – undo
41 41
 require_once('modules/DynamicFields/FieldCases.php');
42 42
 require_once('modules/DynamicFields/DynamicField.php');
43 43
  global $db;
44
- if(!isset($db)){
44
+ if (!isset($db)) {
45 45
  	$db = DBManagerFactory::getInstance();
46 46
  }
47
- $result = $db->query( 'SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module');
47
+ $result = $db->query('SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module');
48 48
  $modules = array();
49 49
  /*
50 50
   * get the real field_meta_data
51 51
   */
52
- while($row = $db->fetchByAssoc($result)){
52
+ while ($row = $db->fetchByAssoc($result)) {
53 53
  	$the_modules = $row['custom_module'];
54
- 	if(!isset($modules[$the_modules])){
54
+ 	if (!isset($modules[$the_modules])) {
55 55
  		$modules[$the_modules] = array();	
56 56
  	}
57 57
  	$modules[$the_modules][$row['name']] = $row['name'];
58 58
  }
59 59
  	
60 60
  $simulate = false;
61
- if(!isset($_REQUEST['run'])){
61
+ if (!isset($_REQUEST['run'])) {
62 62
  	$simulate = true;
63 63
  	echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE";
64 64
  }	
65 65
 
66
- foreach($modules as $the_module=>$fields){
67
-         if(isset($beanList[$the_module]))
66
+ foreach ($modules as $the_module=>$fields) {
67
+         if (isset($beanList[$the_module]))
68 68
          {
69 69
  	$class_name = $beanList[$the_module];
70 70
  	echo "<br><br>Scanning $the_module <br>";
71 71
 		
72 72
 		require_once($beanFiles[$class_name]);
73 73
 		$mod = new $class_name();
74
-		if(!$db->tableExists($mod->table_name . "_cstm")){
74
+		if (!$db->tableExists($mod->table_name."_cstm")) {
75 75
 			$mod->custom_fields = new DynamicField();
76 76
 			$mod->custom_fields->setup($mod);
77 77
 		$mod->custom_fields->createCustomTable();
78 78
 		}
79 79
 
80
-		$result = $db->query("DESCRIBE $mod->table_name" . "_cstm");
80
+		$result = $db->query("DESCRIBE $mod->table_name"."_cstm");
81 81
 		
82
-		while($row = $db->fetchByAssoc($result)){
82
+		while ($row = $db->fetchByAssoc($result)) {
83 83
 			
84 84
 			
85 85
 			$col = $row['Field'];
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 			$the_field = get_widget($fieldDef['type']);
89 89
 			$the_field->set($fieldDef);
90 90
 				
91
-				if(!isset($fields[$col]) && $col != 'id_c'){
92
-					if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col");
91
+				if (!isset($fields[$col]) && $col != 'id_c') {
92
+					if (!$simulate)$db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col");
93 93
 					unset($fields[$col]);
94
-					echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>";
95
-				}	else{
96
-					if($col != 'id_c'){
97
-					if(trim($the_field->get_db_type()) != trim($type)){
94
+					echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>";
95
+				} else {
96
+					if ($col != 'id_c') {
97
+					if (trim($the_field->get_db_type()) != trim($type)) {
98 98
 						
99
-					echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>";
100
-					if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));		
99
+					echo "Fixing Column Type for $col changing $type to ".$the_field->get_db_type()."<br>";
100
+					if (!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm'));		
101 101
 					}
102 102
 					}
103 103
 					
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 			
107 107
 		}
108 108
 			
109
-			echo sizeof($fields) . " field(s) missing from $mod->table_name" . "_cstm<br>";
110
-			foreach($fields as $field){
111
-				echo "Adding Column $field to $mod->table_name" . "_cstm<br>";
112
-				if(!$simulate){
109
+			echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>";
110
+			foreach ($fields as $field) {
111
+				echo "Adding Column $field to $mod->table_name"."_cstm<br>";
112
+				if (!$simulate) {
113 113
 					$the_field = $mod->getFieldDefinition($field);
114 114
 					$field = get_widget($the_field['type']);
115 115
 					$field->set($the_field);
116
-					$query = $field->get_db_add_alter_table($mod->table_name . '_cstm');
116
+					$query = $field->get_db_add_alter_table($mod->table_name.'_cstm');
117 117
 					echo $query;
118
-            		if(!empty($query)){
118
+            		if (!empty($query)) {
119 119
                 		$mod->db->query($query);
120 120
             		}
121 121
 				}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	
127 127
 	DynamicField::deleteCache();	
128 128
 	echo '<br>Done<br>';
129
-	if($simulate){
129
+	if ($simulate) {
130 130
 		echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';	
131 131
 	}
132 132
 		
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
2
+if(!defined('sugarEntry') || !sugarEntry) {
3
+    die('Not A Valid Entry Point');
4
+}
3 5
 /*********************************************************************************
4 6
  * SugarCRM Community Edition is a customer relationship management program developed by
5 7
  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
@@ -89,15 +91,19 @@  discard block
 block discarded – undo
89 91
 			$the_field->set($fieldDef);
90 92
 				
91 93
 				if(!isset($fields[$col]) && $col != 'id_c'){
92
-					if(!$simulate)$db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col");
94
+					if(!$simulate) {
95
+					    $db->query("ALTER TABLE $mod->table_name" . "_cstm DROP COLUMN $col");
96
+					}
93 97
 					unset($fields[$col]);
94 98
 					echo "Dropping Column $col from $mod->table_name" . "_cstm for module $the_module<br>";
95
-				}	else{
99
+				} else{
96 100
 					if($col != 'id_c'){
97 101
 					if(trim($the_field->get_db_type()) != trim($type)){
98 102
 						
99 103
 					echo "Fixing Column Type for $col changing $type to ". $the_field->get_db_type() . "<br>";
100
-					if(!$simulate)$db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));		
104
+					if(!$simulate) {
105
+					    $db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));
106
+					}
101 107
 					}
102 108
 					}
103 109
 					
Please login to merge, or discard this patch.