Completed
Push — 16.1 ( dce808...4651d6 )
by Nathan
68:40 queued 52:57
created
api/src/Cache/Memcache.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -54,26 +54,26 @@  discard block
 block discarded – undo
54 54
 	 * @throws Exception if connection to backend could not be established
55 55
 	 * @param array $params eg. array('localhost'[,'localhost:11211',...])
56 56
 	 */
57
-	function __construct(array $params=null)
57
+	function __construct(array $params = null)
58 58
 	{
59
-		check_load_extension('memcache',true);
59
+		check_load_extension('memcache', true);
60 60
 		$this->memcache = new \Memcache();
61 61
 
62
-		if (!$params) $params = array('localhost');	// some reasonable default
62
+		if (!$params) $params = array('localhost'); // some reasonable default
63 63
 
64 64
 		$ok = false;
65
-		foreach($params as $host_port)
65
+		foreach ($params as $host_port)
66 66
 		{
67
-			$parts = explode(':',$host_port);
67
+			$parts = explode(':', $host_port);
68 68
 			$host = array_shift($parts);
69
-			$port = $parts ? array_shift($parts) : 11211;	// default port
69
+			$port = $parts ? array_shift($parts) : 11211; // default port
70 70
 
71
-			$ok = $this->memcache->addServer($host,$port) || $ok;
71
+			$ok = $this->memcache->addServer($host, $port) || $ok;
72 72
 			//error_log(__METHOD__."(".array2string($params).") memcache->addServer('$host',$port) = ".(int)$ok);
73 73
 		}
74 74
 		if (!$ok)
75 75
 		{
76
-			throw new Exception (__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!");
76
+			throw new Exception(__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!");
77 77
 		}
78 78
 		$this->igbinary_available = function_exists('igbinary_serialize') && function_exists('igbinary_unserialize');
79 79
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @param int $expiration =0
87 87
 	 * @return boolean true on success, false on error, incl. key already exists in cache
88 88
 	 */
89
-	function add(array $keys,$data,$expiration=0)
89
+	function add(array $keys, $data, $expiration = 0)
90 90
 	{
91 91
 		return $this->memcache->add(self::key($keys),
92 92
 			$this->igbinary_available ? igbinary_serialize($data) : serialize($data),
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param int $expiration =0
102 102
 	 * @return boolean true on success, false on error
103 103
 	 */
104
-	function set(array $keys,$data,$expiration=0)
104
+	function set(array $keys, $data, $expiration = 0)
105 105
 	{
106 106
 		return $this->memcache->set(self::key($keys),
107 107
 			$this->igbinary_available ? igbinary_serialize($data) : serialize($data),
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	function get(array $keys)
118 118
 	{
119
-		if (($data = $this->memcache->get($key=self::key($keys))) === false)
119
+		if (($data = $this->memcache->get($key = self::key($keys))) === false)
120 120
 		{
121 121
 			//error_log(__METHOD__."(".array2string($keys).") key='$key' NOT found!");
122 122
 			return null;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	{
136 136
 		$locations = array_pop($keys);
137 137
 		$prefix = self::key($keys);
138
-		foreach($locations as &$location)
138
+		foreach ($locations as &$location)
139 139
 		{
140 140
 			$location = $prefix.'::'.$location;
141 141
 		}
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			return array();
145 145
 		}
146 146
 		$ret = array();
147
-		$prefix_len = strlen($prefix)+2;
148
-		foreach($multiple as $location => $data)
147
+		$prefix_len = strlen($prefix) + 2;
148
+		foreach ($multiple as $location => $data)
149 149
 		{
150
-			$key = substr($location,$prefix_len);
150
+			$key = substr($location, $prefix_len);
151 151
 			//error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes).");
152 152
 			$ret[$key] = $this->igbinary_available && $data[1] !== ':' ? igbinary_unserialize($data) : unserialize($data);
153 153
 		}
@@ -175,6 +175,6 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	private function key(array $keys)
177 177
 	{
178
-		return implode('::',$keys);
178
+		return implode('::', $keys);
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,11 @@
 block discarded – undo
59 59
 		check_load_extension('memcache',true);
60 60
 		$this->memcache = new \Memcache();
61 61
 
62
-		if (!$params) $params = array('localhost');	// some reasonable default
62
+		if (!$params)
63
+		{
64
+			$params = array('localhost');
65
+		}
66
+		// some reasonable default
63 67
 
64 68
 		$ok = false;
65 69
 		foreach($params as $host_port)
Please login to merge, or discard this patch.
api/src/Cache/Base.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param boolean $verbose =false true: echo failed checks
29 29
 	 * @return int number of failed checks
30 30
 	 */
31
-	function check($verbose=false)
31
+	function check($verbose = false)
32 32
 	{
33 33
 		// set us up as provider for Api\Cache class
34 34
 		$GLOBALS['egw_info']['server']['install_id'] = md5(microtime(true));
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 		Api\Cache::$default_provider = get_class($this);
38 38
 
39 39
 		$failed = 0;
40
-		foreach(array(
40
+		foreach (array(
41 41
 			Api\Cache::TREE => 'tree',
42 42
 			Api\Cache::INSTANCE => 'instance',
43 43
 		) as $level => $label)
44 44
 		{
45 45
 			$locations = array();
46
-			foreach(array('string',123,true,false,null,array(),array(1,2,3)) as $data)
46
+			foreach (array('string', 123, true, false, null, array(), array(1, 2, 3)) as $data)
47 47
 			{
48 48
 				$location = md5(microtime(true).$label.serialize($data));
49
-				$get_before_set = $this->get(array($level,__CLASS__,$location));
49
+				$get_before_set = $this->get(array($level, __CLASS__, $location));
50 50
 				if (!is_null($get_before_set))
51 51
 				{
52 52
 					if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
53 53
 					++$failed;
54 54
 				}
55
-				if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true)
55
+				if (($set = $this->set(array($level, __CLASS__, $location), $data, 10)) !== true)
56 56
 				{
57 57
 					if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n";
58 58
 					++$failed;
59 59
 				}
60
-				$get_after_set = $this->get(array($level,__CLASS__,$location));
60
+				$get_after_set = $this->get(array($level, __CLASS__, $location));
61 61
 				if ($get_after_set !== $data)
62 62
 				{
63 63
 					if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 				}
66 66
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
67 67
 				{
68
-					$mget_after_set = $this->mget(array($level,__CLASS__,array($location)));
68
+					$mget_after_set = $this->mget(array($level, __CLASS__, array($location)));
69 69
 					if ($mget_after_set[$location] !== $data)
70 70
 					{
71 71
 						if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
72 72
 						++$failed;
73 73
 					}
74 74
 				}
75
-				$add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data');
75
+				$add_after_set = $this->add(array($level, __CLASS__, $location), 'other-data');
76 76
 				if ($add_after_set !== false)
77 77
 				{
78 78
 					if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n";
79 79
 					++$failed;
80 80
 				}
81
-				if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true)
81
+				if (($delete = $this->delete(array($level, __CLASS__, $location))) !== true)
82 82
 				{
83 83
 					if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
84 84
 					++$failed;
85 85
 				}
86
-				$get_after_delete = $this->get(array($level,__CLASS__,$location));
86
+				$get_after_delete = $this->get(array($level, __CLASS__, $location));
87 87
 				if (!is_null($get_after_delete))
88 88
 				{
89 89
 					if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
94 94
 				{
95 95
 					$locations[$location] = $data;
96
-					$mget_after_delete = $this->mget(array($level,__CLASS__,array($location)));
96
+					$mget_after_delete = $this->mget(array($level, __CLASS__, array($location)));
97 97
 					if (isset($mget_after_delete[$location]))
98 98
 					{
99 99
 						if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				{
105 105
 					$locations[$location] = $data;
106 106
 				}
107
-				$add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10);
107
+				$add_after_delete = $this->add(array($level, __CLASS__, $location), $data, 10);
108 108
 				if ($add_after_delete !== true)
109 109
 				{
110 110
 					if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 				}
113 113
 				else
114 114
 				{
115
-					$get_after_add = $this->get(array($level,__CLASS__,$location));
115
+					$get_after_add = $this->get(array($level, __CLASS__, $location));
116 116
 					if ($get_after_add !== $data)
117 117
 					{
118 118
 						if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			// get all above in one request
124 124
 			$keys = array_keys($locations);
125
-			$keys_bogus = array_merge(array('not-set'),array_keys($locations),array('not-set-too'));
125
+			$keys_bogus = array_merge(array('not-set'), array_keys($locations), array('not-set-too'));
126 126
 			if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
127 127
 			{
128
-				$mget = $this->mget(array($level,__CLASS__,$keys));
129
-				$mget_bogus = $this->mget(array($level,__CLASS__,$keys_bogus));
128
+				$mget = $this->mget(array($level, __CLASS__, $keys));
129
+				$mget_bogus = $this->mget(array($level, __CLASS__, $keys_bogus));
130 130
 			/* Api\Cache::getCache() gives a different result, as it does NOT use $level direkt
131 131
 			}
132 132
 			else
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	function flush(array $keys)
162 162
 	{
163
-		unset($keys);	// required by function signature
163
+		unset($keys); // required by function signature
164 164
 		return false;
165 165
 	}
166 166
 }
Please login to merge, or discard this patch.
Braces   +52 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,18 +49,27 @@  discard block
 block discarded – undo
49 49
 				$get_before_set = $this->get(array($level,__CLASS__,$location));
50 50
 				if (!is_null($get_before_set))
51 51
 				{
52
-					if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
52
+					if ($verbose)
53
+					{
54
+						echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
55
+					}
53 56
 					++$failed;
54 57
 				}
55 58
 				if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true)
56 59
 				{
57
-					if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n";
60
+					if ($verbose)
61
+					{
62
+						echo "$label: set returned ".array2string($set)." !== TRUE\n";
63
+					}
58 64
 					++$failed;
59 65
 				}
60 66
 				$get_after_set = $this->get(array($level,__CLASS__,$location));
61 67
 				if ($get_after_set !== $data)
62 68
 				{
63
-					if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
69
+					if ($verbose)
70
+					{
71
+						echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
72
+					}
64 73
 					++$failed;
65 74
 				}
66 75
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
@@ -68,25 +77,37 @@  discard block
 block discarded – undo
68 77
 					$mget_after_set = $this->mget(array($level,__CLASS__,array($location)));
69 78
 					if ($mget_after_set[$location] !== $data)
70 79
 					{
71
-						if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
80
+						if ($verbose)
81
+						{
82
+							echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
83
+						}
72 84
 						++$failed;
73 85
 					}
74 86
 				}
75 87
 				$add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data');
76 88
 				if ($add_after_set !== false)
77 89
 				{
78
-					if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n";
90
+					if ($verbose)
91
+					{
92
+						echo "$label: add_after_set=".array2string($add_after_set)."\n";
93
+					}
79 94
 					++$failed;
80 95
 				}
81 96
 				if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true)
82 97
 				{
83
-					if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
98
+					if ($verbose)
99
+					{
100
+						echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
101
+					}
84 102
 					++$failed;
85 103
 				}
86 104
 				$get_after_delete = $this->get(array($level,__CLASS__,$location));
87 105
 				if (!is_null($get_after_delete))
88 106
 				{
89
-					if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
107
+					if ($verbose)
108
+					{
109
+						echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
110
+					}
90 111
 					++$failed;
91 112
 				}
92 113
 				// prepare for mget of everything
@@ -96,18 +117,27 @@  discard block
 block discarded – undo
96 117
 					$mget_after_delete = $this->mget(array($level,__CLASS__,array($location)));
97 118
 					if (isset($mget_after_delete[$location]))
98 119
 					{
99
-						if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
120
+						if ($verbose)
121
+						{
122
+							echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
123
+						}
100 124
 						++$failed;
101 125
 					}
102 126
 				}
103
-				elseif (!is_null($data))	// emulation can NOT distinquish between null and not set
127
+				elseif (!is_null($data))
128
+				{
129
+					// emulation can NOT distinquish between null and not set
104 130
 				{
105 131
 					$locations[$location] = $data;
106 132
 				}
133
+				}
107 134
 				$add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10);
108 135
 				if ($add_after_delete !== true)
109 136
 				{
110
-					if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
137
+					if ($verbose)
138
+					{
139
+						echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
140
+					}
111 141
 					++$failed;
112 142
 				}
113 143
 				else
@@ -115,7 +145,10 @@  discard block
 block discarded – undo
115 145
 					$get_after_add = $this->get(array($level,__CLASS__,$location));
116 146
 					if ($get_after_add !== $data)
117 147
 					{
118
-						if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
148
+						if ($verbose)
149
+						{
150
+							echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
151
+						}
119 152
 						++$failed;
120 153
 					}
121 154
 				}
@@ -136,12 +169,18 @@  discard block
 block discarded – undo
136 169
 			}*/
137 170
 				if ($mget !== $locations)
138 171
 				{
139
-					if ($verbose) echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
172
+					if ($verbose)
173
+					{
174
+						echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
175
+					}
140 176
 					++$failed;
141 177
 				}
142 178
 				if ($mget_bogus !== $locations)
143 179
 				{
144
-					if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
180
+					if ($verbose)
181
+					{
182
+						echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
183
+					}
145 184
 					++$failed;
146 185
 				}
147 186
 			}
Please login to merge, or discard this patch.
api/src/Cache/Provider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int $expiration =0
39 39
 	 * @return boolean true on success, false on error, incl. key already exists in cache
40 40
 	 */
41
-	function add(array $keys,$data,$expiration=0);
41
+	function add(array $keys, $data, $expiration = 0);
42 42
 
43 43
 	/**
44 44
 	 * Stores some data in the cache
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param int $expiration =0
49 49
 	 * @return boolean true on success, false on error
50 50
 	 */
51
-	function set(array $keys,$data,$expiration=0);
51
+	function set(array $keys, $data, $expiration = 0);
52 52
 
53 53
 	/**
54 54
 	 * Get some data from the cache
Please login to merge, or discard this patch.
api/src/Country.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 * @param boolean $translated =true use translated name or english
365 365
 	 * @return string
366 366
 	 */
367
-	public static function get_full_name($code,$translated=true)
367
+	public static function get_full_name($code, $translated = true)
368 368
 	{
369 369
 		if ($translated)
370 370
 		{
@@ -383,36 +383,36 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	public static function country_code($name)
385 385
 	{
386
-		if (!$name) return '';	// nothing to do
386
+		if (!$name) return ''; // nothing to do
387 387
 
388 388
 		if (strlen($name) == 2 && isset(self::$country_array[$name]))
389 389
 		{
390
-			return $name;	// $name is already a country-code
390
+			return $name; // $name is already a country-code
391 391
 		}
392 392
 
393
-		if (($code = array_search(strtoupper($name),self::$country_array)) !== false)
393
+		if (($code = array_search(strtoupper($name), self::$country_array)) !== false)
394 394
 		{
395 395
 			return $code;
396 396
 		}
397 397
 		if (!self::$countries_translated) self::_translate_countries();
398 398
 
399
-		if (($code = array_search(strtoupper($name),self::$countries_translated)) !== false ||
400
-			($code = array_search($name,self::$countries_translated)) !== false)
399
+		if (($code = array_search(strtoupper($name), self::$countries_translated)) !== false ||
400
+			($code = array_search($name, self::$countries_translated)) !== false)
401 401
 		{
402 402
 			return $code;
403 403
 		}
404 404
 		// search case-insensitive all translations for the english phrase of given country $name
405 405
 		// we do that to catch all possible cases of translations
406
-		static $en_names = array();	// we do some caching to minimize db-accesses
406
+		static $en_names = array(); // we do some caching to minimize db-accesses
407 407
 		if (isset($en_names[$name]))
408 408
 		{
409 409
 			$name = $en_names[$name];
410 410
 		}
411
-		elseif (($name_en = Translation::get_message_id($name,'common')))
411
+		elseif (($name_en = Translation::get_message_id($name, 'common')))
412 412
 		{
413 413
 			$name = $en_names[$name] = strtoupper($name_en);
414 414
 		}
415
-		if (($code = array_search(strtoupper($name),self::$country_array)) !== false)
415
+		if (($code = array_search(strtoupper($name), self::$country_array)) !== false)
416 416
 		{
417 417
 			return $code;
418 418
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 * @param boolean $translated =true use translated names or english
426 426
 	 * @return array with 2-letter code => name pairs
427 427
 	 */
428
-	public static function countries($translated=true)
428
+	public static function countries($translated = true)
429 429
 	{
430 430
 		if ($translated)
431 431
 		{
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 
448 448
 		self::$countries_translated = self::$country_array;
449 449
 		// try to translate them and sort alphabetic
450
-		foreach(self::$countries_translated as $k => $name)
450
+		foreach (self::$countries_translated as $k => $name)
451 451
 		{
452 452
 			self::$countries_translated[$k] = lang($name);
453 453
 		}
454 454
 
455
-		if(class_exists('Collator') && class_exists('Locale'))
455
+		if (class_exists('Collator') && class_exists('Locale'))
456 456
 		{
457 457
 			$col = new \Collator(Preferences::setlocale());
458 458
 			$col->asort(self::$countries_translated);
Please login to merge, or discard this patch.
Braces   +21 added lines, -5 removed lines patch added patch discarded remove patch
@@ -368,7 +368,10 @@  discard block
 block discarded – undo
368 368
 	{
369 369
 		if ($translated)
370 370
 		{
371
-			if (!self::$countries_translated) self::_translate_countries();
371
+			if (!self::$countries_translated)
372
+			{
373
+				self::_translate_countries();
374
+			}
372 375
 
373 376
 			return self::$countries_translated[strtoupper($code)];
374 377
 		}
@@ -383,7 +386,11 @@  discard block
 block discarded – undo
383 386
 	 */
384 387
 	public static function country_code($name)
385 388
 	{
386
-		if (!$name) return '';	// nothing to do
389
+		if (!$name)
390
+		{
391
+			return '';
392
+		}
393
+		// nothing to do
387 394
 
388 395
 		if (strlen($name) == 2 && isset(self::$country_array[$name]))
389 396
 		{
@@ -394,7 +401,10 @@  discard block
 block discarded – undo
394 401
 		{
395 402
 			return $code;
396 403
 		}
397
-		if (!self::$countries_translated) self::_translate_countries();
404
+		if (!self::$countries_translated)
405
+		{
406
+			self::_translate_countries();
407
+		}
398 408
 
399 409
 		if (($code = array_search(strtoupper($name),self::$countries_translated)) !== false ||
400 410
 			($code = array_search($name,self::$countries_translated)) !== false)
@@ -429,7 +439,10 @@  discard block
 block discarded – undo
429 439
 	{
430 440
 		if ($translated)
431 441
 		{
432
-			if (!self::$countries_translated) self::_translate_countries();
442
+			if (!self::$countries_translated)
443
+			{
444
+				self::_translate_countries();
445
+			}
433 446
 
434 447
 			return self::$countries_translated;
435 448
 		}
@@ -443,7 +456,10 @@  discard block
 block discarded – undo
443 456
 	 */
444 457
 	protected static function _translate_countries()
445 458
 	{
446
-		if (self::$countries_translated) return;
459
+		if (self::$countries_translated)
460
+		{
461
+			return;
462
+		}
447 463
 
448 464
 		self::$countries_translated = self::$country_array;
449 465
 		// try to translate them and sort alphabetic
Please login to merge, or discard this patch.
api/src/Auth/Fallbackmail2sql.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	/**
23 23
 	 * Constructor
24 24
 	 */
25
-	function __construct($primary='mail', $fallback='sql')
25
+	function __construct($primary = 'mail', $fallback = 'sql')
26 26
 	{
27 27
 		parent::__construct($primary, $fallback);
28 28
 	}
Please login to merge, or discard this patch.
api/src/Auth/Nis.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
27 27
 	 * @return boolean true if successful authenticated, false otherwise
28 28
 	 */
29
-	function authenticate($username, $passwd, $passwd_type='text')
29
+	function authenticate($username, $passwd, $passwd_type = 'text')
30 30
 	{
31
-		unset($passwd_type);	// not used but required by interface
31
+		unset($passwd_type); // not used but required by interface
32 32
 
33 33
 		$domain = yp_get_default_domain();
34
-		if(!empty($GLOBALS['egw_info']['server']['nis_domain']))
34
+		if (!empty($GLOBALS['egw_info']['server']['nis_domain']))
35 35
 		{
36 36
 			$domain = $GLOBALS['egw_info']['server']['nis_domain'];
37 37
 		}
38 38
 
39 39
 		$map = "passwd.byname";
40
-		if(!empty($GLOBALS['egw_info']['server']['nis_map']))
40
+		if (!empty($GLOBALS['egw_info']['server']['nis_map']))
41 41
 		{
42 42
 			$map = $GLOBALS['egw_info']['server']['nis_map'];
43 43
 		}
44
-		$entry = yp_match( $domain, $map, $username );
44
+		$entry = yp_match($domain, $map, $username);
45 45
 
46 46
 		/*
47 47
 		 * we assume that the map is structured in the usual
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	 * @param int $account_id =0 account id of user whose passwd should be changed
64 64
 	 * @return boolean true if password successful changed, false otherwise
65 65
 	 */
66
-	function change_password($old_passwd, $new_passwd, $account_id=0)
66
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
67 67
 	{
68
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
68
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
69 69
 
70 70
 		// can't change passwords unless server runs as root (bad idea)
71
-		return( False );
71
+		return(False);
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
api/src/Auth/Sqlssl.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
30 30
 	 * @return boolean true if successful authenticated, false otherwise
31 31
 	 */
32
-	function authenticate($username, $passwd, $passwd_type='text')
32
+	function authenticate($username, $passwd, $passwd_type = 'text')
33 33
 	{
34
-		unset($passwd_type);	// not used but required by interface
34
+		unset($passwd_type); // not used but required by interface
35 35
 
36 36
 		$local_debug = False;
37 37
 
38
-		if($local_debug)
38
+		if ($local_debug)
39 39
 		{
40 40
 			echo "<b>Debug SQL: uid - $username passwd - $passwd</b>";
41 41
 		}
42
-		if (!($row = $this->db->select($this->table,'account_lid,account_pwd',array(
42
+		if (!($row = $this->db->select($this->table, 'account_lid,account_pwd', array(
43 43
 			'account_lid' => $username,
44 44
 			'account_status' => 'A',
45 45
 			'account_type'   => 'u',
46
-		),__LINE__,__FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
46
+		), __LINE__, __FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
47 47
 		{
48 48
 			return false;
49 49
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		# Apache + mod_ssl provide the data in the environment
52 52
 		# Certificate (chain) verification occurs inside mod_ssl
53 53
 		# see http://www.modssl.org/docs/2.8/ssl_howto.html#ToC6
54
-		if(!isset($_SERVER['SSL_CLIENT_S_DN']))
54
+		if (!isset($_SERVER['SSL_CLIENT_S_DN']))
55 55
 		{
56 56
 			# if we're not doing SSL authentication, behave like auth_sql
57 57
 			return Api\Auth::compare_password($passwd, $row['account_pwd'], 'md5', strtolower($username));
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @param int $account_id =0 account id of user whose passwd should be changed
68 68
 	 * @return boolean true if password successful changed, false otherwise
69 69
 	 */
70
-	function change_password($old_passwd, $new_passwd, $account_id=0)
70
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
71 71
 	{
72
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
72
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
73 73
 
74 74
 		// deny password changes.
75 75
 		return False;
Please login to merge, or discard this patch.
api/src/Auth/Pam.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
31 31
 	 * @return boolean true if successful authenticated, false otherwise
32 32
 	 */
33
-	function authenticate($username, $passwd, $passwd_type='text')
33
+	function authenticate($username, $passwd, $passwd_type = 'text')
34 34
 	{
35
-		unset($passwd_type);	// not used but required by interface
35
+		unset($passwd_type); // not used but required by interface
36 36
 
37 37
 		if (pam_auth($username, get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd))
38 38
 		{
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 			if (!$GLOBALS['egw']->accounts->name2id($username) &&
41 41
 				function_exists('posix_getpwnam') && ($data = posix_getpwnam($username)))
42 42
 			{
43
-				list($fullname) = explode(',',$data['gecos']);
44
-				$parts = explode(' ',$fullname);
43
+				list($fullname) = explode(',', $data['gecos']);
44
+				$parts = explode(' ', $fullname);
45 45
 				if (count($parts) > 1)
46 46
 				{
47 47
 					$lastname = array_pop($parts);
48
-					$firstname = implode(' ',$parts);
48
+					$firstname = implode(' ', $parts);
49 49
 					$email = Api\Accounts::email($firstname, $lastname, $username);
50 50
 
51 51
 					$GLOBALS['auto_create_acct'] = array(
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @param int $account_id =0 account id of user whose passwd should be changed
70 70
 	 * @return boolean true if password successful changed, false otherwise
71 71
 	 */
72
-	function change_password($old_passwd, $new_passwd, $account_id=0)
72
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
73 73
 	{
74
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
74
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
75 75
 
76 76
 		// deny password changes.
77 77
 		return False;
Please login to merge, or discard this patch.
api/src/Auth/Mail.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
35 35
 	 * @return boolean true if successful authenticated, false otherwise
36 36
 	 */
37
-	function authenticate($username, $passwd, $passwd_type='text')
37
+	function authenticate($username, $passwd, $passwd_type = 'text')
38 38
 	{
39
-		unset($passwd_type);	// not used but required by function signature
39
+		unset($passwd_type); // not used but required by function signature
40 40
 
41 41
 		switch ($GLOBALS['egw_info']['server']['mail_login_type'])
42 42
 		{
43 43
 			case 'vmailmgr':
44
-				$username = $username . '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
44
+				$username = $username.'@'.$GLOBALS['egw_info']['server']['mail_suffix'];
45 45
 				break;
46 46
 			case 'email':
47 47
 				$username = $GLOBALS['egw']->accounts->id2name($username, 'account_email');
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				$mailauth = true;
69 69
 				$imap->logout();
70 70
 			}
71
-			catch(Horde_Imap_Client_Exception $e) {
71
+			catch (Horde_Imap_Client_Exception $e) {
72 72
 				// throw everything but authentication failed as exception
73 73
 				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) throw $e;
74 74
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 				case 'imap':
86 86
 				default:
87 87
 					if (!isset($port)) $port = 143;
88
-					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username , $passwd);
88
+					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username, $passwd);
89 89
 					break;
90 90
 				case 'imaps':
91 91
 					if (!isset($port)) $port = 993;
92
-					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
92
+					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
93 93
 					break;
94 94
 				case 'pop3':
95 95
 					if (!isset($port)) $port = 110;
96
-					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
96
+					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
97 97
 					break;
98 98
 				case 'pop3s':
99 99
 					if (!isset($port)) $port = 995;
100
-					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
100
+					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
101 101
 					break;
102 102
 			}
103 103
 			if ($mailauth) imap_close($mailauth);
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @param int $account_id =0 account id of user whose passwd should be changed
114 114
 	 * @return boolean true if password successful changed, false otherwise
115 115
 	 */
116
-	function change_password($old_passwd, $new_passwd, $account_id=0)
116
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
117 117
 	{
118
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by function sigature
118
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by function sigature
119 119
 
120 120
 		return False;
121 121
 	}
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,7 +70,10 @@  discard block
 block discarded – undo
70 70
 			}
71 71
 			catch(Horde_Imap_Client_Exception $e) {
72 72
 				// throw everything but authentication failed as exception
73
-				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) throw $e;
73
+				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED)
74
+				{
75
+					throw $e;
76
+				}
74 77
 
75 78
 				$mailauth = false;
76 79
 			}
@@ -84,23 +87,38 @@  discard block
 block discarded – undo
84 87
 			{
85 88
 				case 'imap':
86 89
 				default:
87
-					if (!isset($port)) $port = 143;
90
+					if (!isset($port))
91
+					{
92
+						$port = 143;
93
+					}
88 94
 					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username , $passwd);
89 95
 					break;
90 96
 				case 'imaps':
91
-					if (!isset($port)) $port = 993;
97
+					if (!isset($port))
98
+					{
99
+						$port = 993;
100
+					}
92 101
 					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
93 102
 					break;
94 103
 				case 'pop3':
95
-					if (!isset($port)) $port = 110;
104
+					if (!isset($port))
105
+					{
106
+						$port = 110;
107
+					}
96 108
 					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
97 109
 					break;
98 110
 				case 'pop3s':
99
-					if (!isset($port)) $port = 995;
111
+					if (!isset($port))
112
+					{
113
+						$port = 995;
114
+					}
100 115
 					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
101 116
 					break;
102 117
 			}
103
-			if ($mailauth) imap_close($mailauth);
118
+			if ($mailauth)
119
+			{
120
+				imap_close($mailauth);
121
+			}
104 122
 		}
105 123
 		return !!$mailauth;
106 124
 	}
Please login to merge, or discard this patch.