Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
api/src/Framework/Bundle.php 1 patch
Braces   +22 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,7 +74,11 @@  discard block
 block discarded – undo
74 74
 		$query = null;
75 75
 		foreach($js_includes as $file)
76 76
 		{
77
-			if ($file == '/api/js/jsapi/egw.js') continue;	// loaded via own tag, and we must not load it twice!
77
+			if ($file == '/api/js/jsapi/egw.js')
78
+			{
79
+				continue;
80
+			}
81
+			// loaded via own tag, and we must not load it twice!
78 82
 
79 83
 			if (!isset($to_include[$file]))
80 84
 			{
@@ -133,17 +137,27 @@  discard block
 block discarded – undo
133 137
 	{
134 138
 		$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
135 139
 		// ignore not existing minurl
136
-		if (!empty($minurl) && !file_exists(EGW_SERVER_ROOT.$minurl)) $minurl = null;
140
+		if (!empty($minurl) && !file_exists(EGW_SERVER_ROOT.$minurl))
141
+		{
142
+			$minurl = null;
143
+		}
137 144
 		$to_include_first = $to_include = $to_minify = array();
138 145
 		$max_modified = 0;
139 146
 		$query = null;
140 147
 		foreach($js_includes as $path)
141 148
 		{
142
-			if ($path == '/api/js/jsapi/egw.js') continue; // Leave egw.js out of bundle
149
+			if ($path == '/api/js/jsapi/egw.js')
150
+			{
151
+				continue;
152
+			}
153
+			// Leave egw.js out of bundle
143 154
 			unset($query);
144 155
 			list($path,$query) = explode('?',$path,2);
145 156
 			$mod = filemtime(EGW_SERVER_ROOT.$path);
146
-			if ($mod > $max_modified) $max_modified = $mod;
157
+			if ($mod > $max_modified)
158
+			{
159
+				$max_modified = $mod;
160
+			}
147 161
 
148 162
 			// ckeditor must be included before bundled files, as they depend on it!
149 163
 			if (strpos($path,'/ckeditor/ckeditor.js') !== false)
@@ -182,7 +196,10 @@  discard block
 block discarded – undo
182 196
 			// need to include minified javascript before not minified stuff like jscalendar-setup, as it might depend on it
183 197
 			array_unshift($to_include, $path);
184 198
 		}
185
-		if ($to_include_first) $to_include = array_merge($to_include_first, $to_include);
199
+		if ($to_include_first)
200
+		{
201
+			$to_include = array_merge($to_include_first, $to_include);
202
+		}
186 203
 		//error_log(__METHOD__."("./*array2string($js_includes).*/", $max_modified, $minurl) returning ".array2string($to_include));
187 204
 		return $to_include;
188 205
 	}
Please login to merge, or discard this patch.
api/src/Framework/Extra.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,9 +164,12 @@
 block discarded – undo
164 164
 	{
165 165
 		// adding links of refreshed entry, to give others apps more information about necessity to refresh
166 166
 		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 &&	// do not run twice
167
-			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))	// app/id given
167
+			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))
168
+		{
169
+			// app/id given
168 170
 		{
169 171
 			$links = Link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
172
+		}
170 173
 			$apps = array();
171 174
 			foreach($links as $link)
172 175
 			{
Please login to merge, or discard this patch.
api/src/Framework/Ajax.php 1 patch
Braces   +56 added lines, -14 removed lines patch added patch discarded remove patch
@@ -104,7 +104,9 @@  discard block
 block discarded – undo
104 104
 
105 105
 		//Width may not be smaller than MIN_SIDEBAR_WIDTH
106 106
 		if ($width < self::MIN_SIDEBAR_WIDTH)
107
-			$width = self::MIN_SIDEBAR_WIDTH;
107
+		{
108
+					$width = self::MIN_SIDEBAR_WIDTH;
109
+		}
108 110
 
109 111
 		return $width;
110 112
 	}
@@ -156,7 +158,10 @@  discard block
 block discarded – undo
156 158
 	 */
157 159
 	static function link($url = '', $extravars = '', $link_app=null)
158 160
 	{
159
-		if (is_null($link_app)) $link_app = self::$link_app;
161
+		if (is_null($link_app))
162
+		{
163
+			$link_app = self::$link_app;
164
+		}
160 165
 		$link = parent::link($url, $extravars);
161 166
 
162 167
 		// $link_app === true --> detect application, otherwise use given application
@@ -185,7 +190,10 @@  discard block
 block discarded – undo
185 190
 		$srcs = array();
186 191
 		foreach(Api\Hooks::process('csp-frame-src') as $src)
187 192
 		{
188
-			if ($src) $srcs = array_merge($srcs, $src);
193
+			if ($src)
194
+			{
195
+				$srcs = array_merge($srcs, $src);
196
+			}
189 197
 		}
190 198
 		return $srcs;
191 199
 	}
@@ -199,7 +207,10 @@  discard block
 block discarded – undo
199 207
 	function header(array $extra=array())
200 208
 	{
201 209
 		// make sure header is output only once
202
-		if (self::$header_done) return '';
210
+		if (self::$header_done)
211
+		{
212
+			return '';
213
+		}
203 214
 		self::$header_done = true;
204 215
 
205 216
 		$this->send_headers();
@@ -266,7 +277,10 @@  discard block
 block discarded – undo
266 277
 			// for remote manual never check/create framework
267 278
 			if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr')))
268 279
 			{
269
-				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']='';
280
+				if (empty($GLOBALS['egw_info']['flags']['java_script']))
281
+				{
282
+					$GLOBALS['egw_info']['flags']['java_script']='';
283
+				}
270 284
 				$extra['check-framework'] = $_GET['cd'] !== 'no';
271 285
 			}
272 286
 		}
@@ -539,7 +553,10 @@  discard block
 block discarded – undo
539 553
 	 */
540 554
 	public function sidebox($appname,$menu_title,$file,$type=null)
541 555
 	{
542
-		if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
556
+		if (!isset($file['menuOpened']))
557
+		{
558
+			$file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
559
+		}
543 560
 		//error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened");
544 561
 		$this->sidebox_menu_opened = false;
545 562
 
@@ -666,7 +683,10 @@  discard block
 block discarded – undo
666 683
 		foreach($tablist as $data)
667 684
 		{
668 685
 			$tabs[] = $data['appName'];
669
-			if ($data['active']) $active = $data['appName'];
686
+			if ($data['active'])
687
+			{
688
+				$active = $data['appName'];
689
+			}
670 690
 		}
671 691
 		// send app a notification, that it's tab got closed
672 692
 		// used eg. in phpFreeChat to leave the chat
@@ -790,10 +810,22 @@  discard block
 block discarded – undo
790 810
 		}
791 811
 
792 812
 		unset($apps['logout']);	// never display it
793
-		if (isset($apps['about'])) $apps['about']['noNavbar'] = true;
794
-		if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true;
795
-		if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true;
796
-		if (isset($apps['home'])) $apps['home']['noNavbar'] = true;
813
+		if (isset($apps['about']))
814
+		{
815
+			$apps['about']['noNavbar'] = true;
816
+		}
817
+		if (isset($apps['preferences']))
818
+		{
819
+			$apps['preferences']['noNavbar'] = true;
820
+		}
821
+		if (isset($apps['manual']))
822
+		{
823
+			$apps['manual']['noNavbar'] = true;
824
+		}
825
+		if (isset($apps['home']))
826
+		{
827
+			$apps['home']['noNavbar'] = true;
828
+		}
797 829
 
798 830
 		// no need for website icon, if we have sitemgr
799 831
 		if (isset($apps['sitemgr']) && isset($apps['sitemgr-link']))
@@ -862,7 +894,10 @@  discard block
 block discarded – undo
862 894
 		else
863 895
 		{
864 896
 			$active_tab = $GLOBALS['egw_info']['user']['preferences']['common']['active_tab'];
865
-			if (!$active_tab) $active_tab = $default_app;
897
+			if (!$active_tab)
898
+			{
899
+				$active_tab = $default_app;
900
+			}
866 901
 		}
867 902
 		// if we have the open tabs in the session, use it instead the maybe forced common prefs open_tabs
868 903
 		if (!($open_tabs = Api\Cache::getSession(__CLASS__, 'open_tabs')))
@@ -887,9 +922,12 @@  discard block
 block discarded – undo
887 922
 		// Restore Tabs
888 923
 		foreach($open_tabs as $n => $app)
889 924
 		{
890
-			if (isset($apps[$app]))		// user might no longer have app rights
925
+			if (isset($apps[$app]))
926
+			{
927
+				// user might no longer have app rights
891 928
 			{
892 929
 				$apps[$app]['opened'] = $n;
930
+			}
893 931
 				if ($app == $active_tab)
894 932
 				{
895 933
 					$apps[$app]['active'] = true;
@@ -915,7 +953,11 @@  discard block
 block discarded – undo
915 953
 	function footer($no_framework=true)
916 954
 	{
917 955
 		//error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace());
918
-		if (self::$footer_done) return;	// prevent (multiple) footers
956
+		if (self::$footer_done)
957
+		{
958
+			return;
959
+		}
960
+		// prevent (multiple) footers
919 961
 		self::$footer_done = true;
920 962
 
921 963
 		if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
Please login to merge, or discard this patch.
api/src/Framework/Minimal.php 1 patch
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 	function header(array $extra=array())
48 48
 	{
49 49
 		// make sure header is output only once
50
-		if (self::$header_done) return '';
50
+		if (self::$header_done)
51
+		{
52
+			return '';
53
+		}
51 54
 		self::$header_done = true;
52 55
 
53 56
 		// js stuff is not needed by login page or in popups
@@ -135,7 +138,11 @@  discard block
 block discarded – undo
135 138
 	function footer()
136 139
 	{
137 140
 		static $footer_done=0;
138
-		if ($footer_done++) return;	// prevent multiple footers, not sure we still need this (RalfBecker)
141
+		if ($footer_done++)
142
+		{
143
+			return;
144
+		}
145
+		// prevent multiple footers, not sure we still need this (RalfBecker)
139 146
 
140 147
 		return "</body>\n</html>\n";	// close body and html tag, eg. for popups
141 148
 	}
Please login to merge, or discard this patch.
api/src/Framework/Updates.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 			if (($remote = file_get_contents(self::CURRENT_VERSION_URL, false, Api\Framework::proxy_context())))
50 50
 			{
51 51
 				list($current, $security) = explode("\n", $remote);
52
-				if (empty($security)) $security = $current;
52
+				if (empty($security))
53
+				{
54
+					$security = $current;
55
+				}
53 56
 				$versions = array(
54 57
 					'current'  => $current,		// last maintenance update
55 58
 					'security' => $security,	// last security update
@@ -114,7 +117,10 @@  discard block
 block discarded – undo
114 117
 	protected static function update_older($version, $days)
115 118
 	{
116 119
 		list(,,$date) = explode('.', $version);
117
-		if ($date < 20140000) return false;
120
+		if ($date < 20140000)
121
+		{
122
+			return false;
123
+		}
118 124
 		$version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4));
119 125
 
120 126
 		return (time() - $version_timestamp) / 86400 > $days;
Please login to merge, or discard this patch.
api/src/autoload.php 1 patch
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,11 @@  discard block
 block discarded – undo
37 37
 spl_autoload_register(function($class)
38 38
 {
39 39
 	$parts = explode('\\', $class);
40
-	if (array_shift($parts) != 'EGroupware') return;	// not our prefix
40
+	if (array_shift($parts) != 'EGroupware')
41
+	{
42
+		return;
43
+	}
44
+	// not our prefix
41 45
 
42 46
 	$app = lcfirst(array_shift($parts));
43 47
 	$base = EGW_INCLUDE_ROOT.'/'.$app.'/src/';
@@ -63,7 +67,10 @@  discard block
 block discarded – undo
63 67
 spl_autoload_register(function($class)
64 68
 {
65 69
 	// fixing warnings generated by php 5.3.8 is_a($obj) trying to autoload huge strings
66
-	if (strlen($class) > 64 || strpos($class, '.') !== false) return;
70
+	if (strlen($class) > 64 || strpos($class, '.') !== false)
71
+	{
72
+		return;
73
+	}
67 74
 
68 75
 	$components = explode('_',$class);
69 76
 	$app = array_shift($components);
Please login to merge, or discard this patch.
api/src/Ldap/ServerInfo.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -218,7 +218,8 @@
 block discarded – undo
218 218
 					{
219 219
 						if(($info = ldap_get_entries($ds, $sr)))
220 220
 						{
221
-							if($info[0]['objectclasses']) {
221
+							if($info[0]['objectclasses'])
222
+							{
222 223
 								for($i=0; $i<$info[0]['objectclasses']['count']; $i++)
223 224
 								{
224 225
 									$matches = null;
Please login to merge, or discard this patch.
api/src/Preferences.php 1 patch
Braces   +81 added lines, -20 removed lines patch added patch discarded remove patch
@@ -196,7 +196,10 @@  discard block
 block discarded – undo
196 196
 		foreach((array)$ids as $id)
197 197
 		{
198 198
 			// if prefs are not returned, null or not an array, read them from db
199
-			if (!isset($prefs[$id]) && !is_array($prefs[$id])) $db_read[] = $id;
199
+			if (!isset($prefs[$id]) && !is_array($prefs[$id]))
200
+			{
201
+				$db_read[] = $id;
202
+			}
200 203
 		}
201 204
 		if ($db_read)
202 205
 		{
@@ -209,7 +212,10 @@  discard block
 block discarded – undo
209 212
 			}
210 213
 			foreach($db_read as $id)
211 214
 			{
212
-				if (!isset($prefs[$id])) $prefs[$id] = array();
215
+				if (!isset($prefs[$id]))
216
+				{
217
+					$prefs[$id] = array();
218
+				}
213 219
 				Cache::setInstance(__CLASS__, $id, $prefs[$id]);
214 220
 			}
215 221
 		}
@@ -237,7 +243,10 @@  discard block
 block discarded – undo
237 243
 		$replace = $with = array();
238 244
 		foreach($vals as $key => $val)
239 245
 		{
240
-			if ($this->debug) error_log(__METHOD__." replacing \$\$$key\$\$ with $val  ");
246
+			if ($this->debug)
247
+			{
248
+				error_log(__METHOD__." replacing \$\$$key\$\$ with $val  ");
249
+			}
241 250
 			$replace[] = '$$'.$key.'$$';
242 251
 			$with[]    = $val;
243 252
 		}
@@ -275,7 +284,10 @@  discard block
 block discarded – undo
275 284
 	 */
276 285
 	function standard_substitutes()
277 286
 	{
278
-		if ($this->debug) error_log(__METHOD__." is called ");
287
+		if ($this->debug)
288
+		{
289
+			error_log(__METHOD__." is called ");
290
+		}
279 291
 		if (!is_array(@$GLOBALS['egw_info']['user']['preferences']))
280 292
 		{
281 293
 			$GLOBALS['egw_info']['user']['preferences'] = $this->data;	// else no lang()
@@ -301,12 +313,18 @@  discard block
 block discarded – undo
301 313
 			'email'     => lang('email-address of the user, eg. "%1"',$this->values['email']),
302 314
 			'date'      => lang('todays date, eg. "%1"',$this->values['date']),
303 315
 		);
304
-		if ($this->debug) error_log(__METHOD__.print_r($this->vars,true));
316
+		if ($this->debug)
317
+		{
318
+			error_log(__METHOD__.print_r($this->vars,true));
319
+		}
305 320
 		// do the substituetion in the effective prefs (data)
306 321
 		//
307 322
 		foreach($this->data as $app => $data)
308 323
 		{
309
-			if(!is_array($data)) continue;
324
+			if(!is_array($data))
325
+			{
326
+				continue;
327
+			}
310 328
 			foreach($data as $key => $val)
311 329
 			{
312 330
 				if (!is_array($val) && strpos($val,'$$') !== False)
@@ -401,7 +419,11 @@  discard block
 block discarded – undo
401 419
 			$primary_group = Accounts::id2name($this->account_id, 'account_primary_group');
402 420
 			foreach((array)$GLOBALS['egw']->accounts->memberships($this->account_id, true) as $gid)
403 421
 			{
404
-				if ($gid != $primary_group) $to_read[] = $gid + self::DEFAULT_ID;	// need to offset it with DEFAULT_ID = -2!
422
+				if ($gid != $primary_group)
423
+				{
424
+					$to_read[] = $gid + self::DEFAULT_ID;
425
+				}
426
+				// need to offset it with DEFAULT_ID = -2!
405 427
 			}
406 428
 			$to_read[] = $primary_group + self::DEFAULT_ID;
407 429
 		}
@@ -508,9 +530,15 @@  discard block
 block discarded – undo
508 530
 		// Etemplate::complete_array_merge() is identical to PHP >= 5.3 array_replace_recursive()
509 531
 		$default = Etemplate::complete_array_merge($this->default, $this->forced);
510 532
 
511
-		if ($app) $default = $default[$app];
533
+		if ($app)
534
+		{
535
+			$default = $default[$app];
536
+		}
512 537
 
513
-		if ($name && is_array($default)) $default = $default[$name];
538
+		if ($name && is_array($default))
539
+		{
540
+			$default = $default[$name];
541
+		}
514 542
 
515 543
 		return $default;
516 544
 	}
@@ -588,9 +616,13 @@  discard block
 block discarded – undo
588 616
 				{
589 617
 					$this->session[$app_name][$var] = $this->data[$app_name][$var] = $value;
590 618
 					Cache::setSession('preferences','preferences',$this->session);
591
-					if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
619
+					if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
620
+					{
621
+						// egw object in setup is limited
592 622
 					{
593
-						$GLOBALS['egw']->invalidate_session_cache();	// in case with cache the egw_info array in the session
623
+						$GLOBALS['egw']->invalidate_session_cache();
624
+					}
625
+					// in case with cache the egw_info array in the session
594 626
 					}
595 627
 				}
596 628
 				break;
@@ -646,9 +678,12 @@  discard block
 block discarded – undo
646 678
 		}
647 679
 		$pref = &$this->$type;
648 680
 
649
-		if (($all = empty($var))) // to check if $var is regarded as empty (false, 0, '', null, array() should do the trick
681
+		if (($all = empty($var)))
682
+		{
683
+			// to check if $var is regarded as empty (false, 0, '', null, array() should do the trick
650 684
 		{
651 685
 			unset($pref[$app_name]);
686
+		}
652 687
 			unset($this->data[$app_name]);
653 688
 		}
654 689
 		else
@@ -727,7 +762,10 @@  discard block
 block discarded – undo
727 762
 		$db = isset($GLOBALS['egw_setup']->db) ? $GLOBALS['egw_setup']->db : $GLOBALS['egw']->db;
728 763
 
729 764
 		$where = array();
730
-		if ($app) $where['preference_app'] = $app;
765
+		if ($app)
766
+		{
767
+			$where['preference_app'] = $app;
768
+		}
731 769
 
732 770
 		switch($type)
733 771
 		{
@@ -747,7 +785,11 @@  discard block
 block discarded – undo
747 785
 		foreach($db->select(self::TABLE, '*', $where, __LINE__, __FILE__) as $row)
748 786
 		{
749 787
 			$prefs = self::unserialize($row['preference_value']);
750
-			if (!is_array($prefs)) $prefs = array();	// would stall update otherwise
788
+			if (!is_array($prefs))
789
+			{
790
+				$prefs = array();
791
+			}
792
+			// would stall update otherwise
751 793
 
752 794
 			if ($name[0] == '/' && substr($name, -1) == '/')
753 795
 			{
@@ -764,10 +806,16 @@  discard block
 block discarded – undo
764 806
 			$updated = false;
765 807
 			foreach($attrs as $attr)
766 808
 			{
767
-				if (isset($old_value) && $prefs[$attr] != $old_value) continue;
809
+				if (isset($old_value) && $prefs[$attr] != $old_value)
810
+				{
811
+					continue;
812
+				}
768 813
 
769 814
 				$val = is_callable($value) ? call_user_func($value, $attr, $prefs[$attr], $row['preference_owner']) : $value;
770
-				if ($val === $prefs[$attr]) continue;
815
+				if ($val === $prefs[$attr])
816
+				{
817
+					continue;
818
+				}
771 819
 
772 820
 				$updated = true;
773 821
 				if ((string)$val !== '')
@@ -832,7 +880,11 @@  discard block
 block discarded – undo
832 880
 			{
833 881
 				$prefs = array_intersect_key($prefs, array_flip($names));
834 882
 			}
835
-			if (!$prefs) continue;	// nothing to change, as nothing set
883
+			if (!$prefs)
884
+			{
885
+				continue;
886
+			}
887
+			// nothing to change, as nothing set
836 888
 
837 889
 			$row['preference_app'] = $to_app;
838 890
 			unset($row['preference_value']);
@@ -898,9 +950,15 @@  discard block
 block discarded – undo
898 950
 			foreach($prefs as $app => $value)
899 951
 			{
900 952
 				// check if app preferences have changed, if not no need to save them
901
-				if ($old_prefs && $old_prefs[$app] == $value) continue;
953
+				if ($old_prefs && $old_prefs[$app] == $value)
954
+				{
955
+					continue;
956
+				}
902 957
 
903
-				if (!$changed++) $this->db->transaction_begin();
958
+				if (!$changed++)
959
+				{
960
+					$this->db->transaction_begin();
961
+				}
904 962
 
905 963
 				if (!is_array($value) || !$value)
906 964
 				{
@@ -986,7 +1044,10 @@  discard block
 block discarded – undo
986 1044
 			list($lang,$lang2) = explode('-',$lang);
987 1045
 			$country_from_lang = strtoupper($lang2);
988 1046
 		}
989
-		if (is_null($charset)) $charset = Translation::charset();
1047
+		if (is_null($charset))
1048
+		{
1049
+			$charset = Translation::charset();
1050
+		}
990 1051
 
991 1052
 		foreach(array(
992 1053
 			$lang.'_'.$country,
Please login to merge, or discard this patch.
api/src/Storage.php 1 patch
Braces   +64 added lines, -15 removed lines patch added patch discarded remove patch
@@ -127,7 +127,11 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$this->allow_multiple_values = $allow_multiple_values;
129 129
 		$this->extra_table = $extra_table;
130
-		if (!$this->extra_id) $this->extra_id = $this->autoinc_id;	// default to auto id of regular table
130
+		if (!$this->extra_id)
131
+		{
132
+			$this->extra_id = $this->autoinc_id;
133
+		}
134
+		// default to auto id of regular table
131 135
 
132 136
 		// if names from columns of extra table are only postfixes (starting with _), prepend column prefix
133 137
 		if (!($prefix=$column_prefix))
@@ -145,7 +149,10 @@  discard block
 block discarded – undo
145 149
 		) as $col => $val)
146 150
 		{
147 151
 			$this->$col = $col_name = $val;
148
-			if ($col_name[0] == '_') $this->$col = $prefix . $val;
152
+			if ($col_name[0] == '_')
153
+			{
154
+				$this->$col = $prefix . $val;
155
+			}
149 156
 		}
150 157
 		// some sanity checks, maybe they should be active only for development
151 158
 		if (!($extra_defs = $this->db->get_table_definitions($app,$extra_table)))
@@ -179,13 +186,23 @@  discard block
 block discarded – undo
179 186
 	 */
180 187
 	function read_customfields($ids,$field_names=null)
181 188
 	{
182
-		if (is_null($field_names)) $field_names = array_keys($this->customfields);
189
+		if (is_null($field_names))
190
+		{
191
+			$field_names = array_keys($this->customfields);
192
+		}
183 193
 
184 194
 		foreach((array)$ids as $key => $id)
185 195
 		{
186
-			if (!(int)$id && is_array($ids)) unset($ids[$key]);
196
+			if (!(int)$id && is_array($ids))
197
+			{
198
+				unset($ids[$key]);
199
+			}
187 200
 		}
188
-		if (!$ids || !$field_names) return array();	// nothing to do
201
+		if (!$ids || !$field_names)
202
+		{
203
+			return array();
204
+		}
205
+		// nothing to do
189 206
 
190 207
 		$entries = array();
191 208
 		foreach($this->db->select($this->extra_table,'*',array(
@@ -194,7 +211,10 @@  discard block
 block discarded – undo
194 211
 		),__LINE__,__FILE__,false,'',$this->app) as $row)
195 212
 		{
196 213
 			$entry =& $entries[$row[$this->extra_id]];
197
-			if (!is_array($entry)) $entry = array();
214
+			if (!is_array($entry))
215
+			{
216
+				$entry = array();
217
+			}
198 218
 			$field = $this->get_cf_field($row[$this->extra_key]);
199 219
 
200 220
 			if ($this->allow_multiple_values && $this->is_multiple($row[$this->extra_key]))
@@ -220,7 +240,10 @@  discard block
 block discarded – undo
220 240
 	{
221 241
 		foreach (array_keys((array)$this->customfields) as $name)
222 242
 		{
223
-			if (!isset($data[$field = $this->get_cf_field($name)])) continue;
243
+			if (!isset($data[$field = $this->get_cf_field($name)]))
244
+			{
245
+				continue;
246
+			}
224 247
 
225 248
 			$where = array(
226 249
 				$this->extra_id    => isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]],
@@ -232,7 +255,11 @@  discard block
 block discarded – undo
232 255
 			if(empty($data[$field]) || $is_multiple || !$this->extra_has_unique_index)
233 256
 			{
234 257
 				$this->db->delete($this->extra_table,$where,__LINE__,__FILE__,$this->app);
235
-				if (empty($data[$field])) continue;	// nothing else to do for empty values
258
+				if (empty($data[$field]))
259
+				{
260
+					continue;
261
+				}
262
+				// nothing else to do for empty values
236 263
 			}
237 264
 			foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) :
238 265
 				// regular custom fields (!$is_multiple) eg. addressbook store multiple values comma-separated
@@ -305,9 +332,12 @@  discard block
 block discarded – undo
305 332
 	 */
306 333
 	function save($keys=null,$extra_where=null)
307 334
 	{
308
-		if (is_array($keys) && count($keys) && !isset($keys[0]))	// allow to use an etag, eg array('etag=etag+1')
335
+		if (is_array($keys) && count($keys) && !isset($keys[0]))
336
+		{
337
+			// allow to use an etag, eg array('etag=etag+1')
309 338
 		{
310 339
 			$this->data_merge($keys);
340
+		}
311 341
 			$keys = null;
312 342
 		}
313 343
 		$ret = parent::save($keys,$extra_where);
@@ -340,13 +370,20 @@  discard block
 block discarded – undo
340 370
 				{
341 371
 					$ids[] = $row[$this->autoinc_id];
342 372
 				}
343
-				if (!$ids) return 0;	// no rows affected
373
+				if (!$ids)
374
+				{
375
+					return 0;
376
+				}
377
+				// no rows affected
344 378
 			}
345 379
 			else
346 380
 			{
347 381
 				$ids = (array)$query[$this->autoinc_id];
348 382
 			}
349
-			if ($only_return_ids) return $ids;
383
+			if ($only_return_ids)
384
+			{
385
+				return $ids;
386
+			}
350 387
 			$this->db->delete($this->extra_table,array($this->extra_id => $ids),__LINE__,__FILE__);
351 388
 		}
352 389
 		return parent::delete($keys);
@@ -388,7 +425,10 @@  discard block
 block discarded – undo
388 425
 			{
389 426
 				foreach($selectcols as $col)
390 427
 				{
391
-					if ($this->is_cf($col)) $fields[] = $this->get_cf_name($col);
428
+					if ($this->is_cf($col))
429
+					{
430
+						$fields[] = $this->get_cf_name($col);
431
+					}
392 432
 				}
393 433
 			}
394 434
 			if (($cfs = $this->read_customfields(array_keys($id2keys),$fields)))
@@ -507,7 +547,10 @@  discard block
 block discarded – undo
507 547
 					}
508 548
 				}
509 549
 			}
510
-			if ($cfcriteria && $op =='OR') $criteria[] = implode(' OR ',$cfcriteria);
550
+			if ($cfcriteria && $op =='OR')
551
+			{
552
+				$criteria[] = implode(' OR ',$cfcriteria);
553
+			}
511 554
 		}
512 555
 		if($only_keys === true)
513 556
 		{
@@ -598,11 +641,14 @@  discard block
 block discarded – undo
598 641
 				}
599 642
 				elseif (is_string($name) && $this->is_cf($name))
600 643
 				{
601
-					if (!empty($val))	// empty -> dont filter
644
+					if (!empty($val))
645
+					{
646
+						// empty -> dont filter
602 647
 					{
603 648
 						if ($val[0] === '!')	// negative filter
604 649
 						{
605 650
 							$sql_filter = 'extra_filter.'.$this->extra_value.'!='.$this->db->quote(substr($val,1));
651
+					}
606 652
 						}
607 653
 						else	// using Db::expression to allow to use array() with possible values or NULL
608 654
 						{
@@ -639,9 +685,12 @@  discard block
 block discarded – undo
639 685
 					}
640 686
 					unset($filter[$name]);
641 687
 				}
642
-				elseif(is_int($name) && $this->is_cf($val))	// lettersearch: #cfname LIKE 's%'
688
+				elseif(is_int($name) && $this->is_cf($val))
689
+				{
690
+					// lettersearch: #cfname LIKE 's%'
643 691
 				{
644 692
 					$_cf = explode(' ',$val);
693
+				}
645 694
 					foreach($_cf as $cf_np)
646 695
 					{
647 696
 						// building cf_name by glueing parts together (, in case someone used whitespace in their custom field names)
Please login to merge, or discard this patch.