Completed
Push — master ( 58f496...a833c2 )
by Adam
18:52
created
include/generic/SugarWidgets/SugarWidgetSubPanelIcon.php 1 patch
Spacing   +27 added lines, -27 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.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		global $app_list_strings;
57 57
 		global $current_user;
58 58
 
59
-		if(isset($layout_def['varname']))
59
+		if (isset($layout_def['varname']))
60 60
 		{
61 61
 			$key = strtoupper($layout_def['varname']);
62 62
 		}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 //add module image
69 69
 		//add module image
70
-		if(!empty($layout_def['target_module_key'])) {
70
+		if (!empty($layout_def['target_module_key'])) {
71 71
 			if (!empty($layout_def['fields'][strtoupper($layout_def['target_module_key'])])) {
72
-				$module=$layout_def['fields'][strtoupper($layout_def['target_module_key'])];
72
+				$module = $layout_def['fields'][strtoupper($layout_def['target_module_key'])];
73 73
 			}
74 74
 		}
75 75
 
76 76
         if (empty($module)) {
77
-			if(empty($layout_def['target_module']))
77
+			if (empty($layout_def['target_module']))
78 78
 			{
79 79
 				$module = $layout_def['module'];
80 80
 			}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			}
85 85
 		}
86 86
 		$action = 'DetailView';
87
-		if(empty($layout_def['target_record_key']))
87
+		if (empty($layout_def['target_record_key']))
88 88
 		{
89 89
 			$record = $layout_def['fields']['ID'];
90 90
 		}
@@ -94,70 +94,70 @@  discard block
 block discarded – undo
94 94
 			$record = $layout_def['fields'][$record_key];
95 95
 		}
96 96
 		$action_access = false;
97
-		if(!empty($record) &&
97
+		if (!empty($record) &&
98 98
 			($layout_def[$action] && !$layout_def['owner_module']
99 99
 			||  $layout_def[$action] && !ACLController::moduleSupportsACL($layout_def['owner_module'])
100 100
 			|| ACLController::checkAccess($layout_def['owner_module'], 'view', $layout_def['owner_id'] == $current_user->id))) {
101 101
 			$action_access = true;
102 102
 		}
103
-		$icon_img_html = SugarThemeRegistry::current()->getImage( $module . '', 'border="0"',null,null,'.gif',$app_list_strings['moduleList'][$module]);
103
+		$icon_img_html = SugarThemeRegistry::current()->getImage($module.'', 'border="0"', null, null, '.gif', $app_list_strings['moduleList'][$module]);
104 104
 		if (!empty($layout_def['attachment_image_only']) && $layout_def['attachment_image_only'] == true) {
105
-			$ret="";
105
+			$ret = "";
106 106
 		} else {
107 107
 			if ($action_access) {
108
-				$ret = '<a href="index.php?module=' . $module . '&action=' . $action . '&record=' . $record	. '" >' . $icon_img_html . "</a>";
108
+				$ret = '<a href="index.php?module='.$module.'&action='.$action.'&record='.$record.'" >'.$icon_img_html."</a>";
109 109
 			} else {
110 110
 				$ret = $icon_img_html;
111 111
 			}
112 112
 		}
113 113
 
114
-		if(!empty($layout_def['image2']) &&  !empty($layout_def['image2_ext_url_field'])){
114
+		if (!empty($layout_def['image2']) && !empty($layout_def['image2_ext_url_field'])) {
115 115
 
116 116
 			if (!empty($layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])])) {
117
-				$link_url  = $layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])];
117
+				$link_url = $layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])];
118 118
 			}
119 119
 
120 120
             $imagePath = '';
121
-            if ( $layout_def['image2'] == '__VARIABLE' ) {
122
-                if ( !empty($layout_def['fields'][$key.'_ICON']) ) {
121
+            if ($layout_def['image2'] == '__VARIABLE') {
122
+                if (!empty($layout_def['fields'][$key.'_ICON'])) {
123 123
                     $imagePath = $layout_def['fields'][$key.'_ICON'];
124 124
                 }
125 125
             } else {
126 126
                 $imagePath = $layout_def['image2'];
127 127
             }
128 128
 
129
-            if ( !empty($imagePath) ) {
130
-                $icon_img_html = SugarThemeRegistry::current()->getImage( $imagePath . '', 'border="0"',null,null,'.gif',$imagePath);
131
-                $ret.= (empty($link_url)) ? '' : '&nbsp;<a href="' . $link_url. '" TARGET = "_blank">' . "$icon_img_html</a>";
129
+            if (!empty($imagePath)) {
130
+                $icon_img_html = SugarThemeRegistry::current()->getImage($imagePath.'', 'border="0"', null, null, '.gif', $imagePath);
131
+                $ret .= (empty($link_url)) ? '' : '&nbsp;<a href="'.$link_url.'" TARGET = "_blank">'."$icon_img_html</a>";
132 132
             }
133 133
         }
134 134
 //if requested, add attachment icon.
135
-		if(!empty($layout_def['image2']) && !empty($layout_def['image2_url_field'])){
135
+		if (!empty($layout_def['image2']) && !empty($layout_def['image2_url_field'])) {
136 136
 
137 137
 			if (is_array($layout_def['image2_url_field'])) {
138 138
 				//Generate file url.
139 139
 				if (!empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])])
140
-				and !empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])]) ) {
140
+				and !empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])])) {
141 141
 
142
-					$key=$layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])];
143
-                    $file=$layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])];
144
-                    $filepath="index.php?entryPoint=download&id=".$key."&type=".$layout_def['module'];
142
+					$key = $layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])];
143
+                    $file = $layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])];
144
+                    $filepath = "index.php?entryPoint=download&id=".$key."&type=".$layout_def['module'];
145 145
 				}
146 146
 			} else {
147 147
 				if (!empty($layout_def['fields'][strtoupper($layout_def['image2_url_field'])])) {
148
-					$filepath="index.php?entryPoint=download&id=".$layout_def['fields']['ID']."&type=".$layout_def['module'];
148
+					$filepath = "index.php?entryPoint=download&id=".$layout_def['fields']['ID']."&type=".$layout_def['module'];
149 149
 				}
150 150
 			}
151
-			$icon_img_html = SugarThemeRegistry::current()->getImage( $layout_def['image2'] . '', 'border="0"',null,null,'.gif',$layout_def['image2']);
151
+			$icon_img_html = SugarThemeRegistry::current()->getImage($layout_def['image2'].'', 'border="0"', null, null, '.gif', $layout_def['image2']);
152 152
 			if ($action_access && !empty($filepath)) {
153
-				$ret .= '<a href="' . $filepath. '" >' . "$icon_img_html</a>";
153
+				$ret .= '<a href="'.$filepath.'" >'."$icon_img_html</a>";
154 154
 			} elseif (!empty($filepath)) {
155 155
 				$ret .= $icon_img_html;
156 156
 			}
157 157
 		}
158 158
 		// now handle attachments for Emails
159
-		else if(!empty($layout_def['module']) && $layout_def['module'] == 'Emails' && !empty($layout_def['fields']['ATTACHMENT_IMAGE'])) {
160
-			$ret.= $layout_def['fields']['ATTACHMENT_IMAGE'];
159
+		else if (!empty($layout_def['module']) && $layout_def['module'] == 'Emails' && !empty($layout_def['fields']['ATTACHMENT_IMAGE'])) {
160
+			$ret .= $layout_def['fields']['ATTACHMENT_IMAGE'];
161 161
 		}
162 162
 		return $ret;
163 163
 	}
Please login to merge, or discard this patch.
include/generic/SugarWidgets/SugarWidgetSubPanelConcat.php 1 patch
Spacing   +4 added lines, -4 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.
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 {
48 48
 	function displayList(&$layout_def)
49 49
 	{
50
-		$value='';
50
+		$value = '';
51 51
 		if (isset($layout_def['source']) and is_array($layout_def['source']) and isset($layout_def['fields']) and is_array($layout_def['fields'])) {
52 52
 			
53 53
 			foreach ($layout_def['source'] as $field) {
54 54
 			
55 55
 				if (isset($layout_def['fields'][strtoupper($field)])) {
56
-					$value.=$layout_def['fields'][strtoupper($field)];
56
+					$value .= $layout_def['fields'][strtoupper($field)];
57 57
 				} else {
58
-					$value.=$field;
58
+					$value .= $field;
59 59
 				}	
60 60
 			}
61 61
 		}
Please login to merge, or discard this patch.
include/generic/SugarWidgets/SugarWidgetSubPanelRemoveButton.php 1 patch
Spacing   +13 added lines, -13 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.
@@ -63,26 +63,26 @@  discard block
 block discarded – undo
63 63
 
64 64
 		$action = 'DeleteRelationship';
65 65
 		$record = $layout_def['fields']['ID'];
66
-		$current_module=$layout_def['module'];
66
+		$current_module = $layout_def['module'];
67 67
 		//in document revisions subpanel ,users are now allowed to 
68 68
 		//delete the latest revsion of a document. this will be tested here
69 69
 		//and if the condition is met delete button will be removed.
70
-		$hideremove=false;
71
-		if ($current_module=='DocumentRevisions') {
72
-			if ($layout_def['fields']['ID']==$layout_def['fields']['LATEST_REVISION_ID']) {
73
-				$hideremove=true;
70
+		$hideremove = false;
71
+		if ($current_module == 'DocumentRevisions') {
72
+			if ($layout_def['fields']['ID'] == $layout_def['fields']['LATEST_REVISION_ID']) {
73
+				$hideremove = true;
74 74
 			}
75 75
 		}
76 76
 		// Implicit Team-memberships are not "removeable" 
77 77
 		elseif ($_REQUEST['module'] == 'Teams' && $current_module == 'Users') {
78
-			if($layout_def['fields']['UPLINE'] != translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) {
78
+			if ($layout_def['fields']['UPLINE'] != translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) {
79 79
 				$hideremove = true;
80 80
 			}	
81 81
 			
82 82
 			//We also cannot remove the user whose private team is set to the parent_record_id value
83 83
 			$user = new User();
84 84
 			$user->retrieve($layout_def['fields']['ID']);
85
-			if($parent_record_id == $user->getPrivateTeamID())
85
+			if ($parent_record_id == $user->getPrivateTeamID())
86 86
 			{
87 87
 			    $hideremove = true;
88 88
 			}
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 		$subpanel = $layout_def['subpanel_id'];
95 95
 		$return_id = $_REQUEST['record'];
96 96
 		if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) {
97
-			$linked_field= $layout_def['linked_field_set'] ;
97
+			$linked_field = $layout_def['linked_field_set'];
98 98
 		} else {
99 99
 			$linked_field = $layout_def['linked_field'];
100 100
 		}
101 101
 		$refresh_page = 0;
102
-		if(!empty($layout_def['refresh_page'])){
102
+		if (!empty($layout_def['refresh_page'])) {
103 103
 			$refresh_page = 1;
104 104
 		}
105 105
 		$return_url = "index.php?module=$return_module&action=$return_action&subpanel=$subpanel&record=$return_id&sugar_body_only=1&inline=1";
106 106
 
107 107
 		$icon_remove_text = mb_strtolower($app_strings['LBL_ID_FF_REMOVE'], 'UTF-8');
108 108
 		
109
-         if($linked_field == 'get_emails_by_assign_or_link')
109
+         if ($linked_field == 'get_emails_by_assign_or_link')
110 110
             $linked_field = 'emails';
111 111
 		//based on listview since that lets you select records
112
-		if($layout_def['ListView'] && !$hideremove) {
112
+		if ($layout_def['ListView'] && !$hideremove) {
113 113
             $retStr = "<a href=\"javascript:sub_p_rem('$subpanel', '$linked_field'" 
114 114
                     .", '$record', $refresh_page);\"" 
115 115
 			. ' class="listViewTdToolsS1"'
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			. ">$icon_remove_text</a>";
119 119
         return $retStr;
120 120
             
121
-		}else{
121
+		} else {
122 122
 			return '';
123 123
 		}
124 124
 	}
Please login to merge, or discard this patch.
include/generic/DeleteRelationship.php 1 patch
Spacing   +20 added lines, -20 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.
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 
67 67
 require_once('include/formbase.php');
68 68
 
69
- global $beanFiles,$beanList;
69
+ global $beanFiles, $beanList;
70 70
  $bean_name = $beanList[$_REQUEST['module']];
71 71
  require_once($beanFiles[$bean_name]);
72 72
  $focus = new $bean_name();
73
- if (  empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field'])  || empty($_REQUEST['record']))
73
+ if (empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record']))
74 74
  {
75 75
 	die("need linked_field, linked_id and record fields");
76 76
  }
77 77
  $linked_field = $_REQUEST['linked_field'];
78 78
  $record = $_REQUEST['record'];
79 79
  $linked_id = $_REQUEST['linked_id'];
80
- if($bean_name == 'Team')
80
+ if ($bean_name == 'Team')
81 81
  {
82 82
  	$focus->retrieve($record);
83 83
  	$focus->remove_user_from_team($linked_id);
@@ -86,21 +86,21 @@  discard block
 block discarded – undo
86 86
  {
87 87
  	// cut it off:
88 88
  	$focus->load_relationship($linked_field);
89
- 	if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto')
89
+ 	if ($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto')
90 90
  		unset($focus->$linked_field->_relationship->relationship_role_column);
91
- 	$focus->$linked_field->delete($record,$linked_id);
91
+ 	$focus->$linked_field->delete($record, $linked_id);
92 92
  }
93
- if ($bean_name == 'Campaign' and $linked_field=='prospectlists' ) {
93
+ if ($bean_name == 'Campaign' and $linked_field == 'prospectlists') {
94 94
 
95
- 	$query="SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists ";
96
- 	$query.=" left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id";
97
-	$query.=" where email_marketing.campaign_id='$record'";
98
- 	$query.=" and email_marketing_prospect_lists.prospect_list_id='$linked_id'";
95
+ 	$query = "SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists ";
96
+ 	$query .= " left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id";
97
+	$query .= " where email_marketing.campaign_id='$record'";
98
+ 	$query .= " and email_marketing_prospect_lists.prospect_list_id='$linked_id'";
99 99
 
100
- 	$result=$focus->db->query($query);
101
-	while (($row=$focus->db->fetchByAssoc($result)) != null) {
102
-			$del_query =" update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'",'datetime');
103
- 			$del_query.=" WHERE  email_marketing_prospect_lists.id='{$row['id']}'";
100
+ 	$result = $focus->db->query($query);
101
+	while (($row = $focus->db->fetchByAssoc($result)) != null) {
102
+			$del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'", 'datetime');
103
+ 			$del_query .= " WHERE  email_marketing_prospect_lists.id='{$row['id']}'";
104 104
 		 	$focus->db->query($del_query);
105 105
 	}
106 106
  	$focus->db->query($query);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     $user->retrieve($linked_id);
112 112
     if (!empty($user->id)) {  //make sure that record exists. we may have a contact on our hands.
113 113
 
114
-    	if($focus->update_vcal)
114
+    	if ($focus->update_vcal)
115 115
     	{
116 116
         	vCal::cache_sugar_vcal($user);
117 117
     	}
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
     $eapm->mark_deleted($linked_id);
123 123
 }
124 124
 
125
-if(!empty($_REQUEST['return_url'])){
126
-	$_REQUEST['return_url'] =urldecode($_REQUEST['return_url']);
125
+if (!empty($_REQUEST['return_url'])) {
126
+	$_REQUEST['return_url'] = urldecode($_REQUEST['return_url']);
127 127
 }
128
-$GLOBALS['log']->debug("deleted relationship: bean: $bean_name, linked_field: $linked_field, linked_id:$linked_id" );
129
-if(empty($_REQUEST['refresh_page'])){
128
+$GLOBALS['log']->debug("deleted relationship: bean: $bean_name, linked_field: $linked_field, linked_id:$linked_id");
129
+if (empty($_REQUEST['refresh_page'])) {
130 130
 	handleRedirect();
131 131
 }
132 132
 
Please login to merge, or discard this patch.
include/SugarTheme/SugarTheme.php 1 patch
Spacing   +139 added lines, -139 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.
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * theme basis.
47 47
  ********************************************************************************/
48 48
 
49
-if(!defined('JSMIN_AS_LIB'))
49
+if (!defined('JSMIN_AS_LIB'))
50 50
     define('JSMIN_AS_LIB', true);
51 51
 
52 52
 require_once("include/SugarTheme/cssmin.php");
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @deprecated only here for BC during upgrades
115 115
      * @var array
116 116
      */
117
-    protected $fonts  = array();
117
+    protected $fonts = array();
118 118
 
119 119
     /**
120 120
      * Maximum sugar version this theme is for; defaults to 5.5.1 as all the themes without this
@@ -292,44 +292,44 @@  discard block
 block discarded – undo
292 292
         )
293 293
     {
294 294
         // apply parent theme's properties first
295
-        if ( isset($defaults['parentTheme']) ) {
295
+        if (isset($defaults['parentTheme'])) {
296 296
             $themedef = array();
297 297
             include("themes/{$defaults['parentTheme']}/themedef.php");
298
-            foreach ( $themedef as $key => $value ) {
299
-                if ( property_exists(__CLASS__,$key) ) {
298
+            foreach ($themedef as $key => $value) {
299
+                if (property_exists(__CLASS__, $key)) {
300 300
                     // For all arrays ( except colors and fonts ) you can just specify the items
301 301
                     // to change instead of all of the values
302
-                    if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) )
303
-                        $this->$key = array_merge($this->$key,$value);
302
+                    if (is_array($this->$key) && !in_array($key, array('colors', 'fonts')))
303
+                        $this->$key = array_merge($this->$key, $value);
304 304
                     else
305 305
                         $this->$key = $value;
306 306
                 }
307 307
             }
308 308
         }
309
-        foreach ( $defaults as $key => $value ) {
310
-            if ( property_exists(__CLASS__,$key) ) {
309
+        foreach ($defaults as $key => $value) {
310
+            if (property_exists(__CLASS__, $key)) {
311 311
                 // For all arrays ( except colors and fonts ) you can just specify the items
312 312
                 // to change instead of all of the values
313
-                if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) )
314
-                    $this->$key = array_merge($this->$key,$value);
313
+                if (is_array($this->$key) && !in_array($key, array('colors', 'fonts')))
314
+                    $this->$key = array_merge($this->$key, $value);
315 315
                 else
316 316
                     $this->$key = $value;
317 317
             }
318 318
         }
319
-        if ( !inDeveloperMode() ) {
320
-            if ( sugar_is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) {
319
+        if (!inDeveloperMode()) {
320
+            if (sugar_is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) {
321 321
                 $caches = unserialize(file_get_contents($cachedfile));
322
-                if ( isset($caches['jsCache']) )
322
+                if (isset($caches['jsCache']))
323 323
                     $this->_jsCache       = $caches['jsCache'];
324
-                if ( isset($caches['cssCache']) )
324
+                if (isset($caches['cssCache']))
325 325
                     $this->_cssCache      = $caches['cssCache'];
326
-                if ( isset($caches['imageCache']) )
326
+                if (isset($caches['imageCache']))
327 327
                     $this->_imageCache    = $caches['imageCache'];
328
-                if ( isset($caches['templateCache']) )
328
+                if (isset($caches['templateCache']))
329 329
                     $this->_templateCache = $caches['templateCache'];
330 330
             }
331 331
             $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php');
332
-			if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) {
332
+			if (!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) {
333 333
 				$this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile));
334 334
 			}
335 335
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     public function __wakeup()
349 349
     {
350 350
         // clean all properties
351
-        foreach(get_object_vars($this) as $k => $v) {
351
+        foreach (get_object_vars($this) as $k => $v) {
352 352
             $this->$k = null;
353 353
         }
354 354
         throw new Exception("Not a serializable object");
@@ -361,14 +361,14 @@  discard block
 block discarded – undo
361 361
     public function __destruct()
362 362
     {
363 363
         // Set the current directory to one which we expect it to be (i.e. the root directory of the install
364
-        $dir = realpath(dirname(__FILE__) . '/../..');
364
+        $dir = realpath(dirname(__FILE__).'/../..');
365 365
         static $includePathIsPatched = false;
366 366
         if ($includePathIsPatched == false)
367 367
         {
368 368
             $path = explode(PATH_SEPARATOR, get_include_path());
369 369
             if (in_array($dir, $path) == false)
370 370
             {
371
-                set_include_path($dir . PATH_SEPARATOR . get_include_path());
371
+                set_include_path($dir.PATH_SEPARATOR.get_include_path());
372 372
             }
373 373
             $includePathIsPatched = true;
374 374
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         $cachedir = sugar_cached($this->getFilePath());
377 377
         sugar_mkdir($cachedir, 0775, true);
378 378
         // clear out the cache on destroy if we are asked to
379
-        if ( $this->_clearCacheOnDestroy ) {
379
+        if ($this->_clearCacheOnDestroy) {
380 380
 
381 381
             if (is_file("$cachedir/pathCache.php"))
382 382
                 unlink("$cachedir/pathCache.php");
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 				unlink("$cachedir/spriteCache.php");
385 385
 
386 386
         }
387
-        elseif ( !inDeveloperMode() ) {
387
+        elseif (!inDeveloperMode()) {
388 388
             // only update the caches if they have been changed in this request
389
-            if ( count($this->_jsCache) != $this->_initialCacheSize['jsCache']
389
+            if (count($this->_jsCache) != $this->_initialCacheSize['jsCache']
390 390
                     || count($this->_cssCache) != $this->_initialCacheSize['cssCache']
391 391
                     || count($this->_imageCache) != $this->_initialCacheSize['imageCache']
392 392
                     || count($this->_templateCache) != $this->_initialCacheSize['templateCache']
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                     );
405 405
 
406 406
             }
407
-			if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) {
407
+			if (count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) {
408 408
 				sugar_file_put_contents(
409 409
 					"$cachedir/spriteCache.php",
410 410
 					serialize($this->_spriteCache)
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
         $key
434 434
         )
435 435
     {
436
-        if ( isset($this->$key) )
436
+        if (isset($this->$key))
437 437
             return $this->$key;
438 438
     }
439 439
 
440
-    public function __isset($key){
440
+    public function __isset($key) {
441 441
     	return isset($this->$key);
442 442
 
443 443
     }
@@ -604,38 +604,38 @@  discard block
 block discarded – undo
604 604
 
605 605
 
606 606
 		// sprites
607
-		if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) {
607
+		if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) {
608 608
 
609 609
 			// system wide sprites
610
-			if(file_exists("cache/sprites/default/sprites.css"))
610
+			if (file_exists("cache/sprites/default/sprites.css"))
611 611
 				$html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />';
612 612
 
613 613
 			// theme specific sprites
614
-			if(file_exists("cache/sprites/{$this->dirName}/sprites.css"))
614
+			if (file_exists("cache/sprites/{$this->dirName}/sprites.css"))
615 615
 				$html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />';
616 616
 
617 617
 			// parent sprites
618
-			if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) {
619
-				if(file_exists("cache/sprites/{$parent->dirName}/sprites.css"))
618
+			if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) {
619
+				if (file_exists("cache/sprites/{$parent->dirName}/sprites.css"))
620 620
 					$html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />';
621 621
 			}
622 622
 
623 623
 			// repeatable sprites
624
-			if(file_exists("cache/sprites/Repeatable/sprites.css"))
624
+			if (file_exists("cache/sprites/Repeatable/sprites.css"))
625 625
 				$html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />';
626 626
 		}
627 627
 
628 628
         // for BC during upgrade
629
-        if ( !empty($this->colors) ) {
630
-            if ( isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors))
629
+        if (!empty($this->colors)) {
630
+            if (isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors))
631 631
                 $color = $_SESSION['authenticated_user_theme_color'];
632 632
             else
633 633
                 $color = $this->colors[0];
634 634
             $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('colors.'.$color.'.css').'" id="current_color_style" />';
635 635
         }
636 636
 
637
-        if ( !empty($this->fonts) ) {
638
-            if ( isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts))
637
+        if (!empty($this->fonts)) {
638
+            if (isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts))
639 639
                 $font = $_SESSION['authenticated_user_theme_font'];
640 640
             else
641 641
                 $font = $this->fonts[0];
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
         $templateName
670 670
         )
671 671
     {
672
-        if ( isset($this->_templateCache[$templateName]) )
672
+        if (isset($this->_templateCache[$templateName]))
673 673
             return $this->_templateCache[$templateName];
674 674
 
675 675
         $templatePath = '';
@@ -719,28 +719,28 @@  discard block
 block discarded – undo
719 719
         static $cached_results = array();
720 720
 
721 721
 		// trap deprecated use of image extension
722
-		if(is_null($ext)) {
723
-			$imageNameExp = explode('.',$imageName);
724
-			if(count($imageNameExp) == 1)
722
+		if (is_null($ext)) {
723
+			$imageNameExp = explode('.', $imageName);
724
+			if (count($imageNameExp) == 1)
725 725
 				$imageName .= '.gif';
726 726
 		} else {
727 727
 			$imageName .= $ext;
728 728
 		}
729 729
 
730 730
 		// trap alt attributes in other_attributes
731
-		if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes))
731
+		if (preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes))
732 732
 			$GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName");
733 733
 		// sprite handler, makes use of own caching mechanism
734
-		if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) {
734
+		if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) {
735 735
 			// get sprite metadata
736
-			if($sp = $this->getSpriteMeta($imageName)) {
736
+			if ($sp = $this->getSpriteMeta($imageName)) {
737 737
 				// requested size should match
738
-				if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) &&
739
-					(!is_null($height) && $sp['height'] == $height) || (is_null($height)) )
738
+				if ((!is_null($width) && $sp['width'] == $width) || (is_null($width)) &&
739
+					(!is_null($height) && $sp['height'] == $height) || (is_null($height)))
740 740
 				{
741 741
                     $other_attributes .= ' data-orig="'.$imageName.'"';
742 742
 
743
-                     if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt))
743
+                     if ($sprite = $this->getSprite($sp['class'], $other_attributes, $alt))
744 744
                      {
745 745
                          return $sprite;
746 746
                      }
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
 		}
750 750
 
751 751
 		// img caching
752
-		if(empty($cached_results[$imageName])) {
753
-			$imageURL = $this->getImageURL($imageName,false);
754
-			if ( empty($imageURL) )
752
+		if (empty($cached_results[$imageName])) {
753
+			$imageURL = $this->getImageURL($imageName, false);
754
+			if (empty($imageURL))
755 755
 				return false;
756
-            if(strpos($imageURL, '.svg', strlen($imageURL)-4)){
756
+            if (strpos($imageURL, '.svg', strlen($imageURL) - 4)) {
757 757
                 $cached_results[$imageName] = file_get_contents($imageURL);
758 758
             } else {
759 759
                 $cached_results[$imageName] = '<img src="'.getJSPath($imageURL).'" ';
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
 		$attr_width = (is_null($width)) ? "" : "width=\"$width\"";
765 765
 		$attr_height = (is_null($height)) ? "" : "height=\"$height\"";
766 766
 
767
-        if(strpos($cached_results[$imageName], 'svg') !== false){
767
+        if (strpos($cached_results[$imageName], 'svg') !== false) {
768 768
             return $cached_results[$imageName];
769 769
         }
770
-		return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />";
770
+		return $cached_results[$imageName]." $attr_width $attr_height $other_attributes alt=\"$alt\" />";
771 771
     }
772 772
 
773 773
 	/**
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
 	public function getSpriteMeta($imageName) {
780 780
 
781 781
 		// return from cache
782
-	    if(isset($this->_spriteCache[$imageName]))
782
+	    if (isset($this->_spriteCache[$imageName]))
783 783
 			return $this->_spriteCache[$imageName];
784 784
 
785 785
 			// sprite keys are base on imageURL
786
-		$imageURL = $this->getImageURL($imageName,false);
787
-		if(empty($imageURL)) {
786
+		$imageURL = $this->getImageURL($imageName, false);
787
+		if (empty($imageURL)) {
788 788
 			$this->_spriteCache[$imageName] = false;
789 789
 			return false;
790 790
 		}
@@ -795,12 +795,12 @@  discard block
 block discarded – undo
795 795
 		// add current theme dir
796 796
 		$meta->loadSpriteMeta($this->dirName);
797 797
 		// add parent theme dir
798
-		if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) {
798
+		if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) {
799 799
 			$meta->loadSpriteMeta($parent->dirName);
800 800
 		}
801 801
 
802 802
 		// add to cache
803
-		if(isset($meta->sprites[$imageURL])) {
803
+		if (isset($meta->sprites[$imageURL])) {
804 804
 			$this->_spriteCache[$imageName] = $meta->sprites[$imageURL];
805 805
 			// add imageURL to cache
806 806
 			//$this->_spriteCache[$imageName]['imageURL'] = $imageURL;
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		// handle multiple class tags
825 825
 		$class_regex = '/class=["\']([^\'"]+)["\']/i';
826 826
 		preg_match($class_regex, $attr, $match);
827
-		if(isset($match[1])) {
827
+		if (isset($match[1])) {
828 828
 			$attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr);
829 829
 
830 830
 		// single class
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 			$attr .= ' class="spr_'.$class.'"';
833 833
 		}
834 834
 
835
-		if($title)
835
+		if ($title)
836 836
 			$attr .= ' title="'.$title.'"';
837 837
 
838 838
 		// use </span> instead of /> to prevent weird UI results
@@ -856,13 +856,13 @@  discard block
 block discarded – undo
856 856
     )
857 857
     {
858 858
 
859
-		if($img_name) {
859
+		if ($img_name) {
860 860
 			$img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt);
861
-			if($img == false) {
861
+			if ($img == false) {
862 862
 				$GLOBALS['log']->debug('Sprites: unknown image getLink');
863 863
 				$img = 'unknown';
864 864
 			}
865
-			switch($img_placement) {
865
+			switch ($img_placement) {
866 866
 				case 'left': 	$inner_html = $img."<span class='title'>".$title."</span>"; break;
867 867
 				case 'right':	$inner_html = "<span class='title'>".$title."</span>".$img; break;
868 868
 				default:		$inner_html = $img; break;
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
     public function getImageURL(
886 886
         $imageName,
887 887
         $addJSPath = true
888
-        ){
889
-        if ( isset($this->_imageCache[$imageName]) ) {
890
-            if ( $addJSPath )
888
+        ) {
889
+        if (isset($this->_imageCache[$imageName])) {
890
+            if ($addJSPath)
891 891
                 return getJSPath($this->_imageCache[$imageName]);
892 892
             else
893 893
                 return $this->_imageCache[$imageName];
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
             $imagePath = $filename;
900 900
         elseif (isset($this->parentTheme)
901 901
                 && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme
902
-                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName,false)) != '')
902
+                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName, false)) != '')
903 903
             $imagePath = $filename;
904 904
         elseif (($filename = $this->_getImageFileName('custom/'.$this->getDefaultImagePath().'/'.$imageName)) != '')
905 905
             $imagePath = $filename;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 
915 915
         $this->_imageCache[$imageName] = $imagePath;
916 916
 
917
-        if ( $addJSPath )
917
+        if ($addJSPath)
918 918
             return getJSPath($imagePath);
919 919
 
920 920
         return $imagePath;
@@ -931,13 +931,13 @@  discard block
 block discarded – undo
931 931
         )
932 932
     {
933 933
         // return now if the extension matches that of which we are looking for
934
-        if ( sugar_is_file($imageName) )
934
+        if (sugar_is_file($imageName))
935 935
             return $imageName;
936 936
         $pathParts = pathinfo($imageName);
937
-        foreach ( $this->imageExtensions as $extension )
938
-            if ( isset($pathParts['extension']) )
939
-                if ( ( $extension != $pathParts['extension'] )
940
-                        && sugar_is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension) )
937
+        foreach ($this->imageExtensions as $extension)
938
+            if (isset($pathParts['extension']))
939
+                if (($extension != $pathParts['extension'])
940
+                        && sugar_is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension))
941 941
                     return $pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension;
942 942
 
943 943
         return '';
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
      */
954 954
     public function getCSSURL($cssFileName, $returnURL = true)
955 955
     {
956
-        if ( isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName])) ) {
957
-            if ( $returnURL )
956
+        if (isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName]))) {
957
+            if ($returnURL)
958 958
                 return getJSPath("cache/".$this->_cssCache[$cssFileName]);
959 959
             else
960 960
                 return sugar_cached($this->_cssCache[$cssFileName]);
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
         $fullFileName = $this->getCSSPath().'/'.$cssFileName;
966 966
         if (isset($this->parentTheme)
967 967
                 && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme
968
-                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName,false)) != '')
968
+                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName, false)) != '')
969 969
             $cssFileContents .= file_get_contents($filename);
970 970
         else {
971 971
             if (sugar_is_file($defaultFileName))
@@ -994,24 +994,24 @@  discard block
 block discarded – undo
994 994
 
995 995
         // if this is the style.css file, prepend the base.css and calendar-win2k-cold-1.css
996 996
         // files before the theme styles
997
-        if ( $cssFileName == 'style.css' && !isset($this->parentTheme) ) {
998
-            if ( inDeveloperMode() )
999
-                $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents;
997
+        if ($cssFileName == 'style.css' && !isset($this->parentTheme)) {
998
+            if (inDeveloperMode())
999
+                $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css').$cssFileContents;
1000 1000
             else
1001
-                $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents;
1001
+                $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css').$cssFileContents;
1002 1002
         }
1003 1003
 
1004 1004
         // minify the css
1005
-        if ( !inDeveloperMode() && !sugar_is_file($cssFilePath) ) {
1005
+        if (!inDeveloperMode() && !sugar_is_file($cssFilePath)) {
1006 1006
             $cssFileContents = cssmin::minify($cssFileContents);
1007 1007
         }
1008 1008
 
1009 1009
         // now write the css to cache
1010
-        sugar_file_put_contents($cssFilePath,$cssFileContents);
1010
+        sugar_file_put_contents($cssFilePath, $cssFileContents);
1011 1011
 
1012 1012
         $this->_cssCache[$cssFileName] = $fullFileName;
1013 1013
 
1014
-        if ( $returnURL )
1014
+        if ($returnURL)
1015 1015
             return getJSPath("cache/".$fullFileName);
1016 1016
 
1017 1017
         return sugar_cached($fullFileName);
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
      */
1028 1028
     public function getJSURL($jsFileName, $returnURL = true)
1029 1029
     {
1030
-        if ( isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName])) ) {
1031
-            if ( $returnURL )
1030
+        if (isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName]))) {
1031
+            if ($returnURL)
1032 1032
                 return getJSPath("cache/".$this->_jsCache[$jsFileName]);
1033 1033
             else
1034 1034
                 return sugar_cached($this->_jsCache[$jsFileName]);
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
         $defaultFileName = $this->getDefaultJSPath().'/'.$jsFileName;
1040 1040
         if (isset($this->parentTheme)
1041 1041
                 && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme
1042
-                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName,false)) != ''    && !in_array($jsFileName,$this->ignoreParentFiles)) {
1042
+                && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName, false)) != '' && !in_array($jsFileName, $this->ignoreParentFiles)) {
1043 1043
            $jsFileContents .= file_get_contents($filename);
1044 1044
        } else {
1045 1045
             if (sugar_is_file($defaultFileName))
@@ -1060,18 +1060,18 @@  discard block
 block discarded – undo
1060 1060
         $jsFilePath = create_cache_directory($fullFileName);
1061 1061
 
1062 1062
         // minify the js
1063
-        if ( !inDeveloperMode()&& !sugar_is_file(str_replace('.js','-min.js',$jsFilePath)) ) {
1063
+        if (!inDeveloperMode() && !sugar_is_file(str_replace('.js', '-min.js', $jsFilePath))) {
1064 1064
             $jsFileContents = SugarMin::minify($jsFileContents);
1065
-            $jsFilePath = str_replace('.js','-min.js',$jsFilePath);
1066
-            $fullFileName = str_replace('.js','-min.js',$fullFileName);
1065
+            $jsFilePath = str_replace('.js', '-min.js', $jsFilePath);
1066
+            $fullFileName = str_replace('.js', '-min.js', $fullFileName);
1067 1067
         }
1068 1068
 
1069 1069
         // now write the js to cache
1070
-        sugar_file_put_contents($jsFilePath,$jsFileContents);
1070
+        sugar_file_put_contents($jsFilePath, $jsFileContents);
1071 1071
 
1072 1072
         $this->_jsCache[$jsFileName] = $fullFileName;
1073 1073
 
1074
-        if ( $returnURL )
1074
+        if ($returnURL)
1075 1075
             return getJSPath("cache/".$fullFileName);
1076 1076
 
1077 1077
         return sugar_cached($fullFileName);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         // first, lets get all the paths of where to look
1088 1088
         $pathsToSearch = array($this->getImagePath());
1089 1089
         $theme = $this;
1090
-        while (isset($theme->parentTheme) && SugarThemeRegistry::get($theme->parentTheme) instanceOf SugarTheme ) {
1090
+        while (isset($theme->parentTheme) && SugarThemeRegistry::get($theme->parentTheme) instanceOf SugarTheme) {
1091 1091
             $theme = SugarThemeRegistry::get($theme->parentTheme);
1092 1092
             $pathsToSearch[] = $theme->getImagePath();
1093 1093
         }
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
         // now build the array
1097 1097
         $imageArray = array();
1098
-        foreach ( $pathsToSearch as $path )
1098
+        foreach ($pathsToSearch as $path)
1099 1099
         {
1100 1100
             if (!sugar_is_dir($path)) $path = "custom/$path";
1101 1101
             if (sugar_is_dir($path) && is_readable($path) && $dir = opendir($path)) {
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
                             || $file == "Attic"
1108 1108
                             )
1109 1109
                         continue;
1110
-                    if ( !isset($imageArray[$file]) )
1111
-                        $imageArray[$file] = $this->getImageURL($file,false);
1110
+                    if (!isset($imageArray[$file]))
1111
+                        $imageArray[$file] = $this->getImageURL($file, false);
1112 1112
                 }
1113 1113
                 closedir($dir);
1114 1114
             }
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
 
1131 1131
         $config = array();
1132 1132
 
1133
-        foreach($this->config_options as $name => $def){
1133
+        foreach ($this->config_options as $name => $def) {
1134 1134
             $config[$name] = $def;
1135 1135
 
1136 1136
             $value = '';
1137
-            if(isset($sugar_config['theme_settings'][$this->dirName][$name])){
1137
+            if (isset($sugar_config['theme_settings'][$this->dirName][$name])) {
1138 1138
                 $value = $sugar_config['theme_settings'][$this->dirName][$name];
1139
-            } else if(isset($def['default'])){
1139
+            } else if (isset($def['default'])) {
1140 1140
                 $value = $def['default'];
1141 1141
             }
1142 1142
             $config[$name] = $value;
@@ -1189,28 +1189,28 @@  discard block
 block discarded – undo
1189 1189
         }
1190 1190
 
1191 1191
         // Assume theme is designed for 5.5.x if not specified otherwise
1192
-        if ( !isset($themedef['version']) )
1192
+        if (!isset($themedef['version']))
1193 1193
             $themedef['version']['regex_matches'] = array('5\.5\.*');
1194 1194
 
1195 1195
         // Check to see if theme is valid for this version of Sugar; return false if not
1196 1196
         $version_ok = false;
1197
-        if( isset($themedef['version']['exact_matches']) ){
1197
+        if (isset($themedef['version']['exact_matches'])) {
1198 1198
             $matches_empty = false;
1199
-            foreach( $themedef['version']['exact_matches'] as $match ){
1200
-                if( $match == $GLOBALS['sugar_version'] ){
1199
+            foreach ($themedef['version']['exact_matches'] as $match) {
1200
+                if ($match == $GLOBALS['sugar_version']) {
1201 1201
                     $version_ok = true;
1202 1202
                 }
1203 1203
             }
1204 1204
         }
1205
-        if( !$version_ok && isset($themedef['version']['regex_matches']) ){
1205
+        if (!$version_ok && isset($themedef['version']['regex_matches'])) {
1206 1206
             $matches_empty = false;
1207
-            foreach( $themedef['version']['regex_matches'] as $match ){
1208
-                if( preg_match( "/$match/", $GLOBALS['sugar_version'] ) ){
1207
+            foreach ($themedef['version']['regex_matches'] as $match) {
1208
+                if (preg_match("/$match/", $GLOBALS['sugar_version'])) {
1209 1209
                     $version_ok = true;
1210 1210
                 }
1211 1211
             }
1212 1212
         }
1213
-        if ( !$version_ok )
1213
+        if (!$version_ok)
1214 1214
             return false;
1215 1215
 
1216 1216
         $theme = new SugarTheme($themedef);
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
         $themeName
1227 1227
         )
1228 1228
     {
1229
-        if ( self::exists($themeName) )
1229
+        if (self::exists($themeName))
1230 1230
             unset(self::$_themes[$themeName]);
1231 1231
     }
1232 1232
 
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
         $themeName
1240 1240
         )
1241 1241
     {
1242
-        if ( isset(self::$_themes[$themeName]) )
1242
+        if (isset(self::$_themes[$themeName]))
1243 1243
             return self::$_themes[$themeName];
1244 1244
     }
1245 1245
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
      */
1251 1251
     public static function current()
1252 1252
     {
1253
-        if ( !isset(self::$_currentTheme) )
1253
+        if (!isset(self::$_currentTheme))
1254 1254
             self::buildRegistry();
1255 1255
 
1256 1256
         return self::$_themes[self::$_currentTheme];
@@ -1263,10 +1263,10 @@  discard block
 block discarded – undo
1263 1263
      */
1264 1264
     public static function getDefault()
1265 1265
     {
1266
-        if ( !isset(self::$_currentTheme) )
1266
+        if (!isset(self::$_currentTheme))
1267 1267
             self::buildRegistry();
1268 1268
 
1269
-        if ( isset($GLOBALS['sugar_config']['default_theme']) && self::exists($GLOBALS['sugar_config']['default_theme']) ) {
1269
+        if (isset($GLOBALS['sugar_config']['default_theme']) && self::exists($GLOBALS['sugar_config']['default_theme'])) {
1270 1270
             return self::get($GLOBALS['sugar_config']['default_theme']);
1271 1271
         }
1272 1272
         $array_keys = array_keys(self::availableThemes());
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
         $themeName
1296 1296
         )
1297 1297
     {
1298
-        if ( !self::exists($themeName) )
1298
+        if (!self::exists($themeName))
1299 1299
             return false;
1300 1300
 
1301 1301
         self::$_currentTheme = $themeName;
@@ -1312,17 +1312,17 @@  discard block
 block discarded – undo
1312 1312
     public static function buildRegistry()
1313 1313
     {
1314 1314
         self::$_themes = array();
1315
-        $dirs = array("themes/","custom/themes/");
1315
+        $dirs = array("themes/", "custom/themes/");
1316 1316
 
1317 1317
         // check for a default themedef file
1318 1318
         $themedefDefault = array();
1319
-        if ( sugar_is_file("custom/themes/default/themedef.php") ) {
1319
+        if (sugar_is_file("custom/themes/default/themedef.php")) {
1320 1320
             $themedef = array();
1321 1321
             require("custom/themes/default/themedef.php");
1322 1322
             $themedefDefault = $themedef;
1323 1323
         }
1324 1324
 
1325
-        foreach ($dirs as $dirPath ) {
1325
+        foreach ($dirs as $dirPath) {
1326 1326
             if (sugar_is_dir('./'.$dirPath) && is_readable('./'.$dirPath) && $dir = opendir('./'.$dirPath)) {
1327 1327
                 while (($file = readdir($dir)) !== false) {
1328 1328
                     if ($file == ".."
@@ -1337,18 +1337,18 @@  discard block
 block discarded – undo
1337 1337
                         continue;
1338 1338
                     $themedef = array();
1339 1339
                     require("./{$dirPath}{$file}/themedef.php");
1340
-                    $themedef = array_merge($themedef,$themedefDefault);
1340
+                    $themedef = array_merge($themedef, $themedefDefault);
1341 1341
                     $themedef['dirName'] = $file;
1342 1342
                     // check for theme already existing in the registry
1343 1343
                     // if so, then it will override the current one
1344
-                    if ( self::exists($themedef['dirName']) ) {
1344
+                    if (self::exists($themedef['dirName'])) {
1345 1345
                         $existingTheme = self::get($themedef['dirName']);
1346
-                        foreach ( SugarTheme::getThemeDefFields() as $field )
1347
-                            if ( !isset($themedef[$field]) )
1346
+                        foreach (SugarTheme::getThemeDefFields() as $field)
1347
+                            if (!isset($themedef[$field]))
1348 1348
                                 $themedef[$field] = $existingTheme->$field;
1349 1349
                         self::remove($themedef['dirName']);
1350 1350
                     }
1351
-                    if ( isset($themedef['name']) ) {
1351
+                    if (isset($themedef['name'])) {
1352 1352
                         self::add($themedef);
1353 1353
                     }
1354 1354
                 }
@@ -1356,8 +1356,8 @@  discard block
 block discarded – undo
1356 1356
             }
1357 1357
         }
1358 1358
         // default to setting the default theme as the current theme
1359
-        if ( !isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme']) ) {
1360
-            if ( count(self::availableThemes()) == 0 )
1359
+        if (!isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme'])) {
1360
+            if (count(self::availableThemes()) == 0)
1361 1361
             {
1362 1362
                 sugar_die('No valid themes are found on this instance');
1363 1363
             } else {
@@ -1379,9 +1379,9 @@  discard block
 block discarded – undo
1379 1379
     private static function getDefaultThemeKey()
1380 1380
     {
1381 1381
         $availableThemes = self::availableThemes();
1382
-        foreach($availableThemes as $key=>$theme)
1382
+        foreach ($availableThemes as $key=>$theme)
1383 1383
         {
1384
-            if(strtolower($key) == 'sugar')
1384
+            if (strtolower($key) == 'sugar')
1385 1385
             {
1386 1386
                 return $key;
1387 1387
             }
@@ -1400,11 +1400,11 @@  discard block
 block discarded – undo
1400 1400
     {
1401 1401
         $themelist = array();
1402 1402
         $disabledThemes = array();
1403
-        if ( isset($GLOBALS['sugar_config']['disabled_themes']) )
1404
-            $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']);
1403
+        if (isset($GLOBALS['sugar_config']['disabled_themes']))
1404
+            $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']);
1405 1405
 
1406
-        foreach ( self::$_themes as $themename => $themeobject ) {
1407
-            if ( in_array($themename,$disabledThemes) )
1406
+        foreach (self::$_themes as $themename => $themeobject) {
1407
+            if (in_array($themename, $disabledThemes))
1408 1408
                 continue;
1409 1409
             $themelist[$themeobject->dirName] = $themeobject->name;
1410 1410
         }
@@ -1421,11 +1421,11 @@  discard block
 block discarded – undo
1421 1421
     {
1422 1422
         $themelist = array();
1423 1423
         $disabledThemes = array();
1424
-        if ( isset($GLOBALS['sugar_config']['disabled_themes']) )
1425
-            $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']);
1424
+        if (isset($GLOBALS['sugar_config']['disabled_themes']))
1425
+            $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']);
1426 1426
 
1427
-        foreach ( self::$_themes as $themename => $themeobject ) {
1428
-            if ( in_array($themename,$disabledThemes) )
1427
+        foreach (self::$_themes as $themename => $themeobject) {
1428
+            if (in_array($themename, $disabledThemes))
1429 1429
                 $themelist[$themeobject->dirName] = $themeobject->name;
1430 1430
         }
1431 1431
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
     {
1442 1442
         $themelist = array();
1443 1443
 
1444
-        foreach ( self::$_themes as $themename => $themeobject )
1444
+        foreach (self::$_themes as $themename => $themeobject)
1445 1445
             $themelist[$themeobject->dirName] = $themeobject->name;
1446 1446
 
1447 1447
         return $themelist;
@@ -1478,18 +1478,18 @@  discard block
 block discarded – undo
1478 1478
     {
1479 1479
         global $sugar_config;
1480 1480
 
1481
-        if ( !self::exists($themeName) )
1481
+        if (!self::exists($themeName))
1482 1482
             return false;
1483 1483
 
1484 1484
         $config = array();
1485 1485
 
1486
-        foreach(self::$_themes[$themeName]->config_options as $name => $def){
1486
+        foreach (self::$_themes[$themeName]->config_options as $name => $def) {
1487 1487
             $config[$name] = $def;
1488 1488
 
1489 1489
             $value = '';
1490
-            if(isset($sugar_config['theme_settings'][$themeName][$name])){
1490
+            if (isset($sugar_config['theme_settings'][$themeName][$name])) {
1491 1491
                 $value = $sugar_config['theme_settings'][$themeName][$name];
1492
-            } else if(isset($def['default'])){
1492
+            } else if (isset($def['default'])) {
1493 1493
                 $value = $def['default'];
1494 1494
             }
1495 1495
             $config[$name]['value'] = $value;
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
      */
1506 1506
     public static function clearAllCaches()
1507 1507
     {
1508
-        foreach ( self::$_themes as $themeobject ) {
1508
+        foreach (self::$_themes as $themeobject) {
1509 1509
             $themeobject->clearCache();
1510 1510
         }
1511 1511
     }
Please login to merge, or discard this patch.
include/SugarObjects/LanguageManager.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 	 * @param module - the name of the module we are working with
50 50
 	 * @param templates - an array of templates this module uses
51 51
 	 */
52
-	static function createLanguageFile($module , $templates=array('default'), $refresh = false){
52
+	static function createLanguageFile($module, $templates = array('default'), $refresh = false) {
53 53
 		global $mod_strings, $current_language;
54
-		if(inDeveloperMode() || !empty($_SESSION['developerMode'])){
54
+		if (inDeveloperMode() || !empty($_SESSION['developerMode'])) {
55 55
         	$refresh = true;
56 56
     	}
57 57
 		$temp_mod_strings = $mod_strings;
58 58
 		$lang = $current_language;
59
-        if(empty($lang))
59
+        if (empty($lang))
60 60
             $lang = $GLOBALS['sugar_config']['default_language'];
61 61
 		static $createdModules = array();
62
-		if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){
62
+		if (empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))) {
63 63
 			$loaded_mod_strings = array();
64
-			$loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings);
64
+			$loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings);
65 65
 			$createdModules[$module] = true;
66
-			LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings);
66
+			LanguageManager::refreshLanguage($module, $lang, $loaded_mod_strings);
67 67
 		}
68 68
 	}
69 69
 
@@ -74,48 +74,48 @@  discard block
 block discarded – undo
74 74
 	 * @param lang - current language this module use
75 75
 	 * @param loaded_mod_strings - the string that we will add the module template language  into
76 76
 	 */
77
-	static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){
77
+	static function loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings) {
78 78
 		$templates = array_reverse($templates);
79
-		foreach($templates as $template){
80
-			$temp = LanguageManager::addTemplate($module,$lang, $template);
79
+		foreach ($templates as $template) {
80
+			$temp = LanguageManager::addTemplate($module, $lang, $template);
81 81
 			$loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp);
82 82
 		}
83 83
 		return $loaded_mod_strings;
84 84
 	}
85 85
 
86
-	static function addTemplate($module, $lang, $template){
87
-		if($template == 'default')$template = 'basic';
86
+	static function addTemplate($module, $lang, $template) {
87
+		if ($template == 'default')$template = 'basic';
88 88
 		$templates = array();
89 89
 		$fields = array();
90
-		if(empty($templates[$template])){
91
-			$path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php';
92
-			if(file_exists($path)){
90
+		if (empty($templates[$template])) {
91
+			$path = 'include/SugarObjects/templates/'.$template.'/language/'.$lang.'.lang.php';
92
+			if (file_exists($path)) {
93 93
 				require($path);
94 94
 				$templates[$template] = $mod_strings;
95
-			}else{
96
-				$path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php';
97
-				if(file_exists($path)){
95
+			} else {
96
+				$path = 'include/SugarObjects/implements/'.$template.'/language/'.$lang.'.lang.php';
97
+				if (file_exists($path)) {
98 98
 					require($path);
99 99
 					$templates[$template] = $mod_strings;
100 100
 				}
101 101
 			}
102 102
 		}
103
-		if(!empty($templates[$template])){
103
+		if (!empty($templates[$template])) {
104 104
 			return $templates[$template];
105 105
 		}
106 106
 	}
107 107
 
108
-	static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){
109
-		if(empty($lang))
108
+	static function saveCache($module, $lang, $loaded_mod_strings, $additonal_objects = array()) {
109
+		if (empty($lang))
110 110
 			$lang = $GLOBALS['sugar_config']['default_language'];
111 111
 
112
-		$file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php');
113
-		write_array_to_file('mod_strings',$loaded_mod_strings, $file);
112
+		$file = create_cache_directory('modules/'.$module.'/language/'.$lang.'.lang.php');
113
+		write_array_to_file('mod_strings', $loaded_mod_strings, $file);
114 114
 		include($file);
115 115
 
116 116
 		// put the item in the sugar cache.
117
-		$key = self::getLanguageCacheKey($module,$lang);
118
-		sugar_cache_put($key,$loaded_mod_strings);
117
+		$key = self::getLanguageCacheKey($module, $lang);
118
+		sugar_cache_put($key, $loaded_mod_strings);
119 119
 	}
120 120
 
121 121
 	/**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
 	 *                      clear language cache for all modules.
125 125
 	 * @param string lang the name of the object we are clearing this is for sugar_cache
126 126
 	 */
127
-	static function clearLanguageCache($module_dir = '', $lang = ''){
128
-		if(empty($lang)) {
127
+	static function clearLanguageCache($module_dir = '', $lang = '') {
128
+		if (empty($lang)) {
129 129
 			$languages = array_keys($GLOBALS['sugar_config']['languages']);
130 130
 		} else {
131 131
 			$languages = array($lang);
132 132
 		}
133 133
 		//if we have a module name specified then just remove that language file
134 134
 		//otherwise go through each module and clean up the language
135
-		if(!empty($module_dir)) {
136
-			foreach($languages as $clean_lang) {
135
+		if (!empty($module_dir)) {
136
+			foreach ($languages as $clean_lang) {
137 137
 				LanguageManager::_clearCache($module_dir, $clean_lang);
138 138
 			}
139 139
 		} else {
140 140
 			$cache_dir = sugar_cached('modules/');
141
-			if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) {
142
-				while(($entry = readdir($dir)) !== false) {
141
+			if (file_exists($cache_dir) && $dir = @opendir($cache_dir)) {
142
+				while (($entry = readdir($dir)) !== false) {
143 143
 					if ($entry == "." || $entry == "..") continue;
144
-						foreach($languages as $clean_lang) {
144
+						foreach ($languages as $clean_lang) {
145 145
 							LanguageManager::_clearCache($entry, $clean_lang);
146 146
 						}
147 147
 				}
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	 * @param string module_dir the module_dir to clear
156 156
 	 * @param string lang the name of the language file we are clearing this is for sugar_cache
157 157
 	 */
158
-	static function _clearCache($module_dir = '', $lang){
159
-		if(!empty($module_dir) && !empty($lang)){
158
+	static function _clearCache($module_dir = '', $lang) {
159
+		if (!empty($module_dir) && !empty($lang)) {
160 160
 			$file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php';
161
-			if(file_exists($file)){
161
+			if (file_exists($file)) {
162 162
 				unlink($file);
163
-				$key = self::getLanguageCacheKey($module_dir,$lang);
163
+				$key = self::getLanguageCacheKey($module_dir, $lang);
164 164
 				sugar_cache_clear($key);
165 165
 			}
166 166
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @param string $lang the given language we wish to load
175 175
 	 * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
176 176
 	 */
177
-	static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){
177
+	static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null) {
178 178
 		// Some of the vardefs do not correctly define dictionary as global.  Declare it first.
179 179
 		$lang_paths = array(
180 180
 					'modules/'.$module.'/language/'.$lang.'.lang.php',
@@ -185,35 +185,35 @@  discard block
 block discarded – undo
185 185
 
186 186
 		#27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files.
187 187
 		static $createdModules;
188
-		if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){
188
+		if (empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])) {
189 189
 				$object = $GLOBALS['beanList'][$module];
190 190
 
191 191
 				if ($object == 'aCase')
192 192
 		            $object = 'Case';
193 193
 
194
-		        if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){
194
+		        if (!empty($GLOBALS["dictionary"]["$object"]["templates"])) {
195 195
 		        	$templates = $GLOBALS["dictionary"]["$object"]["templates"];
196
-					$loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings);
196
+					$loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings);
197 197
 					$createdModules[$module] = true;
198 198
 		        }
199 199
 		}
200 200
 		//end of fix #27023
201 201
 
202 202
 		// Add in additional search paths if they were provided.
203
-		if(!empty($additional_search_paths) && is_array($additional_search_paths))
203
+		if (!empty($additional_search_paths) && is_array($additional_search_paths))
204 204
 		{
205 205
 			$lang_paths = array_merge($lang_paths, $additional_search_paths);
206 206
 		}
207 207
 
208 208
 		//search a predefined set of locations for the vardef files
209
-		foreach($lang_paths as $path){
210
-			if(file_exists($path)){
209
+		foreach ($lang_paths as $path) {
210
+			if (file_exists($path)) {
211 211
 				require($path);
212
-				if(!empty($mod_strings)){
213
-					if (function_exists('sugarArrayMergeRecursive')){
212
+				if (!empty($mod_strings)) {
213
+					if (function_exists('sugarArrayMergeRecursive')) {
214 214
 						$loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings);
215 215
 					}
216
-					else{
216
+					else {
217 217
 						$loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings);
218 218
 					}
219 219
 				}
@@ -222,43 +222,43 @@  discard block
 block discarded – undo
222 222
 
223 223
 		//great! now that we have loaded all of our vardefs.
224 224
 		//let's go save them to the cache file.
225
-		if(!empty($loaded_mod_strings))
225
+		if (!empty($loaded_mod_strings))
226 226
 			LanguageManager::saveCache($module, $lang, $loaded_mod_strings);
227 227
 	}
228 228
 
229
-	static function loadModuleLanguage($module, $lang, $refresh=false){
229
+	static function loadModuleLanguage($module, $lang, $refresh = false) {
230 230
 		//here check if the cache file exists, if it does then load it, if it doesn't
231 231
 		//then call refreshVardef
232 232
 		//if either our session or the system is set to developerMode then refresh is set to true
233 233
 
234 234
 		// Retrieve the vardefs from cache.
235
-		$key = self::getLanguageCacheKey($module,$lang);
235
+		$key = self::getLanguageCacheKey($module, $lang);
236 236
 
237
-		if(!$refresh)
237
+		if (!$refresh)
238 238
 		{
239 239
 			$return_result = sugar_cache_retrieve($key);
240
-			if(!empty($return_result) && is_array($return_result)){
240
+			if (!empty($return_result) && is_array($return_result)) {
241 241
 				return $return_result;
242 242
 			}
243 243
 		}
244 244
 
245 245
 		// Some of the vardefs do not correctly define dictionary as global.  Declare it first.
246 246
 		$cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php';
247
-		if($refresh || !file_exists($cachedfile)){
247
+		if ($refresh || !file_exists($cachedfile)) {
248 248
 			LanguageManager::refreshLanguage($module, $lang);
249 249
 		}
250 250
 
251 251
 		//at this point we should have the cache/modules/... file
252 252
 		//which was created from the refreshVardefs so let's try to load it.
253
-		if(file_exists($cachedfile)){
253
+		if (file_exists($cachedfile)) {
254 254
 			global $mod_strings;
255 255
 
256 256
 			require $cachedfile;
257 257
 
258 258
 			// now that we hae loaded the data from disk, put it in the cache.
259
-			if(!empty($mod_strings))
260
-				sugar_cache_put($key,$mod_strings);
261
-			if(!empty($_SESSION['translation_mode'])){
259
+			if (!empty($mod_strings))
260
+				sugar_cache_put($key, $mod_strings);
261
+			if (!empty($_SESSION['translation_mode'])) {
262 262
 				$mod_strings = array_map('translated_prefix', $mod_strings);
263 263
 			}
264 264
 			return $mod_strings;
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
     {
289 289
         $jsFiles = array();
290 290
         getFiles($jsFiles, sugar_cached('jsLanguage'));
291
-        foreach($jsFiles as $file) {
291
+        foreach ($jsFiles as $file) {
292 292
             unlink($file);
293 293
         }
294 294
 
295
-        if( empty($GLOBALS['sugar_config']['js_lang_version']) )
295
+        if (empty($GLOBALS['sugar_config']['js_lang_version']))
296 296
             $GLOBALS['sugar_config']['js_lang_version'] = 1;
297 297
         else
298 298
             $GLOBALS['sugar_config']['js_lang_version'] += 1;
299 299
 
300
-        write_array_to_file( "sugar_config", $GLOBALS['sugar_config'], "config.php");
300
+        write_array_to_file("sugar_config", $GLOBALS['sugar_config'], "config.php");
301 301
     }
302 302
 }
303 303
 
304
-function translated_prefix($key){
305
-	return '[translated]' . $key;
304
+function translated_prefix($key) {
305
+	return '[translated]'.$key;
306 306
 }
Please login to merge, or discard this patch.
include/SugarObjects/templates/basic/vardefs.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
  ********************************************************************************/
39 39
 
40 40
 $vardefs = array(  
41
-'fields' => array (
41
+'fields' => array(
42 42
 	  'id' =>
43
-	  array (
43
+	  array(
44 44
 	    'name' => 'id',
45 45
 	    'vname' => 'LBL_ID',
46 46
 	    'type' => 'id',
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         'merge_filter' => 'selected',
67 67
 	    ),
68 68
 	  'date_entered' =>
69
-	  array (
69
+	  array(
70 70
 	    'name' => 'date_entered',
71 71
 	    'vname' => 'LBL_DATE_ENTERED',
72 72
 	    'type' => 'datetime',
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		'inline_edit' => false,
78 78
 	  ),
79 79
 	  'date_modified' =>
80
-	  array (
80
+	  array(
81 81
 	    'name' => 'date_modified',
82 82
 	    'vname' => 'LBL_DATE_MODIFIED',
83 83
 	    'type' => 'datetime',
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		'inline_edit' => false,
89 89
 	  ),
90 90
 		'modified_user_id' =>
91
-	  array (
91
+	  array(
92 92
 	    'name' => 'modified_user_id',
93 93
 	    'rname' => 'user_name',
94 94
 	    'id_name' => 'modified_user_id',
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		'inline_edit' => false,
105 105
 	  ),
106 106
 	  'modified_by_name' => 
107
-	  array (
107
+	  array(
108 108
 	    'name' => 'modified_by_name',
109 109
 	    'vname' => 'LBL_MODIFIED_NAME',
110 110
 	    'type' => 'relate',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		'inline_edit' => false,
121 121
 	  ),  
122 122
 	  'created_by' =>
123
-	  array (
123
+	  array(
124 124
 	    'name' => 'created_by',
125 125
 	    'rname' => 'user_name',
126 126
 	    'id_name' => 'modified_user_id',
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		'inline_edit' => false,
136 136
 	  ),
137 137
 	  'created_by_name' =>
138
-	  array (
138
+	  array(
139 139
 	    'name' => 'created_by_name',
140 140
 		'vname' => 'LBL_CREATED',
141 141
 		'type' => 'relate',
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		'inline_edit' => false,
153 153
 	),
154 154
 	  'description' =>
155
-	  array (
155
+	  array(
156 156
 	    'name' => 'description',
157 157
 	    'vname' => 'LBL_DESCRIPTION',
158 158
 	    'type' => 'text',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	    'cols' => 80,
162 162
 	  ),
163 163
 	  'deleted' =>
164
-	  array (
164
+	  array(
165 165
 	    'name' => 'deleted',
166 166
 	    'vname' => 'LBL_DELETED',
167 167
 	    'type' => 'bool',
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	    
173 173
 /////////////////RELATIONSHIP LINKS////////////////////////////
174 174
 	  'created_by_link' =>
175
-  array (
175
+  array(
176 176
      'name' => 'created_by_link',
177 177
     'type' => 'link',
178
-    'relationship' => strtolower($module) . '_created_by',
178
+    'relationship' => strtolower($module).'_created_by',
179 179
     'vname' => 'LBL_CREATED_USER',
180 180
     'link_type' => 'one',
181 181
     'module'=>'Users',
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
     'source'=>'non-db',
184 184
   ),
185 185
   'modified_user_link' =>
186
-  array (
186
+  array(
187 187
         'name' => 'modified_user_link',
188 188
     'type' => 'link',
189
-    'relationship' => strtolower($module). '_modified_user',
189
+    'relationship' => strtolower($module).'_modified_user',
190 190
     'vname' => 'LBL_MODIFIED_USER',
191 191
     'link_type' => 'one',
192 192
     'module'=>'Users',
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
   ),
196 196
 
197 197
 ),
198
-'indices' => array (
198
+'indices' => array(
199 199
        'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')),
200 200
        ),
201 201
 'relationships'=>array(
Please login to merge, or discard this patch.
include/database/SqlsrvManager.php 1 patch
Spacing   +57 added lines, -57 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.
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
                     "ReturnDatesAsStrings" => true,
176 176
                     "MultipleActiveResultSets" => true,
177 177
                     );
178
-        if(!empty($configOptions['db_name'])) {
178
+        if (!empty($configOptions['db_name'])) {
179 179
             $options["Database"] = $configOptions['db_name'];
180 180
         }
181 181
         $this->database = sqlsrv_connect($connect_param, $options);
182
-        if(empty($this->database)) {
182
+        if (empty($this->database)) {
183 183
             $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].".");
184
-            if($dieOnError) {
185
-                    if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
184
+            if ($dieOnError) {
185
+                    if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
186 186
                         sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
187 187
                     } else {
188 188
                         sugar_die("Could not connect to the database. Please refer to suitecrm.log for details.");
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
 
195
-        if($this->checkError('Could Not Connect:', $dieOnError))
195
+        if ($this->checkError('Could Not Connect:', $dieOnError))
196 196
             $GLOBALS['log']->info("connected to db");
197 197
 
198 198
         sqlsrv_query($this->database, 'SET DATEFORMAT mdy');
@@ -208,26 +208,26 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false)
210 210
     {
211
-        if(is_array($sql)) {
211
+        if (is_array($sql)) {
212 212
             return $this->queryArray($sql, $dieOnError, $msg, $suppress);
213 213
         }
214 214
         $sql = $this->_appendN($sql);
215 215
 
216 216
         $this->countQuery($sql);
217
-        $GLOBALS['log']->info('Query:' . $sql);
217
+        $GLOBALS['log']->info('Query:'.$sql);
218 218
         $this->checkConnection();
219 219
         $this->query_time = microtime(true);
220 220
 
221
-        $result = $suppress?@sqlsrv_query($this->database, $sql):sqlsrv_query($this->database, $sql);
221
+        $result = $suppress ? @sqlsrv_query($this->database, $sql) : sqlsrv_query($this->database, $sql);
222 222
 
223 223
         $this->query_time = microtime(true) - $this->query_time;
224 224
         $GLOBALS['log']->info('Query Execution Time:'.$this->query_time);
225 225
 
226 226
 
227
-        $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError);
227
+        $this->checkError($msg.' Query Failed:'.$sql.'::', $dieOnError);
228 228
 
229 229
         //suppress non error messages
230
-        sqlsrv_configure('WarningsReturnAsErrors',false);
230
+        sqlsrv_configure('WarningsReturnAsErrors', false);
231 231
 
232 232
         return $result;
233 233
     }
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 	{
240 240
         $field_array = array();
241 241
 
242
-        if ( !$result ) {
242
+        if (!$result) {
243 243
         	return false;
244 244
         }
245 245
 
246
-        foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) {
246
+        foreach (sqlsrv_field_metadata($result) as $fieldMetadata) {
247 247
             $key = $fieldMetadata['Name'];
248
-            if($make_lower_case==true)
248
+            if ($make_lower_case == true)
249 249
                 $key = strtolower($key);
250 250
 
251 251
             $field_array[] = $key;
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
 	{
262 262
 		if (empty($result))	return false;
263 263
 
264
-	    $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC);
264
+	    $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
265 265
         if (empty($row)) {
266 266
             return false;
267 267
         }
268 268
 
269
-        foreach($row as $key => $column) {
269
+        foreach ($row as $key => $column) {
270 270
             // MSSQL returns a space " " when a varchar column is empty ("") and not null.
271 271
             // We need to strip empty spaces
272 272
             // notice we only strip if one space is returned.  we do not want to strip
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function convert($string, $type, array $additional_parameters = array())
286 286
     {
287
-        if ( $type == 'datetime')
287
+        if ($type == 'datetime')
288 288
         // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details
289 289
             return "CONVERT(datetime,$string,120)";
290 290
         else
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
      * @param  array  $fielddef2
301 301
      * @return bool   true if they match, false if they don't
302 302
      */
303
-    public function compareVarDefs($fielddef1,$fielddef2, $ignoreName = false)
303
+    public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false)
304 304
     {
305
-        if((isset($fielddef2['dbType']) && $fielddef2['dbType'] == 'id') || preg_match('/(_id$|^id$)/', $fielddef2['name'])){
306
-            if(isset($fielddef1['type']) && isset($fielddef2['type'])){
305
+        if ((isset($fielddef2['dbType']) && $fielddef2['dbType'] == 'id') || preg_match('/(_id$|^id$)/', $fielddef2['name'])) {
306
+            if (isset($fielddef1['type']) && isset($fielddef2['type'])) {
307 307
                 $fielddef2['type'] = $fielddef1['type'];
308 308
             }
309 309
         }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     public function disconnect()
319 319
     {
320 320
     	$GLOBALS['log']->debug('Calling Mssql::disconnect()');
321
-        if(!empty($this->database)){
321
+        if (!empty($this->database)) {
322 322
             $this->freeResult();
323 323
             sqlsrv_close($this->database);
324 324
             $this->database = null;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      */
331 331
     protected function freeDbResult($dbResult)
332 332
     {
333
-        if(!empty($dbResult))
333
+        if (!empty($dbResult))
334 334
             sqlsrv_free_stmt($dbResult);
335 335
     }
336 336
 
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function getConstraintSql($indices, $table)
344 344
     {
345
-        if ( $this->doesTableHaveAClusteredIndexDefined($table) ) {
345
+        if ($this->doesTableHaveAClusteredIndexDefined($table)) {
346 346
             return parent::getConstraintSql($indices, $table);
347 347
         }
348 348
 
349 349
         // check to see if one of the passed in indices is a primary one; if so we can bail as well
350
-        foreach ( $indices as $index ) {
351
-            if ( $index['type'] == 'primary' ) {
350
+        foreach ($indices as $index) {
351
+            if ($index['type'] == 'primary') {
352 352
                 return parent::getConstraintSql($indices, $table);
353 353
             }
354 354
         }
355 355
 
356 356
         // Change the first index listed to be a clustered one instead ( so we have at least one for the table )
357
-        if ( isset($indices[0]) ) {
357
+        if (isset($indices[0])) {
358 358
             $indices[0]['type'] = 'clustered';
359 359
         }
360 360
 
@@ -370,41 +370,41 @@  discard block
 block discarded – undo
370 370
         $result = $this->query("sp_columns_90 $tablename");
371 371
 
372 372
         $columns = array();
373
-        while (($row=$this->fetchByAssoc($result)) !=null) {
373
+        while (($row = $this->fetchByAssoc($result)) != null) {
374 374
             $column_name = strtolower($row['COLUMN_NAME']);
375
-            $columns[$column_name]['name']=$column_name;
376
-            $columns[$column_name]['type']=strtolower($row['TYPE_NAME']);
377
-            if ( $row['TYPE_NAME'] == 'decimal' ) {
378
-                $columns[$column_name]['len']=strtolower($row['PRECISION']);
379
-                $columns[$column_name]['len'].=','.strtolower($row['SCALE']);
375
+            $columns[$column_name]['name'] = $column_name;
376
+            $columns[$column_name]['type'] = strtolower($row['TYPE_NAME']);
377
+            if ($row['TYPE_NAME'] == 'decimal') {
378
+                $columns[$column_name]['len'] = strtolower($row['PRECISION']);
379
+                $columns[$column_name]['len'] .= ','.strtolower($row['SCALE']);
380 380
             }
381
-			elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) {
382
-				$columns[$column_name]['len']=strtolower($row['PRECISION']);
383
-				if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) {
384
-				    $columns[$column_name]['len']='max';
381
+			elseif (in_array($row['TYPE_NAME'], array('nchar', 'nvarchar'))) {
382
+				$columns[$column_name]['len'] = strtolower($row['PRECISION']);
383
+				if ($row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0') {
384
+				    $columns[$column_name]['len'] = 'max';
385 385
 				}
386 386
 			}
387
-            elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) {
388
-                $columns[$column_name]['len']=strtolower($row['LENGTH']);
387
+            elseif (!in_array($row['TYPE_NAME'], array('datetime', 'text'))) {
388
+                $columns[$column_name]['len'] = strtolower($row['LENGTH']);
389 389
             }
390
-            if ( stristr($row['TYPE_NAME'],'identity') ) {
390
+            if (stristr($row['TYPE_NAME'], 'identity')) {
391 391
                 $columns[$column_name]['auto_increment'] = '1';
392
-                $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME']));
392
+                $columns[$column_name]['type'] = str_replace(' identity', '', strtolower($row['TYPE_NAME']));
393 393
             }
394 394
 
395
-            if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI')))
395
+            if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'], 'PRI')))
396 396
                 $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true';
397 397
 
398 398
             $column_def = 1;
399
-            if ( strtolower($tablename) == 'relationships' ) {
399
+            if (strtolower($tablename) == 'relationships') {
400 400
                 $column_def = $this->getOne("select cdefault from syscolumns where id = object_id('relationships') and name = '$column_name'");
401 401
             }
402
-            if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) {	// NOTE Not using !empty as an empty string may be a viable default value.
402
+            if ($column_def != 0 && ($row['COLUMN_DEF'] != null)) {	// NOTE Not using !empty as an empty string may be a viable default value.
403 403
                 $matches = array();
404
-                $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES);
405
-                if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) )
404
+                $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'], ENT_QUOTES);
405
+                if (preg_match('/\([\(|\'](.*)[\)|\']\)/i', $row['COLUMN_DEF'], $matches))
406 406
                     $columns[$column_name]['default'] = $matches[1];
407
-                elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) )
407
+                elseif (preg_match('/\(N\'(.*)\'\)/i', $row['COLUMN_DEF'], $matches))
408 408
                     $columns[$column_name]['default'] = $matches[1];
409 409
                 else
410 410
                     $columns[$column_name]['default'] = $row['COLUMN_DEF'];
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 EOSQL;
431 431
 
432 432
         $result = $this->getOne($query);
433
-        if ( !$result ) {
433
+        if (!$result) {
434 434
             return false;
435 435
         }
436 436
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 EOSQL;
454 454
 
455 455
         $result = $this->getOne($query);
456
-        if ( !$result ) {
456
+        if (!$result) {
457 457
             return false;
458 458
         }
459 459
 
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
      * @see DBManager::changeColumnSQL()
467 467
      * @see MssqlHelper::changeColumnSQL()
468 468
      */
469
-    protected function changeColumnSQL($tablename,$fieldDefs, $action, $ignoreRequired = false)
469
+    protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false)
470 470
     {
471 471
         $sql = '';
472
-        if ( $action == 'drop' && $this->doesTableHaveAFulltextIndexDefined($tablename) ) {
472
+        if ($action == 'drop' && $this->doesTableHaveAFulltextIndexDefined($tablename)) {
473 473
             $sql .= "DROP FULLTEXT INDEX ON {$tablename}";
474 474
         }
475 475
 
@@ -495,33 +495,33 @@  discard block
 block discarded – undo
495 495
     public function lastDbError()
496 496
     {
497 497
         $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
498
-        if(empty($errors)) return false;
498
+        if (empty($errors)) return false;
499 499
         global $app_strings;
500 500
         if (empty($app_strings)
501 501
 		    or !isset($app_strings['ERR_MSSQL_DB_CONTEXT'])
502
-			or !isset($app_strings['ERR_MSSQL_WARNING']) ) {
502
+			or !isset($app_strings['ERR_MSSQL_WARNING'])) {
503 503
         //ignore the message from sql-server if $app_strings array is empty. This will happen
504 504
         //only if connection if made before languge is set.
505 505
 		    return false;
506 506
         }
507 507
         $messages = array();
508
-        foreach($errors as $error) {
508
+        foreach ($errors as $error) {
509 509
             $sqlmsg = $error['message'];
510 510
             $sqlpos = strpos($sqlmsg, 'Changed database context to');
511 511
             $sqlpos2 = strpos($sqlmsg, 'Warning:');
512 512
             $sqlpos3 = strpos($sqlmsg, 'Checking identity information:');
513
-            if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) {
513
+            if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) {
514 514
                 continue;
515 515
             }
516 516
             $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']);
517 517
             $sqlpos2 = strpos($sqlmsg, $app_strings['ERR_MSSQL_WARNING']);
518
-    		if ( $sqlpos !== false || $sqlpos2 !== false) {
518
+    		if ($sqlpos !== false || $sqlpos2 !== false) {
519 519
                     continue;
520 520
             }
521 521
             $messages[] = $sqlmsg;
522 522
         }
523 523
 
524
-        if(!empty($messages)) {
524
+        if (!empty($messages)) {
525 525
             return join("\n", $messages);
526 526
         }
527 527
         return false;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     protected function verifyGenericQueryRollback($type, $table, $query)
549 549
     {
550 550
         $this->log->debug("verifying $type statement");
551
-        if(!sqlsrv_begin_transaction($this->database)) {
551
+        if (!sqlsrv_begin_transaction($this->database)) {
552 552
             return "Failed to create transaction";
553 553
         }
554 554
         $this->query($query, false);
Please login to merge, or discard this patch.
include/database/MysqlManager.php 1 patch
Spacing   +140 added lines, -140 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.
@@ -170,25 +170,25 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false)
172 172
 	{
173
-		if(is_array($sql)) {
173
+		if (is_array($sql)) {
174 174
 			return $this->queryArray($sql, $dieOnError, $msg, $suppress);
175 175
 		}
176 176
 
177 177
 		parent::countQuery($sql);
178
-		$GLOBALS['log']->info('Query:' . $sql);
178
+		$GLOBALS['log']->info('Query:'.$sql);
179 179
 		$this->checkConnection();
180 180
 		$this->query_time = microtime(true);
181 181
 		$this->lastsql = $sql;
182
-		$result = $suppress?@mysql_query($sql, $this->database):mysql_query($sql, $this->database);
182
+		$result = $suppress ? @mysql_query($sql, $this->database) : mysql_query($sql, $this->database);
183 183
 
184 184
 		$this->query_time = microtime(true) - $this->query_time;
185 185
 		$GLOBALS['log']->info('Query Execution Time:'.$this->query_time);
186 186
 
187 187
 
188
-		if($keepResult)
188
+		if ($keepResult)
189 189
 			$this->lastResult = $result;
190 190
 
191
-		$this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError);
191
+		$this->checkError($msg.' Query Failed:'.$sql.'::', $dieOnError);
192 192
 		return $result;
193 193
 	}
194 194
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	public function disconnect()
225 225
 	{
226 226
 		$GLOBALS['log']->debug('Calling MySQL::disconnect()');
227
-		if(!empty($this->database)){
227
+		if (!empty($this->database)) {
228 228
 			$this->freeResult();
229 229
 			mysql_close($this->database);
230 230
 			$this->database = null;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	protected function freeDbResult($dbResult)
238 238
 	{
239
-		if(!empty($dbResult))
239
+		if (!empty($dbResult))
240 240
 			mysql_free_result($dbResult);
241 241
 	}
242 242
 
@@ -262,15 +262,15 @@  discard block
 block discarded – undo
262 262
         $count = (int)$count;
263 263
 	    if ($start < 0)
264 264
 			$start = 0;
265
-		$GLOBALS['log']->debug('Limit Query:' . $sql. ' Start: ' .$start . ' count: ' . $count);
265
+		$GLOBALS['log']->debug('Limit Query:'.$sql.' Start: '.$start.' count: '.$count);
266 266
 
267 267
 	    $sql = "$sql LIMIT $start,$count";
268 268
 		$this->lastsql = $sql;
269 269
 
270
-		if(!empty($GLOBALS['sugar_config']['check_query'])){
270
+		if (!empty($GLOBALS['sugar_config']['check_query'])) {
271 271
 			$this->checkQuery($sql);
272 272
 		}
273
-		if(!$execute) {
273
+		if (!$execute) {
274 274
 			return $sql;
275 275
 		}
276 276
 
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	protected function checkQuery($sql, $object_name = false)
285 285
 	{
286
-		$result   = $this->query('EXPLAIN ' . $sql);
286
+		$result   = $this->query('EXPLAIN '.$sql);
287 287
 		$badQuery = array();
288 288
 		while ($row = $this->fetchByAssoc($result)) {
289 289
 			if (empty($row['table']))
290 290
 				continue;
291 291
 			$badQuery[$row['table']] = '';
292 292
 			if (strtoupper($row['type']) == 'ALL')
293
-				$badQuery[$row['table']]  .=  ' Full Table Scan;';
293
+				$badQuery[$row['table']] .= ' Full Table Scan;';
294 294
 			if (empty($row['key']))
295 295
 				$badQuery[$row['table']] .= ' No Index Key Used;';
296 296
 			if (!empty($row['Extra']) && substr_count($row['Extra'], 'Using filesort') > 0)
@@ -299,18 +299,18 @@  discard block
 block discarded – undo
299 299
 				$badQuery[$row['table']] .= ' Using Temporary Table;';
300 300
 		}
301 301
 
302
-		if ( empty($badQuery) )
302
+		if (empty($badQuery))
303 303
 			return true;
304 304
 
305
-		foreach($badQuery as $table=>$data ){
306
-			if(!empty($data)){
307
-				$warning = ' Table:' . $table . ' Data:' . $data;
308
-				if(!empty($GLOBALS['sugar_config']['check_query_log'])){
305
+		foreach ($badQuery as $table=>$data) {
306
+			if (!empty($data)) {
307
+				$warning = ' Table:'.$table.' Data:'.$data;
308
+				if (!empty($GLOBALS['sugar_config']['check_query_log'])) {
309 309
 					$GLOBALS['log']->fatal($sql);
310
-					$GLOBALS['log']->fatal('CHECK QUERY:' .$warning);
310
+					$GLOBALS['log']->fatal('CHECK QUERY:'.$warning);
311 311
 				}
312
-				else{
313
-					$GLOBALS['log']->warn('CHECK QUERY:' .$warning);
312
+				else {
313
+					$GLOBALS['log']->warn('CHECK QUERY:'.$warning);
314 314
 				}
315 315
 			}
316 316
 		}
@@ -327,19 +327,19 @@  discard block
 block discarded – undo
327 327
 		$result = $this->query("DESCRIBE $tablename");
328 328
 
329 329
 		$columns = array();
330
-		while (($row=$this->fetchByAssoc($result)) !=null) {
330
+		while (($row = $this->fetchByAssoc($result)) != null) {
331 331
 			$name = strtolower($row['Field']);
332
-			$columns[$name]['name']=$name;
332
+			$columns[$name]['name'] = $name;
333 333
 			$matches = array();
334 334
 			preg_match_all('/(\w+)(?:\(([0-9]+,?[0-9]*)\)|)( unsigned)?/i', $row['Type'], $matches);
335
-			$columns[$name]['type']=strtolower($matches[1][0]);
336
-			if ( isset($matches[2][0]) && in_array(strtolower($matches[1][0]),array('varchar','char','varchar2','int','decimal','float')) )
337
-				$columns[$name]['len']=strtolower($matches[2][0]);
338
-			if ( stristr($row['Extra'],'auto_increment') )
335
+			$columns[$name]['type'] = strtolower($matches[1][0]);
336
+			if (isset($matches[2][0]) && in_array(strtolower($matches[1][0]), array('varchar', 'char', 'varchar2', 'int', 'decimal', 'float')))
337
+				$columns[$name]['len'] = strtolower($matches[2][0]);
338
+			if (stristr($row['Extra'], 'auto_increment'))
339 339
 				$columns[$name]['auto_increment'] = '1';
340
-			if ($row['Null'] == 'NO' && !stristr($row['Key'],'PRI'))
340
+			if ($row['Null'] == 'NO' && !stristr($row['Key'], 'PRI'))
341 341
 				$columns[$name]['required'] = 'true';
342
-			if (!empty($row['Default']) )
342
+			if (!empty($row['Default']))
343 343
 				$columns[$name]['default'] = $row['Default'];
344 344
 		}
345 345
 		return $columns;
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 	/**
349 349
 	 * @see DBManager::getFieldsArray()
350 350
 	 */
351
-	public function getFieldsArray($result, $make_lower_case=false)
351
+	public function getFieldsArray($result, $make_lower_case = false)
352 352
 	{
353 353
 		$field_array = array();
354 354
 
355
-		if(empty($result))
355
+		if (empty($result))
356 356
 			return 0;
357 357
 
358 358
 		$fields = mysql_num_fields($result);
359
-		for ($i=0; $i < $fields; $i++) {
359
+		for ($i = 0; $i < $fields; $i++) {
360 360
 			$meta = mysql_fetch_field($result, $i);
361 361
 			if (!$meta)
362 362
 				return array();
363 363
 
364
-			if($make_lower_case == true)
364
+			if ($make_lower_case == true)
365 365
 				$meta->name = strtolower($meta->name);
366 366
 
367 367
 			$field_array[] = $meta->name;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			if (!empty($r)) {
394 394
 				while ($a = $this->fetchByAssoc($r)) {
395 395
 					$row = array_values($a);
396
-					$tables[]=$row[0];
396
+					$tables[] = $row[0];
397 397
 				}
398 398
 				return $tables;
399 399
 			}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 		if ($this->getDatabase()) {
421 421
 			$result = $this->query("SHOW TABLES LIKE ".$this->quoted($tableName));
422
-			if(empty($result)) return false;
422
+			if (empty($result)) return false;
423 423
 			$row = $this->fetchByAssoc($result);
424 424
 			return !empty($row);
425 425
 		}
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 			if (!empty($r)) {
441 441
 				while ($a = $this->fetchByAssoc($r)) {
442 442
 					$row = array_values($a);
443
-					$tables[]=$row[0];
443
+					$tables[] = $row[0];
444 444
 				}
445 445
 				return $tables;
446 446
 			}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 */
454 454
 	public function quote($string)
455 455
 	{
456
-		if(is_array($string)) {
456
+		if (is_array($string)) {
457 457
 			return $this->arrayQuote($string);
458 458
 		}
459 459
 		return mysql_real_escape_string($this->quoteInternal($string), $this->getDatabase());
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	{
475 475
 		global $sugar_config;
476 476
 
477
-		if(is_null($configOptions))
477
+		if (is_null($configOptions))
478 478
 			$configOptions = $sugar_config['dbconfig'];
479 479
 
480 480
 		if ($this->getOption('persistent')) {
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 					$configOptions['db_user_name'],
492 492
 					$configOptions['db_password']
493 493
 					);
494
-			if(empty($this->database)) {
494
+			if (empty($this->database)) {
495 495
 				$GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name'].":".mysql_error());
496
-				if($dieOnError) {
497
-					if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
496
+				if ($dieOnError) {
497
+					if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) {
498 498
 						sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
499 499
 					} else {
500 500
 						sugar_die("Could not connect to the database. Please refer to suitecrm.log for details.");
@@ -504,15 +504,15 @@  discard block
 block discarded – undo
504 504
 				}
505 505
 			}
506 506
 			// Do not pass connection information because we have not connected yet
507
-			if($this->database  && $this->getOption('persistent')){
507
+			if ($this->database && $this->getOption('persistent')) {
508 508
 				$_SESSION['administrator_error'] = "<b>Severe Performance Degradation: Persistent Database Connections "
509 509
 					. "not working.  Please set \$sugar_config['dbconfigoption']['persistent'] to false "
510 510
 					. "in your config.php file</b>";
511 511
 			}
512 512
 		}
513
-		if(!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) {
514
-			$GLOBALS['log']->fatal( "Unable to select database {$configOptions['db_name']}: " . mysql_error($this->database));
515
-			if($dieOnError) {
513
+		if (!empty($configOptions['db_name']) && !@mysql_select_db($configOptions['db_name'])) {
514
+			$GLOBALS['log']->fatal("Unable to select database {$configOptions['db_name']}: ".mysql_error($this->database));
515
+			if ($dieOnError) {
516 516
 				sugar_die($GLOBALS['app_strings']['ERR_NO_DB']);
517 517
 			} else {
518 518
 				return false;
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 	    mysql_query("SET CHARACTER SET utf8", $this->database);
524 524
 	    $names = "SET NAMES 'utf8'";
525 525
 	    $collation = $this->getOption('collation');
526
-	    if(!empty($collation)) {
526
+	    if (!empty($collation)) {
527 527
 	        $names .= " COLLATE '$collation'";
528 528
 		}
529 529
 	    mysql_query($names, $this->database);
530 530
 
531
-		if(!$this->checkError('Could Not Connect:', $dieOnError))
531
+		if (!$this->checkError('Could Not Connect:', $dieOnError))
532 532
 			$GLOBALS['log']->info("connected to db");
533 533
 		$this->connectOptions = $configOptions;
534 534
 
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
 	public function repairTableParams($tablename, $fielddefs, $indices, $execute = true, $engine = null)
546 546
 	{
547
-		$sql = parent::repairTableParams($tablename,$fielddefs,$indices,false,$engine);
547
+		$sql = parent::repairTableParams($tablename, $fielddefs, $indices, false, $engine);
548 548
 
549
-		if ( $sql == '' )
549
+		if ($sql == '')
550 550
 			return '';
551 551
 
552
-		if ( stristr($sql,'create table') )
552
+		if (stristr($sql, 'create table'))
553 553
 		{
554 554
 			if ($execute) {
555
-				$msg = "Error creating table: ".$tablename. ":";
556
-				$this->query($sql,true,$msg);
555
+				$msg = "Error creating table: ".$tablename.":";
556
+				$this->query($sql, true, $msg);
557 557
 			}
558 558
 			return $sql;
559 559
 		}
@@ -562,23 +562,23 @@  discard block
 block discarded – undo
562 562
 		$match = array();
563 563
 		preg_match_all('!/\*.*?\*/!is', $sql, $match);
564 564
 		$commentBlocks = $match[0];
565
-		$sql = preg_replace('!/\*.*?\*/!is','', $sql);
565
+		$sql = preg_replace('!/\*.*?\*/!is', '', $sql);
566 566
 
567 567
 		// now, we should only have alter table statements
568 568
 		// let's replace the 'alter table name' part with a comma
569
-		$sql = preg_replace("!alter table $tablename!is",', ', $sql);
569
+		$sql = preg_replace("!alter table $tablename!is", ', ', $sql);
570 570
 
571 571
 		// re-add it at the beginning
572
-		$sql = substr_replace($sql,'',strpos($sql,','),1);
573
-		$sql = str_replace(";","",$sql);
574
-		$sql = str_replace("\n","",$sql);
572
+		$sql = substr_replace($sql, '', strpos($sql, ','), 1);
573
+		$sql = str_replace(";", "", $sql);
574
+		$sql = str_replace("\n", "", $sql);
575 575
 		$sql = "ALTER TABLE $tablename $sql";
576 576
 
577
-		if ( $execute )
578
-			$this->query($sql,'Error with MySQL repair table');
577
+		if ($execute)
578
+			$this->query($sql, 'Error with MySQL repair table');
579 579
 
580 580
 		// and re-add the comments at the beginning
581
-		$sql = implode("\n",$commentBlocks) . "\n". $sql . "\n";
581
+		$sql = implode("\n", $commentBlocks)."\n".$sql."\n";
582 582
 
583 583
 		return $sql;
584 584
 	}
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	public function convert($string, $type, array $additional_parameters = array())
590 590
 	{
591 591
 		$all_parameters = $additional_parameters;
592
-		if(is_array($string)) {
592
+		if (is_array($string)) {
593 593
 			$all_parameters = array_merge($string, $all_parameters);
594 594
 		} elseif (!is_null($string)) {
595 595
 			array_unshift($all_parameters, $string);
@@ -602,17 +602,17 @@  discard block
 block discarded – undo
602 602
 			case 'left':
603 603
 				return "LEFT($all_strings)";
604 604
 			case 'date_format':
605
-				if(empty($additional_parameters)) {
605
+				if (empty($additional_parameters)) {
606 606
 					return "DATE_FORMAT($string,'%Y-%m-%d')";
607 607
 				} else {
608 608
 					$format = $additional_parameters[0];
609
-					if($format[0] != "'") {
609
+					if ($format[0] != "'") {
610 610
 						$format = $this->quoted($format);
611 611
 					}
612 612
 					return "DATE_FORMAT($string,$format)";
613 613
 				}
614 614
 			case 'ifnull':
615
-				if(empty($additional_parameters) && !strstr($all_strings, ",")) {
615
+				if (empty($additional_parameters) && !strstr($all_strings, ",")) {
616 616
 					$all_strings .= ",''";
617 617
 				}
618 618
 				return "IFNULL($all_strings)";
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             case 'add_tz_offset' :
632 632
                 $getUserUTCOffset = $GLOBALS['timedate']->getUserUTCOffset();
633 633
                 $operation = $getUserUTCOffset < 0 ? '-' : '+';
634
-                return $string . ' ' . $operation . ' INTERVAL ' . abs($getUserUTCOffset) . ' MINUTE';
634
+                return $string.' '.$operation.' INTERVAL '.abs($getUserUTCOffset).' MINUTE';
635 635
             case 'avg':
636 636
                 return "avg($string)";
637 637
 		}
@@ -672,15 +672,15 @@  discard block
 block discarded – undo
672 672
 	 */
673 673
 	protected function isEngineEnabled($engine)
674 674
 	{
675
-		if(!is_string($engine)) return false;
675
+		if (!is_string($engine)) return false;
676 676
 
677 677
 		$engine = strtoupper($engine);
678 678
 
679 679
 		$r = $this->query("SHOW ENGINES");
680 680
 
681
-		while ( $row = $this->fetchByAssoc($r) )
682
-			if ( strtoupper($row['Engine']) == $engine )
683
-				return ($row['Support']=='YES' || $row['Support']=='DEFAULT');
681
+		while ($row = $this->fetchByAssoc($r))
682
+			if (strtoupper($row['Engine']) == $engine)
683
+				return ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT');
684 684
 
685 685
 		return false;
686 686
 	}
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
 	*/
709 709
 	public function createTableSQLParams($tablename, $fieldDefs, $indices, $engine = null)
710 710
 	{
711
-		if ( empty($engine) && isset($fieldDefs['engine']))
711
+		if (empty($engine) && isset($fieldDefs['engine']))
712 712
 			$engine = $fieldDefs['engine'];
713
-		if ( !$this->isEngineEnabled($engine) )
713
+		if (!$this->isEngineEnabled($engine))
714 714
 			$engine = '';
715 715
 
716 716
 		$columns = $this->columnSQLRep($fieldDefs, false, $tablename);
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 
724 724
 		// cn: bug 9873 - module tables do not get created in utf8 with assoc collation
725 725
 		$collation = $this->getOption('collation');
726
-		if(empty($collation)) {
726
+		if (empty($collation)) {
727 727
 		    $collation = 'utf8_general_ci';
728 728
 		}
729 729
 		$sql = "CREATE TABLE $tablename ($columns $keys) CHARACTER SET utf8 COLLATE $collation";
730 730
 
731 731
 		if (!empty($engine))
732
-			$sql.= " ENGINE=$engine";
732
+			$sql .= " ENGINE=$engine";
733 733
 
734 734
 		return $sql;
735 735
 	}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
     public function isTextType($type)
742 742
     {
743 743
         $type = $this->getColumnType(strtolower($type));
744
-        return in_array($type, array('blob','text','longblob', 'longtext'));
744
+        return in_array($type, array('blob', 'text', 'longblob', 'longtext'));
745 745
     }
746 746
 
747 747
 	/**
@@ -752,16 +752,16 @@  discard block
 block discarded – undo
752 752
 		// always return as array for post-processing
753 753
 		$ref = parent::oneColumnSQLRep($fieldDef, $ignoreRequired, $table, true);
754 754
 
755
-		if ( $ref['colType'] == 'int' && !empty($fieldDef['len']) ) {
755
+		if ($ref['colType'] == 'int' && !empty($fieldDef['len'])) {
756 756
 			$ref['colType'] .= "(".$fieldDef['len'].")";
757 757
 		}
758 758
 
759 759
 		// bug 22338 - don't set a default value on text or blob fields
760
-		if ( isset($ref['default']) &&
760
+		if (isset($ref['default']) &&
761 761
             in_array($ref['colBaseType'], array('text', 'blob', 'longtext', 'longblob')))
762 762
 			    $ref['default'] = '';
763 763
 
764
-		if ( $return_as_array )
764
+		if ($return_as_array)
765 765
 			return $ref;
766 766
 		else
767 767
 			return "{$ref['name']} {$ref['colType']} {$ref['default']} {$ref['required']} {$ref['auto_increment']}";
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false)
774 774
 	{
775 775
 		$columns = array();
776
-		if ($this->isFieldArray($fieldDefs)){
777
-			foreach ($fieldDefs as $def){
776
+		if ($this->isFieldArray($fieldDefs)) {
777
+			foreach ($fieldDefs as $def) {
778 778
 				if ($action == 'drop')
779 779
 					$columns[] = $def['name'];
780 780
 				else
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 
812 812
 	$columns = array();
813 813
 	foreach ($indices as $index) {
814
-		if(!empty($index['db']) && $index['db'] != $this->dbType)
814
+		if (!empty($index['db']) && $index['db'] != $this->dbType)
815 815
 			continue;
816 816
 		if (isset($index['source']) && $index['source'] != 'db')
817 817
 			continue;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 				* that this can easily be fixed by referring to db dictionary
842 842
 				* to find the correct primary field name
843 843
 				*/
844
-			if ( $alter_table )
844
+			if ($alter_table)
845 845
 				$columns[] = " INDEX $name ($fields)";
846 846
 			else
847 847
 				$columns[] = " KEY $name ($fields)";
@@ -850,13 +850,13 @@  discard block
 block discarded – undo
850 850
 			if ($this->full_text_indexing_installed())
851 851
 				$columns[] = " FULLTEXT ($fields)";
852 852
 			else
853
-				$GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:',$name);
853
+				$GLOBALS['log']->debug('MYISAM engine is not available/enabled, full-text indexes will be skipped. Skipping:', $name);
854 854
 			break;
855 855
 		}
856 856
 	}
857 857
 	$columns = implode(", $alter_action ", $columns);
858
-	if(!empty($alter_action)){
859
-		$columns = $alter_action . ' '. $columns;
858
+	if (!empty($alter_action)) {
859
+		$columns = $alter_action.' '.$columns;
860 860
 	}
861 861
 	return $columns;
862 862
 	}
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 	public function setAutoIncrementStart($table, $field_name, $start_value)
879 879
 	{
880 880
 		$start_value = (int)$start_value;
881
-		return $this->query( "ALTER TABLE $table AUTO_INCREMENT = $start_value;");
881
+		return $this->query("ALTER TABLE $table AUTO_INCREMENT = $start_value;");
882 882
 	}
883 883
 
884 884
 	/**
@@ -907,18 +907,18 @@  discard block
 block discarded – undo
907 907
 		$result = $this->query("SHOW INDEX FROM $tablename");
908 908
 
909 909
 		$indices = array();
910
-		while (($row=$this->fetchByAssoc($result)) !=null) {
911
-			$index_type='index';
912
-			if ($row['Key_name'] =='PRIMARY') {
913
-				$index_type='primary';
910
+		while (($row = $this->fetchByAssoc($result)) != null) {
911
+			$index_type = 'index';
912
+			if ($row['Key_name'] == 'PRIMARY') {
913
+				$index_type = 'primary';
914 914
 			}
915
-			elseif ( $row['Non_unique'] == '0' ) {
916
-				$index_type='unique';
915
+			elseif ($row['Non_unique'] == '0') {
916
+				$index_type = 'unique';
917 917
 			}
918 918
 			$name = strtolower($row['Key_name']);
919
-			$indices[$name]['name']=$name;
920
-			$indices[$name]['type']=$index_type;
921
-			$indices[$name]['fields'][]=strtolower($row['Column_name']);
919
+			$indices[$name]['name'] = $name;
920
+			$indices[$name]['type'] = $index_type;
921
+			$indices[$name]['fields'][] = strtolower($row['Column_name']);
922 922
 		}
923 923
 		return $indices;
924 924
 	}
@@ -929,11 +929,11 @@  discard block
 block discarded – undo
929 929
 	public function add_drop_constraint($table, $definition, $drop = false)
930 930
 	{
931 931
 		$type         = $definition['type'];
932
-		$fields       = implode(',',$definition['fields']);
932
+		$fields       = implode(',', $definition['fields']);
933 933
 		$name         = $definition['name'];
934 934
 		$sql          = '';
935 935
 
936
-		switch ($type){
936
+		switch ($type) {
937 937
 		// generic indices
938 938
 		case 'index':
939 939
 		case 'alternate_key':
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 	 */
978 978
 	public function fetchOne($sql, $dieOnError = false, $msg = '', $suppress = false)
979 979
 	{
980
-		if(stripos($sql, ' LIMIT ') === false) {
980
+		if (stripos($sql, ' LIMIT ') === false) {
981 981
 			// little optimization to just fetch one row
982 982
 			$sql .= " LIMIT 0,1";
983 983
 		}
@@ -997,13 +997,13 @@  discard block
 block discarded – undo
997 997
 	 */
998 998
 	public function massageFieldDef(&$fieldDef, $tablename)
999 999
 	{
1000
-		parent::massageFieldDef($fieldDef,$tablename);
1000
+		parent::massageFieldDef($fieldDef, $tablename);
1001 1001
 
1002
-		if ( isset($fieldDef['default']) &&
1002
+		if (isset($fieldDef['default']) &&
1003 1003
 			($fieldDef['dbType'] == 'text'
1004 1004
 				|| $fieldDef['dbType'] == 'blob'
1005 1005
 				|| $fieldDef['dbType'] == 'longtext'
1006
-				|| $fieldDef['dbType'] == 'longblob' ))
1006
+				|| $fieldDef['dbType'] == 'longblob'))
1007 1007
 			unset($fieldDef['default']);
1008 1008
 		if ($fieldDef['dbType'] == 'uint')
1009 1009
 			$fieldDef['len'] = '10';
@@ -1011,22 +1011,22 @@  discard block
 block discarded – undo
1011 1011
 			$fieldDef['len'] = '20';
1012 1012
 		if ($fieldDef['dbType'] == 'bool')
1013 1013
 			$fieldDef['type'] = 'tinyint';
1014
-		if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']) )
1014
+		if ($fieldDef['dbType'] == 'bool' && empty($fieldDef['default']))
1015 1015
 			$fieldDef['default'] = '0';
1016
-		if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']) )
1016
+		if (($fieldDef['dbType'] == 'varchar' || $fieldDef['dbType'] == 'enum') && empty($fieldDef['len']))
1017 1017
 			$fieldDef['len'] = '255';
1018 1018
 		if ($fieldDef['dbType'] == 'uint')
1019 1019
 			$fieldDef['len'] = '10';
1020
-		if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']) )
1020
+		if ($fieldDef['dbType'] == 'int' && empty($fieldDef['len']))
1021 1021
 			$fieldDef['len'] = '11';
1022 1022
 
1023
-		if($fieldDef['dbType'] == 'decimal') {
1024
-			if(isset($fieldDef['len'])) {
1025
-				if(strstr($fieldDef['len'], ",") === false) {
1023
+		if ($fieldDef['dbType'] == 'decimal') {
1024
+			if (isset($fieldDef['len'])) {
1025
+				if (strstr($fieldDef['len'], ",") === false) {
1026 1026
 					$fieldDef['len'] .= ",0";
1027 1027
 				}
1028 1028
 			} else {
1029
-				$fieldDef['len']  = '10,0';
1029
+				$fieldDef['len'] = '10,0';
1030 1030
 			}
1031 1031
 		}
1032 1032
 	}
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	{
1047 1047
 		$sql = array();
1048 1048
 		foreach ($indexes as $index) {
1049
-			$name =$index['name'];
1050
-			if($execute) {
1049
+			$name = $index['name'];
1050
+			if ($execute) {
1051 1051
 			unset(self::$index_descriptions[$tablename][$name]);
1052 1052
 			}
1053 1053
 			if ($index['type'] == 'primary') {
@@ -1057,8 +1057,8 @@  discard block
 block discarded – undo
1057 1057
 			}
1058 1058
 		}
1059 1059
 		if (!empty($sql)) {
1060
-            $sql = "ALTER TABLE $tablename " . join(",", $sql) . ";";
1061
-			if($execute)
1060
+            $sql = "ALTER TABLE $tablename ".join(",", $sql).";";
1061
+			if ($execute)
1062 1062
 				$this->query($sql);
1063 1063
 		} else {
1064 1064
 			$sql = '';
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 		$q = "SHOW COLLATION LIKE 'utf8%'";
1085 1085
 		$r = $this->query($q);
1086 1086
 		$res = array();
1087
-		while($a = $this->fetchByAssoc($r)) {
1087
+		while ($a = $this->fetchByAssoc($r)) {
1088 1088
 			$res[] = $a['Collation'];
1089 1089
 		}
1090 1090
 		return $res;
@@ -1104,13 +1104,13 @@  discard block
 block discarded – undo
1104 1104
 	public function emptyValue($type)
1105 1105
 	{
1106 1106
 		$ctype = $this->getColumnType($type);
1107
-		if($ctype == "datetime") {
1107
+		if ($ctype == "datetime") {
1108 1108
 			return $this->convert($this->quoted("0000-00-00 00:00:00"), "datetime");
1109 1109
 		}
1110
-		if($ctype == "date") {
1110
+		if ($ctype == "date") {
1111 1111
 			return $this->convert($this->quoted("0000-00-00"), "date");
1112 1112
 		}
1113
-		if($ctype == "time") {
1113
+		if ($ctype == "time") {
1114 1114
 			return $this->convert($this->quoted("00:00:00"), "time");
1115 1115
 		}
1116 1116
 		return parent::emptyValue($type);
@@ -1122,13 +1122,13 @@  discard block
 block discarded – undo
1122 1122
 	 */
1123 1123
 	public function lastDbError()
1124 1124
 	{
1125
-		if($this->database) {
1126
-		    if(mysql_errno($this->database)) {
1125
+		if ($this->database) {
1126
+		    if (mysql_errno($this->database)) {
1127 1127
 			    return "MySQL error ".mysql_errno($this->database).": ".mysql_error($this->database);
1128 1128
 		    }
1129 1129
 		} else {
1130
-			$err =  mysql_error();
1131
-			if($err) {
1130
+			$err = mysql_error();
1131
+			if ($err) {
1132 1132
 			    return $err;
1133 1133
 			}
1134 1134
 		}
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	 */
1142 1142
 	protected function quoteTerm($term)
1143 1143
 	{
1144
-		if(strpos($term, ' ') !== false) {
1144
+		if (strpos($term, ' ') !== false) {
1145 1145
 			return '"'.$term.'"';
1146 1146
 		}
1147 1147
 		return $term;
@@ -1157,16 +1157,16 @@  discard block
 block discarded – undo
1157 1157
 	public function getFulltextQuery($field, $terms, $must_terms = array(), $exclude_terms = array())
1158 1158
 	{
1159 1159
 		$condition = array();
1160
-		foreach($terms as $term) {
1160
+		foreach ($terms as $term) {
1161 1161
 			$condition[] = $this->quoteTerm($term);
1162 1162
 		}
1163
-		foreach($must_terms as $term) {
1163
+		foreach ($must_terms as $term) {
1164 1164
 			$condition[] = "+".$this->quoteTerm($term);
1165 1165
 		}
1166
-		foreach($exclude_terms as $term) {
1166
+		foreach ($exclude_terms as $term) {
1167 1167
 			$condition[] = "-".$this->quoteTerm($term);
1168 1168
 		}
1169
-		$condition = $this->quoted(join(" ",$condition));
1169
+		$condition = $this->quoted(join(" ", $condition));
1170 1170
 		return "MATCH($field) AGAINST($condition IN BOOLEAN MODE)";
1171 1171
 	}
1172 1172
 
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 	{
1179 1179
 		$charsets = array();
1180 1180
 		$res = $this->query("show variables like 'character\\_set\\_%'");
1181
-		while($row = $this->fetchByAssoc($res)) {
1181
+		while ($row = $this->fetchByAssoc($res)) {
1182 1182
 			$charsets[$row['Variable_name']] = $row['Value'];
1183 1183
 		}
1184 1184
 		return $charsets;
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 	{
1189 1189
 		$charsets = $this->getCharsetInfo();
1190 1190
 		$charset_str = array();
1191
-		foreach($charsets as $name => $value) {
1191
+		foreach ($charsets as $name => $value) {
1192 1192
 			$charset_str[] = "$name = $value";
1193 1193
 		}
1194 1194
 		return array(
@@ -1210,18 +1210,18 @@  discard block
 block discarded – undo
1210 1210
 	{
1211 1211
 		$this->log->debug("creating temp table for [$table]...");
1212 1212
 		$result = $this->query("SHOW CREATE TABLE {$table}");
1213
-		if(empty($result)) {
1213
+		if (empty($result)) {
1214 1214
 			return false;
1215 1215
 		}
1216 1216
 		$row = $this->fetchByAssoc($result);
1217
-		if(empty($row) || empty($row['Create Table'])) {
1217
+		if (empty($row) || empty($row['Create Table'])) {
1218 1218
 		    return false;
1219 1219
 		}
1220 1220
 		$create = $row['Create Table'];
1221 1221
 		// rewrite DDL with _temp name
1222 1222
 		$tempTableQuery = str_replace("CREATE TABLE `{$table}`", "CREATE TABLE `{$table}__uw_temp`", $create);
1223 1223
 		$r2 = $this->query($tempTableQuery);
1224
-		if(empty($r2)) {
1224
+		if (empty($r2)) {
1225 1225
 			return false;
1226 1226
 		}
1227 1227
 
@@ -1243,11 +1243,11 @@  discard block
 block discarded – undo
1243 1243
 		$this->log->debug("verifying ALTER TABLE");
1244 1244
 		// Skipping ALTER TABLE [table] DROP PRIMARY KEY because primary keys are not being copied
1245 1245
 		// over to the temp tables
1246
-		if(strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) {
1246
+		if (strpos(strtoupper($query), 'DROP PRIMARY KEY') !== false) {
1247 1247
 			$this->log->debug("Skipping DROP PRIMARY KEY");
1248 1248
 			return '';
1249 1249
 		}
1250
-		if(!$this->makeTempTableCopy($table)) {
1250
+		if (!$this->makeTempTableCopy($table)) {
1251 1251
 			return 'Could not create temp table copy';
1252 1252
 		}
1253 1253
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		$this->log->debug('testing query: ['.$query.']');
1256 1256
 		$tempTableTestQuery = str_replace("ALTER TABLE `{$table}`", "ALTER TABLE `{$table}__uw_temp`", $query);
1257 1257
 		if (strpos($tempTableTestQuery, 'idx') === false) {
1258
-			if(strpos($tempTableTestQuery, '__uw_temp') === false) {
1258
+			if (strpos($tempTableTestQuery, '__uw_temp') === false) {
1259 1259
 				return 'Could not use a temp table to test query!';
1260 1260
 			}
1261 1261
 
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 			$this->query($tempTableTestQuery_idx, false, "Preflight Failed for: {$query}");
1269 1269
 		}
1270 1270
 		$mysqlError = $this->getL();
1271
-		if(!empty($mysqlError)) {
1271
+		if (!empty($mysqlError)) {
1272 1272
 			return $mysqlError;
1273 1273
 		}
1274 1274
 		$this->dropTableName("{$table}__uw_temp");
@@ -1280,13 +1280,13 @@  discard block
 block discarded – undo
1280 1280
 	{
1281 1281
 		$this->log->debug("verifying $querytype statement");
1282 1282
 
1283
-		if(!$this->makeTempTableCopy($table)) {
1283
+		if (!$this->makeTempTableCopy($table)) {
1284 1284
 			return 'Could not create temp table copy';
1285 1285
 		}
1286 1286
 		// test the query on the test table
1287 1287
 		$this->log->debug('testing query: ['.$query.']');
1288 1288
 		$tempTableTestQuery = str_replace("$querytype `{$table}`", "$querytype `{$table}__uw_temp`", $query);
1289
-		if(strpos($tempTableTestQuery, '__uw_temp') === false) {
1289
+		if (strpos($tempTableTestQuery, '__uw_temp') === false) {
1290 1290
 			return 'Could not use a temp table to test query!';
1291 1291
 		}
1292 1292
 
@@ -1366,11 +1366,11 @@  discard block
 block discarded – undo
1366 1366
 	public function userExists($username)
1367 1367
 	{
1368 1368
 		$db = $this->getOne("SELECT DATABASE()");
1369
-		if(!$this->selectDb("mysql")) {
1369
+		if (!$this->selectDb("mysql")) {
1370 1370
 			return false;
1371 1371
 		}
1372 1372
 		$user = $this->getOne("select count(*) from user where user = ".$this->quoted($username));
1373
-		if(!$this->selectDb($db)) {
1373
+		if (!$this->selectDb($db)) {
1374 1374
 			$this->checkError("Cannot select database $db", true);
1375 1375
 		}
1376 1376
 		return !empty($user);
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 							IDENTIFIED BY '{$qpassword}';", true);
1393 1393
 
1394 1394
 		$this->query("SET PASSWORD FOR \"{$user}\"@\"{$host_name}\" = password('{$qpassword}');", true);
1395
-		if($host_name != 'localhost') {
1395
+		if ($host_name != 'localhost') {
1396 1396
 			$this->createDbUser($database_name, "localhost", $user, $password);
1397 1397
 		}
1398 1398
 	}
@@ -1438,10 +1438,10 @@  discard block
 block discarded – undo
1438 1438
 	public function canInstall()
1439 1439
 	{
1440 1440
 		$db_version = $this->version();
1441
-		if(empty($db_version)) {
1441
+		if (empty($db_version)) {
1442 1442
 			return array('ERR_DB_VERSION_FAILURE');
1443 1443
 		}
1444
-		if(version_compare($db_version, '4.1.2') < 0) {
1444
+		if (version_compare($db_version, '4.1.2') < 0) {
1445 1445
 			return array('ERR_DB_MYSQL_VERSION', $db_version);
1446 1446
 		}
1447 1447
 		return true;
Please login to merge, or discard this patch.