@@ -32,33 +32,33 @@ discard block |
||
32 | 32 | const SAMBA4 = 2; |
33 | 33 | |
34 | 34 | /** |
35 | - * @var array $namingContext holds the supported namingcontexts |
|
36 | - */ |
|
35 | + * @var array $namingContext holds the supported namingcontexts |
|
36 | + */ |
|
37 | 37 | var $namingContext = array(); |
38 | 38 | |
39 | 39 | /** |
40 | - * @var string $version holds the LDAP server version |
|
41 | - */ |
|
40 | + * @var string $version holds the LDAP server version |
|
41 | + */ |
|
42 | 42 | var $version = 2; |
43 | 43 | |
44 | 44 | /** |
45 | - * @var integer $serverType holds the type of LDAP server(OpenLDAP, ADS, NDS, ...) |
|
46 | - */ |
|
45 | + * @var integer $serverType holds the type of LDAP server(OpenLDAP, ADS, NDS, ...) |
|
46 | + */ |
|
47 | 47 | var $serverType = 0; |
48 | 48 | |
49 | 49 | /** |
50 | - * @var string $_subSchemaEntry the subschema entry DN |
|
51 | - */ |
|
50 | + * @var string $_subSchemaEntry the subschema entry DN |
|
51 | + */ |
|
52 | 52 | var $subSchemaEntry = ''; |
53 | 53 | |
54 | 54 | /** |
55 | - * @var array $supportedObjectClasses the supported objectclasses |
|
56 | - */ |
|
55 | + * @var array $supportedObjectClasses the supported objectclasses |
|
56 | + */ |
|
57 | 57 | var $supportedObjectClasses = array(); |
58 | 58 | |
59 | 59 | /** |
60 | - * @var array $supportedOIDs the supported OIDs |
|
61 | - */ |
|
60 | + * @var array $supportedOIDs the supported OIDs |
|
61 | + */ |
|
62 | 62 | var $supportedOIDs = array(); |
63 | 63 | |
64 | 64 | /** |
@@ -79,50 +79,50 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * gets the version |
|
83 | - * |
|
84 | - * @return integer the supported ldap version |
|
85 | - */ |
|
82 | + * gets the version |
|
83 | + * |
|
84 | + * @return integer the supported ldap version |
|
85 | + */ |
|
86 | 86 | function getVersion() |
87 | 87 | { |
88 | 88 | return $this->version; |
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | - * sets the namingcontexts |
|
93 | - * |
|
94 | - * @param array $_namingContext the supported namingcontexts |
|
95 | - */ |
|
92 | + * sets the namingcontexts |
|
93 | + * |
|
94 | + * @param array $_namingContext the supported namingcontexts |
|
95 | + */ |
|
96 | 96 | function setNamingContexts($_namingContext) |
97 | 97 | { |
98 | 98 | $this->namingContext = $_namingContext; |
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | - * sets the type of the ldap server(OpenLDAP, ADS, NDS, ...) |
|
103 | - * |
|
104 | - * @param integer $_serverType the type of ldap server |
|
105 | - */ |
|
102 | + * sets the type of the ldap server(OpenLDAP, ADS, NDS, ...) |
|
103 | + * |
|
104 | + * @param integer $_serverType the type of ldap server |
|
105 | + */ |
|
106 | 106 | function setServerType($_serverType) |
107 | 107 | { |
108 | 108 | $this->serverType = $_serverType; |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * sets the DN for the subschema entry |
|
113 | - * |
|
114 | - * @param string $_subSchemaEntry the subschema entry DN |
|
115 | - */ |
|
112 | + * sets the DN for the subschema entry |
|
113 | + * |
|
114 | + * @param string $_subSchemaEntry the subschema entry DN |
|
115 | + */ |
|
116 | 116 | function setSubSchemaEntry($_subSchemaEntry) |
117 | 117 | { |
118 | 118 | $this->subSchemaEntry = $_subSchemaEntry; |
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * sets the supported objectclasses |
|
123 | - * |
|
124 | - * @param array $_supportedObjectClasses the supported objectclasses |
|
125 | - */ |
|
122 | + * sets the supported objectclasses |
|
123 | + * |
|
124 | + * @param array $_supportedObjectClasses the supported objectclasses |
|
125 | + */ |
|
126 | 126 | function setSupportedObjectClasses($_supportedObjectClasses) |
127 | 127 | { |
128 | 128 | $this->supportedOIDs = $_supportedObjectClasses; |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * sets the version |
|
134 | - * |
|
135 | - * @param integer $_version the supported ldap version |
|
136 | - */ |
|
133 | + * sets the version |
|
134 | + * |
|
135 | + * @param integer $_version the supported ldap version |
|
136 | + */ |
|
137 | 137 | function setVersion($_version) |
138 | 138 | { |
139 | 139 | $this->version = $_version; |
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * checks for supported objectclasses |
|
144 | - * |
|
145 | - * @return bool returns true if the ldap server supports this objectclass |
|
146 | - */ |
|
143 | + * checks for supported objectclasses |
|
144 | + * |
|
145 | + * @return bool returns true if the ldap server supports this objectclass |
|
146 | + */ |
|
147 | 147 | function supportsObjectClass($_objectClass) |
148 | 148 | { |
149 | 149 | if($this->supportedObjectClasses[strtolower($_objectClass)]) |
@@ -218,7 +218,8 @@ |
||
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; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function supportsObjectClass($_objectClass) |
147 | 147 | { |
148 | - if($this->supportedObjectClasses[strtolower($_objectClass)]) |
|
148 | + if ($this->supportedObjectClasses[strtolower($_objectClass)]) |
|
149 | 149 | { |
150 | 150 | return true; |
151 | 151 | } |
@@ -160,21 +160,21 @@ discard block |
||
160 | 160 | * @param int $version 2 or 3 |
161 | 161 | * @return ldapserverinfo |
162 | 162 | */ |
163 | - public static function get($ds, $host, $version=3) |
|
163 | + public static function get($ds, $host, $version = 3) |
|
164 | 164 | { |
165 | - $filter='(objectclass=*)'; |
|
166 | - $justthese = array('structuralObjectClass','namingContexts','supportedLDAPVersion','subschemaSubentry','vendorname'); |
|
167 | - if(($sr = @ldap_read($ds, '', $filter, $justthese))) |
|
165 | + $filter = '(objectclass=*)'; |
|
166 | + $justthese = array('structuralObjectClass', 'namingContexts', 'supportedLDAPVersion', 'subschemaSubentry', 'vendorname'); |
|
167 | + if (($sr = @ldap_read($ds, '', $filter, $justthese))) |
|
168 | 168 | { |
169 | - if(($info = ldap_get_entries($ds, $sr))) |
|
169 | + if (($info = ldap_get_entries($ds, $sr))) |
|
170 | 170 | { |
171 | 171 | $ldapServerInfo = new ServerInfo($host); |
172 | 172 | $ldapServerInfo->setVersion($version); |
173 | 173 | |
174 | 174 | // check for naming contexts |
175 | - if($info[0]['namingcontexts']) |
|
175 | + if ($info[0]['namingcontexts']) |
|
176 | 176 | { |
177 | - for($i=0; $i<$info[0]['namingcontexts']['count']; $i++) |
|
177 | + for ($i = 0; $i < $info[0]['namingcontexts']['count']; $i++) |
|
178 | 178 | { |
179 | 179 | $namingcontexts[] = $info[0]['namingcontexts'][$i]; |
180 | 180 | } |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | // check for ldap server type |
185 | - if($info[0]['structuralobjectclass']) |
|
185 | + if ($info[0]['structuralobjectclass']) |
|
186 | 186 | { |
187 | - switch($info[0]['structuralobjectclass'][0]) |
|
187 | + switch ($info[0]['structuralobjectclass'][0]) |
|
188 | 188 | { |
189 | 189 | case 'OpenLDAProotDSE': |
190 | 190 | $ldapServerType = self::OPENLDAP; |
@@ -201,30 +201,30 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | // check for subschema entry dn |
204 | - if($info[0]['subschemasubentry']) |
|
204 | + if ($info[0]['subschemasubentry']) |
|
205 | 205 | { |
206 | 206 | $subschemasubentry = $info[0]['subschemasubentry'][0]; |
207 | 207 | $ldapServerInfo->setSubSchemaEntry($subschemasubentry); |
208 | 208 | } |
209 | 209 | |
210 | 210 | // create list of supported objetclasses |
211 | - if(!empty($subschemasubentry)) |
|
211 | + if (!empty($subschemasubentry)) |
|
212 | 212 | { |
213 | - $filter='(objectclass=*)'; |
|
213 | + $filter = '(objectclass=*)'; |
|
214 | 214 | $justthese = array('objectClasses'); |
215 | 215 | |
216 | - if(($sr = ldap_read($ds, $subschemasubentry, $filter, $justthese))) |
|
216 | + if (($sr = ldap_read($ds, $subschemasubentry, $filter, $justthese))) |
|
217 | 217 | { |
218 | - if(($info = ldap_get_entries($ds, $sr))) |
|
218 | + if (($info = ldap_get_entries($ds, $sr))) |
|
219 | 219 | { |
220 | - if($info[0]['objectclasses']) { |
|
221 | - for($i=0; $i<$info[0]['objectclasses']['count']; $i++) |
|
220 | + if ($info[0]['objectclasses']) { |
|
221 | + for ($i = 0; $i < $info[0]['objectclasses']['count']; $i++) |
|
222 | 222 | { |
223 | 223 | $matches = null; |
224 | - if(preg_match('/^\( (.*) NAME \'(\w*)\' /', $info[0]['objectclasses'][$i], $matches)) |
|
224 | + if (preg_match('/^\( (.*) NAME \'(\w*)\' /', $info[0]['objectclasses'][$i], $matches)) |
|
225 | 225 | { |
226 | 226 | #_debug_array($matches); |
227 | - if(count($matches) == 3) |
|
227 | + if (count($matches) == 3) |
|
228 | 228 | { |
229 | 229 | $supportedObjectClasses[$matches[1]] = strtolower($matches[2]); |
230 | 230 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param string $function name of the global (window) javascript function to call |
65 | 65 | * @param array $parameters =array() |
66 | 66 | */ |
67 | - public function apply($function,array $parameters=array()) |
|
67 | + public function apply($function, array $parameters = array()) |
|
68 | 68 | { |
69 | 69 | if (is_string($function)) |
70 | 70 | { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function call($function) |
89 | 89 | { |
90 | 90 | $parameters = func_get_args(); |
91 | - array_shift($parameters); // shift off $function |
|
91 | + array_shift($parameters); // shift off $function |
|
92 | 92 | |
93 | 93 | if (is_string($function)) |
94 | 94 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $method name of the jquery to call |
111 | 111 | * @param array $parameters =array() |
112 | 112 | */ |
113 | - public function jquery($selector,$method,array $parameters=array()) |
|
113 | + public function jquery($selector, $method, array $parameters = array()) |
|
114 | 114 | { |
115 | 115 | if (is_string($selector) && is_string($method)) |
116 | 116 | { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param string $app =null default current app from flags |
170 | 170 | * or only the current application |
171 | 171 | */ |
172 | - public function redirect($url, $global = false, $app=null) |
|
172 | + public function redirect($url, $global = false, $app = null) |
|
173 | 173 | { |
174 | 174 | if (is_string($url) && is_bool($global)) |
175 | 175 | { |
@@ -242,13 +242,13 @@ |
||
242 | 242 | if ($ret === false && ($err = json_last_error())) |
243 | 243 | { |
244 | 244 | static $json_err2str = array( |
245 | - JSON_ERROR_NONE => 'No errors', |
|
246 | - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
|
247 | - JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', |
|
248 | - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
|
249 | - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
|
250 | - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', |
|
251 | - ); |
|
245 | + JSON_ERROR_NONE => 'No errors', |
|
246 | + JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
|
247 | + JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', |
|
248 | + JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
|
249 | + JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
|
250 | + JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', |
|
251 | + ); |
|
252 | 252 | error_log(__METHOD__.'('.array2string($var).') json_last_error()='.$err.'='.$json_err2str[$err]); |
253 | 253 | |
254 | 254 | if (($var = self::fix_content($var))) |
@@ -268,7 +268,10 @@ |
||
268 | 268 | */ |
269 | 269 | public static function fix_content($var, $prefix='') |
270 | 270 | { |
271 | - if (json_encode($var) !== false) return $var; |
|
271 | + if (json_encode($var) !== false) |
|
272 | + { |
|
273 | + return $var; |
|
274 | + } |
|
272 | 275 | |
273 | 276 | if (is_scalar($var)) |
274 | 277 | { |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | // Wrap the result array into a parent "response" Object |
227 | 227 | $res = array( |
228 | 228 | 'response' => $inst->responseArray, |
229 | - )+Api\Framework::get_page_generation_time(); |
|
229 | + ) + Api\Framework::get_page_generation_time(); |
|
230 | 230 | |
231 | - return self::json_encode($res); //PHP5.3+, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
231 | + return self::json_encode($res); //PHP5.3+, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @param string $prefix ='' |
269 | 269 | * @return mixed |
270 | 270 | */ |
271 | - public static function fix_content($var, $prefix='') |
|
271 | + public static function fix_content($var, $prefix = '') |
|
272 | 272 | { |
273 | 273 | if (json_encode($var) !== false) return $var; |
274 | 274 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | else |
281 | 281 | { |
282 | - foreach($var as $name => &$value) |
|
282 | + foreach ($var as $name => &$value) |
|
283 | 283 | { |
284 | 284 | $value = self::fix_content($value, $prefix ? $prefix.'['.$name.']' : $name); |
285 | 285 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | //reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? |
309 | 309 | return preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
310 | - '|\xED[\xA0-\xBF][\x80-\xBF]/S', self::UTF8_REPLACEMENT_CHAR, $string ); |
|
310 | + '|\xED[\xA0-\xBF][\x80-\xBF]/S', self::UTF8_REPLACEMENT_CHAR, $string); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param string $filename =null if not starting with as slash relative to EGw files dir (this is strongly prefered for security reasons) |
70 | 70 | */ |
71 | - public function __construct($filename=null) |
|
71 | + public function __construct($filename = null) |
|
72 | 72 | { |
73 | - $this->filenames =& Api\Cache::getSession('phpgwapi', __CLASS__); |
|
73 | + $this->filenames = & Api\Cache::getSession('phpgwapi', __CLASS__); |
|
74 | 74 | |
75 | 75 | if ($filename) |
76 | 76 | { |
77 | 77 | $this->filename = $filename; |
78 | 78 | |
79 | - if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename; |
|
79 | + if (!$this->filenames || !in_array($filename, $this->filenames)) $this->filenames[] = $filename; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param int $start =0 last position in log-file |
88 | 88 | * @throws Api\Exception\WrongParameter |
89 | 89 | */ |
90 | - public function ajax_chunk($filename,$start=0) |
|
90 | + public function ajax_chunk($filename, $start = 0) |
|
91 | 91 | { |
92 | - if (!in_array($filename,$this->filenames)) |
|
92 | + if (!in_array($filename, $this->filenames)) |
|
93 | 93 | { |
94 | 94 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
95 | 95 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | if (file_exists($filename)) |
99 | 99 | { |
100 | 100 | $size = filesize($filename); |
101 | - if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE) |
|
101 | + if (!$start || $start < 0 || $start > $size || $size - $start > 4 * self::MAX_CHUNK_SIZE) |
|
102 | 102 | { |
103 | - $start = $size - 4*self::MAX_CHUNK_SIZE; |
|
103 | + $start = $size - 4 * self::MAX_CHUNK_SIZE; |
|
104 | 104 | if ($start < 0) $start = 0; |
105 | 105 | } |
106 | 106 | $hsize = Api\Vfs::hsize($size); |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param boolean $truncate =false true: truncate file, false: delete file |
132 | 132 | * @throws Api\Exception\WrongParameter |
133 | 133 | */ |
134 | - public function ajax_delete($filename,$truncate=false) |
|
134 | + public function ajax_delete($filename, $truncate = false) |
|
135 | 135 | { |
136 | - if (!in_array($filename,$this->filenames)) |
|
136 | + if (!in_array($filename, $this->filenames)) |
|
137 | 137 | { |
138 | 138 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
139 | 139 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return string |
156 | 156 | * @throws Api\Exception\WrongParameter |
157 | 157 | */ |
158 | - public function show($header=null) |
|
158 | + public function show($header = null) |
|
159 | 159 | { |
160 | 160 | if (!isset($this->filename)) |
161 | 161 | { |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p> |
168 | 168 | <div style="float: right; margin: 2px; margin-right: 5px"> |
169 | 169 | '.Api\Html::form( |
170 | - Api\Html::input('clear_log',lang('Clear window'),'button','id="clear_log"')."\n". |
|
171 | - Api\Html::input('delete_log',lang('Delete file'),'button','id="purge_log"')."\n". |
|
172 | - Api\Html::input('empty_log',lang('Empty file'),'button','id="empty_log"')."\n". |
|
173 | - Api\Html::input('download_log',lang('Download'),'submit','id="download_log"'), |
|
174 | - '','/index.php',array( |
|
170 | + Api\Html::input('clear_log', lang('Clear window'), 'button', 'id="clear_log"')."\n". |
|
171 | + Api\Html::input('delete_log', lang('Delete file'), 'button', 'id="purge_log"')."\n". |
|
172 | + Api\Html::input('empty_log', lang('Empty file'), 'button', 'id="empty_log"')."\n". |
|
173 | + Api\Html::input('download_log', lang('Download'), 'submit', 'id="download_log"'), |
|
174 | + '', '/index.php', array( |
|
175 | 175 | 'menuaction' => 'api.'.__CLASS__.'.download', |
176 | 176 | 'filename' => $this->filename, |
177 | 177 | )).' |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | public function download() |
188 | 188 | { |
189 | 189 | $filename = $_GET['filename']; |
190 | - if (!in_array($filename,$this->filenames)) |
|
190 | + if (!in_array($filename, $this->filenames)) |
|
191 | 191 | { |
192 | 192 | throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!"); |
193 | 193 | } |
194 | 194 | Api\Header\Content::type(basename($filename), 'text/plain'); |
195 | 195 | if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
196 | - for($n=ob_get_level(); $n > 0; --$n) |
|
196 | + for ($n = ob_get_level(); $n > 0; --$n) |
|
197 | 197 | { |
198 | - ob_end_clean(); // stop all output buffering, to NOT run into memory_limit |
|
198 | + ob_end_clean(); // stop all output buffering, to NOT run into memory_limit |
|
199 | 199 | } |
200 | 200 | readfile($filename); |
201 | 201 | exit; |
@@ -79,7 +79,10 @@ discard block |
||
79 | 79 | |
80 | 80 | $this->filename = $filename; |
81 | 81 | |
82 | - if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename; |
|
82 | + if (!$this->filenames || !in_array($filename,$this->filenames)) |
|
83 | + { |
|
84 | + $this->filenames[] = $filename; |
|
85 | + } |
|
83 | 86 | } |
84 | 87 | } |
85 | 88 | |
@@ -96,7 +99,10 @@ discard block |
||
96 | 99 | { |
97 | 100 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
98 | 101 | } |
99 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
102 | + if ($filename[0] != '/') |
|
103 | + { |
|
104 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
105 | + } |
|
100 | 106 | |
101 | 107 | if (file_exists($filename)) |
102 | 108 | { |
@@ -104,7 +110,10 @@ discard block |
||
104 | 110 | if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE) |
105 | 111 | { |
106 | 112 | $start = $size - 4*self::MAX_CHUNK_SIZE; |
107 | - if ($start < 0) $start = 0; |
|
113 | + if ($start < 0) |
|
114 | + { |
|
115 | + $start = 0; |
|
116 | + } |
|
108 | 117 | } |
109 | 118 | $hsize = Api\Vfs::hsize($size); |
110 | 119 | $content = file_get_contents($filename, false, null, $start, self::MAX_CHUNK_SIZE); |
@@ -140,7 +149,10 @@ discard block |
||
140 | 149 | { |
141 | 150 | throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!"); |
142 | 151 | } |
143 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
152 | + if ($filename[0] != '/') |
|
153 | + { |
|
154 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
155 | + } |
|
144 | 156 | if ($truncate) |
145 | 157 | { |
146 | 158 | file_put_contents($filename, ''); |
@@ -164,7 +176,10 @@ discard block |
||
164 | 176 | { |
165 | 177 | throw new Api\Exception\WrongParameter("Must be instanciated with filename!"); |
166 | 178 | } |
167 | - if (is_null($header)) $header = $this->filename; |
|
179 | + if (is_null($header)) |
|
180 | + { |
|
181 | + $header = $this->filename; |
|
182 | + } |
|
168 | 183 | |
169 | 184 | return ' |
170 | 185 | <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p> |
@@ -195,7 +210,10 @@ discard block |
||
195 | 210 | throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!"); |
196 | 211 | } |
197 | 212 | Api\Header\Content::type(basename($filename), 'text/plain'); |
198 | - if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
213 | + if ($filename[0] != '/') |
|
214 | + { |
|
215 | + $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename; |
|
216 | + } |
|
199 | 217 | for($n=ob_get_level(); $n > 0; --$n) |
200 | 218 | { |
201 | 219 | ob_end_clean(); // stop all output buffering, to NOT run into memory_limit |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @var int |
73 | 73 | */ |
74 | - protected $start=0; |
|
74 | + protected $start = 0; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Number of entries queried from callback in one call |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param array $filter filter for propfind call |
96 | 96 | * @param array $files =array() extra files/responses to return too |
97 | 97 | */ |
98 | - public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
|
98 | + public function __construct(Handler $handler, $path, array $filter, array &$files = array()) |
|
99 | 99 | { |
100 | 100 | if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
101 | 101 | $this->path = $path; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $current = current($this->files); |
127 | 127 | |
128 | 128 | if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
129 | - return $current['path']; // we return path as key |
|
129 | + return $current['path']; // we return path as key |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | // try query further files via propfind callback of handler and store result in $this->files |
149 | - $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
|
149 | + $this->files = $this->handler->propfind_callback($this->path, $this->filter, array($this->start, self::CHUNK_SIZE)); |
|
150 | 150 | if (!is_array($this->files) || !($entries = count($this->files))) |
151 | 151 | { |
152 | 152 | if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
153 | - return false; // no further entries |
|
153 | + return false; // no further entries |
|
154 | 154 | } |
155 | 155 | $this->start += self::CHUNK_SIZE; |
156 | 156 | reset($this->files); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $this->start = 0; |
171 | 171 | $this->files = $this->common_files; |
172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
172 | + if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
173 | 173 | reset($this->files); |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return boolean |
180 | 180 | */ |
181 | - public function valid () |
|
181 | + public function valid() |
|
182 | 182 | { |
183 | 183 | if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
184 | 184 | return current($this->files) !== false; |
@@ -97,7 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
99 | 99 | { |
100 | - if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
100 | + if ($this->debug) |
|
101 | + { |
|
102 | + error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
103 | + } |
|
101 | 104 | $this->path = $path; |
102 | 105 | $this->handler = $handler; |
103 | 106 | $this->filter = $filter; |
@@ -112,7 +115,10 @@ discard block |
||
112 | 115 | */ |
113 | 116 | public function current() |
114 | 117 | { |
115 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
118 | + if ($this->debug) |
|
119 | + { |
|
120 | + error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
121 | + } |
|
116 | 122 | return current($this->files); |
117 | 123 | } |
118 | 124 | |
@@ -125,7 +131,10 @@ discard block |
||
125 | 131 | { |
126 | 132 | $current = current($this->files); |
127 | 133 | |
128 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
134 | + if ($this->debug) |
|
135 | + { |
|
136 | + error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
137 | + } |
|
129 | 138 | return $current['path']; // we return path as key |
130 | 139 | } |
131 | 140 | |
@@ -136,26 +145,38 @@ discard block |
||
136 | 145 | { |
137 | 146 | if (next($this->files) !== false) |
138 | 147 | { |
139 | - if ($this->debug) error_log(__METHOD__."() returning TRUE"); |
|
148 | + if ($this->debug) |
|
149 | + { |
|
150 | + error_log(__METHOD__."() returning TRUE"); |
|
151 | + } |
|
140 | 152 | return true; |
141 | 153 | } |
142 | 154 | // check if previous query gave less then CHUNK_SIZE entries --> we're done |
143 | 155 | if ($this->start && count($this->files) < self::CHUNK_SIZE) |
144 | 156 | { |
145 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
157 | + if ($this->debug) |
|
158 | + { |
|
159 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
160 | + } |
|
146 | 161 | return false; |
147 | 162 | } |
148 | 163 | // try query further files via propfind callback of handler and store result in $this->files |
149 | 164 | $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
150 | 165 | if (!is_array($this->files) || !($entries = count($this->files))) |
151 | 166 | { |
152 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
167 | + if ($this->debug) |
|
168 | + { |
|
169 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
170 | + } |
|
153 | 171 | return false; // no further entries |
154 | 172 | } |
155 | 173 | $this->start += self::CHUNK_SIZE; |
156 | 174 | reset($this->files); |
157 | 175 | |
158 | - if ($this->debug) error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
176 | + if ($this->debug) |
|
177 | + { |
|
178 | + error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
179 | + } |
|
159 | 180 | |
160 | 181 | return current($this->files) !== false; |
161 | 182 | } |
@@ -165,11 +186,18 @@ discard block |
||
165 | 186 | */ |
166 | 187 | public function rewind() |
167 | 188 | { |
168 | - if ($this->debug) error_log(__METHOD__."()"); |
|
189 | + if ($this->debug) |
|
190 | + { |
|
191 | + error_log(__METHOD__."()"); |
|
192 | + } |
|
169 | 193 | |
170 | 194 | $this->start = 0; |
171 | 195 | $this->files = $this->common_files; |
172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
196 | + if (!$this->files) |
|
197 | + { |
|
198 | + $this->next(); |
|
199 | + } |
|
200 | + // otherwise valid will return false and nothing get returned |
|
173 | 201 | reset($this->files); |
174 | 202 | } |
175 | 203 | |
@@ -180,7 +208,10 @@ discard block |
||
180 | 208 | */ |
181 | 209 | public function valid () |
182 | 210 | { |
183 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
211 | + if ($this->debug) |
|
212 | + { |
|
213 | + error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
214 | + } |
|
184 | 215 | return current($this->files) !== false; |
185 | 216 | } |
186 | 217 | } |
@@ -249,12 +249,12 @@ |
||
249 | 249 | |
250 | 250 | $this->component = Horde_Icalendar::newComponent($type, $this); |
251 | 251 | //error_log(__METHOD__."() this->component = Horde_Icalendar::newComponent('$type', \$this) = ".array2string($this->component)); |
252 | - if ($this->component === false) |
|
253 | - { |
|
254 | - error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE"); |
|
255 | - return; |
|
256 | - //return PEAR::raiseError("Unable to create object for type $type"); |
|
257 | - } |
|
252 | + if ($this->component === false) |
|
253 | + { |
|
254 | + error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE"); |
|
255 | + return; |
|
256 | + //return PEAR::raiseError("Unable to create object for type $type"); |
|
257 | + } |
|
258 | 258 | if ($this->charset && $this->charset != 'utf-8') |
259 | 259 | { |
260 | 260 | $data = Api\Translation::convert($data, $this->charset, 'utf-8'); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param array $callback_params =array() further parameters for the callback, 1. parameter is component |
107 | 107 | * @param boolean $add_container =false true, add container / $this as last parameter to callback |
108 | 108 | */ |
109 | - public function __construct($ical_file,$base='VCALENDAR',$charset=null,$callback=null,array $callback_params=array(), $add_container=false) |
|
109 | + public function __construct($ical_file, $base = 'VCALENDAR', $charset = null, $callback = null, array $callback_params = array(), $add_container = false) |
|
110 | 110 | { |
111 | 111 | // call parent constructor |
112 | 112 | parent::__construct(); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | if (!is_resource($this->ical_file)) |
133 | 133 | { |
134 | - throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file),0,100)); |
|
134 | + throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file), 0, 100)); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | $line = array_shift($this->unread_lines); |
157 | 157 | } |
158 | - elseif(feof($this->ical_file)) |
|
158 | + elseif (feof($this->ical_file)) |
|
159 | 159 | { |
160 | 160 | $line = false; |
161 | 161 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | $line = ltrim(fgets($this->ical_file), "\xef\xbb\xbf"); |
165 | 165 | } |
166 | 166 | // check if end of container reached |
167 | - if ($this->container && $line && substr($line,0,4+strlen($this->base)) === 'END:'.$this->base) |
|
167 | + if ($this->container && $line && substr($line, 0, 4 + strlen($this->base)) === 'END:'.$this->base) |
|
168 | 168 | { |
169 | - $this->unread_line($line); // put back end-of-container, to continue to return false |
|
169 | + $this->unread_line($line); // put back end-of-container, to continue to return false |
|
170 | 170 | $line = false; |
171 | 171 | } |
172 | 172 | //error_log(__METHOD__."() returning ".($line === false ? 'FALSE' : "'$line'")); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | protected function unread_line($line) |
183 | 183 | { |
184 | 184 | //error_log(__METHOD__."('$line')"); |
185 | - array_unshift($this->unread_lines,$line); |
|
185 | + array_unshift($this->unread_lines, $line); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | //error_log(__METHOD__."() returning a ".gettype($this->component)); |
196 | 196 | if ($this->callback) |
197 | 197 | { |
198 | - $ret = is_a($this->component,'Horde_Icalendar'); |
|
198 | + $ret = is_a($this->component, 'Horde_Icalendar'); |
|
199 | 199 | do { |
200 | 200 | if ($ret === false) $this->next(); |
201 | - if (!is_a($this->component,'Horde_Icalendar')) return false; |
|
201 | + if (!is_a($this->component, 'Horde_Icalendar')) return false; |
|
202 | 202 | $params = $this->callback_params; |
203 | - array_unshift($params,$this->component); |
|
203 | + array_unshift($params, $this->component); |
|
204 | 204 | } |
205 | - while(($ret = call_user_func_array($this->callback,$params)) === false); |
|
205 | + while (($ret = call_user_func_array($this->callback, $params)) === false); |
|
206 | 206 | |
207 | 207 | return $ret; |
208 | 208 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | unset($this->component); |
229 | 229 | |
230 | - while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:') |
|
230 | + while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:') |
|
231 | 231 | { |
232 | 232 | error_log("'".$line."'"); |
233 | 233 | // ignore it |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | $this->component = false; |
238 | 238 | return; |
239 | 239 | } |
240 | - $type = substr(trim($line),6); |
|
240 | + $type = substr(trim($line), 6); |
|
241 | 241 | |
242 | 242 | //error_log(__METHOD__."() found $type component"); |
243 | 243 | |
244 | 244 | $data = $line; |
245 | - while (($line = $this->read_line()) && substr($line,0,4+strlen($type)) !== 'END:'.$type) |
|
245 | + while (($line = $this->read_line()) && substr($line, 0, 4 + strlen($type)) !== 'END:'.$type) |
|
246 | 246 | { |
247 | 247 | $data .= $line; |
248 | 248 | } |
@@ -277,23 +277,23 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function rewind() |
279 | 279 | { |
280 | - @fseek($this->ical_file,0,SEEK_SET); |
|
280 | + @fseek($this->ical_file, 0, SEEK_SET); |
|
281 | 281 | |
282 | 282 | // advance to begin of container |
283 | - while(($line = $this->read_line()) && substr($line,0,6+strlen($this->base)) !== 'BEGIN:'.$this->base) |
|
283 | + while (($line = $this->read_line()) && substr($line, 0, 6 + strlen($this->base)) !== 'BEGIN:'.$this->base) |
|
284 | 284 | { |
285 | 285 | |
286 | 286 | } |
287 | 287 | // if no container start found --> use whole file (rewind) and set container marker |
288 | 288 | if (!($this->container = $line !== false)) |
289 | 289 | { |
290 | - fseek($this->ical_file,0,SEEK_SET); |
|
290 | + fseek($this->ical_file, 0, SEEK_SET); |
|
291 | 291 | } |
292 | 292 | //error_log(__METHOD__."() $this->base container ".($this->container ? 'found' : 'NOT found')); |
293 | 293 | |
294 | 294 | $data = $line; |
295 | 295 | // advance to first component |
296 | - while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:') |
|
296 | + while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:') |
|
297 | 297 | { |
298 | 298 | $matches = null; |
299 | 299 | if (preg_match('/^VERSION:(\d\.\d)\s*$/ism', $line, $matches)) |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | { |
309 | 309 | $data .= "END:$this->base\n"; |
310 | 310 | //error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')"); |
311 | - $this->parsevCalendar($data,$this->base,$this->charset); |
|
311 | + $this->parsevCalendar($data, $this->base, $this->charset); |
|
312 | 312 | } |
313 | 313 | if ($line) $this->unread_line($line); |
314 | 314 | |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @return boolean |
323 | 323 | */ |
324 | - public function valid () |
|
324 | + public function valid() |
|
325 | 325 | { |
326 | 326 | //error_log(__METHOD__."() returning ".(is_a($this->component,'Horde_Icalendar') ? 'TRUE' : 'FALSE').' get_class($this->component)='.get_class($this->component)); |
327 | - return is_a($this->component,'Horde_Icalendar'); |
|
327 | + return is_a($this->component, 'Horde_Icalendar'); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n"; |
443 | 443 | //$calendar_ical = new calendar_ical(); |
444 | 444 | //$calendar_ical->setSupportedFields('file'); |
445 | - $ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
|
446 | - foreach($ical_it as $uid => $vevent) |
|
445 | + $ical_it = new IcalIterator($ical_file); //,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
|
446 | + foreach ($ical_it as $uid => $vevent) |
|
447 | 447 | { |
448 | 448 | echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n"; |
449 | 449 | } |
@@ -116,7 +116,10 @@ discard block |
||
116 | 116 | if (is_callable($callback)) |
117 | 117 | { |
118 | 118 | $this->callback = $callback; |
119 | - if ($add_container) $callback_params[] = $this; |
|
119 | + if ($add_container) |
|
120 | + { |
|
121 | + $callback_params[] = $this; |
|
122 | + } |
|
120 | 123 | $this->callback_params = $callback_params; |
121 | 124 | } |
122 | 125 | if (is_string($ical_file)) |
@@ -197,8 +200,14 @@ discard block |
||
197 | 200 | { |
198 | 201 | $ret = is_a($this->component,'Horde_Icalendar'); |
199 | 202 | do { |
200 | - if ($ret === false) $this->next(); |
|
201 | - if (!is_a($this->component,'Horde_Icalendar')) return false; |
|
203 | + if ($ret === false) |
|
204 | + { |
|
205 | + $this->next(); |
|
206 | + } |
|
207 | + if (!is_a($this->component,'Horde_Icalendar')) |
|
208 | + { |
|
209 | + return false; |
|
210 | + } |
|
202 | 211 | $params = $this->callback_params; |
203 | 212 | array_unshift($params,$this->component); |
204 | 213 | } |
@@ -232,9 +241,12 @@ discard block |
||
232 | 241 | error_log("'".$line."'"); |
233 | 242 | // ignore it |
234 | 243 | } |
235 | - if ($line === false) // end-of-file or end-of-container |
|
244 | + if ($line === false) |
|
245 | + { |
|
246 | + // end-of-file or end-of-container |
|
236 | 247 | { |
237 | 248 | $this->component = false; |
249 | + } |
|
238 | 250 | return; |
239 | 251 | } |
240 | 252 | $type = substr(trim($line),6); |
@@ -310,7 +322,10 @@ discard block |
||
310 | 322 | //error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')"); |
311 | 323 | $this->parsevCalendar($data,$this->base,$this->charset); |
312 | 324 | } |
313 | - if ($line) $this->unread_line($line); |
|
325 | + if ($line) |
|
326 | + { |
|
327 | + $this->unread_line($line); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // advance to first element |
316 | 331 | $this->next(); |
@@ -439,7 +454,10 @@ discard block |
||
439 | 454 | '; |
440 | 455 | echo $GLOBALS['egw']->framework->header(); |
441 | 456 | //$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics'); |
442 | - if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n"; |
|
457 | + if (!is_resource($ical_file)) |
|
458 | + { |
|
459 | + echo "<pre>$ical_file</pre>\n"; |
|
460 | + } |
|
443 | 461 | //$calendar_ical = new calendar_ical(); |
444 | 462 | //$calendar_ical->setSupportedFields('file'); |
445 | 463 | $ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
@@ -447,5 +465,8 @@ discard block |
||
447 | 465 | { |
448 | 466 | echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n"; |
449 | 467 | } |
450 | - if (is_resource($ical_file)) fclose($ical_file); |
|
451 | -} |
|
452 | 468 | \ No newline at end of file |
469 | + if (is_resource($ical_file)) |
|
470 | + { |
|
471 | + fclose($ical_file); |
|
472 | + } |
|
473 | + } |
|
453 | 474 | \ No newline at end of file |
@@ -1044,13 +1044,13 @@ |
||
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | /** |
1047 | - * Get the color of a category |
|
1048 | - * |
|
1049 | - * For multiple cats, the first with a color is used |
|
1050 | - * |
|
1051 | - * @param int|string $_cats multiple comma-separated cat_id's |
|
1052 | - * @return string |
|
1053 | - */ |
|
1047 | + * Get the color of a category |
|
1048 | + * |
|
1049 | + * For multiple cats, the first with a color is used |
|
1050 | + * |
|
1051 | + * @param int|string $_cats multiple comma-separated cat_id's |
|
1052 | + * @return string |
|
1053 | + */ |
|
1054 | 1054 | static function cats2color($_cats) |
1055 | 1055 | { |
1056 | 1056 | static $cat2color = array(); |
@@ -122,7 +122,10 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function __construct($accountid='',$app_name = '') |
124 | 124 | { |
125 | - if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp']; |
|
125 | + if (!$app_name) |
|
126 | + { |
|
127 | + $app_name = $GLOBALS['egw_info']['flags']['currentapp']; |
|
128 | + } |
|
126 | 129 | |
127 | 130 | if ($accountid === self::GLOBAL_ACCOUNT || |
128 | 131 | $accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2) |
@@ -138,10 +141,13 @@ discard block |
||
138 | 141 | $this->app_name = $app_name; |
139 | 142 | $this->db = $GLOBALS['egw']->db; |
140 | 143 | |
141 | - if (is_null(self::$cache)) // should not be necessary, as cache is load and restored by egw object |
|
144 | + if (is_null(self::$cache)) |
|
145 | + { |
|
146 | + // should not be necessary, as cache is load and restored by egw object |
|
142 | 147 | { |
143 | 148 | self::init_cache(); |
144 | 149 | } |
150 | + } |
|
145 | 151 | if (is_null(self::$global_marker)) |
146 | 152 | { |
147 | 153 | // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 |
@@ -189,7 +195,9 @@ discard block |
||
189 | 195 | $cats = array(); |
190 | 196 | foreach(self::$cache as $cat) |
191 | 197 | { |
192 | - if ($filter) foreach($filter as $col => $val) |
|
198 | + if ($filter) |
|
199 | + { |
|
200 | + foreach($filter as $col => $val) |
|
193 | 201 | { |
194 | 202 | if (!is_array($val) && $val[0] === '!') |
195 | 203 | { |
@@ -197,10 +205,14 @@ discard block |
||
197 | 205 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
198 | 206 | { |
199 | 207 | if ($cat[$col] == substr($val,1) || trim($cat[$col]) == substr($val,1)) continue 2; |
208 | + } |
|
200 | 209 | } |
201 | 210 | else |
202 | 211 | { |
203 | - if ($cat[$col] == substr($val,1)) continue 2; |
|
212 | + if ($cat[$col] == substr($val,1)) |
|
213 | + { |
|
214 | + continue 2; |
|
215 | + } |
|
204 | 216 | } |
205 | 217 | } |
206 | 218 | elseif (is_array($val)) |
@@ -208,11 +220,17 @@ discard block |
||
208 | 220 | // also match against trimmed database entry on name and description fields |
209 | 221 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
210 | 222 | { |
211 | - if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) continue 2; |
|
223 | + if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) |
|
224 | + { |
|
225 | + continue 2; |
|
226 | + } |
|
212 | 227 | } |
213 | 228 | else |
214 | 229 | { |
215 | - if (!in_array($cat[$col],$val)) continue 2; |
|
230 | + if (!in_array($cat[$col],$val)) |
|
231 | + { |
|
232 | + continue 2; |
|
233 | + } |
|
216 | 234 | } |
217 | 235 | } |
218 | 236 | else |
@@ -220,16 +238,25 @@ discard block |
||
220 | 238 | // also match against trimmed database entry on name and description fields |
221 | 239 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
222 | 240 | { |
223 | - if ($cat[$col] != $val && trim($cat[$col]) != $val) continue 2; |
|
241 | + if ($cat[$col] != $val && trim($cat[$col]) != $val) |
|
242 | + { |
|
243 | + continue 2; |
|
244 | + } |
|
224 | 245 | } |
225 | 246 | else |
226 | 247 | { |
227 | - if ($cat[$col] != $val) continue 2; |
|
248 | + if ($cat[$col] != $val) |
|
249 | + { |
|
250 | + continue 2; |
|
251 | + } |
|
228 | 252 | } |
229 | 253 | } |
230 | 254 | } |
231 | 255 | // check if certain parent required |
232 | - if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue; |
|
256 | + if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) |
|
257 | + { |
|
258 | + continue; |
|
259 | + } |
|
233 | 260 | |
234 | 261 | // return global categories just if $globals is set |
235 | 262 | if (!$globals && $cat['appname'] == self::GLOBAL_APPNAME) |
@@ -247,30 +274,55 @@ discard block |
||
247 | 274 | switch ($type) |
248 | 275 | { |
249 | 276 | case 'subs': |
250 | - if (!$cat['parent']) continue 2; // 2 for switch AND foreach! |
|
277 | + if (!$cat['parent']) |
|
278 | + { |
|
279 | + continue 2; |
|
280 | + } |
|
281 | + // 2 for switch AND foreach! |
|
251 | 282 | break; |
252 | 283 | case 'mains': |
253 | - if ($cat['parent']) continue 2; |
|
284 | + if ($cat['parent']) |
|
285 | + { |
|
286 | + continue 2; |
|
287 | + } |
|
254 | 288 | break; |
255 | 289 | case 'appandmains': |
256 | - if ($cat['appname'] != $this->app_name || $cat['parent']) continue 2; |
|
290 | + if ($cat['appname'] != $this->app_name || $cat['parent']) |
|
291 | + { |
|
292 | + continue 2; |
|
293 | + } |
|
257 | 294 | break; |
258 | 295 | case 'appandsubs': |
259 | - if ($cat['appname'] != $this->app_name || !$cat['parent']) continue 2; |
|
296 | + if ($cat['appname'] != $this->app_name || !$cat['parent']) |
|
297 | + { |
|
298 | + continue 2; |
|
299 | + } |
|
260 | 300 | break; |
261 | 301 | case 'noglobal': |
262 | - if ($cat['appname'] == $this->app_name) continue 2; |
|
302 | + if ($cat['appname'] == $this->app_name) |
|
303 | + { |
|
304 | + continue 2; |
|
305 | + } |
|
263 | 306 | break; |
264 | 307 | case 'noglobalapp': |
265 | - if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id) continue 2; |
|
308 | + if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id) |
|
309 | + { |
|
310 | + continue 2; |
|
311 | + } |
|
266 | 312 | break; |
267 | 313 | } |
268 | 314 | |
269 | 315 | // check name and description for $query |
270 | - if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) continue; |
|
316 | + if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) |
|
317 | + { |
|
318 | + continue; |
|
319 | + } |
|
271 | 320 | |
272 | 321 | // check if last modified since |
273 | - if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) continue; |
|
322 | + if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) |
|
323 | + { |
|
324 | + continue; |
|
325 | + } |
|
274 | 326 | |
275 | 327 | $cat['data'] = $cat['data'] ? json_php_unserialize($cat['data'], true) : array(); |
276 | 328 | |
@@ -281,13 +333,23 @@ discard block |
||
281 | 333 | //error_log(__METHOD__."($type,$start,$limit,$query,$sort,$order,$globals,parent=$parent_id,$lastmod,$column) account_id=$this->account_id, appname=$this->app_name = FALSE"); |
282 | 334 | return array(); |
283 | 335 | } |
284 | - if (!$sort) $sort = 'ASC'; |
|
336 | + if (!$sort) |
|
337 | + { |
|
338 | + $sort = 'ASC'; |
|
339 | + } |
|
285 | 340 | // order the entries if necessary (cache is already ordered in or default order: cat_main, cat_level, cat_name ASC) |
286 | 341 | if ($this->total_records > 1 && !empty($order) && |
287 | 342 | preg_match('/^[a-zA-Z_(), ]+$/',$order) && preg_match('/^(ASC|DESC|asc|desc)$/',$sort)) |
288 | 343 | { |
289 | - if (strstr($order,'cat_data') !== false) $order = 'cat_data'; // sitemgr orders by round(cat_data)! |
|
290 | - if (substr($order,0,4) == 'cat_') $order = substr($order,4); |
|
344 | + if (strstr($order,'cat_data') !== false) |
|
345 | + { |
|
346 | + $order = 'cat_data'; |
|
347 | + } |
|
348 | + // sitemgr orders by round(cat_data)! |
|
349 | + if (substr($order,0,4) == 'cat_') |
|
350 | + { |
|
351 | + $order = substr($order,4); |
|
352 | + } |
|
291 | 353 | $sign = strtoupper($sort) == 'DESC' ? -1 : 1; |
292 | 354 | usort($cats, function($a, $b) use ($order, $sign) |
293 | 355 | { |
@@ -301,7 +363,10 @@ discard block |
||
301 | 363 | // limit the number of returned rows |
302 | 364 | if ($limit) |
303 | 365 | { |
304 | - if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
366 | + if (!is_int($limit)) |
|
367 | + { |
|
368 | + $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
369 | + } |
|
305 | 370 | $cats = array_slice($cats,(int)$start,$limit); |
306 | 371 | } |
307 | 372 | // return only a certain column (why not return is as value?) |
@@ -334,15 +399,24 @@ discard block |
||
334 | 399 | */ |
335 | 400 | function return_sorted_array($start=0,$limit=True,$query='',$sort='ASC',$order='cat_name',$globals=False, $parent_id=0,$unserialize_data=true,$filter=null) |
336 | 401 | { |
337 | - if (!$sort) $sort = 'ASC'; |
|
338 | - if (!$order) $order = 'cat_name'; |
|
402 | + if (!$sort) |
|
403 | + { |
|
404 | + $sort = 'ASC'; |
|
405 | + } |
|
406 | + if (!$order) |
|
407 | + { |
|
408 | + $order = 'cat_name'; |
|
409 | + } |
|
339 | 410 | |
340 | 411 | //error_log(__METHOD__."($start,$limit,$query,$sort,$order,globals=$globals,parent=$parent_id,$unserialize_data) account_id=$this->account_id, appname=$this->app_name: ".function_backtrace()); |
341 | 412 | |
342 | 413 | $parents = $cats = array(); |
343 | 414 | |
344 | 415 | // Cast parent_id to array, but only if there is one |
345 | - if($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id; |
|
416 | + if($parent_id !== false && $parent_id !== null) |
|
417 | + { |
|
418 | + $parent_id = (array)$parent_id; |
|
419 | + } |
|
346 | 420 | if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parent_id,-1,'',$filter,$unserialize_data))) |
347 | 421 | { |
348 | 422 | $cats = array(); |
@@ -352,7 +426,9 @@ discard block |
||
352 | 426 | $parents[] = $cat['id']; |
353 | 427 | } |
354 | 428 | |
355 | - if($parent_id || !$cats) // Avoid wiping search results |
|
429 | + if($parent_id || !$cats) |
|
430 | + { |
|
431 | + // Avoid wiping search results |
|
356 | 432 | { |
357 | 433 | // Go find the children |
358 | 434 | while (count($parents)) |
@@ -360,6 +436,7 @@ discard block |
||
360 | 436 | if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data))) |
361 | 437 | { |
362 | 438 | break; |
439 | + } |
|
363 | 440 | } |
364 | 441 | $parents = $children = array(); |
365 | 442 | foreach($subs as $cat) |
@@ -391,7 +468,10 @@ discard block |
||
391 | 468 | // limit the number of returned rows |
392 | 469 | if ($limit) |
393 | 470 | { |
394 | - if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
471 | + if (!is_int($limit)) |
|
472 | + { |
|
473 | + $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
474 | + } |
|
395 | 475 | $cats = array_slice($cats,(int)$start,$limit); |
396 | 476 | } |
397 | 477 | reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
@@ -410,9 +490,15 @@ discard block |
||
410 | 490 | */ |
411 | 491 | static function read($id) |
412 | 492 | { |
413 | - if (is_null(self::$cache)) self::init_cache(); |
|
493 | + if (is_null(self::$cache)) |
|
494 | + { |
|
495 | + self::init_cache(); |
|
496 | + } |
|
414 | 497 | |
415 | - if (!isset(self::$cache[$id])) return false; |
|
498 | + if (!isset(self::$cache[$id])) |
|
499 | + { |
|
500 | + return false; |
|
501 | + } |
|
416 | 502 | |
417 | 503 | $cat = self::$cache[$id]; |
418 | 504 | $cat['data'] = $cat['data'] ? ((($arr=json_php_unserialize($cat['data'], true)) !== false || $cat['data'] === 'b:0;') ? |
@@ -475,8 +561,11 @@ discard block |
||
475 | 561 | * @return string truncated commaseparated list of category ids |
476 | 562 | */ |
477 | 563 | function check_list($needed, $cat_list) |
478 | - { |
|
479 | - if (empty($cat_list)) return $cat_list; |
|
564 | + { |
|
565 | + if (empty($cat_list)) |
|
566 | + { |
|
567 | + return $cat_list; |
|
568 | + } |
|
480 | 569 | if (is_array($cat_list)) |
481 | 570 | { |
482 | 571 | $cat_list = implode(',',$cat_list); |
@@ -487,10 +576,13 @@ discard block |
||
487 | 576 | { |
488 | 577 | foreach($cat_arr as $id=>$cat_id) |
489 | 578 | { |
490 | - if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ)) // allow reading all global cats |
|
579 | + if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ)) |
|
580 | + { |
|
581 | + // allow reading all global cats |
|
491 | 582 | { |
492 | 583 | unset($cat_arr[$id]); |
493 | 584 | } |
585 | + } |
|
494 | 586 | } |
495 | 587 | $cat_list = implode(',',$cat_arr); |
496 | 588 | } |
@@ -596,9 +688,15 @@ discard block |
||
596 | 688 | { |
597 | 689 | $update = array('cat_level' => $cat['level']-1); |
598 | 690 | |
599 | - if ($new_main) $update['cat_main'] = $new_main; |
|
691 | + if ($new_main) |
|
692 | + { |
|
693 | + $update['cat_main'] = $new_main; |
|
694 | + } |
|
600 | 695 | |
601 | - if ($cat['parent'] == $cat_id) $update['cat_parent'] = $new_parent; |
|
696 | + if ($cat['parent'] == $cat_id) |
|
697 | + { |
|
698 | + $update['cat_parent'] = $new_parent; |
|
699 | + } |
|
602 | 700 | |
603 | 701 | $this->db->update(self::TABLE,$update,array( |
604 | 702 | 'cat_id' => $cat['id'], |
@@ -624,9 +722,13 @@ discard block |
||
624 | 722 | 'modify_subs' => $modify_subs, |
625 | 723 | 'location' => 'delete_category' |
626 | 724 | ); |
627 | - if($this->is_global($cat_id, true)) // true = application global (otherwise eg. global addressbook categories call all apps) |
|
725 | + if($this->is_global($cat_id, true)) |
|
726 | + { |
|
727 | + // true = application global (otherwise eg. global addressbook categories call all apps) |
|
628 | 728 | { |
629 | - Hooks::process($GLOBALS['hook_values'],False,True); // called for every app now, not only enabled ones) |
|
729 | + Hooks::process($GLOBALS['hook_values'],False,True); |
|
730 | + } |
|
731 | + // called for every app now, not only enabled ones) |
|
630 | 732 | } |
631 | 733 | else |
632 | 734 | { |
@@ -682,12 +784,22 @@ discard block |
||
682 | 784 | // check if we try to move an element down its own subtree, which will fail |
683 | 785 | foreach ($this->return_sorted_array('',False,'','','',False, $values['id']) as $cat) |
684 | 786 | { |
685 | - if ($cat['id'] == $values['parent']) return lang('Cannot set a category as parent, which is part of this categorys subtree!'); |
|
787 | + if ($cat['id'] == $values['parent']) |
|
788 | + { |
|
789 | + return lang('Cannot set a category as parent, which is part of this categorys subtree!'); |
|
790 | + } |
|
686 | 791 | } |
687 | 792 | // check if we try to be our own parent |
688 | - if ($values['parent']==$values['id']) return lang('Cannot set this cat as its own parent!'); // deny to be our own parent |
|
793 | + if ($values['parent']==$values['id']) |
|
794 | + { |
|
795 | + return lang('Cannot set this cat as its own parent!'); |
|
796 | + } |
|
797 | + // deny to be our own parent |
|
689 | 798 | // check if parent still exists |
690 | - if ((int)$values['parent']>0 && !$this->read($values['parent'])) return lang('Chosen parent category no longer exists'); |
|
799 | + if ((int)$values['parent']>0 && !$this->read($values['parent'])) |
|
800 | + { |
|
801 | + return lang('Chosen parent category no longer exists'); |
|
802 | + } |
|
691 | 803 | return true; |
692 | 804 | } |
693 | 805 | |
@@ -704,7 +816,10 @@ discard block |
||
704 | 816 | if (isset($values['old_parent']) && (int)$values['old_parent'] != (int)$values['parent']) |
705 | 817 | { |
706 | 818 | $ret = $this->check_consistency4update($values); |
707 | - if ($ret !== true) throw new Exception\WrongUserinput($ret); |
|
819 | + if ($ret !== true) |
|
820 | + { |
|
821 | + throw new Exception\WrongUserinput($ret); |
|
822 | + } |
|
708 | 823 | // everything seems in order -> proceed |
709 | 824 | $values['level'] = ($values['parent'] ? $this->id2name($values['parent'],'level')+1:0); |
710 | 825 | $this->adapt_level_in_subtree($values); |
@@ -717,7 +832,10 @@ discard block |
||
717 | 832 | if ($values['parent'] > 0) |
718 | 833 | { |
719 | 834 | $ret = $this->check_consistency4update($values); |
720 | - if ($ret !== true) throw new Exception\WrongUserinput($ret); |
|
835 | + if ($ret !== true) |
|
836 | + { |
|
837 | + throw new Exception\WrongUserinput($ret); |
|
838 | + } |
|
721 | 839 | |
722 | 840 | // everything seems in order -> proceed |
723 | 841 | $values['main'] = $this->id2name($values['parent'],'main'); |
@@ -773,7 +891,10 @@ discard block |
||
773 | 891 | { |
774 | 892 | static $cache = array(); // a litle bit of caching |
775 | 893 | |
776 | - if (isset($cache[$cat_name])) return $cache[$cat_name]; |
|
894 | + if (isset($cache[$cat_name])) |
|
895 | + { |
|
896 | + return $cache[$cat_name]; |
|
897 | + } |
|
777 | 898 | |
778 | 899 | if ($strip === true) |
779 | 900 | { |
@@ -826,7 +947,11 @@ discard block |
||
826 | 947 | */ |
827 | 948 | static function is_global($cat,$application_global=false) |
828 | 949 | { |
829 | - if (!is_array($cat) && !($cat = self::read($cat))) return null; // cat not found |
|
950 | + if (!is_array($cat) && !($cat = self::read($cat))) |
|
951 | + { |
|
952 | + return null; |
|
953 | + } |
|
954 | + // cat not found |
|
830 | 955 | |
831 | 956 | $global_owner = false; |
832 | 957 | foreach(explode(',',$cat['owner']) as $owner) |
@@ -848,10 +973,19 @@ discard block |
||
848 | 973 | */ |
849 | 974 | static function id2name($cat_id=0, $item='name') |
850 | 975 | { |
851 | - if(!$cat_id) return '--'; |
|
852 | - if (!$item) $item = 'parent'; |
|
976 | + if(!$cat_id) |
|
977 | + { |
|
978 | + return '--'; |
|
979 | + } |
|
980 | + if (!$item) |
|
981 | + { |
|
982 | + $item = 'parent'; |
|
983 | + } |
|
853 | 984 | |
854 | - if (is_null(self::$cache)) self::init_cache(); |
|
985 | + if (is_null(self::$cache)) |
|
986 | + { |
|
987 | + self::init_cache(); |
|
988 | + } |
|
855 | 989 | |
856 | 990 | $cat = self::$cache[$cat_id]; |
857 | 991 | if ($item == 'path') |
@@ -892,7 +1026,10 @@ discard block |
||
892 | 1026 | if ($cat_name) |
893 | 1027 | { |
894 | 1028 | $filter['name'] = $cat_name; |
895 | - if ($cat_id) $filter['id'] = '!'.(int)$cat_id; |
|
1029 | + if ($cat_id) |
|
1030 | + { |
|
1031 | + $filter['id'] = '!'.(int)$cat_id; |
|
1032 | + } |
|
896 | 1033 | } |
897 | 1034 | elseif ($cat_id) |
898 | 1035 | { |
@@ -921,7 +1058,10 @@ discard block |
||
921 | 1058 | { |
922 | 1059 | $where = array('cat_owner' => $owner); |
923 | 1060 | |
924 | - if ($app) $where['cat_appname'] = $app; |
|
1061 | + if ($app) |
|
1062 | + { |
|
1063 | + $where['cat_appname'] = $app; |
|
1064 | + } |
|
925 | 1065 | |
926 | 1066 | if ((int)$to) |
927 | 1067 | { |
@@ -967,7 +1107,11 @@ discard block |
||
967 | 1107 | false,'ORDER BY cat_main, cat_level, cat_name ASC') as $cat) |
968 | 1108 | { |
969 | 1109 | $cat = Db::strip_array_keys($cat,'cat_'); |
970 | - if ($cat['appname'] == '*update*') continue; // --> ignore update marker |
|
1110 | + if ($cat['appname'] == '*update*') |
|
1111 | + { |
|
1112 | + continue; |
|
1113 | + } |
|
1114 | + // --> ignore update marker |
|
971 | 1115 | $cat['app_name'] = $cat['appname']; |
972 | 1116 | // backlink children to their parent |
973 | 1117 | if ($cat['parent']) |
@@ -1058,7 +1202,10 @@ discard block |
||
1058 | 1202 | // ACL check |
1059 | 1203 | $cats = $GLOBALS['egw']->categories->check_list(Acl::READ, $_cats); |
1060 | 1204 | |
1061 | - if (!$cats) return null; |
|
1205 | + if (!$cats) |
|
1206 | + { |
|
1207 | + return null; |
|
1208 | + } |
|
1062 | 1209 | |
1063 | 1210 | if (isset($cat2color[$cats])) |
1064 | 1211 | { |
@@ -1090,7 +1237,10 @@ discard block |
||
1090 | 1237 | */ |
1091 | 1238 | public static function delete_account($account_id, $new_owner=null) |
1092 | 1239 | { |
1093 | - if (is_null(self::$cache)) self::init_cache(); |
|
1240 | + if (is_null(self::$cache)) |
|
1241 | + { |
|
1242 | + self::init_cache(); |
|
1243 | + } |
|
1094 | 1244 | |
1095 | 1245 | $deleted = 0; |
1096 | 1246 | $cat = null; |
@@ -1110,7 +1260,10 @@ discard block |
||
1110 | 1260 | else |
1111 | 1261 | { |
1112 | 1262 | unset($owners[$owner_key]); |
1113 | - if ($new_owner && $account_id > 0) $owners[] = $new_owner; |
|
1263 | + if ($new_owner && $account_id > 0) |
|
1264 | + { |
|
1265 | + $owners[] = $new_owner; |
|
1266 | + } |
|
1114 | 1267 | $data['owner'] = implode(',', $owners); |
1115 | 1268 | // app_name have to match cat to update! |
1116 | 1269 | if (!isset($cat) || $cat->app_name != $data['appname']) |
@@ -1132,7 +1285,10 @@ discard block |
||
1132 | 1285 | */ |
1133 | 1286 | public static function delete_orphans() |
1134 | 1287 | { |
1135 | - if (is_null(self::$cache)) self::init_cache(); |
|
1288 | + if (is_null(self::$cache)) |
|
1289 | + { |
|
1290 | + self::init_cache(); |
|
1291 | + } |
|
1136 | 1292 | |
1137 | 1293 | $checked = array(); |
1138 | 1294 | $deleted = 0; |
@@ -120,23 +120,23 @@ discard block |
||
120 | 120 | * @param int|string $accountid ='' account id or lid, default to current user |
121 | 121 | * @param string $app_name ='' app name defaults to current app |
122 | 122 | */ |
123 | - function __construct($accountid='',$app_name = '') |
|
123 | + function __construct($accountid = '', $app_name = '') |
|
124 | 124 | { |
125 | 125 | if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp']; |
126 | 126 | |
127 | 127 | if ($accountid === self::GLOBAL_ACCOUNT || |
128 | 128 | $accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2) |
129 | 129 | { |
130 | - $this->account_id = (int) $accountid; |
|
130 | + $this->account_id = (int)$accountid; |
|
131 | 131 | } |
132 | 132 | else |
133 | 133 | { |
134 | - $this->account_id = (int) get_account_id($accountid); |
|
134 | + $this->account_id = (int)get_account_id($accountid); |
|
135 | 135 | $this->global_owners = $this->account_id ? $GLOBALS['egw']->accounts->memberships($this->account_id, true) : array(); |
136 | 136 | $this->global_owners[] = self::GLOBAL_ACCOUNT; |
137 | 137 | } |
138 | - $this->app_name = $app_name; |
|
139 | - $this->db = $GLOBALS['egw']->db; |
|
138 | + $this->app_name = $app_name; |
|
139 | + $this->db = $GLOBALS['egw']->db; |
|
140 | 140 | |
141 | 141 | if (is_null(self::$cache)) // should not be necessary, as cache is load and restored by egw object |
142 | 142 | { |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | { |
159 | 159 | $all_children = array_map('intval', (array)$cat_id); |
160 | 160 | |
161 | - $children = $this->return_array('subs',0,False,'','','',True,$cat_id,-1,'id'); |
|
161 | + $children = $this->return_array('subs', 0, False, '', '', '', True, $cat_id, -1, 'id'); |
|
162 | 162 | if (is_array($children) && count($children)) |
163 | 163 | { |
164 | - $all_children = array_merge($all_children,$this->return_all_children($children)); |
|
164 | + $all_children = array_merge($all_children, $this->return_all_children($children)); |
|
165 | 165 | } |
166 | 166 | return $all_children; |
167 | 167 | } |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | * @param array $filter =null array with column-name (without cat_-prefix) => value pairs (! negates the value) |
184 | 184 | * @return array of cat-arrays or $column values |
185 | 185 | */ |
186 | - function return_array($type='all', $start=0, $limit=true, $query='', $sort='ASC',$order='',$globals=false, $parent_id=null, $lastmod=-1, $column='', $filter=null) |
|
186 | + function return_array($type = 'all', $start = 0, $limit = true, $query = '', $sort = 'ASC', $order = '', $globals = false, $parent_id = null, $lastmod = -1, $column = '', $filter = null) |
|
187 | 187 | { |
188 | 188 | //error_log(__METHOD__."($type,$start,$limit,$query,$sort,$order,globals=$globals,parent=".array2string($parent_id).",$lastmod,$column,filter=".array2string($filter).") account_id=$this->account_id, appname=$this->app_name: ".function_backtrace()); |
189 | 189 | $cats = array(); |
190 | - foreach(self::$cache as $cat) |
|
190 | + foreach (self::$cache as $cat) |
|
191 | 191 | { |
192 | - if ($filter) foreach($filter as $col => $val) |
|
192 | + if ($filter) foreach ($filter as $col => $val) |
|
193 | 193 | { |
194 | 194 | if (!is_array($val) && $val[0] === '!') |
195 | 195 | { |
196 | 196 | // also match against trimmed database entry on name and description fields |
197 | 197 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
198 | 198 | { |
199 | - if ($cat[$col] == substr($val,1) || trim($cat[$col]) == substr($val,1)) continue 2; |
|
199 | + if ($cat[$col] == substr($val, 1) || trim($cat[$col]) == substr($val, 1)) continue 2; |
|
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
203 | - if ($cat[$col] == substr($val,1)) continue 2; |
|
203 | + if ($cat[$col] == substr($val, 1)) continue 2; |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | elseif (is_array($val)) |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | // also match against trimmed database entry on name and description fields |
209 | 209 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
210 | 210 | { |
211 | - if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) continue 2; |
|
211 | + if (!in_array($cat[$col], $val) && !in_array(trim($cat[$col]), $val)) continue 2; |
|
212 | 212 | } |
213 | 213 | else |
214 | 214 | { |
215 | - if (!in_array($cat[$col],$val)) continue 2; |
|
215 | + if (!in_array($cat[$col], $val)) continue 2; |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | else |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | // check if certain parent required |
232 | - if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue; |
|
232 | + if ($parent_id && !in_array($cat['parent'], (array)$parent_id)) continue; |
|
233 | 233 | |
234 | 234 | // return global categories just if $globals is set |
235 | 235 | if (!$globals && $cat['appname'] == self::GLOBAL_APPNAME) |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | // check for read permission |
241 | - if(!$this->check_perms(Acl::READ, $cat, $globals === 'all_no_acl')) |
|
241 | + if (!$this->check_perms(Acl::READ, $cat, $globals === 'all_no_acl')) |
|
242 | 242 | { |
243 | 243 | continue; |
244 | 244 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | switch ($type) |
248 | 248 | { |
249 | 249 | case 'subs': |
250 | - if (!$cat['parent']) continue 2; // 2 for switch AND foreach! |
|
250 | + if (!$cat['parent']) continue 2; // 2 for switch AND foreach! |
|
251 | 251 | break; |
252 | 252 | case 'mains': |
253 | 253 | if ($cat['parent']) continue 2; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | // check name and description for $query |
270 | - if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) continue; |
|
270 | + if ($query && stristr($cat['name'], $query) === false && stristr($cat['description'], $query) === false) continue; |
|
271 | 271 | |
272 | 272 | // check if last modified since |
273 | 273 | if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) continue; |
@@ -284,37 +284,37 @@ discard block |
||
284 | 284 | if (!$sort) $sort = 'ASC'; |
285 | 285 | // order the entries if necessary (cache is already ordered in or default order: cat_main, cat_level, cat_name ASC) |
286 | 286 | if ($this->total_records > 1 && !empty($order) && |
287 | - preg_match('/^[a-zA-Z_(), ]+$/',$order) && preg_match('/^(ASC|DESC|asc|desc)$/',$sort)) |
|
287 | + preg_match('/^[a-zA-Z_(), ]+$/', $order) && preg_match('/^(ASC|DESC|asc|desc)$/', $sort)) |
|
288 | 288 | { |
289 | - if (strstr($order,'cat_data') !== false) $order = 'cat_data'; // sitemgr orders by round(cat_data)! |
|
290 | - if (substr($order,0,4) == 'cat_') $order = substr($order,4); |
|
289 | + if (strstr($order, 'cat_data') !== false) $order = 'cat_data'; // sitemgr orders by round(cat_data)! |
|
290 | + if (substr($order, 0, 4) == 'cat_') $order = substr($order, 4); |
|
291 | 291 | $sign = strtoupper($sort) == 'DESC' ? -1 : 1; |
292 | 292 | usort($cats, function($a, $b) use ($order, $sign) |
293 | 293 | { |
294 | - if (in_array($order, array('name','description','appname','app_name'))) |
|
294 | + if (in_array($order, array('name', 'description', 'appname', 'app_name'))) |
|
295 | 295 | { |
296 | 296 | return $sign * strcasecmp($a[$order], $b[$order]); |
297 | 297 | } |
298 | - return $sign*(int)$a[$order] - $sign*(int)$b[$order]; |
|
298 | + return $sign * (int)$a[$order] - $sign * (int)$b[$order]; |
|
299 | 299 | }); |
300 | 300 | } |
301 | 301 | // limit the number of returned rows |
302 | 302 | if ($limit) |
303 | 303 | { |
304 | 304 | if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
305 | - $cats = array_slice($cats,(int)$start,$limit); |
|
305 | + $cats = array_slice($cats, (int)$start, $limit); |
|
306 | 306 | } |
307 | 307 | // return only a certain column (why not return is as value?) |
308 | 308 | if ($column) |
309 | 309 | { |
310 | - foreach($cats as $k => $cat) |
|
310 | + foreach ($cats as $k => $cat) |
|
311 | 311 | { |
312 | 312 | $cats[$k] = $cat[$column]; |
313 | 313 | } |
314 | 314 | } |
315 | 315 | //error_log(__METHOD__."($type,$start,$limit,$query,$sort,$order,$globals,parent=".array2string($parent_id).",$lastmod,$column,filter=".array2string($filter).",$unserialize_data) account_id=$this->account_id, appname=$this->app_name = ".array2string($cats)); |
316 | 316 | |
317 | - reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
|
317 | + reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
|
318 | 318 | return $cats; |
319 | 319 | } |
320 | 320 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param boolean $unserialize_data =true return $cat['data'] as array (not serialized array) |
333 | 333 | * @return array with cats |
334 | 334 | */ |
335 | - function return_sorted_array($start=0,$limit=True,$query='',$sort='ASC',$order='cat_name',$globals=False, $parent_id=0,$unserialize_data=true,$filter=null) |
|
335 | + function return_sorted_array($start = 0, $limit = True, $query = '', $sort = 'ASC', $order = 'cat_name', $globals = False, $parent_id = 0, $unserialize_data = true, $filter = null) |
|
336 | 336 | { |
337 | 337 | if (!$sort) $sort = 'ASC'; |
338 | 338 | if (!$order) $order = 'cat_name'; |
@@ -342,27 +342,27 @@ discard block |
||
342 | 342 | $parents = $cats = array(); |
343 | 343 | |
344 | 344 | // Cast parent_id to array, but only if there is one |
345 | - if($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id; |
|
346 | - if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parent_id,-1,'',$filter,$unserialize_data))) |
|
345 | + if ($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id; |
|
346 | + if (!($cats = $this->return_array('all', 0, false, $query, $sort, $order, $globals, $parent_id, -1, '', $filter, $unserialize_data))) |
|
347 | 347 | { |
348 | 348 | $cats = array(); |
349 | 349 | } |
350 | - foreach($cats as $cat) |
|
350 | + foreach ($cats as $cat) |
|
351 | 351 | { |
352 | 352 | $parents[] = $cat['id']; |
353 | 353 | } |
354 | 354 | |
355 | - if($parent_id || !$cats) // Avoid wiping search results |
|
355 | + if ($parent_id || !$cats) // Avoid wiping search results |
|
356 | 356 | { |
357 | 357 | // Go find the children |
358 | 358 | while (count($parents)) |
359 | 359 | { |
360 | - if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data))) |
|
360 | + if (!($subs = $this->return_array('all', 0, false, $query, $sort, $order, $globals, $parents, -1, '', $filter, $unserialize_data))) |
|
361 | 361 | { |
362 | 362 | break; |
363 | 363 | } |
364 | 364 | $parents = $children = array(); |
365 | - foreach($subs as $cat) |
|
365 | + foreach ($subs as $cat) |
|
366 | 366 | { |
367 | 367 | $parents[] = $cat['id']; |
368 | 368 | $children[$cat['parent']][] = $cat; |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | { |
373 | 373 | $cats2 = $cats; |
374 | 374 | $cats = array(); |
375 | - foreach($cats2 as $cat) |
|
375 | + foreach ($cats2 as $cat) |
|
376 | 376 | { |
377 | 377 | $cats[] = $cat; |
378 | 378 | if (isset($children[$cat['id']])) |
379 | 379 | { |
380 | - foreach($children[$cat['id']] as $child) |
|
380 | + foreach ($children[$cat['id']] as $child) |
|
381 | 381 | { |
382 | 382 | $cats[] = $child; |
383 | 383 | } |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | if ($limit) |
393 | 393 | { |
394 | 394 | if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
395 | - $cats = array_slice($cats,(int)$start,$limit); |
|
395 | + $cats = array_slice($cats, (int)$start, $limit); |
|
396 | 396 | } |
397 | - reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
|
397 | + reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
|
398 | 398 | return $cats; |
399 | 399 | } |
400 | 400 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (!isset(self::$cache[$id])) return false; |
416 | 416 | |
417 | 417 | $cat = self::$cache[$id]; |
418 | - $cat['data'] = $cat['data'] ? ((($arr=json_php_unserialize($cat['data'], true)) !== false || $cat['data'] === 'b:0;') ? |
|
418 | + $cat['data'] = $cat['data'] ? ((($arr = json_php_unserialize($cat['data'], true)) !== false || $cat['data'] === 'b:0;') ? |
|
419 | 419 | $arr : $cat['data']) : array(); |
420 | 420 | |
421 | 421 | return $cat; |
@@ -433,31 +433,31 @@ discard block |
||
433 | 433 | { |
434 | 434 | if ((int)$values['parent'] > 0) |
435 | 435 | { |
436 | - $values['level'] = $this->id2name($values['parent'],'level')+1; |
|
437 | - $values['main'] = $this->id2name($values['parent'],'main'); |
|
436 | + $values['level'] = $this->id2name($values['parent'], 'level') + 1; |
|
437 | + $values['main'] = $this->id2name($values['parent'], 'main'); |
|
438 | 438 | } |
439 | 439 | else |
440 | 440 | { |
441 | 441 | $values['level'] = 0; |
442 | 442 | } |
443 | - $this->db->insert(self::TABLE,$cat=array( |
|
443 | + $this->db->insert(self::TABLE, $cat = array( |
|
444 | 444 | 'cat_parent' => $values['parent'], |
445 | 445 | 'cat_owner' => isset($values['owner']) ? $values['owner'] : $this->account_id, |
446 | 446 | 'cat_access' => isset($values['access']) ? $values['access'] : 'public', |
447 | 447 | 'cat_appname' => $this->app_name, |
448 | 448 | 'cat_name' => $values['name'], |
449 | - 'cat_description' => isset($values['description']) ? $values['description'] : $values['descr'], // support old name different from returned one |
|
449 | + 'cat_description' => isset($values['description']) ? $values['description'] : $values['descr'], // support old name different from returned one |
|
450 | 450 | 'cat_data' => is_array($values['data']) ? json_encode($values['data']) : $values['data'], |
451 | 451 | 'cat_main' => $values['main'], |
452 | 452 | 'cat_level' => $values['level'], |
453 | 453 | 'last_mod' => time(), |
454 | - ),(int)$values['id'] > 0 ? array('cat_id' => $values['id']) : array(),__LINE__,__FILE__); |
|
454 | + ), (int)$values['id'] > 0 ? array('cat_id' => $values['id']) : array(), __LINE__, __FILE__); |
|
455 | 455 | |
456 | - $cat['cat_id'] = $id = (int)$values['id'] > 0 ? (int)$values['id'] : $this->db->get_last_insert_id(self::TABLE,'cat_id'); |
|
456 | + $cat['cat_id'] = $id = (int)$values['id'] > 0 ? (int)$values['id'] : $this->db->get_last_insert_id(self::TABLE, 'cat_id'); |
|
457 | 457 | |
458 | 458 | if (!(int)$values['parent'] && $id != $values['main']) |
459 | 459 | { |
460 | - $this->db->update(self::TABLE,array('cat_main' => $id),array('cat_id' => $id),__LINE__,__FILE__); |
|
460 | + $this->db->update(self::TABLE, array('cat_main' => $id), array('cat_id' => $id), __LINE__, __FILE__); |
|
461 | 461 | $cat['cat_main'] = $id; |
462 | 462 | } |
463 | 463 | // update cache accordingly |
@@ -479,20 +479,20 @@ discard block |
||
479 | 479 | if (empty($cat_list)) return $cat_list; |
480 | 480 | if (is_array($cat_list)) |
481 | 481 | { |
482 | - $cat_list = implode(',',$cat_list); |
|
482 | + $cat_list = implode(',', $cat_list); |
|
483 | 483 | //error_log(__METHOD__.__LINE__.' string expected, array found for cat_list. Converted to:'.$cat_list); |
484 | 484 | } |
485 | - $cat_arr = explode(',',$cat_list); |
|
485 | + $cat_arr = explode(',', $cat_list); |
|
486 | 486 | if (!empty($cat_arr) && is_array($cat_arr) && count($cat_arr) > 0) |
487 | 487 | { |
488 | - foreach($cat_arr as $id=>$cat_id) |
|
488 | + foreach ($cat_arr as $id=>$cat_id) |
|
489 | 489 | { |
490 | 490 | if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ)) // allow reading all global cats |
491 | 491 | { |
492 | 492 | unset($cat_arr[$id]); |
493 | 493 | } |
494 | 494 | } |
495 | - $cat_list = implode(',',$cat_arr); |
|
495 | + $cat_list = implode(',', $cat_arr); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $cat_list; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | * @param boolean $allow_global_read if true, global cats are allowed (independent of app) for reading |
510 | 510 | * @return boolean true permission granted, false for permission denied, null for category does not exist |
511 | 511 | */ |
512 | - public function check_perms($needed, $category, $no_acl_check=false, $allow_global_read=false) |
|
512 | + public function check_perms($needed, $category, $no_acl_check = false, $allow_global_read = false) |
|
513 | 513 | { |
514 | 514 | if (!is_array($category) && !($category = self::read($category))) |
515 | 515 | { |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | // Read access to global categories |
528 | - if ($needed == Acl::READ && (($is_global=array_intersect(explode(',',$category['owner']),$this->global_owners)) || |
|
529 | - $no_acl_check && $category['access'] == 'public') && // no_acl_check only means public cats |
|
528 | + if ($needed == Acl::READ && (($is_global = array_intersect(explode(',', $category['owner']), $this->global_owners)) || |
|
529 | + $no_acl_check && $category['access'] == 'public') && // no_acl_check only means public cats |
|
530 | 530 | ($category['appname'] == self::GLOBAL_APPNAME || $category['appname'] == $this->app_name || |
531 | 531 | $is_global && $allow_global_read)) |
532 | 532 | { |
@@ -549,16 +549,16 @@ discard block |
||
549 | 549 | // Load the application grants |
550 | 550 | if ($category['appname'] == $this->app_name && is_null($this->grants)) |
551 | 551 | { |
552 | - $this->grants = $GLOBALS['egw']->acl->get_grants($this->app_name,true); |
|
552 | + $this->grants = $GLOBALS['egw']->acl->get_grants($this->app_name, true); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Check for ACL granted access, the self::GLOBAL_ACCOUNT user must not get access by ACL to keep old behaviour |
556 | 556 | $acl_grant = $this->account_id != self::GLOBAL_ACCOUNT && $category['appname'] == $this->app_name; |
557 | 557 | $owner_grant = false; |
558 | - foreach(explode(',',$category['owner']) as $owner) |
|
558 | + foreach (explode(',', $category['owner']) as $owner) |
|
559 | 559 | { |
560 | - $owner_grant = $owner_grant || (($this->grants[$owner] & $needed) && |
|
561 | - ($category['access'] == 'public' || ($this->grants[$owner] & Acl::PRIVAT))); |
|
560 | + $owner_grant = $owner_grant || (($this->grants[$owner]&$needed) && |
|
561 | + ($category['access'] == 'public' || ($this->grants[$owner]&Acl::PRIVAT))); |
|
562 | 562 | } |
563 | 563 | return $acl_grant && $owner_grant; |
564 | 564 | } |
@@ -575,35 +575,35 @@ discard block |
||
575 | 575 | //error_log(__METHOD__."(".array2string($cat_id).', drop_subs='.array2string($drop_subs).', modify_subs='.array2string($modify_subs).') '.function_backtrace()); |
576 | 576 | if ($modify_subs) |
577 | 577 | { |
578 | - $new_parent = $this->id2name($cat_id,'parent'); |
|
578 | + $new_parent = $this->id2name($cat_id, 'parent'); |
|
579 | 579 | |
580 | - foreach ((array) $this->return_sorted_array('',False,'','','',False, $cat_id) as $cat) |
|
580 | + foreach ((array)$this->return_sorted_array('', False, '', '', '', False, $cat_id) as $cat) |
|
581 | 581 | { |
582 | 582 | if ($cat['level'] == 1) |
583 | 583 | { |
584 | - $this->db->update(self::TABLE,array( |
|
584 | + $this->db->update(self::TABLE, array( |
|
585 | 585 | 'cat_level' => 0, |
586 | 586 | 'cat_parent' => 0, |
587 | 587 | 'cat_main' => $cat['id'], |
588 | - ),array( |
|
588 | + ), array( |
|
589 | 589 | 'cat_id' => $cat['id'], |
590 | 590 | 'cat_appname' => $this->app_name, |
591 | - ),__LINE__,__FILE__); |
|
591 | + ), __LINE__, __FILE__); |
|
592 | 592 | |
593 | 593 | $new_main = $cat['id']; |
594 | 594 | } |
595 | 595 | else |
596 | 596 | { |
597 | - $update = array('cat_level' => $cat['level']-1); |
|
597 | + $update = array('cat_level' => $cat['level'] - 1); |
|
598 | 598 | |
599 | 599 | if ($new_main) $update['cat_main'] = $new_main; |
600 | 600 | |
601 | 601 | if ($cat['parent'] == $cat_id) $update['cat_parent'] = $new_parent; |
602 | 602 | |
603 | - $this->db->update(self::TABLE,$update,array( |
|
603 | + $this->db->update(self::TABLE, $update, array( |
|
604 | 604 | 'cat_id' => $cat['id'], |
605 | 605 | 'cat_appname' => $this->app_name, |
606 | - ),__LINE__,__FILE__); |
|
606 | + ), __LINE__, __FILE__); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | } |
@@ -624,16 +624,16 @@ discard block |
||
624 | 624 | 'modify_subs' => $modify_subs, |
625 | 625 | 'location' => 'delete_category' |
626 | 626 | ); |
627 | - if($this->is_global($cat_id, true)) // true = application global (otherwise eg. global addressbook categories call all apps) |
|
627 | + if ($this->is_global($cat_id, true)) // true = application global (otherwise eg. global addressbook categories call all apps) |
|
628 | 628 | { |
629 | - Hooks::process($GLOBALS['hook_values'],False,True); // called for every app now, not only enabled ones) |
|
629 | + Hooks::process($GLOBALS['hook_values'], False, True); // called for every app now, not only enabled ones) |
|
630 | 630 | } |
631 | 631 | else |
632 | 632 | { |
633 | - Hooks::single($GLOBALS['hook_values'], self::id2name($cat_id,'appname')); |
|
633 | + Hooks::single($GLOBALS['hook_values'], self::id2name($cat_id, 'appname')); |
|
634 | 634 | } |
635 | 635 | |
636 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
636 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
637 | 637 | |
638 | 638 | // update cache accordingly |
639 | 639 | self::invalidate_cache($modify_subs ? null : $where['cat_id']); |
@@ -649,17 +649,17 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function adapt_level_in_subtree($values) |
651 | 651 | { |
652 | - foreach ((array) $this->return_sorted_array('',False,'','','',False, $values['id']) as $cat) |
|
652 | + foreach ((array)$this->return_sorted_array('', False, '', '', '', False, $values['id']) as $cat) |
|
653 | 653 | { |
654 | 654 | if ($cat['parent'] == $values['id']) |
655 | 655 | { |
656 | - $this->db->update(self::TABLE,array( |
|
657 | - 'cat_level' => $values['level']+1, |
|
656 | + $this->db->update(self::TABLE, array( |
|
657 | + 'cat_level' => $values['level'] + 1, |
|
658 | 658 | 'last_mod' => time(), |
659 | - ),array( |
|
659 | + ), array( |
|
660 | 660 | 'cat_id' => $cat['id'], |
661 | 661 | 'cat_appname' => $this->app_name, |
662 | - ),__LINE__,__FILE__); |
|
662 | + ), __LINE__, __FILE__); |
|
663 | 663 | $cat['level'] = $values['level'] + 1; |
664 | 664 | self::invalidate_cache($cat['id']); |
665 | 665 | $this->adapt_level_in_subtree($cat); |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | function check_consistency4update($values) |
681 | 681 | { |
682 | 682 | // check if we try to move an element down its own subtree, which will fail |
683 | - foreach ($this->return_sorted_array('',False,'','','',False, $values['id']) as $cat) |
|
683 | + foreach ($this->return_sorted_array('', False, '', '', '', False, $values['id']) as $cat) |
|
684 | 684 | { |
685 | 685 | if ($cat['id'] == $values['parent']) return lang('Cannot set a category as parent, which is part of this categorys subtree!'); |
686 | 686 | } |
687 | 687 | // check if we try to be our own parent |
688 | - if ($values['parent']==$values['id']) return lang('Cannot set this cat as its own parent!'); // deny to be our own parent |
|
688 | + if ($values['parent'] == $values['id']) return lang('Cannot set this cat as its own parent!'); // deny to be our own parent |
|
689 | 689 | // check if parent still exists |
690 | - if ((int)$values['parent']>0 && !$this->read($values['parent'])) return lang('Chosen parent category no longer exists'); |
|
690 | + if ((int)$values['parent'] > 0 && !$this->read($values['parent'])) return lang('Chosen parent category no longer exists'); |
|
691 | 691 | return true; |
692 | 692 | } |
693 | 693 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $ret = $this->check_consistency4update($values); |
707 | 707 | if ($ret !== true) throw new Exception\WrongUserinput($ret); |
708 | 708 | // everything seems in order -> proceed |
709 | - $values['level'] = ($values['parent'] ? $this->id2name($values['parent'],'level')+1:0); |
|
709 | + $values['level'] = ($values['parent'] ? $this->id2name($values['parent'], 'level') + 1 : 0); |
|
710 | 710 | $this->adapt_level_in_subtree($values); |
711 | 711 | |
712 | 712 | return $this->add($values); |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | if ($ret !== true) throw new Exception\WrongUserinput($ret); |
721 | 721 | |
722 | 722 | // everything seems in order -> proceed |
723 | - $values['main'] = $this->id2name($values['parent'],'main'); |
|
724 | - $values['level'] = $this->id2name($values['parent'],'level') + 1; |
|
723 | + $values['main'] = $this->id2name($values['parent'], 'main'); |
|
724 | + $values['level'] = $this->id2name($values['parent'], 'level') + 1; |
|
725 | 725 | } |
726 | 726 | else |
727 | 727 | { |
@@ -732,9 +732,9 @@ discard block |
||
732 | 732 | // adapt the level info in each child |
733 | 733 | $this->adapt_level_in_subtree($values); |
734 | 734 | } |
735 | - $this->db->update(self::TABLE,$cat=array( |
|
735 | + $this->db->update(self::TABLE, $cat = array( |
|
736 | 736 | 'cat_name' => $values['name'], |
737 | - 'cat_description' => isset($values['description']) ? $values['description'] : $values['descr'], // support old name different from the one read |
|
737 | + 'cat_description' => isset($values['description']) ? $values['description'] : $values['descr'], // support old name different from the one read |
|
738 | 738 | 'cat_data' => is_array($values['data']) ? json_encode($values['data']) : $values['data'], |
739 | 739 | 'cat_parent' => $values['parent'], |
740 | 740 | 'cat_access' => $values['access'], |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | 'cat_main' => $values['main'], |
743 | 743 | 'cat_level' => $values['level'], |
744 | 744 | 'last_mod' => time(), |
745 | - ),array( |
|
745 | + ), array( |
|
746 | 746 | 'cat_id' => $values['id'], |
747 | 747 | 'cat_appname' => $this->app_name, |
748 | - ),__LINE__,__FILE__); |
|
748 | + ), __LINE__, __FILE__); |
|
749 | 749 | |
750 | 750 | $cat['cat_id'] = $values['id']; |
751 | 751 | $cat['cat_appname'] = $this->app_name; |
@@ -769,9 +769,9 @@ discard block |
||
769 | 769 | * @param boolean|string $strip =false if true, strips 'X-' ($strip) from category names added by some SyncML clients |
770 | 770 | * @return int cat-id or 0 if not found |
771 | 771 | */ |
772 | - function name2id($cat_name, $strip=false) |
|
772 | + function name2id($cat_name, $strip = false) |
|
773 | 773 | { |
774 | - static $cache = array(); // a litle bit of caching |
|
774 | + static $cache = array(); // a litle bit of caching |
|
775 | 775 | |
776 | 776 | if (isset($cache[$cat_name])) return $cache[$cat_name]; |
777 | 777 | |
@@ -792,17 +792,17 @@ discard block |
||
792 | 792 | $cats[] = $stripped_cat_name; |
793 | 793 | } |
794 | 794 | |
795 | - if (!($cats = $this->return_array('all',0,false,'','','',true,null,-1,'',array( |
|
795 | + if (!($cats = $this->return_array('all', 0, false, '', '', '', true, null, -1, '', array( |
|
796 | 796 | 'name' => $cats, |
797 | 797 | 'appname' => array($this->app_name, self::GLOBAL_APPNAME), |
798 | 798 | )))) |
799 | 799 | { |
800 | - return 0; // cat not found, dont cache it, as it might be created in this request |
|
800 | + return 0; // cat not found, dont cache it, as it might be created in this request |
|
801 | 801 | } |
802 | 802 | if (count($cats) > 1) |
803 | 803 | { |
804 | 804 | // if more the one cat matches we weight them by: exact name match; own, global, other users cat; appplication cats |
805 | - foreach($cats as $k => $cat) |
|
805 | + foreach ($cats as $k => $cat) |
|
806 | 806 | { |
807 | 807 | $cats[$k]['weight'] = 100 * ($cat['name'] == $cat_name) + |
808 | 808 | 10 * ($cat['owner'] == $this->account_id ? 3 : ($cat['owner'] <= self::GLOBAL_ACCOUNT ? 2 : 1)) + |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | return $b['weight'] - $a['weight']; |
815 | 815 | }); |
816 | 816 | } |
817 | - return $cache[$cat['cat_name']] = (int) $cats[0]['id']; |
|
817 | + return $cache[$cat['cat_name']] = (int)$cats[0]['id']; |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | * @param boolean $application_global =false true check for application global categories only (appname == 'phpgw') |
825 | 825 | * @return boolean |
826 | 826 | */ |
827 | - static function is_global($cat,$application_global=false) |
|
827 | + static function is_global($cat, $application_global = false) |
|
828 | 828 | { |
829 | - if (!is_array($cat) && !($cat = self::read($cat))) return null; // cat not found |
|
829 | + if (!is_array($cat) && !($cat = self::read($cat))) return null; // cat not found |
|
830 | 830 | |
831 | 831 | $global_owner = false; |
832 | - foreach(explode(',',$cat['owner']) as $owner) |
|
832 | + foreach (explode(',', $cat['owner']) as $owner) |
|
833 | 833 | { |
834 | 834 | $global_owner = $global_owner || $owner <= self::GLOBAL_ACCOUNT; |
835 | 835 | } |
@@ -846,9 +846,9 @@ discard block |
||
846 | 846 | * @param string $item ='name' requested information, 'path' = / delimited path of category names (incl. parents) |
847 | 847 | * @return string information or '--' if not found or !$cat_id |
848 | 848 | */ |
849 | - static function id2name($cat_id=0, $item='name') |
|
849 | + static function id2name($cat_id = 0, $item = 'name') |
|
850 | 850 | { |
851 | - if(!$cat_id) return '--'; |
|
851 | + if (!$cat_id) return '--'; |
|
852 | 852 | if (!$item) $item = 'parent'; |
853 | 853 | |
854 | 854 | if (is_null(self::$cache)) self::init_cache(); |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | { |
859 | 859 | if ($cat['parent']) |
860 | 860 | { |
861 | - return self::id2name($cat['parent'],'path').' / '.$cat['name']; |
|
861 | + return self::id2name($cat['parent'], 'path').' / '.$cat['name']; |
|
862 | 862 | } |
863 | 863 | $item = 'name'; |
864 | 864 | } |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * @param int $parent =0 category id of parent |
888 | 888 | * @return int/boolean cat_id or false if cat not exists |
889 | 889 | */ |
890 | - function exists($type,$cat_name = '',$cat_id = 0,$parent = 0) |
|
890 | + function exists($type, $cat_name = '', $cat_id = 0, $parent = 0) |
|
891 | 891 | { |
892 | 892 | if ($cat_name) |
893 | 893 | { |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | { |
899 | 899 | $filter['id'] = $cat_id; |
900 | 900 | } |
901 | - if (!($cats = $this->return_array($type,0,false,'','','',true,$parent,-1,'id',$filter))) |
|
901 | + if (!($cats = $this->return_array($type, 0, false, '', '', '', true, $parent, -1, 'id', $filter))) |
|
902 | 902 | { |
903 | 903 | $ret = false; |
904 | 904 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | * @param int $to =0 new owner or 0 to delete the cats |
918 | 918 | * @param string $app ='' if given only cats matching $app are modifed/deleted |
919 | 919 | */ |
920 | - function change_owner($owner,$to=0,$app='') |
|
920 | + function change_owner($owner, $to = 0, $app = '') |
|
921 | 921 | { |
922 | 922 | $where = array('cat_owner' => $owner); |
923 | 923 | |
@@ -925,11 +925,11 @@ discard block |
||
925 | 925 | |
926 | 926 | if ((int)$to) |
927 | 927 | { |
928 | - $this->db->update(self::TABLE,array('cat_owner' => $to),$where,__LINE__,__FILE__); |
|
928 | + $this->db->update(self::TABLE, array('cat_owner' => $to), $where, __LINE__, __FILE__); |
|
929 | 929 | } |
930 | 930 | else |
931 | 931 | { |
932 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
932 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
933 | 933 | } |
934 | 934 | // update cache accordingly |
935 | 935 | self::invalidate_cache(); |
@@ -947,10 +947,10 @@ discard block |
||
947 | 947 | if (is_null(self::$cache)) |
948 | 948 | { |
949 | 949 | // check if we are already updated to global owner == 0, if not do it now |
950 | - if (!$GLOBALS['egw']->db->select(self::TABLE,'COUNT(*)',array('cat_owner'=>'0'),__LINE__,__FILE__)->fetchColumn()) |
|
950 | + if (!$GLOBALS['egw']->db->select(self::TABLE, 'COUNT(*)', array('cat_owner'=>'0'), __LINE__, __FILE__)->fetchColumn()) |
|
951 | 951 | { |
952 | - $GLOBALS['egw']->db->update(self::TABLE,array('cat_owner'=>'0'),"(cat_owner='-1' OR cat_appname='phpgw')",__LINE__,__FILE__); |
|
953 | - $GLOBALS['egw']->db->insert(self::TABLE,array( |
|
952 | + $GLOBALS['egw']->db->update(self::TABLE, array('cat_owner'=>'0'), "(cat_owner='-1' OR cat_appname='phpgw')", __LINE__, __FILE__); |
|
953 | + $GLOBALS['egw']->db->insert(self::TABLE, array( |
|
954 | 954 | 'cat_main' => 0, |
955 | 955 | 'cat_parent' => 0, |
956 | 956 | 'cat_level' => 0, |
@@ -959,15 +959,15 @@ discard block |
||
959 | 959 | 'cat_name' => 'global=0', |
960 | 960 | 'cat_description' => 'global=0', |
961 | 961 | 'last_mod' => time(), |
962 | - ),false,__LINE__,__FILE__); |
|
962 | + ), false, __LINE__, __FILE__); |
|
963 | 963 | } |
964 | 964 | self::$cache = array(); |
965 | 965 | // read all cats (cant use $this->db!) |
966 | - foreach($GLOBALS['egw']->db->select(self::TABLE,'*',false,__LINE__,__FILE__, |
|
967 | - false,'ORDER BY cat_main, cat_level, cat_name ASC') as $cat) |
|
966 | + foreach ($GLOBALS['egw']->db->select(self::TABLE, '*', false, __LINE__, __FILE__, |
|
967 | + false, 'ORDER BY cat_main, cat_level, cat_name ASC') as $cat) |
|
968 | 968 | { |
969 | - $cat = Db::strip_array_keys($cat,'cat_'); |
|
970 | - if ($cat['appname'] == '*update*') continue; // --> ignore update marker |
|
969 | + $cat = Db::strip_array_keys($cat, 'cat_'); |
|
970 | + if ($cat['appname'] == '*update*') continue; // --> ignore update marker |
|
971 | 971 | $cat['app_name'] = $cat['appname']; |
972 | 972 | // backlink children to their parent |
973 | 973 | if ($cat['parent']) |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | if (isset(self::$cache[$cat['id']])) |
978 | 978 | { |
979 | 979 | $cat['children'] = self::$cache[$cat['id']]['children']; |
980 | - unset(self::$cache[$cat['id']]); // otherwise the order gets messed up! |
|
980 | + unset(self::$cache[$cat['id']]); // otherwise the order gets messed up! |
|
981 | 981 | } |
982 | 982 | self::$cache[$cat['id']] = $cat; |
983 | 983 | } |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @param int|array $cat concerned id(s) or array with cat-data or null for all cats |
996 | 996 | */ |
997 | - public static function invalidate_cache($cat=null) |
|
997 | + public static function invalidate_cache($cat = null) |
|
998 | 998 | { |
999 | 999 | //error_log(__METHOD__."(".array2string($cat).') '.function_backtrace()); |
1000 | 1000 | |
@@ -1006,12 +1006,12 @@ discard block |
||
1006 | 1006 | { |
1007 | 1007 | if (!is_array($cat) || isset($cat[0])) |
1008 | 1008 | { |
1009 | - foreach((array)$cat as $cat_id) |
|
1009 | + foreach ((array)$cat as $cat_id) |
|
1010 | 1010 | { |
1011 | 1011 | unset(self::$cache[$cat_id]); |
1012 | 1012 | } |
1013 | 1013 | } |
1014 | - elseif($cat['id']) |
|
1014 | + elseif ($cat['id']) |
|
1015 | 1015 | { |
1016 | 1016 | self::$cache[$cat['id']] = $cat; |
1017 | 1017 | } |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | */ |
1035 | 1035 | public static function css($appname) |
1036 | 1036 | { |
1037 | - $cats = new Categories('',$appname); |
|
1038 | - $last_mod = $cats->return_array('all',0,1,'','DESC','last_mod', $appname == self::GLOBAL_APPNAME); |
|
1037 | + $cats = new Categories('', $appname); |
|
1038 | + $last_mod = $cats->return_array('all', 0, 1, '', 'DESC', 'last_mod', $appname == self::GLOBAL_APPNAME); |
|
1039 | 1039 | $time = count($last_mod) ? $last_mod[0]['last_mod'] : time(); |
1040 | 1040 | $path = '/api/categories.php?app='.$appname.'&'.$time; |
1041 | 1041 | Framework::includeCSS($path); |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | return $cat2color[$cats]; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - foreach(explode(',', $cats) as $cat) |
|
1068 | + foreach (explode(',', $cats) as $cat) |
|
1069 | 1069 | { |
1070 | 1070 | if (isset($cat2color[$cat])) |
1071 | 1071 | { |
@@ -1088,13 +1088,13 @@ discard block |
||
1088 | 1088 | * @param int $new_owner =null for users data can be transfered to new owner |
1089 | 1089 | * @return int number of deleted or modified categories |
1090 | 1090 | */ |
1091 | - public static function delete_account($account_id, $new_owner=null) |
|
1091 | + public static function delete_account($account_id, $new_owner = null) |
|
1092 | 1092 | { |
1093 | 1093 | if (is_null(self::$cache)) self::init_cache(); |
1094 | 1094 | |
1095 | 1095 | $deleted = 0; |
1096 | 1096 | $cat = null; |
1097 | - foreach(self::$cache as $cat_id => $data) |
|
1097 | + foreach (self::$cache as $cat_id => $data) |
|
1098 | 1098 | { |
1099 | 1099 | if ($data['owner'] && ($owners = explode(',', $data['owner'])) && ($owner_key = array_search($account_id, $owners)) !== false) |
1100 | 1100 | { |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | |
1137 | 1137 | $checked = array(); |
1138 | 1138 | $deleted = 0; |
1139 | - foreach(self::$cache as $data) |
|
1139 | + foreach (self::$cache as $data) |
|
1140 | 1140 | { |
1141 | - foreach(explode(',', $data['owner']) as $owner) |
|
1141 | + foreach (explode(',', $data['owner']) as $owner) |
|
1142 | 1142 | { |
1143 | 1143 | if ($owner && !in_array($owner, $checked)) |
1144 | 1144 | { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | echo "<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n"; |
67 | 67 | } |
68 | 68 | if ($app1 == $app2 && $id1 == $id2 || |
69 | - $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
|
69 | + $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
|
70 | 70 | { |
71 | 71 | return False; // dont link to self or other nosense |
72 | 72 | } |
@@ -412,26 +412,26 @@ discard block |
||
412 | 412 | array('table'=>self::TABLE, |
413 | 413 | 'cols'=>'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3', |
414 | 414 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND c.link_app2='.self::$db->quote($target_app). |
415 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
416 | - 'join'=>" a |
|
415 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
416 | + 'join'=>" a |
|
417 | 417 | JOIN $table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1 |
418 | 418 | JOIN $table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2", |
419 | 419 | ), |
420 | 420 | // retrieve the type of links, where the relation is realized as timesheet->infolog/tracker and projectmanager->timesheet |
421 | 421 | array('table'=>self::TABLE, |
422 | 422 | 'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
423 | - 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
|
424 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
425 | - 'join'=>" a |
|
423 | + 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
|
424 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
425 | + 'join'=>" a |
|
426 | 426 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
427 | 427 | JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1", |
428 | 428 | ), |
429 | 429 | // retrieve the type of links, where the relation is realized as timesheet->projectmanager and infolog->timesheet |
430 | 430 | array('table'=>self::TABLE, |
431 | 431 | 'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
432 | - 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
|
433 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
434 | - 'join'=>" a |
|
432 | + 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
|
433 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
434 | + 'join'=>" a |
|
435 | 435 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
436 | 436 | JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1", |
437 | 437 | ), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param int $lastmod =0 timestamp of last modification (defaults to now=time()) |
60 | 60 | * @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1) |
61 | 61 | */ |
62 | - static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0 ) |
|
62 | + static function link($app1, &$id1, $app2, $id2 = '', $remark = '', $owner = 0, $lastmod = 0) |
|
63 | 63 | { |
64 | 64 | if (self::DEBUG) |
65 | 65 | { |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | if ($app1 == $app2 && $id1 == $id2 || |
69 | 69 | $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
70 | 70 | { |
71 | - return False; // dont link to self or other nosense |
|
71 | + return False; // dont link to self or other nosense |
|
72 | 72 | } |
73 | - if (($link = self::get_link($app1,$id1,$app2,$id2))) |
|
73 | + if (($link = self::get_link($app1, $id1, $app2, $id2))) |
|
74 | 74 | { |
75 | 75 | if ($link['link_remark'] != $remark) |
76 | 76 | { |
77 | - self::update_remark($link['link_id'],$remark); |
|
77 | + self::update_remark($link['link_id'], $remark); |
|
78 | 78 | } |
79 | - return $link['link_id']; // link alread exist |
|
79 | + return $link['link_id']; // link alread exist |
|
80 | 80 | } |
81 | 81 | if (!$owner) |
82 | 82 | { |
83 | 83 | $owner = $GLOBALS['egw_info']['user']['account_id']; |
84 | 84 | } |
85 | - return self::$db->insert(self::TABLE,array( |
|
85 | + return self::$db->insert(self::TABLE, array( |
|
86 | 86 | 'link_app1' => $app1, |
87 | 87 | 'link_id1' => $id1, |
88 | 88 | 'link_app2' => $app2, |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'link_remark' => $remark, |
91 | 91 | 'link_lastmod' => $lastmod ? $lastmod : time(), |
92 | 92 | 'link_owner' => $owner, |
93 | - ),False,__LINE__,__FILE__) ? self::$db->get_last_insert_id(self::TABLE,'link_id') : false; |
|
93 | + ), False, __LINE__, __FILE__) ? self::$db->get_last_insert_id(self::TABLE, 'link_id') : false; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @param string $remark new text for the remark |
101 | 101 | * @return boolean true on success, else false |
102 | 102 | */ |
103 | - static function update_remark($link_id,$remark) |
|
103 | + static function update_remark($link_id, $remark) |
|
104 | 104 | { |
105 | - return self::$db->update(self::TABLE,array( |
|
105 | + return self::$db->update(self::TABLE, array( |
|
106 | 106 | 'link_remark' => $remark, |
107 | 107 | 'link_lastmod' => time(), |
108 | - ),array( |
|
108 | + ), array( |
|
109 | 109 | 'link_id' => $link_id, |
110 | - ),__LINE__,__FILE__); |
|
110 | + ), __LINE__, __FILE__); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
122 | 122 | * @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found |
123 | 123 | */ |
124 | - static function get_links($app, $id, $only_app='', $order='link_lastmod DESC', $deleted=false, $limit=null) |
|
124 | + static function get_links($app, $id, $only_app = '', $order = 'link_lastmod DESC', $deleted = false, $limit = null) |
|
125 | 125 | { |
126 | 126 | if (self::DEBUG) |
127 | 127 | { |
128 | - echo "<p>solink.get_links($app,".print_r($id,true).",$only_app,$order,$deleted)</p>\n"; |
|
128 | + echo "<p>solink.get_links($app,".print_r($id, true).",$only_app,$order,$deleted)</p>\n"; |
|
129 | 129 | } |
130 | 130 | if (($not_only = $only_app[0] == '!')) |
131 | 131 | { |
132 | - $only_app = substr($only_app,1); |
|
132 | + $only_app = substr($only_app, 1); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $offset = false; |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | { |
138 | 138 | list($offset, $limit) = $limit; |
139 | 139 | } |
140 | - elseif($limit) |
|
140 | + elseif ($limit) |
|
141 | 141 | { |
142 | 142 | $offset = 0; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $links = array(); |
146 | 146 | try { |
147 | - foreach(self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
147 | + foreach (self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
148 | 148 | 'link_app1' => $app, |
149 | 149 | 'link_id1' => $id, |
150 | - ),') OR (',array( |
|
150 | + ), ') OR (', array( |
|
151 | 151 | 'link_app2' => $app, |
152 | 152 | 'link_id2' => $id, |
153 | - ),'))', |
|
153 | + ), '))', |
|
154 | 154 | $deleted ? '' : ' AND deleted IS NULL' |
155 | 155 | ), __LINE__, __FILE__, $offset, $order ? " ORDER BY $order" : '', 'phpgwapi', $limit) as $row) |
156 | 156 | { |
157 | 157 | // check if left side (1) is one of our targets --> add it |
158 | - if ($row['link_app1'] == $app && in_array($row['link_id1'],(array)$id)) |
|
158 | + if ($row['link_app1'] == $app && in_array($row['link_id1'], (array)$id)) |
|
159 | 159 | { |
160 | - self::_add2links($row,true,$only_app,$not_only,$links); |
|
160 | + self::_add2links($row, true, $only_app, $not_only, $links); |
|
161 | 161 | } |
162 | 162 | // check if right side (2) is one of our targets --> add it (both can be true for multiple targets!) |
163 | - if ($row['link_app2'] == $app && in_array($row['link_id2'],(array)$id)) |
|
163 | + if ($row['link_app2'] == $app && in_array($row['link_id2'], (array)$id)) |
|
164 | 164 | { |
165 | - self::_add2links($row,false,$only_app,$not_only,$links); |
|
165 | + self::_add2links($row, false, $only_app, $not_only, $links); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | } |
171 | 171 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
172 | 172 | // caused by non-ascii chars compared with ascii field uid |
173 | - catch(Api\Db\Exception $e) { |
|
173 | + catch (Api\Db\Exception $e) { |
|
174 | 174 | _egw_log_exception($e); |
175 | 175 | } |
176 | 176 | return is_array($id) ? $links : ($links[$id] ? $links[$id] : array()); |
177 | 177 | } |
178 | 178 | |
179 | - private static function _add2links($row,$left,$only_app,$not_only,array &$links) |
|
179 | + private static function _add2links($row, $left, $only_app, $not_only, array &$links) |
|
180 | 180 | { |
181 | 181 | $linked_app = $left ? $row['link_app2'] : $row['link_app1']; |
182 | 182 | $linked_id = $left ? $row['link_id2'] : $row['link_id1']; |
183 | 183 | $app_id = $left ? $row['link_id1'] : $row['link_id2']; |
184 | - list($app) = explode('-',$linked_app); |
|
184 | + list($app) = explode('-', $linked_app); |
|
185 | 185 | if ($only_app && $not_only == ($linked_app == $only_app) || !$GLOBALS['egw_info']['user']['apps'][$app]) |
186 | 186 | { |
187 | 187 | #echo "$linked_app == $only_app, ";var_dump($linked_app == $only_app);echo " ->dont return a link<br>"; |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @param string $id2 ='' id in $app2, if no integer link_id given in $app_link_id |
209 | 209 | * @return array with link-data or False |
210 | 210 | */ |
211 | - static function get_link($app_link_id,$id='',$app2='',$id2='') |
|
211 | + static function get_link($app_link_id, $id = '', $app2 = '', $id2 = '') |
|
212 | 212 | { |
213 | 213 | if (self::DEBUG) |
214 | 214 | { |
215 | 215 | echo "<p>solink.get_link('$app_link_id',$id,'$app2','$id2')</p>\n"; |
216 | 216 | } |
217 | - if ((int) $app_link_id > 0) |
|
217 | + if ((int)$app_link_id > 0) |
|
218 | 218 | { |
219 | 219 | $where = array('link_id' => $app_link_id); |
220 | 220 | } |
@@ -224,24 +224,24 @@ discard block |
||
224 | 224 | { |
225 | 225 | return False; |
226 | 226 | } |
227 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
227 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
228 | 228 | 'link_app1' => $app_link_id, |
229 | 229 | 'link_id1' => $id, |
230 | 230 | 'link_app2' => $app2, |
231 | 231 | 'link_id2' => $id2, |
232 | - ),') OR (',array( |
|
232 | + ), ') OR (', array( |
|
233 | 233 | 'link_app2' => $app_link_id, |
234 | 234 | 'link_id2' => $id, |
235 | 235 | 'link_app1' => $app2, |
236 | 236 | 'link_id1' => $id2, |
237 | - ),')'); |
|
237 | + ), ')'); |
|
238 | 238 | } |
239 | 239 | try { |
240 | - return self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
240 | + return self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
241 | 241 | } |
242 | 242 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
243 | 243 | // caused by non-ascii chars compared with ascii field uid |
244 | - catch(Api\Db\Exception $e) { |
|
244 | + catch (Api\Db\Exception $e) { |
|
245 | 245 | _egw_log_exception($e); |
246 | 246 | } |
247 | 247 | return false; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete of linked entry |
260 | 260 | * @return array with deleted links |
261 | 261 | */ |
262 | - static function unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='',$hold_for_purge=false) |
|
262 | + static function unlink($link_id, $app = '', $id = '', $owner = 0, $app2 = '', $id2 = '', $hold_for_purge = false) |
|
263 | 263 | { |
264 | 264 | if (self::DEBUG) |
265 | 265 | { |
@@ -284,21 +284,21 @@ discard block |
||
284 | 284 | $check1['link_id1'] = $id; |
285 | 285 | $check2['link_id2'] = $id; |
286 | 286 | } |
287 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
287 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
288 | 288 | } |
289 | 289 | elseif ($app != '' && $app2 != '') |
290 | 290 | { |
291 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
291 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
292 | 292 | 'link_app1' => $app, |
293 | 293 | 'link_id1' => $id, |
294 | 294 | 'link_app2' => $app2, |
295 | 295 | 'link_id2' => $id2, |
296 | - ),') OR (',array( |
|
296 | + ), ') OR (', array( |
|
297 | 297 | 'link_app1' => $app2, |
298 | 298 | 'link_id1' => $id2, |
299 | 299 | 'link_app2' => $app, |
300 | 300 | 'link_id2' => $id, |
301 | - ),')'); |
|
301 | + ), ')'); |
|
302 | 302 | } |
303 | 303 | if ($owner) |
304 | 304 | { |
@@ -308,25 +308,25 @@ discard block |
||
308 | 308 | } |
309 | 309 | $deleted = array(); |
310 | 310 | try { |
311 | - foreach(self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__) as $row) |
|
311 | + foreach (self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__) as $row) |
|
312 | 312 | { |
313 | 313 | $deleted[] = $row; |
314 | 314 | } |
315 | - if($hold_for_purge) |
|
315 | + if ($hold_for_purge) |
|
316 | 316 | { |
317 | - self::$db->update(self::TABLE,array( |
|
317 | + self::$db->update(self::TABLE, array( |
|
318 | 318 | 'deleted' => time(), |
319 | 319 | 'link_lastmod' => time(), |
320 | - ), $where, __LINE__,__FILE__); |
|
320 | + ), $where, __LINE__, __FILE__); |
|
321 | 321 | } |
322 | 322 | else |
323 | 323 | { |
324 | - self::$db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
324 | + self::$db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
328 | 328 | // caused by non-ascii chars compared with ascii field uid |
329 | - catch(Api\Db\Exception $e) { |
|
329 | + catch (Api\Db\Exception $e) { |
|
330 | 330 | _egw_log_exception($e); |
331 | 331 | } |
332 | 332 | |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | $check1['link_id1'] = $id; |
358 | 358 | $check2['link_id2'] = $id; |
359 | 359 | } |
360 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
361 | - self::$db->update(self::TABLE,array('deleted'=> null), $where, __LINE__,__FILE__); |
|
360 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
361 | + self::$db->update(self::TABLE, array('deleted'=> null), $where, __LINE__, __FILE__); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * @param int $new_owner account_id of new owner |
372 | 372 | * @return int number of links changed |
373 | 373 | */ |
374 | - static function chown($owner,$new_owner) |
|
374 | + static function chown($owner, $new_owner) |
|
375 | 375 | { |
376 | - if ((int)$owner <= 0 || (int) $new_owner <= 0) |
|
376 | + if ((int)$owner <= 0 || (int)$new_owner <= 0) |
|
377 | 377 | { |
378 | 378 | return 0; |
379 | 379 | } |
380 | - self::$db->update(self::TABLE,array('owner'=>$new_owner),array('owner'=>$owner),__LINE__,__FILE__); |
|
380 | + self::$db->update(self::TABLE, array('owner'=>$new_owner), array('owner'=>$owner), __LINE__, __FILE__); |
|
381 | 381 | |
382 | 382 | return self::$db->affected_rows(); |
383 | 383 | } |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
405 | 405 | * @return array with links from entries from $app to $target_app/$target_id plus the other (b) link_id/app/id in the keys 'link3'/'app3'/'id3' |
406 | 406 | */ |
407 | - static function get_3links($app, $target_app, $target_id=null, $just_app_ids=false, $order='link_lastmod DESC', $limit=null) |
|
407 | + static function get_3links($app, $target_app, $target_id = null, $just_app_ids = false, $order = 'link_lastmod DESC', $limit = null) |
|
408 | 408 | { |
409 | 409 | $table = self::TABLE; |
410 | - $arrayofselects=array( |
|
410 | + $arrayofselects = array( |
|
411 | 411 | // retrieve the type of links, where the relation is realized as timesheet->infolog/tracker via infolog->projectmanager to timesheet->projectmanager |
412 | 412 | array('table'=>self::TABLE, |
413 | 413 | 'cols'=>'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3', |
414 | 414 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND c.link_app2='.self::$db->quote($target_app). |
415 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
415 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND c.', array('link_id2' => $target_id))), |
|
416 | 416 | 'join'=>" a |
417 | 417 | JOIN $table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1 |
418 | 418 | JOIN $table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2", |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | array('table'=>self::TABLE, |
422 | 422 | 'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
423 | 423 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
424 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
424 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND b.', array('link_id1' => $target_id))), |
|
425 | 425 | 'join'=>" a |
426 | 426 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
427 | 427 | JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1", |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | array('table'=>self::TABLE, |
431 | 431 | 'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
432 | 432 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
433 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
433 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND a.', array('link_id2' => $target_id))), |
|
434 | 434 | 'join'=>" a |
435 | 435 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
436 | 436 | JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1", |
@@ -442,17 +442,17 @@ discard block |
||
442 | 442 | { |
443 | 443 | list($offset, $limit) = $limit; |
444 | 444 | } |
445 | - elseif($limit) |
|
445 | + elseif ($limit) |
|
446 | 446 | { |
447 | 447 | $offset = 0; |
448 | 448 | } |
449 | 449 | |
450 | 450 | $links = array(); |
451 | - foreach(self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
451 | + foreach (self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
452 | 452 | { |
453 | 453 | if ($just_app_ids) |
454 | 454 | { |
455 | - if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'],(array)$target_id))) |
|
455 | + if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'], (array)$target_id))) |
|
456 | 456 | { |
457 | 457 | $links[$row['link_id']] = $row['link_id2']; |
458 | 458 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } |
464 | 464 | else |
465 | 465 | { |
466 | - $links[] = Api\Db::strip_array_keys($row,'link_'); |
|
466 | + $links[] = Api\Db::strip_array_keys($row, 'link_'); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | static function init_static( ) |
479 | 479 | { |
480 | - self::$db = $GLOBALS['egw']->db; |
|
480 | + self::$db = $GLOBALS['egw']->db; |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | Storage::init_static(); |
@@ -302,7 +302,10 @@ |
||
302 | 302 | } |
303 | 303 | if ($owner) |
304 | 304 | { |
305 | - if ($app) $where = array($where); |
|
305 | + if ($app) |
|
306 | + { |
|
307 | + $where = array($where); |
|
308 | + } |
|
306 | 309 | $where['link_owner'] = $owner; |
307 | 310 | } |
308 | 311 | } |
@@ -269,7 +269,7 @@ |
||
269 | 269 | { |
270 | 270 | $where = array('link_id' => $link_id); |
271 | 271 | } |
272 | - elseif ($app == '' AND $owner == '') |
|
272 | + elseif ($app == '' and $owner == '') |
|
273 | 273 | { |
274 | 274 | return 0; |
275 | 275 | } |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * @param Base $storage |
47 | 47 | * @param \Traversable $rs |
48 | 48 | */ |
49 | - public function __construct(Base $storage, \Traversable $rs=null) |
|
49 | + public function __construct(Base $storage, \Traversable $rs = null) |
|
50 | 50 | { |
51 | 51 | $this->storage = $storage; |
52 | 52 | |
53 | 53 | $this->total = $storage->total; |
54 | 54 | |
55 | - if (is_a($rs,'IteratorAggregate')) |
|
55 | + if (is_a($rs, 'IteratorAggregate')) |
|
56 | 56 | { |
57 | 57 | $this->rs = $rs->getIterator(); |
58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function current() |
71 | 71 | { |
72 | - if (is_a($this->rs,'iterator')) |
|
72 | + if (is_a($this->rs, 'iterator')) |
|
73 | 73 | { |
74 | 74 | $data = $this->rs->current(); |
75 | 75 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function key() |
87 | 87 | { |
88 | - if (is_a($this->rs,'iterator')) |
|
88 | + if (is_a($this->rs, 'iterator')) |
|
89 | 89 | { |
90 | 90 | return $this->rs->key(); |
91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function next() |
99 | 99 | { |
100 | - if (is_a($this->rs,'iterator')) |
|
100 | + if (is_a($this->rs, 'iterator')) |
|
101 | 101 | { |
102 | 102 | return $this->rs->next(); |
103 | 103 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function rewind() |
110 | 110 | { |
111 | - if (is_a($this->rs,'iterator')) |
|
111 | + if (is_a($this->rs, 'iterator')) |
|
112 | 112 | { |
113 | 113 | return $this->rs->rewind(); |
114 | 114 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return boolean |
121 | 121 | */ |
122 | - public function valid () |
|
122 | + public function valid() |
|
123 | 123 | { |
124 | - if (is_a($this->rs,'iterator')) |
|
124 | + if (is_a($this->rs, 'iterator')) |
|
125 | 125 | { |
126 | 126 | return $this->rs->valid(); |
127 | 127 | } |