@@ -230,6 +230,7 @@ |
||
| 230 | 230 | * If the entry is not yet created, the file information is stored into the widget's value. |
| 231 | 231 | * When the form is submitted, the information for all files uploaded is available in the returned |
| 232 | 232 | * $content array and the application should deal with the file. |
| 233 | + * @return string |
|
| 233 | 234 | */ |
| 234 | 235 | public static function store_file($path, $file) |
| 235 | 236 | { |
@@ -224,13 +224,13 @@ |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * Ajax callback to receive an incoming file |
|
| 228 | - * |
|
| 229 | - * The incoming file is automatically placed into the appropriate VFS location. |
|
| 230 | - * If the entry is not yet created, the file information is stored into the widget's value. |
|
| 231 | - * When the form is submitted, the information for all files uploaded is available in the returned |
|
| 232 | - * $content array and the application should deal with the file. |
|
| 233 | - */ |
|
| 227 | + * Ajax callback to receive an incoming file |
|
| 228 | + * |
|
| 229 | + * The incoming file is automatically placed into the appropriate VFS location. |
|
| 230 | + * If the entry is not yet created, the file information is stored into the widget's value. |
|
| 231 | + * When the form is submitted, the information for all files uploaded is available in the returned |
|
| 232 | + * $content array and the application should deal with the file. |
|
| 233 | + */ |
|
| 234 | 234 | public static function store_file($path, $file) |
| 235 | 235 | { |
| 236 | 236 | $name = $_REQUEST['widget_id']; |
@@ -27,7 +27,10 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __construct($xml='') |
| 29 | 29 | { |
| 30 | - if($xml) parent::__construct($xml); |
|
| 30 | + if($xml) |
|
| 31 | + { |
|
| 32 | + parent::__construct($xml); |
|
| 33 | + } |
|
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | /** |
@@ -64,9 +67,15 @@ discard block |
||
| 64 | 67 | } |
| 65 | 68 | $value =& self::get_array(self::$request->content, $form_name, true); |
| 66 | 69 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 67 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 70 | + if (!empty($relpath)) |
|
| 71 | + { |
|
| 72 | + $path .= '/'.$relpath; |
|
| 73 | + } |
|
| 68 | 74 | |
| 69 | - if (true) $value = array(); |
|
| 75 | + if (true) |
|
| 76 | + { |
|
| 77 | + $value = array(); |
|
| 78 | + } |
|
| 70 | 79 | |
| 71 | 80 | // Single file, already existing |
| 72 | 81 | if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
@@ -194,7 +203,10 @@ discard block |
||
| 194 | 203 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
| 195 | 204 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
| 196 | 205 | |
| 197 | - if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1]; |
|
| 206 | + if (!in_array($matches[1], $remove_dir)) |
|
| 207 | + { |
|
| 208 | + $remove_dir[] = $matches[1]; |
|
| 209 | + } |
|
| 198 | 210 | } |
| 199 | 211 | } |
| 200 | 212 | if ($replace) |
@@ -218,7 +230,10 @@ discard block |
||
| 218 | 230 | */ |
| 219 | 231 | static function get_temp_dir($app, $postfix=null) |
| 220 | 232 | { |
| 221 | - if (!isset($postfix)) $postfix = md5(time().session_id()); |
|
| 233 | + if (!isset($postfix)) |
|
| 234 | + { |
|
| 235 | + $postfix = md5(time().session_id()); |
|
| 236 | + } |
|
| 222 | 237 | |
| 223 | 238 | return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix; |
| 224 | 239 | } |
@@ -245,10 +260,13 @@ discard block |
||
| 245 | 260 | { |
| 246 | 261 | // add extension to path |
| 247 | 262 | $parts = explode('.',$filename); |
| 248 | - if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
|
| 263 | + if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) |
|
| 264 | + { |
|
| 265 | + // really an extension --> add it to path |
|
| 249 | 266 | { |
| 250 | 267 | $path .= '.'.$extension; |
| 251 | 268 | } |
| 269 | + } |
|
| 252 | 270 | } |
| 253 | 271 | else // multiple upload with dir given (trailing slash) |
| 254 | 272 | { |
@@ -294,7 +312,10 @@ discard block |
||
| 294 | 312 | switch($this->type) |
| 295 | 313 | { |
| 296 | 314 | case 'vfs-upload': |
| 297 | - if(!is_array($value)) $value = array(); |
|
| 315 | + if(!is_array($value)) |
|
| 316 | + { |
|
| 317 | + $value = array(); |
|
| 318 | + } |
|
| 298 | 319 | /* Check & skip files that made it asyncronously |
| 299 | 320 | list($app,$id,$relpath) = explode(':',$this->id,3); |
| 300 | 321 | //... |
@@ -305,7 +326,10 @@ discard block |
||
| 305 | 326 | parent::validate($cname, $content, $validated); |
| 306 | 327 | break; |
| 307 | 328 | } |
| 308 | - if (true) $valid = $value; |
|
| 329 | + if (true) |
|
| 330 | + { |
|
| 331 | + $valid = $value; |
|
| 332 | + } |
|
| 309 | 333 | } |
| 310 | 334 | |
| 311 | 335 | /** |
@@ -317,14 +341,20 @@ discard block |
||
| 317 | 341 | if (empty($id) || $id == 'undefined') |
| 318 | 342 | { |
| 319 | 343 | static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
| 320 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
| 344 | + if (!isset($tmppath[$app])) |
|
| 345 | + { |
|
| 346 | + $tmppath[$app] = self::get_temp_dir ($app); |
|
| 347 | + } |
|
| 321 | 348 | $path = $tmppath[$app]; |
| 322 | 349 | } |
| 323 | 350 | else |
| 324 | 351 | { |
| 325 | 352 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 326 | 353 | } |
| 327 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 354 | + if (!empty($relpath)) |
|
| 355 | + { |
|
| 356 | + $path .= '/'.$relpath; |
|
| 357 | + } |
|
| 328 | 358 | return $path; |
| 329 | 359 | } |
| 330 | 360 | } |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | // Legacy option for vfs-upload |
| 26 | 26 | protected $legacy_options = "mime"; |
| 27 | 27 | |
| 28 | - public function __construct($xml='') |
|
| 28 | + public function __construct($xml = '') |
|
| 29 | 29 | { |
| 30 | - if($xml) parent::__construct($xml); |
|
| 30 | + if ($xml) parent::__construct($xml); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function beforeSendToClient($cname, $expand = array()) |
| 38 | 38 | { |
| 39 | - if($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload') |
|
| 39 | + if ($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload') |
|
| 40 | 40 | { |
| 41 | 41 | $form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content)); |
| 42 | - if($this->attrs['path']) |
|
| 42 | + if ($this->attrs['path']) |
|
| 43 | 43 | { |
| 44 | 44 | $path = $this->attrs['path']; |
| 45 | 45 | } |
@@ -50,26 +50,26 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $this->setElementAttribute($form_name, 'path', $path); |
| 52 | 52 | // ID maps to path - check there for any existing files |
| 53 | - list($app,$id,$relpath) = explode(':',$path,3); |
|
| 54 | - if($app && $id) |
|
| 53 | + list($app, $id, $relpath) = explode(':', $path, 3); |
|
| 54 | + if ($app && $id) |
|
| 55 | 55 | { |
| 56 | - if(!is_numeric($id)) |
|
| 56 | + if (!is_numeric($id)) |
|
| 57 | 57 | { |
| 58 | - $_id = self::expand_name($id,0,0,0,0,self::$request->content); |
|
| 59 | - if($_id != $id) |
|
| 58 | + $_id = self::expand_name($id, 0, 0, 0, 0, self::$request->content); |
|
| 59 | + if ($_id != $id) |
|
| 60 | 60 | { |
| 61 | 61 | $id = $_id; |
| 62 | 62 | $form_name = "$app:$id:$relpath"; |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
| 66 | - $path = Api\Link::vfs_path($app,$id,'',true); |
|
| 65 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
| 66 | + $path = Api\Link::vfs_path($app, $id, '', true); |
|
| 67 | 67 | if (!empty($relpath)) $path .= '/'.$relpath; |
| 68 | 68 | |
| 69 | 69 | if (true) $value = array(); |
| 70 | 70 | |
| 71 | 71 | // Single file, already existing |
| 72 | - if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
|
| 72 | + if (substr($path, -1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
|
| 73 | 73 | { |
| 74 | 74 | $file = Api\Vfs::stat($path); |
| 75 | 75 | $file['path'] = $path; |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | $value = array($file); |
| 79 | 79 | } |
| 80 | 80 | // Single file, missing extension in path |
| 81 | - else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath,-4,1) !== '.') |
|
| 81 | + else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath, -4, 1) !== '.') |
|
| 82 | 82 | { |
| 83 | - $find = Api\Vfs::find(substr($path,0, - strlen($relpath)), array( |
|
| 83 | + $find = Api\Vfs::find(substr($path, 0, - strlen($relpath)), array( |
|
| 84 | 84 | 'type' => 'f', |
| 85 | 85 | 'maxdepth' => 1, |
| 86 | - 'name' => $relpath . '*' |
|
| 86 | + 'name' => $relpath.'*' |
|
| 87 | 87 | )); |
| 88 | - foreach($find as $file) |
|
| 88 | + foreach ($find as $file) |
|
| 89 | 89 | { |
| 90 | 90 | $file_info = Api\Vfs::stat($file); |
| 91 | 91 | $file_info['path'] = $file; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | else if (substr($path, -1) == '/' && Api\Vfs::is_dir($path)) |
| 98 | 98 | { |
| 99 | 99 | $scan = Api\Vfs::scandir($path); |
| 100 | - foreach($scan as $file) |
|
| 100 | + foreach ($scan as $file) |
|
| 101 | 101 | { |
| 102 | 102 | $file_info = Api\Vfs::stat("$path$file"); |
| 103 | 103 | $file_info['path'] = "$path$file"; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | public static function ajax_upload() |
| 114 | 114 | { |
| 115 | 115 | parent::ajax_upload(); |
| 116 | - foreach($_FILES as $file) |
|
| 116 | + foreach ($_FILES as $file) |
|
| 117 | 117 | { |
| 118 | 118 | self::store_file($_REQUEST['path'] ? $_REQUEST['path'] : $_REQUEST['widget_id'], $file); |
| 119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $request_id = urldecode($_REQUEST['request_id']); |
| 128 | 128 | $widget_id = $_REQUEST['widget_id']; |
| 129 | - if(!self::$request = Etemplate\Request::read($request_id)) |
|
| 129 | + if (!self::$request = Etemplate\Request::read($request_id)) |
|
| 130 | 130 | { |
| 131 | 131 | $error = lang("Could not read session"); |
| 132 | 132 | } |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | 145 | $data = self::$request->content[$widget_id]; |
| 146 | - $path = self::store_file($path = (!is_array($data) && $data[0] == '/' ? $data : |
|
| 147 | - self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $_FILES['upload']); |
|
| 146 | + $path = self::store_file($path = (!is_array($data) && $data[0] == '/' ? $data : self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $_FILES['upload']); |
|
| 148 | 147 | |
| 149 | 148 | // store temp. vfs-path like links to be able to move it to correct location after entry is stored |
| 150 | 149 | if (!$data['to_id'] || is_array($data['to_id'])) |
@@ -187,10 +186,10 @@ discard block |
||
| 187 | 186 | static function fix_html_dragins($app, $id, array $links, &$html) |
| 188 | 187 | { |
| 189 | 188 | $replace = $remove_dir = array(); |
| 190 | - foreach($links as $link) |
|
| 189 | + foreach ($links as $link) |
|
| 191 | 190 | { |
| 192 | 191 | $matches = null; |
| 193 | - if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX,'|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches)) |
|
| 192 | + if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX, '|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches)) |
|
| 194 | 193 | { |
| 195 | 194 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
| 196 | 195 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
@@ -202,7 +201,7 @@ discard block |
||
| 202 | 201 | { |
| 203 | 202 | $html = strtr($old = $html, $replace); |
| 204 | 203 | // remove all dirs |
| 205 | - foreach($remove_dir as $dir) |
|
| 204 | + foreach ($remove_dir as $dir) |
|
| 206 | 205 | { |
| 207 | 206 | Api\Vfs::remove($dir); |
| 208 | 207 | } |
@@ -217,7 +216,7 @@ discard block |
||
| 217 | 216 | * @param string $postfix =null default random id |
| 218 | 217 | * @return string vfs path |
| 219 | 218 | */ |
| 220 | - static function get_temp_dir($app, $postfix=null) |
|
| 219 | + static function get_temp_dir($app, $postfix = null) |
|
| 221 | 220 | { |
| 222 | 221 | if (!isset($postfix)) $postfix = md5(time().session_id()); |
| 223 | 222 | |
@@ -237,15 +236,15 @@ discard block |
||
| 237 | 236 | $name = $_REQUEST['widget_id']; |
| 238 | 237 | |
| 239 | 238 | // Find real path |
| 240 | - if($path[0] != '/') |
|
| 239 | + if ($path[0] != '/') |
|
| 241 | 240 | { |
| 242 | 241 | $path = self::get_vfs_path($path); |
| 243 | 242 | } |
| 244 | 243 | $filename = $file['name']; |
| 245 | - if (substr($path,-1) != '/') |
|
| 244 | + if (substr($path, -1) != '/') |
|
| 246 | 245 | { |
| 247 | 246 | // add extension to path |
| 248 | - $parts = explode('.',$filename); |
|
| 247 | + $parts = explode('.', $filename); |
|
| 249 | 248 | if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
| 250 | 249 | { |
| 251 | 250 | $path .= '.'.$extension; |
@@ -257,17 +256,17 @@ discard block |
||
| 257 | 256 | } |
| 258 | 257 | if (!($dir = Api\Vfs::dirname($path))) |
| 259 | 258 | { |
| 260 | - self::set_validation_error($name,lang('Error create parent directory %1!', "dirname('$path') === false")); |
|
| 259 | + self::set_validation_error($name, lang('Error create parent directory %1!', "dirname('$path') === false")); |
|
| 261 | 260 | return false; |
| 262 | 261 | } |
| 263 | - if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE)) |
|
| 262 | + if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE)) |
|
| 264 | 263 | { |
| 265 | - self::set_validation_error($name,lang('Error create parent directory %1!',Api\Vfs::decodePath($dir))); |
|
| 264 | + self::set_validation_error($name, lang('Error create parent directory %1!', Api\Vfs::decodePath($dir))); |
|
| 266 | 265 | return false; |
| 267 | 266 | } |
| 268 | - if (!copy($file['tmp_name'],Api\Vfs::PREFIX.$path)) |
|
| 267 | + if (!copy($file['tmp_name'], Api\Vfs::PREFIX.$path)) |
|
| 269 | 268 | { |
| 270 | - self::set_validation_error($name,lang('Error copying uploaded file to vfs!')); |
|
| 269 | + self::set_validation_error($name, lang('Error copying uploaded file to vfs!')); |
|
| 271 | 270 | return false; |
| 272 | 271 | } |
| 273 | 272 | |
@@ -286,7 +285,7 @@ discard block |
||
| 286 | 285 | * @param array $content |
| 287 | 286 | * @param array &$validated=array() validated content |
| 288 | 287 | */ |
| 289 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
| 288 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
| 290 | 289 | { |
| 291 | 290 | // do not validate, as it would overwrite preserved values with null! |
| 292 | 291 | if (in_array($this->type, array('vfs-size', 'vfs-uid', 'vfs-gid', 'vfs', 'vfs-mime'))) |
@@ -295,12 +294,12 @@ discard block |
||
| 295 | 294 | } |
| 296 | 295 | $form_name = self::form_name($cname, $this->id, $expand); |
| 297 | 296 | $value = $value_in = self::get_array($content, $form_name); |
| 298 | - $valid =& self::get_array($validated, $form_name, true); |
|
| 297 | + $valid = & self::get_array($validated, $form_name, true); |
|
| 299 | 298 | |
| 300 | - switch($this->type) |
|
| 299 | + switch ($this->type) |
|
| 301 | 300 | { |
| 302 | 301 | case 'vfs-upload': |
| 303 | - if(!is_array($value)) $value = array(); |
|
| 302 | + if (!is_array($value)) $value = array(); |
|
| 304 | 303 | /* Check & skip files that made it asyncronously |
| 305 | 304 | list($app,$id,$relpath) = explode(':',$this->id,3); |
| 306 | 305 | //... |
@@ -319,16 +318,16 @@ discard block |
||
| 319 | 318 | */ |
| 320 | 319 | public static function get_vfs_path($path) |
| 321 | 320 | { |
| 322 | - list($app,$id,$relpath) = explode(':',$path,3); |
|
| 321 | + list($app, $id, $relpath) = explode(':', $path, 3); |
|
| 323 | 322 | if (empty($id) || $id == 'undefined') |
| 324 | 323 | { |
| 325 | - static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
| 326 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
| 324 | + static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
|
| 325 | + if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir($app); |
|
| 327 | 326 | $path = $tmppath[$app]; |
| 328 | 327 | } |
| 329 | 328 | else |
| 330 | 329 | { |
| 331 | - $path = Api\Link::vfs_path($app,$id,'',true); |
|
| 330 | + $path = Api\Link::vfs_path($app, $id, '', true); |
|
| 332 | 331 | } |
| 333 | 332 | if (!empty($relpath)) $path .= '/'.$relpath; |
| 334 | 333 | return $path; |
@@ -19,6 +19,9 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Admin extends App |
| 21 | 21 | { |
| 22 | + /** |
|
| 23 | + * @param string $msg |
|
| 24 | + */ |
|
| 22 | 25 | function __construct($msg=null,$code=102) |
| 23 | 26 | { |
| 24 | 27 | if (is_null($msg)) $msg = 'admin'; |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Admin extends App |
| 21 | 21 | { |
| 22 | - function __construct($msg=null,$code=102) |
|
| 22 | + function __construct($msg = null, $code = 102) |
|
| 23 | 23 | { |
| 24 | 24 | if (is_null($msg)) $msg = 'admin'; |
| 25 | 25 | |
| 26 | - parent::__construct($msg,$code); |
|
| 26 | + parent::__construct($msg, $code); |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -21,7 +21,10 @@ |
||
| 21 | 21 | { |
| 22 | 22 | function __construct($msg=null,$code=102) |
| 23 | 23 | { |
| 24 | - if (is_null($msg)) $msg = 'admin'; |
|
| 24 | + if (is_null($msg)) |
|
| 25 | + { |
|
| 26 | + $msg = 'admin'; |
|
| 27 | + } |
|
| 25 | 28 | |
| 26 | 29 | parent::__construct($msg,$code); |
| 27 | 30 | } |
@@ -356,11 +356,6 @@ |
||
| 356 | 356 | /** |
| 357 | 357 | * Add menu items to the topmenu template class to be displayed |
| 358 | 358 | * |
| 359 | - * @param array $app application data |
|
| 360 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
| 361 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
| 362 | - * @access protected |
|
| 363 | - * @return void |
|
| 364 | 359 | */ |
| 365 | 360 | function _add_topmenu_item(array $app_data,$alt_label=null) |
| 366 | 361 | { |
@@ -337,16 +337,16 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | - * called by hooks to add an icon in the topmenu info location |
|
| 341 | - * |
|
| 342 | - * @param string $id unique element id |
|
| 343 | - * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
| 344 | - * @param string $iconlink where the icon links to |
|
| 345 | - * @param booleon $blink set true to make the icon blink |
|
| 346 | - * @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip |
|
| 347 | - * @todo implement in a reasonable way for jdots |
|
| 348 | - * @return void |
|
| 349 | - */ |
|
| 340 | + * called by hooks to add an icon in the topmenu info location |
|
| 341 | + * |
|
| 342 | + * @param string $id unique element id |
|
| 343 | + * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
| 344 | + * @param string $iconlink where the icon links to |
|
| 345 | + * @param booleon $blink set true to make the icon blink |
|
| 346 | + * @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip |
|
| 347 | + * @todo implement in a reasonable way for jdots |
|
| 348 | + * @return void |
|
| 349 | + */ |
|
| 350 | 350 | function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
| 351 | 351 | { |
| 352 | 352 | unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
@@ -354,14 +354,14 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | - * Add menu items to the topmenu template class to be displayed |
|
| 358 | - * |
|
| 359 | - * @param array $app application data |
|
| 360 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
| 361 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
| 362 | - * @access protected |
|
| 363 | - * @return void |
|
| 364 | - */ |
|
| 357 | + * Add menu items to the topmenu template class to be displayed |
|
| 358 | + * |
|
| 359 | + * @param array $app application data |
|
| 360 | + * @param mixed $alt_label string with alternative menu item label default value = null |
|
| 361 | + * @param string $urlextra string with alternate additional code inside <a>-tag |
|
| 362 | + * @access protected |
|
| 363 | + * @return void |
|
| 364 | + */ |
|
| 365 | 365 | function _add_topmenu_item(array $app_data,$alt_label=null) |
| 366 | 366 | { |
| 367 | 367 | switch($app_data['name']) |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param string $template = '' name of the template |
| 59 | 59 | */ |
| 60 | - function __construct($template=self::APP) |
|
| 60 | + function __construct($template = self::APP) |
|
| 61 | 61 | { |
| 62 | - parent::__construct($template); // call the constructor of the extended class |
|
| 62 | + parent::__construct($template); // call the constructor of the extended class |
|
| 63 | 63 | |
| 64 | - $this->template_dir = '/'.$template; // we are packaged as an application |
|
| 64 | + $this->template_dir = '/'.$template; // we are packaged as an application |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -129,16 +129,16 @@ discard block |
||
| 129 | 129 | public static function app_from_url($url) |
| 130 | 130 | { |
| 131 | 131 | $matches = null; |
| 132 | - if (preg_match('/menuaction=([a-z0-9_-]+)\./i',$url,$matches)) |
|
| 132 | + if (preg_match('/menuaction=([a-z0-9_-]+)\./i', $url, $matches)) |
|
| 133 | 133 | { |
| 134 | 134 | return $matches[1]; |
| 135 | 135 | } |
| 136 | 136 | if ($GLOBALS['egw_info']['server']['webserver_url'] && |
| 137 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH))) |
|
| 137 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH))) |
|
| 138 | 138 | { |
| 139 | - list(,$url) = explode($webserver_path, parse_url($url,PHP_URL_PATH),2); |
|
| 139 | + list(,$url) = explode($webserver_path, parse_url($url, PHP_URL_PATH), 2); |
|
| 140 | 140 | } |
| 141 | - if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/',$url,$matches)) |
|
| 141 | + if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/', $url, $matches)) |
|
| 142 | 142 | { |
| 143 | 143 | return $matches[1]; |
| 144 | 144 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $link_app = null if appname or true, some templates generate a special link-handler url |
| 155 | 155 | * @return string The full url after processing |
| 156 | 156 | */ |
| 157 | - static function link($url = '', $extravars = '', $link_app=null) |
|
| 157 | + static function link($url = '', $extravars = '', $link_app = null) |
|
| 158 | 158 | { |
| 159 | 159 | if (is_null($link_app)) $link_app = self::$link_app; |
| 160 | 160 | $link = parent::link($url, $extravars); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | // Link gets handled in JS, so quotes need slashes as well as url-encoded |
| 166 | 166 | // encoded ampersands in get parameters (%26) need to be encoded twise, |
| 167 | 167 | // so they are still encoded when assigned to window.location |
| 168 | - $link_with_slashes = str_replace(array('%27','%26'), array('\%27','%2526'), $link); |
|
| 168 | + $link_with_slashes = str_replace(array('%27', '%26'), array('\%27', '%2526'), $link); |
|
| 169 | 169 | |
| 170 | 170 | //$link = "javascript:window.egw_link_handler?egw_link_handler('$link','$link_app'):parent.egw_link_handler('$link','$link_app');"; |
| 171 | 171 | $link = "javascript:egw_link_handler('$link_with_slashes','$link_app')"; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | protected function _get_csp_frame_src() |
| 184 | 184 | { |
| 185 | 185 | $srcs = array(); |
| 186 | - foreach(Api\Hooks::process('csp-frame-src') as $src) |
|
| 186 | + foreach (Api\Hooks::process('csp-frame-src') as $src) |
|
| 187 | 187 | { |
| 188 | 188 | if ($src) $srcs = array_merge($srcs, $src); |
| 189 | 189 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param array $extra = array() extra attributes passed as data-attribute to egw.js |
| 197 | 197 | * @return string with Api\Html |
| 198 | 198 | */ |
| 199 | - function header(array $extra=array()) |
|
| 199 | + function header(array $extra = array()) |
|
| 200 | 200 | { |
| 201 | 201 | // make sure header is output only once |
| 202 | 202 | if (self::$header_done) return ''; |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $this->tpl->set_file(array('_head' => 'head.tpl')); |
| 223 | 223 | } |
| 224 | - $this->tpl->set_block('_head','head'); |
|
| 225 | - $this->tpl->set_block('_head','framework'); |
|
| 224 | + $this->tpl->set_block('_head', 'head'); |
|
| 225 | + $this->tpl->set_block('_head', 'framework'); |
|
| 226 | 226 | |
| 227 | 227 | // should we draw the framework, or just a header |
| 228 | 228 | $do_framework = isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | { |
| 248 | 248 | self::includeJS('.', 'fw_'.static::APP, static::JS_INCLUDE_APP); |
| 249 | 249 | } |
| 250 | - Api\Cache::unsetSession(__CLASS__,'sidebox_md5'); // sideboxes need to be send again |
|
| 250 | + Api\Cache::unsetSession(__CLASS__, 'sidebox_md5'); // sideboxes need to be send again |
|
| 251 | 251 | |
| 252 | 252 | $extra['navbar-apps'] = $this->get_navbar_apps($_SERVER['REQUEST_URI']); |
| 253 | 253 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | // - if not we need to check if we have an opener (are a popup window) |
| 257 | 257 | // - as popups can open further popups, we need to decend all the way down until we find a framework |
| 258 | 258 | // - only if we cant find a framework in all openers, we redirect to create a new framework |
| 259 | - if(!$do_framework) |
|
| 259 | + if (!$do_framework) |
|
| 260 | 260 | { |
| 261 | 261 | // fetch sidebox from application and set it in extra data, if we are no popup |
| 262 | 262 | if (!$GLOBALS['egw_info']['flags']['nonavbar']) |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | // for remote manual never check/create framework |
| 267 | 267 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
| 268 | 268 | { |
| 269 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
| 269 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script'] = ''; |
|
| 270 | 270 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | $this->tpl->set_var($this->_get_header($extra)); |
| 274 | - $content = $this->tpl->fp('out','head').$content; |
|
| 274 | + $content = $this->tpl->fp('out', 'head').$content; |
|
| 275 | 275 | |
| 276 | 276 | if (!$do_framework) |
| 277 | 277 | { |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | // topmenu |
| 282 | 282 | $vars = $this->_get_navbar($apps = $this->_get_navbar_apps()); |
| 283 | - $this->tpl->set_var($this->topmenu($vars,$apps)); |
|
| 283 | + $this->tpl->set_var($this->topmenu($vars, $apps)); |
|
| 284 | 284 | |
| 285 | 285 | // hook after_navbar (eg. notifications) |
| 286 | - $this->tpl->set_var('hook_after_navbar',$this->_get_after_navbar()); |
|
| 286 | + $this->tpl->set_var('hook_after_navbar', $this->_get_after_navbar()); |
|
| 287 | 287 | |
| 288 | 288 | //Global sidebar width |
| 289 | 289 | $this->tpl->set_var('sidebox_width', self::get_global_sidebar_width()); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // add framework div's |
| 302 | 302 | $this->tpl->set_var($this->_get_footer()); |
| 303 | - $content .= $this->tpl->fp('out','framework'); |
|
| 303 | + $content .= $this->tpl->fp('out', 'framework'); |
|
| 304 | 304 | $content .= self::footer(false); |
| 305 | 305 | |
| 306 | 306 | echo $content; |
@@ -319,14 +319,14 @@ discard block |
||
| 319 | 319 | * @param array $apps |
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | - function topmenu(array $vars,array $apps) |
|
| 322 | + function topmenu(array $vars, array $apps) |
|
| 323 | 323 | { |
| 324 | 324 | $this->topmenu_items = $this->topmenu_info_items = array(); |
| 325 | 325 | |
| 326 | - parent::topmenu($vars,$apps); |
|
| 327 | - $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>",$this->topmenu_items)."</li>\n</ul>"; |
|
| 326 | + parent::topmenu($vars, $apps); |
|
| 327 | + $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>", $this->topmenu_items)."</li>\n</ul>"; |
|
| 328 | 328 | $vars['topmenu_info_items'] = ''; |
| 329 | - foreach($this->topmenu_info_items as $id => $item) |
|
| 329 | + foreach ($this->topmenu_info_items as $id => $item) |
|
| 330 | 330 | { |
| 331 | 331 | $vars['topmenu_info_items'] .= '<div class="topmenu_info_item"'. |
| 332 | 332 | (is_numeric($id) ? '' : ' id="topmenu_info_'.$id.'"').'>'.$item."</div>\n"; |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | * @todo implement in a reasonable way for jdots |
| 348 | 348 | * @return void |
| 349 | 349 | */ |
| 350 | - function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
|
| 350 | + function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null) |
|
| 351 | 351 | { |
| 352 | - unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
|
| 352 | + unset($id, $icon_src, $iconlink, $blink, $tooltip); // not used |
|
| 353 | 353 | // not yet implemented, only used in admin/inc/hook_topmenu_info.inc.php to notify about pending updates |
| 354 | 354 | } |
| 355 | 355 | |
@@ -362,9 +362,9 @@ discard block |
||
| 362 | 362 | * @access protected |
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | - function _add_topmenu_item(array $app_data,$alt_label=null) |
|
| 365 | + function _add_topmenu_item(array $app_data, $alt_label = null) |
|
| 366 | 366 | { |
| 367 | - switch($app_data['name']) |
|
| 367 | + switch ($app_data['name']) |
|
| 368 | 368 | { |
| 369 | 369 | case 'logout': |
| 370 | 370 | if (Api\Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile') |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | else |
| 375 | 375 | { |
| 376 | - return; // no need for logout in topmenu on jdots |
|
| 376 | + return; // no need for logout in topmenu on jdots |
|
| 377 | 377 | } |
| 378 | 378 | break; |
| 379 | 379 | |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | break; |
| 383 | 383 | |
| 384 | 384 | default: |
| 385 | - if (strpos($app_data['url'],'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
| 385 | + if (strpos($app_data['url'], 'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
| 386 | 386 | { |
| 387 | 387 | $app_data['url'] = "javascript:egw_link_handler('".$app_data['url']."','". |
| 388 | 388 | (isset($GLOBALS['egw_info']['user']['apps'][$app_data['name']]) ? |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | $id = $app_data['id'] ? $app_data['id'] : ($app_data['name'] ? $app_data['name'] : $app_data['title']); |
| 393 | - $title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']); |
|
| 394 | - $this->topmenu_items[] = '<a id="topmenu_' . $id . '" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
| 393 | + $title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']); |
|
| 394 | + $this->topmenu_items[] = '<a id="topmenu_'.$id.'" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /** |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | * @access protected |
| 403 | 403 | * @return void |
| 404 | 404 | */ |
| 405 | - function _add_topmenu_info_item($content, $id=null) |
|
| 405 | + function _add_topmenu_info_item($content, $id = null) |
|
| 406 | 406 | { |
| 407 | - if(strpos($content,'menuaction=admin.admin_accesslog.sessions') !== false) |
|
| 407 | + if (strpos($content, 'menuaction=admin.admin_accesslog.sessions') !== false) |
|
| 408 | 408 | { |
| 409 | - $content = preg_replace('/href="([^"]+)"/',"href=\"javascript:egw_link_handler('\\1','admin')\"",$content); |
|
| 409 | + $content = preg_replace('/href="([^"]+)"/', "href=\"javascript:egw_link_handler('\\1','admin')\"", $content); |
|
| 410 | 410 | } |
| 411 | 411 | if ($id) |
| 412 | 412 | { |
@@ -425,10 +425,10 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | static function ajax_tz_selection($tz) |
| 427 | 427 | { |
| 428 | - Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid |
|
| 428 | + Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid |
|
| 429 | 429 | |
| 430 | 430 | $GLOBALS['egw']->preferences->read_repository(); |
| 431 | - $GLOBALS['egw']->preferences->add('common','tz',$tz); |
|
| 431 | + $GLOBALS['egw']->preferences->add('common', 'tz', $tz); |
|
| 432 | 432 | $GLOBALS['egw']->preferences->save_repository(); |
| 433 | 433 | } |
| 434 | 434 | |
@@ -480,13 +480,13 @@ discard block |
||
| 480 | 480 | // only send admin sidebox, for admin index url (when clicked on admin), |
| 481 | 481 | // not for other admin pages, called eg. from sidebox menu of other apps |
| 482 | 482 | // --> that way we always stay in the app, and NOT open admin sidebox for an app tab!!! |
| 483 | - if ($app == 'admin' && substr($_SERVER['PHP_SELF'],-16) != '/admin/index.php' && |
|
| 483 | + if ($app == 'admin' && substr($_SERVER['PHP_SELF'], -16) != '/admin/index.php' && |
|
| 484 | 484 | $_GET['menuaction'] != 'admin.admin_ui.index') |
| 485 | 485 | { |
| 486 | 486 | //error_log(__METHOD__."() app=$app, menuaction=$_GET[menuaction], PHP_SELF=$_SERVER[PHP_SELF] --> sidebox request ignored"); |
| 487 | 487 | return; |
| 488 | 488 | } |
| 489 | - $md5_session =& Api\Cache::getSession(__CLASS__,'sidebox_md5'); |
|
| 489 | + $md5_session = & Api\Cache::getSession(__CLASS__, 'sidebox_md5'); |
|
| 490 | 490 | |
| 491 | 491 | //Set the sidebox content |
| 492 | 492 | $sidebox = $this->get_sidebox($app); |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | if ($md5_session[$app] !== $md5) |
| 496 | 496 | { |
| 497 | 497 | //error_log(__METHOD__."() header changed md5_session[$app]!=='$md5' --> setting it on self::\$extra[setSidebox]"); |
| 498 | - $md5_session[$app] = $md5; // update md5 in session |
|
| 498 | + $md5_session[$app] = $md5; // update md5 in session |
|
| 499 | 499 | self::$extra['setSidebox'] = array($app, $sidebox, $md5); |
| 500 | 500 | } |
| 501 | 501 | //else error_log(__METHOD__."() md5_session[$app]==='$md5' --> nothing to do"); |
@@ -509,9 +509,9 @@ discard block |
||
| 509 | 509 | * @return boolean $consider_navbar_not_yet_called_as_true=true ignored by jdots, we only care for cd=yes GET param |
| 510 | 510 | * @return boolean |
| 511 | 511 | */ |
| 512 | - public function isTop($consider_navbar_not_yet_called_as_true=true) |
|
| 512 | + public function isTop($consider_navbar_not_yet_called_as_true = true) |
|
| 513 | 513 | { |
| 514 | - unset($consider_navbar_not_yet_called_as_true); // not used |
|
| 514 | + unset($consider_navbar_not_yet_called_as_true); // not used |
|
| 515 | 515 | return isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
| 516 | 516 | } |
| 517 | 517 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | * @param array $file |
| 538 | 538 | * @param string $type = null 'admin', 'preferences', 'favorites', ... |
| 539 | 539 | */ |
| 540 | - public function sidebox($appname,$menu_title,$file,$type=null) |
|
| 540 | + public function sidebox($appname, $menu_title, $file, $type = null) |
|
| 541 | 541 | { |
| 542 | 542 | if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
| 543 | 543 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
@@ -546,11 +546,11 @@ discard block |
||
| 546 | 546 | // fix app admin menus to use admin.admin_ui.index loader |
| 547 | 547 | if (($type == 'admin' || $menu_title == lang('Admin')) && $appname != 'admin') |
| 548 | 548 | { |
| 549 | - foreach($file as &$link) |
|
| 549 | + foreach ($file as &$link) |
|
| 550 | 550 | { |
| 551 | 551 | preg_match('/ajax=(true|false)/', $link, $ajax); |
| 552 | 552 | $link = preg_replace("/^(javascript:egw_link_handler\(')(.*)menuaction=([^&]+)(.*)(','[^']+'\))$/", |
| 553 | - '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=' . ($ajax[1] ? $ajax[1] : 'true') .'\',\'admin\')', $file_was=$link); |
|
| 553 | + '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax='.($ajax[1] ? $ajax[1] : 'true').'\',\'admin\')', $file_was = $link); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | } |
@@ -587,15 +587,15 @@ discard block |
||
| 587 | 587 | self::$link_app = $appname; |
| 588 | 588 | // allow other apps to hook into sidebox menu of an app, hook-name: sidebox_$appname |
| 589 | 589 | $this->sidebox_menu_opened = true; |
| 590 | - Api\Hooks::process('sidebox_'.$appname,array($appname),true); // true = call independent of app-permissions |
|
| 590 | + Api\Hooks::process('sidebox_'.$appname, array($appname), true); // true = call independent of app-permissions |
|
| 591 | 591 | |
| 592 | 592 | // calling the old hook |
| 593 | 593 | $this->sidebox_menu_opened = true; |
| 594 | - Api\Hooks::single('sidebox_menu',$appname); |
|
| 594 | + Api\Hooks::single('sidebox_menu', $appname); |
|
| 595 | 595 | self::$link_app = null; |
| 596 | 596 | |
| 597 | 597 | // allow other apps to hook into sidebox menu of every app: sidebox_all |
| 598 | - Api\Hooks::process('sidebox_all',array($GLOBALS['egw_info']['flags']['currentapp']),true); |
|
| 598 | + Api\Hooks::process('sidebox_all', array($GLOBALS['egw_info']['flags']['currentapp']), true); |
|
| 599 | 599 | } |
| 600 | 600 | //If there still is no sidebox content, return null here |
| 601 | 601 | if (!isset($this->sideboxes[$appname])) |
@@ -605,17 +605,17 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | $data = array(); |
| 607 | 607 | $sendToBottom = array(); |
| 608 | - foreach($this->sideboxes[$appname] as $menu_name => &$file) |
|
| 608 | + foreach ($this->sideboxes[$appname] as $menu_name => &$file) |
|
| 609 | 609 | { |
| 610 | 610 | $current_menu = array( |
| 611 | - 'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript! |
|
| 611 | + 'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript! |
|
| 612 | 612 | 'title' => $menu_name, |
| 613 | 613 | 'entries' => array(), |
| 614 | 614 | 'opened' => (boolean)$file['menuOpened'], |
| 615 | 615 | ); |
| 616 | - foreach($file as $item_text => $item_link) |
|
| 616 | + foreach ($file as $item_text => $item_link) |
|
| 617 | 617 | { |
| 618 | - if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' ||// flag, not menu entry |
|
| 618 | + if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' || // flag, not menu entry |
|
| 619 | 619 | $item_text === '_NewLine_' || $item_link === '_NewLine_') |
| 620 | 620 | { |
| 621 | 621 | continue; |
@@ -626,14 +626,14 @@ discard block |
||
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $var = array(); |
| 629 | - $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images/bullet.png'; |
|
| 629 | + $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images/bullet.png'; |
|
| 630 | 630 | $var['target'] = ''; |
| 631 | - if(is_array($item_link)) |
|
| 631 | + if (is_array($item_link)) |
|
| 632 | 632 | { |
| 633 | - if(isset($item_link['icon'])) |
|
| 633 | + if (isset($item_link['icon'])) |
|
| 634 | 634 | { |
| 635 | 635 | $app = isset($item_link['app']) ? $item_link['app'] : $appname; |
| 636 | - $var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app,$item_link['icon']) : False; |
|
| 636 | + $var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app, $item_link['icon']) : False; |
|
| 637 | 637 | } |
| 638 | 638 | $var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']); |
| 639 | 639 | $var['item_link'] = $item_link['link']; |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | public static function ajax_tab_changed_state($tablist) |
| 678 | 678 | { |
| 679 | 679 | $tabs = array(); |
| 680 | - foreach($tablist as $data) |
|
| 680 | + foreach ($tablist as $data) |
|
| 681 | 681 | { |
| 682 | 682 | $tabs[] = $data['appName']; |
| 683 | 683 | if ($data['active']) $active = $data['appName']; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | // used eg. in phpFreeChat to leave the chat |
| 687 | 687 | if (($old_tabs = Api\Cache::getSession(__CLASS__, 'open_tabs'))) |
| 688 | 688 | { |
| 689 | - foreach(array_diff(explode(',',$old_tabs),$tabs) as $app) |
|
| 689 | + foreach (array_diff(explode(',', $old_tabs), $tabs) as $app) |
|
| 690 | 690 | { |
| 691 | 691 | //error_log("Tab '$app' closed, old_tabs=$old_tabs"); |
| 692 | 692 | Api\Hooks::single(array( |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | ), $app); |
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | - $open = implode(',',$tabs); |
|
| 698 | + $open = implode(',', $tabs); |
|
| 699 | 699 | |
| 700 | 700 | if ($open != $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'] || |
| 701 | 701 | $active != $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']) |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $i = 0; |
| 766 | 766 | |
| 767 | 767 | //Parse the "$apps" array for valid content (security) |
| 768 | - foreach($apps as $app) |
|
| 768 | + foreach ($apps as $app) |
|
| 769 | 769 | { |
| 770 | 770 | //Check whether the app really exists and add it to the $app_arr var |
| 771 | 771 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
@@ -796,17 +796,17 @@ discard block |
||
| 796 | 796 | */ |
| 797 | 797 | public function navbar_apps() |
| 798 | 798 | { |
| 799 | - $apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser |
|
| 799 | + $apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser |
|
| 800 | 800 | |
| 801 | 801 | //Add its sidebox width to each app |
| 802 | 802 | foreach ($apps as $app => &$data) |
| 803 | 803 | { |
| 804 | 804 | $data['sideboxwidth'] = self::get_sidebar_width($app); |
| 805 | 805 | // overwrite icon with svg, if supported by browser |
| 806 | - unset($data['icon_hover']); // not used in jdots |
|
| 806 | + unset($data['icon_hover']); // not used in jdots |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - unset($apps['logout']); // never display it |
|
| 809 | + unset($apps['logout']); // never display it |
|
| 810 | 810 | if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
| 811 | 811 | if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
| 812 | 812 | if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | // check if user called a specific url --> open it as active tab |
| 859 | - $last_direct_url =& Api\Cache::getSession(__CLASS__, 'last_direct_url'); |
|
| 859 | + $last_direct_url = & Api\Cache::getSession(__CLASS__, 'last_direct_url'); |
|
| 860 | 860 | if ($last_direct_url) |
| 861 | 861 | { |
| 862 | 862 | $url = $last_direct_url; |
@@ -881,11 +881,11 @@ discard block |
||
| 881 | 881 | if ($active_tab && array_key_exists($active_tab, $apps)) |
| 882 | 882 | { |
| 883 | 883 | // Do not remove cd=yes if it's an ajax=true app |
| 884 | - if (strpos( $apps[$active_tab]['url'],'ajax=true') !== False) |
|
| 884 | + if (strpos($apps[$active_tab]['url'], 'ajax=true') !== False) |
|
| 885 | 885 | { |
| 886 | - $url = preg_replace('/[&?]cd=yes/','',$url); |
|
| 886 | + $url = preg_replace('/[&?]cd=yes/', '', $url); |
|
| 887 | 887 | } |
| 888 | - if($last_direct_url) |
|
| 888 | + if ($last_direct_url) |
|
| 889 | 889 | { |
| 890 | 890 | $apps[$active_tab]['openOnce'] = $url; |
| 891 | 891 | } |
@@ -897,8 +897,8 @@ discard block |
||
| 897 | 897 | { |
| 898 | 898 | $open_tabs = $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs']; |
| 899 | 899 | } |
| 900 | - $open_tabs = $open_tabs ? explode(',',$open_tabs) : array(); |
|
| 901 | - if ($active_tab && !in_array($active_tab,$open_tabs)) |
|
| 900 | + $open_tabs = $open_tabs ? explode(',', $open_tabs) : array(); |
|
| 901 | + if ($active_tab && !in_array($active_tab, $open_tabs)) |
|
| 902 | 902 | { |
| 903 | 903 | $open_tabs[] = $active_tab; |
| 904 | 904 | $store_prefs = true; |
@@ -906,14 +906,14 @@ discard block |
||
| 906 | 906 | if ($store_prefs) |
| 907 | 907 | { |
| 908 | 908 | $GLOBALS['egw']->preferences->read_repository(); |
| 909 | - $GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',',$open_tabs)); |
|
| 909 | + $GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',', $open_tabs)); |
|
| 910 | 910 | $GLOBALS['egw']->preferences->add('common', 'active_tab', $active_tab); |
| 911 | 911 | $GLOBALS['egw']->preferences->save_repository(true); |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | //error_log(__METHOD__."('$url') url_tab='$url_tab', active_tab=$active_tab, open_tabs=".array2string($open_tabs)); |
| 915 | 915 | // Restore Tabs |
| 916 | - foreach($open_tabs as $n => $app) |
|
| 916 | + foreach ($open_tabs as $n => $app) |
|
| 917 | 917 | { |
| 918 | 918 | if (isset($apps[$app])) // user might no longer have app rights |
| 919 | 919 | { |
@@ -940,10 +940,10 @@ discard block |
||
| 940 | 940 | * @param boolean $no_framework = true |
| 941 | 941 | * @return string |
| 942 | 942 | */ |
| 943 | - function footer($no_framework=true) |
|
| 943 | + function footer($no_framework = true) |
|
| 944 | 944 | { |
| 945 | 945 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
| 946 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
| 946 | + if (self::$footer_done) return; // prevent (multiple) footers |
|
| 947 | 947 | self::$footer_done = true; |
| 948 | 948 | |
| 949 | 949 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -955,7 +955,7 @@ discard block |
||
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | return $footer. |
| 958 | - $GLOBALS['egw_info']['flags']['need_footer']."\n". // eg. javascript, which need to be at the end of the page |
|
| 958 | + $GLOBALS['egw_info']['flags']['need_footer']."\n".// eg. javascript, which need to be at the end of the page |
|
| 959 | 959 | "</body>\n</html>\n"; |
| 960 | 960 | } |
| 961 | 961 | |
@@ -993,8 +993,8 @@ discard block |
||
| 993 | 993 | if ($parts['query']) |
| 994 | 994 | { |
| 995 | 995 | $_SERVER['REQUEST_URI'] = '?'.$parts['query']; |
| 996 | - parse_str($parts['query'],$_GET); |
|
| 997 | - $_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST |
|
| 996 | + parse_str($parts['query'], $_GET); |
|
| 997 | + $_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | if (!isset($_GET['menuaction'])) |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | // set session action |
| 1005 | 1005 | $GLOBALS['egw']->session->set_action('Ajax: '.$_GET['menuaction']); |
| 1006 | 1006 | |
| 1007 | - list($app,$class,$method) = explode('.',$_GET['menuaction']); |
|
| 1007 | + list($app, $class, $method) = explode('.', $_GET['menuaction']); |
|
| 1008 | 1008 | |
| 1009 | 1009 | if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
| 1010 | 1010 | { |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | |
| 1017 | 1017 | $GLOBALS[$class] = $obj = CreateObject($app.'.'.$class); |
| 1018 | 1018 | |
| 1019 | - if(!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
| 1019 | + if (!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
| 1020 | 1020 | { |
| 1021 | 1021 | throw new Api\Exception\NoPermission("Bad menuaction {$_GET['menuaction']}, not listed in public_functions!"); |
| 1022 | 1022 | } |
@@ -104,7 +104,9 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | //Width may not be smaller than MIN_SIDEBAR_WIDTH |
| 106 | 106 | if ($width < self::MIN_SIDEBAR_WIDTH) |
| 107 | - $width = self::MIN_SIDEBAR_WIDTH; |
|
| 107 | + { |
|
| 108 | + $width = self::MIN_SIDEBAR_WIDTH; |
|
| 109 | + } |
|
| 108 | 110 | |
| 109 | 111 | return $width; |
| 110 | 112 | } |
@@ -156,7 +158,10 @@ discard block |
||
| 156 | 158 | */ |
| 157 | 159 | static function link($url = '', $extravars = '', $link_app=null) |
| 158 | 160 | { |
| 159 | - if (is_null($link_app)) $link_app = self::$link_app; |
|
| 161 | + if (is_null($link_app)) |
|
| 162 | + { |
|
| 163 | + $link_app = self::$link_app; |
|
| 164 | + } |
|
| 160 | 165 | $link = parent::link($url, $extravars); |
| 161 | 166 | |
| 162 | 167 | // $link_app === true --> detect application, otherwise use given application |
@@ -185,7 +190,10 @@ discard block |
||
| 185 | 190 | $srcs = array(); |
| 186 | 191 | foreach(Api\Hooks::process('csp-frame-src') as $src) |
| 187 | 192 | { |
| 188 | - if ($src) $srcs = array_merge($srcs, $src); |
|
| 193 | + if ($src) |
|
| 194 | + { |
|
| 195 | + $srcs = array_merge($srcs, $src); |
|
| 196 | + } |
|
| 189 | 197 | } |
| 190 | 198 | return $srcs; |
| 191 | 199 | } |
@@ -199,7 +207,10 @@ discard block |
||
| 199 | 207 | function header(array $extra=array()) |
| 200 | 208 | { |
| 201 | 209 | // make sure header is output only once |
| 202 | - if (self::$header_done) return ''; |
|
| 210 | + if (self::$header_done) |
|
| 211 | + { |
|
| 212 | + return ''; |
|
| 213 | + } |
|
| 203 | 214 | self::$header_done = true; |
| 204 | 215 | |
| 205 | 216 | $this->send_headers(); |
@@ -266,7 +277,10 @@ discard block |
||
| 266 | 277 | // for remote manual never check/create framework |
| 267 | 278 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
| 268 | 279 | { |
| 269 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
| 280 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) |
|
| 281 | + { |
|
| 282 | + $GLOBALS['egw_info']['flags']['java_script']=''; |
|
| 283 | + } |
|
| 270 | 284 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
| 271 | 285 | } |
| 272 | 286 | } |
@@ -539,7 +553,10 @@ discard block |
||
| 539 | 553 | */ |
| 540 | 554 | public function sidebox($appname,$menu_title,$file,$type=null) |
| 541 | 555 | { |
| 542 | - if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
| 556 | + if (!isset($file['menuOpened'])) |
|
| 557 | + { |
|
| 558 | + $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
| 559 | + } |
|
| 543 | 560 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
| 544 | 561 | $this->sidebox_menu_opened = false; |
| 545 | 562 | |
@@ -680,7 +697,10 @@ discard block |
||
| 680 | 697 | foreach($tablist as $data) |
| 681 | 698 | { |
| 682 | 699 | $tabs[] = $data['appName']; |
| 683 | - if ($data['active']) $active = $data['appName']; |
|
| 700 | + if ($data['active']) |
|
| 701 | + { |
|
| 702 | + $active = $data['appName']; |
|
| 703 | + } |
|
| 684 | 704 | } |
| 685 | 705 | // send app a notification, that it's tab got closed |
| 686 | 706 | // used eg. in phpFreeChat to leave the chat |
@@ -807,10 +827,22 @@ discard block |
||
| 807 | 827 | } |
| 808 | 828 | |
| 809 | 829 | unset($apps['logout']); // never display it |
| 810 | - if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
|
| 811 | - if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
|
| 812 | - if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
|
| 813 | - if (isset($apps['home'])) $apps['home']['noNavbar'] = true; |
|
| 830 | + if (isset($apps['about'])) |
|
| 831 | + { |
|
| 832 | + $apps['about']['noNavbar'] = true; |
|
| 833 | + } |
|
| 834 | + if (isset($apps['preferences'])) |
|
| 835 | + { |
|
| 836 | + $apps['preferences']['noNavbar'] = true; |
|
| 837 | + } |
|
| 838 | + if (isset($apps['manual'])) |
|
| 839 | + { |
|
| 840 | + $apps['manual']['noNavbar'] = true; |
|
| 841 | + } |
|
| 842 | + if (isset($apps['home'])) |
|
| 843 | + { |
|
| 844 | + $apps['home']['noNavbar'] = true; |
|
| 845 | + } |
|
| 814 | 846 | |
| 815 | 847 | // no need for website icon, if we have sitemgr |
| 816 | 848 | if (isset($apps['sitemgr']) && isset($apps['sitemgr-link'])) |
@@ -872,7 +904,10 @@ discard block |
||
| 872 | 904 | else |
| 873 | 905 | { |
| 874 | 906 | $active_tab = $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']; |
| 875 | - if (!$active_tab) $active_tab = $default_app; |
|
| 907 | + if (!$active_tab) |
|
| 908 | + { |
|
| 909 | + $active_tab = $default_app; |
|
| 910 | + } |
|
| 876 | 911 | } |
| 877 | 912 | |
| 878 | 913 | //self::app_from_url might return an application the user has no rights |
@@ -915,9 +950,12 @@ discard block |
||
| 915 | 950 | // Restore Tabs |
| 916 | 951 | foreach($open_tabs as $n => $app) |
| 917 | 952 | { |
| 918 | - if (isset($apps[$app])) // user might no longer have app rights |
|
| 953 | + if (isset($apps[$app])) |
|
| 954 | + { |
|
| 955 | + // user might no longer have app rights |
|
| 919 | 956 | { |
| 920 | 957 | $apps[$app]['opened'] = $n; |
| 958 | + } |
|
| 921 | 959 | if ($app == $active_tab) |
| 922 | 960 | { |
| 923 | 961 | $apps[$app]['active'] = true; |
@@ -943,7 +981,11 @@ discard block |
||
| 943 | 981 | function footer($no_framework=true) |
| 944 | 982 | { |
| 945 | 983 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
| 946 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
| 984 | + if (self::$footer_done) |
|
| 985 | + { |
|
| 986 | + return; |
|
| 987 | + } |
|
| 988 | + // prevent (multiple) footers |
|
| 947 | 989 | self::$footer_done = true; |
| 948 | 990 | |
| 949 | 991 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -145,7 +145,7 @@ |
||
| 145 | 145 | * Parse beginning of given CSS file for /*@import url("...") statements |
| 146 | 146 | * |
| 147 | 147 | * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css |
| 148 | - * @return array parsed pathes (EGroupware relative) including $path itself |
|
| 148 | + * @return string[] parsed pathes (EGroupware relative) including $path itself |
|
| 149 | 149 | */ |
| 150 | 150 | protected static function resolve_css_includes($path, &$pathes=array()) |
| 151 | 151 | { |
@@ -107,14 +107,20 @@ |
||
| 107 | 107 | $max_modified = 0; |
| 108 | 108 | //no more dynamic minifying: $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True'; |
| 109 | 109 | $base_path = $GLOBALS['egw_info']['server']['webserver_url']; |
| 110 | - if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); |
|
| 110 | + if ($base_path[0] != '/') |
|
| 111 | + { |
|
| 112 | + $base_path = parse_url($base_path, PHP_URL_PATH); |
|
| 113 | + } |
|
| 111 | 114 | $css_files = ''; |
| 112 | 115 | foreach(self::$files as $path) |
| 113 | 116 | { |
| 114 | 117 | foreach(self::resolve_css_includes($path) as $path) |
| 115 | 118 | { |
| 116 | 119 | list($file,$query) = explode('?',$path,2); |
| 117 | - if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod; |
|
| 120 | + if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) |
|
| 121 | + { |
|
| 122 | + $max_modified = $mod; |
|
| 123 | + } |
|
| 118 | 124 | |
| 119 | 125 | // do NOT include app.css or categories.php, as it changes from app to app |
| 120 | 126 | //no more dynamic minifying: if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php') |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param boolean $clear_includes =false true: clear all previous includes |
| 35 | 35 | * @return boolean false: css file not found, true: file found |
| 36 | 36 | */ |
| 37 | - public static function add($app, $name=null, $append=true, $clear_includes=false) |
|
| 37 | + public static function add($app, $name = null, $append = true, $clear_includes = false) |
|
| 38 | 38 | { |
| 39 | 39 | if ($clear_includes) |
| 40 | 40 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | if (!is_null($name)) |
| 45 | 45 | { |
| 46 | - foreach($GLOBALS['egw']->framework->template_dirs as $dir) |
|
| 46 | + foreach ($GLOBALS['egw']->framework->template_dirs as $dir) |
|
| 47 | 47 | { |
| 48 | 48 | if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/templates/'.$dir.'/'.$name.'.css'))) |
| 49 | 49 | { |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $path = $app; |
| 57 | 57 | } |
| 58 | - if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH))) |
|
| 58 | + if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH))) |
|
| 59 | 59 | { |
| 60 | 60 | //error_log(__METHOD__."($app,$name) $path NOT found!"); |
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | - if (!in_array($path,self::$files)) |
|
| 63 | + if (!in_array($path, self::$files)) |
|
| 64 | 64 | { |
| 65 | 65 | if ($append) |
| 66 | 66 | { |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public static function get($resolve=false) |
|
| 82 | + public static function get($resolve = false) |
|
| 83 | 83 | { |
| 84 | 84 | if (!$resolve) |
| 85 | 85 | { |
| 86 | 86 | return self::$files; |
| 87 | 87 | } |
| 88 | 88 | $files = array(); |
| 89 | - foreach(self::$files as $path) |
|
| 89 | + foreach (self::$files as $path) |
|
| 90 | 90 | { |
| 91 | - foreach(self::resolve_css_includes($path) as $path) |
|
| 91 | + foreach (self::resolve_css_includes($path) as $path) |
|
| 92 | 92 | { |
| 93 | 93 | $files[] = $path; |
| 94 | 94 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | $base_path = $GLOBALS['egw_info']['server']['webserver_url']; |
| 110 | 110 | if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); |
| 111 | 111 | $css_files = ''; |
| 112 | - foreach(self::$files as $path) |
|
| 112 | + foreach (self::$files as $path) |
|
| 113 | 113 | { |
| 114 | - foreach(self::resolve_css_includes($path) as $path) |
|
| 114 | + foreach (self::resolve_css_includes($path) as $path) |
|
| 115 | 115 | { |
| 116 | - list($file,$query) = explode('?',$path,2); |
|
| 116 | + list($file, $query) = explode('?', $path, 2); |
|
| 117 | 117 | if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod; |
| 118 | 118 | |
| 119 | 119 | // do NOT include app.css or categories.php, as it changes from app to app |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css |
| 148 | 148 | * @return array parsed pathes (EGroupware relative) including $path itself |
| 149 | 149 | */ |
| 150 | - protected static function resolve_css_includes($path, &$pathes=array()) |
|
| 150 | + protected static function resolve_css_includes($path, &$pathes = array()) |
|
| 151 | 151 | { |
| 152 | 152 | $matches = null; |
| 153 | 153 | |
| 154 | - list($file) = explode('?',$path,2); |
|
| 155 | - if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
| 154 | + list($file) = explode('?', $path, 2); |
|
| 155 | + if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
| 156 | 156 | stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches)) |
| 157 | 157 | { |
| 158 | - foreach($matches[1] as $import_path) |
|
| 158 | + foreach ($matches[1] as $import_path) |
|
| 159 | 159 | { |
| 160 | 160 | if ($import_path[0] != '/') |
| 161 | 161 | { |
| 162 | 162 | $dir = dirname($path); |
| 163 | - while(substr($import_path,0,3) == '../') |
|
| 163 | + while (substr($import_path, 0, 3) == '../') |
|
| 164 | 164 | { |
| 165 | 165 | $dir = dirname($dir); |
| 166 | 166 | $import_path = substr($import_path, 3); |
@@ -187,7 +187,7 @@ |
||
| 187 | 187 | * @param string $action "add" or "delete" |
| 188 | 188 | * @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users |
| 189 | 189 | * @param array $filters key => value pairs for the filter |
| 190 | - * @return boolean Success |
|
| 190 | + * @return boolean|null Success |
|
| 191 | 191 | */ |
| 192 | 192 | public static function set_favorite($app, $_name, $action, $group, $filters = array()) |
| 193 | 193 | { |
@@ -161,7 +161,11 @@ |
||
| 161 | 161 | { |
| 162 | 162 | if(strpos($pref_name, $pref_prefix) === 0) |
| 163 | 163 | { |
| 164 | - if(!is_array($pref)) continue; // old favorite |
|
| 164 | + if(!is_array($pref)) |
|
| 165 | + { |
|
| 166 | + continue; |
|
| 167 | + } |
|
| 168 | + // old favorite |
|
| 165 | 169 | |
| 166 | 170 | $favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref; |
| 167 | 171 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return array with a single sidebox menu item (array) containing html for favorites |
| 44 | 44 | */ |
| 45 | - public static function list_favorites($app, $default=null) |
|
| 45 | + public static function list_favorites($app, $default = null) |
|
| 46 | 46 | { |
| 47 | 47 | if (!$app) |
| 48 | 48 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $target = 'favorite_sidebox_'.$app; |
| 59 | 59 | |
| 60 | 60 | /* @var $filters array an array of favorites*/ |
| 61 | - $filters = self::get_favorites($app); |
|
| 61 | + $filters = self::get_favorites($app); |
|
| 62 | 62 | $is_admin = $GLOBALS['egw_info']['user']['apps']['admin']; |
| 63 | 63 | $html = "<span id='$target' class='ui-helper-clearfix sidebox-favorites'><ul class='ui-menu ui-widget-content ui-corner-all favorites' role='listbox'>\n"; |
| 64 | 64 | |
@@ -69,25 +69,24 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Get link for if there is no nextmatch - this is the fallback |
| 72 | - $registry = Api\Link::get_registry($app,'list'); |
|
| 72 | + $registry = Api\Link::get_registry($app, 'list'); |
|
| 73 | 73 | if (!$registry) |
| 74 | 74 | { |
| 75 | 75 | $registry = Api\Link::get_registry($app, 'index'); |
| 76 | 76 | } |
| 77 | - foreach($filters as $name => $filter) |
|
| 77 | + foreach ($filters as $name => $filter) |
|
| 78 | 78 | { |
| 79 | 79 | //filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database |
| 80 | 80 | if (!$filter) |
| 81 | 81 | { |
| 82 | - error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array. Skipping, more investigation needed. filter = '. array2string($filters[$name])); |
|
| 82 | + error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array. Skipping, more investigation needed. filter = '.array2string($filters[$name])); |
|
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | $li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n"; |
| 86 | 86 | $li .= '<a href="#" class="ui-corner-all" tabindex="-1">'; |
| 87 | - $li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>". |
|
| 87 | + $li .= "<div class='".((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar')."'></div>". |
|
| 88 | 88 | $filter['name']; |
| 89 | - $li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : |
|
| 90 | - "<div class='ui-icon ui-icon-trash' title='" . lang('Delete') . "'></div>"); |
|
| 89 | + $li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : "<div class='ui-icon ui-icon-trash' title='".lang('Delete')."'></div>"); |
|
| 91 | 90 | $li .= "</a></li>\n"; |
| 92 | 91 | //error_log(__METHOD__."() $name, filter=".array2string($filter)." --> ".$li); |
| 93 | 92 | $html .= $li; |
@@ -95,7 +94,7 @@ discard block |
||
| 95 | 94 | |
| 96 | 95 | // If were're here, the app supports favorites, so add a 'Add' link too |
| 97 | 96 | $html .= "<li data-id='add' class='ui-menu-item' role='menuitem'><a href='javascript:app.$app.add_favorite()' class='ui-corner-all'>"; |
| 98 | - $html .= Api\Html::image($app, 'new') . lang('Add current'). '</a></li>'; |
|
| 97 | + $html .= Api\Html::image($app, 'new').lang('Add current').'</a></li>'; |
|
| 99 | 98 | |
| 100 | 99 | $html .= '</ul></span>'; |
| 101 | 100 | |
@@ -117,7 +116,7 @@ discard block |
||
| 117 | 116 | * @return (array|boolean) An array of sorted favorites or False if there's no preferenced sorted list |
| 118 | 117 | * |
| 119 | 118 | */ |
| 120 | - public static function get_fav_sort_pref ($app) |
|
| 119 | + public static function get_fav_sort_pref($app) |
|
| 121 | 120 | { |
| 122 | 121 | $fav_sorted_list = array(); |
| 123 | 122 | |
@@ -157,13 +156,13 @@ discard block |
||
| 157 | 156 | $fav_sort_pref = self::get_fav_sort_pref($app); |
| 158 | 157 | |
| 159 | 158 | // Look through all preferences & pull out favorites |
| 160 | - foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref) |
|
| 159 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref) |
|
| 161 | 160 | { |
| 162 | - if(strpos($pref_name, $pref_prefix) === 0) |
|
| 161 | + if (strpos($pref_name, $pref_prefix) === 0) |
|
| 163 | 162 | { |
| 164 | - if(!is_array($pref)) continue; // old favorite |
|
| 163 | + if (!is_array($pref)) continue; // old favorite |
|
| 165 | 164 | |
| 166 | - $favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref; |
|
| 165 | + $favorites[(string)substr($pref_name, strlen($pref_prefix))] = $pref; |
|
| 167 | 166 | } |
| 168 | 167 | } |
| 169 | 168 | if (is_array($fav_sort_pref)) |
@@ -172,7 +171,7 @@ discard block |
||
| 172 | 171 | { |
| 173 | 172 | $sorted_list[$key] = $favorites[$key]; |
| 174 | 173 | } |
| 175 | - $favorites = array_merge($sorted_list,$favorites); |
|
| 174 | + $favorites = array_merge($sorted_list, $favorites); |
|
| 176 | 175 | } |
| 177 | 176 | return $favorites; |
| 178 | 177 | } |
@@ -204,7 +203,7 @@ discard block |
||
| 204 | 203 | } |
| 205 | 204 | else |
| 206 | 205 | { |
| 207 | - foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid) |
|
| 206 | + foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid) |
|
| 208 | 207 | { |
| 209 | 208 | $prefs = new Api\Preferences($gid); |
| 210 | 209 | $prefs->read_repository(); |
@@ -216,7 +215,7 @@ discard block |
||
| 216 | 215 | } |
| 217 | 216 | } |
| 218 | 217 | } |
| 219 | - if($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all') |
|
| 218 | + if ($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all') |
|
| 220 | 219 | { |
| 221 | 220 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
| 222 | 221 | } |
@@ -227,7 +226,7 @@ discard block |
||
| 227 | 226 | $prefs->read_repository(); |
| 228 | 227 | $type = $group === "all" ? "default" : "user"; |
| 229 | 228 | //error_log(__METHOD__."('$app', '$name', '$action', ".array2string($group).", ...) pref_name=$pref_name, type=$type"); |
| 230 | - if($action == "add") |
|
| 229 | + if ($action == "add") |
|
| 231 | 230 | { |
| 232 | 231 | $filters = array( |
| 233 | 232 | // This is the name as user entered it, minus tags |
@@ -235,9 +234,9 @@ discard block |
||
| 235 | 234 | 'group' => $group ? $group : false, |
| 236 | 235 | 'state' => $filters |
| 237 | 236 | ); |
| 238 | - $pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u','_',$name); |
|
| 239 | - $result = $prefs->add($app,$pref_name,$filters,$type); |
|
| 240 | - $pref = $prefs->save_repository(false,$type); |
|
| 237 | + $pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u', '_', $name); |
|
| 238 | + $result = $prefs->add($app, $pref_name, $filters, $type); |
|
| 239 | + $pref = $prefs->save_repository(false, $type); |
|
| 241 | 240 | |
| 242 | 241 | // Update preferences client side, or it could disappear |
| 243 | 242 | Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app); |
@@ -247,8 +246,8 @@ discard block |
||
| 247 | 246 | } |
| 248 | 247 | else if ($action == "delete") |
| 249 | 248 | { |
| 250 | - $result = $prefs->delete($app,$pref_name, $type); |
|
| 251 | - $pref = $prefs->save_repository(false,$type); |
|
| 249 | + $result = $prefs->delete($app, $pref_name, $type); |
|
| 250 | + $pref = $prefs->save_repository(false, $type); |
|
| 252 | 251 | |
| 253 | 252 | // Update preferences client side, or it could come back |
| 254 | 253 | Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app); |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | /** |
| 39 | 39 | * Get versions of available updates |
| 40 | 40 | * |
| 41 | - * @return array verions for keys "current" and "security" |
|
| 41 | + * @return string verions for keys "current" and "security" |
|
| 42 | 42 | */ |
| 43 | 43 | public static function available() |
| 44 | 44 | { |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | list($current, $security) = explode("\n", $remote); |
| 52 | 52 | if (empty($security)) $security = $current; |
| 53 | 53 | $versions = array( |
| 54 | - 'current' => $current, // last maintenance update |
|
| 55 | - 'security' => $security, // last security update |
|
| 54 | + 'current' => $current, // last maintenance update |
|
| 55 | + 'security' => $security, // last security update |
|
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | return $versions; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | protected static function update_older($version, $days) |
| 115 | 115 | { |
| 116 | - list(,,$date) = explode('.', $version); |
|
| 116 | + list(,, $date) = explode('.', $version); |
|
| 117 | 117 | if ($date < 20140000) return false; |
| 118 | 118 | $version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4)); |
| 119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string &$changelog on return path to changelog |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - public static function api_version(&$changelog=null) |
|
| 129 | + public static function api_version(&$changelog = null) |
|
| 130 | 130 | { |
| 131 | 131 | $changelog = EGW_SERVER_ROOT.'/doc/rpm-build/debian.changes'; |
| 132 | 132 | |
@@ -49,7 +49,10 @@ discard block |
||
| 49 | 49 | if (($remote = file_get_contents(self::CURRENT_VERSION_URL, false, Api\Framework::proxy_context()))) |
| 50 | 50 | { |
| 51 | 51 | list($current, $security) = explode("\n", $remote); |
| 52 | - if (empty($security)) $security = $current; |
|
| 52 | + if (empty($security)) |
|
| 53 | + { |
|
| 54 | + $security = $current; |
|
| 55 | + } |
|
| 53 | 56 | $versions = array( |
| 54 | 57 | 'current' => $current, // last maintenance update |
| 55 | 58 | 'security' => $security, // last security update |
@@ -114,7 +117,10 @@ discard block |
||
| 114 | 117 | protected static function update_older($version, $days) |
| 115 | 118 | { |
| 116 | 119 | list(,,$date) = explode('.', $version); |
| 117 | - if ($date < 20140000) return false; |
|
| 120 | + if ($date < 20140000) |
|
| 121 | + { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 118 | 124 | $version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4)); |
| 119 | 125 | |
| 120 | 126 | return (time() - $version_timestamp) / 86400 > $days; |
@@ -234,7 +234,7 @@ |
||
| 234 | 234 | * @param string $realm |
| 235 | 235 | * @param string $username |
| 236 | 236 | * @param string &$password=null password to use or if null, on return stored password |
| 237 | - * @return string|boolean false if $password not given and can NOT be read |
|
| 237 | + * @return false|string false if $password not given and can NOT be read |
|
| 238 | 238 | */ |
| 239 | 239 | static private function get_digest_A1($realm,$username,&$password=null) |
| 240 | 240 | { |
@@ -255,20 +255,20 @@ |
||
| 255 | 255 | */ |
| 256 | 256 | static public function parse_digest($txt) |
| 257 | 257 | { |
| 258 | - // protect against missing data |
|
| 259 | - $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
| 260 | - $data = array(); |
|
| 261 | - $keys = implode('|', array_keys($needed_parts)); |
|
| 258 | + // protect against missing data |
|
| 259 | + $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
| 260 | + $data = array(); |
|
| 261 | + $keys = implode('|', array_keys($needed_parts)); |
|
| 262 | 262 | |
| 263 | 263 | $matches = null; |
| 264 | - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 264 | + preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 265 | 265 | |
| 266 | - foreach ($matches as $m) |
|
| 267 | - { |
|
| 268 | - $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
| 269 | - unset($needed_parts[$m[1]]); |
|
| 270 | - } |
|
| 271 | - //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
| 272 | - return $needed_parts ? false : $data; |
|
| 266 | + foreach ($matches as $m) |
|
| 267 | + { |
|
| 268 | + $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
| 269 | + unset($needed_parts[$m[1]]); |
|
| 270 | + } |
|
| 271 | + //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
| 272 | + return $needed_parts ? false : $data; |
|
| 273 | 273 | } |
| 274 | 274 | } |
@@ -82,7 +82,10 @@ discard block |
||
| 82 | 82 | error_log(__METHOD__.'() PHP_AUTH_USER='.array2string($_SERVER['PHP_AUTH_USER']).', PHP_AUTH_PW='.array2string($pw).', PHP_AUTH_DIGEST='.array2string($_SERVER['PHP_AUTH_DIGEST'])); |
| 83 | 83 | } |
| 84 | 84 | $realm = $GLOBALS['egw_info']['flags']['auth_realm']; |
| 85 | - if (empty($realm)) $realm = 'EGroupware'; |
|
| 85 | + if (empty($realm)) |
|
| 86 | + { |
|
| 87 | + $realm = 'EGroupware'; |
|
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; |
| 88 | 91 | // Support for basic auth when using PHP CGI (what about digest auth?) |
@@ -139,7 +142,8 @@ discard block |
||
| 139 | 142 | // replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts |
| 140 | 143 | if (strpos($password, '\\x') !== false) |
| 141 | 144 | { |
| 142 | - $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){ |
|
| 145 | + $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) |
|
| 146 | + { |
|
| 143 | 147 | return chr(hexdec($matches[1])); |
| 144 | 148 | }, $password); |
| 145 | 149 | } |
@@ -167,7 +171,10 @@ discard block |
||
| 167 | 171 | if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') || |
| 168 | 172 | $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain') |
| 169 | 173 | { |
| 170 | - if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
|
| 174 | + if (self::ERROR_LOG) |
|
| 175 | + { |
|
| 176 | + error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
|
| 177 | + } |
|
| 171 | 178 | return false; // no plain-text passwords used |
| 172 | 179 | } |
| 173 | 180 | // check for specific user, if given |
@@ -175,10 +182,16 @@ discard block |
||
| 175 | 182 | $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}')) |
| 176 | 183 | { |
| 177 | 184 | unset($user_pw); |
| 178 | - if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
|
| 185 | + if (self::ERROR_LOG) |
|
| 186 | + { |
|
| 187 | + error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
|
| 188 | + } |
|
| 179 | 189 | return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
| 180 | 190 | } |
| 181 | - if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7); |
|
| 191 | + if (substr($user_pw,0,7) == '{PLAIN}') |
|
| 192 | + { |
|
| 193 | + $user_pw = substr($user_pw,7); |
|
| 194 | + } |
|
| 182 | 195 | |
| 183 | 196 | if (self::ERROR_LOG) |
| 184 | 197 | { |
@@ -200,7 +213,10 @@ discard block |
||
| 200 | 213 | { |
| 201 | 214 | $nonce = uniqid(); |
| 202 | 215 | header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"'); |
| 203 | - if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'"); |
|
| 216 | + if (self::ERROR_LOG) |
|
| 217 | + { |
|
| 218 | + error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'"); |
|
| 219 | + } |
|
| 204 | 220 | } |
| 205 | 221 | } |
| 206 | 222 | |
@@ -215,7 +231,10 @@ discard block |
||
| 215 | 231 | */ |
| 216 | 232 | static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null) |
| 217 | 233 | { |
| 218 | - if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
|
| 234 | + if (is_null($auth_digest)) |
|
| 235 | + { |
|
| 236 | + $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
|
| 237 | + } |
|
| 219 | 238 | |
| 220 | 239 | $data = self::parse_digest($auth_digest); |
| 221 | 240 | |
@@ -228,7 +247,10 @@ discard block |
||
| 228 | 247 | |
| 229 | 248 | $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); |
| 230 | 249 | |
| 231 | - if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response)); |
|
| 250 | + if (self::ERROR_LOG) |
|
| 251 | + { |
|
| 252 | + error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response)); |
|
| 253 | + } |
|
| 232 | 254 | return $data['response'] === $valid_response; |
| 233 | 255 | } |
| 234 | 256 | |
@@ -247,10 +269,16 @@ discard block |
||
| 247 | 269 | { |
| 248 | 270 | return false; |
| 249 | 271 | } |
| 250 | - if (is_null($password)) $password = $user_pw; |
|
| 272 | + if (is_null($password)) |
|
| 273 | + { |
|
| 274 | + $password = $user_pw; |
|
| 275 | + } |
|
| 251 | 276 | |
| 252 | 277 | $A1 = md5($username . ':' . $realm . ':' . $password); |
| 253 | - if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
|
| 278 | + if (self::ERROR_LOG > 1) |
|
| 279 | + { |
|
| 280 | + error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
|
| 281 | + } |
|
| 254 | 282 | return $A1; |
| 255 | 283 | } |
| 256 | 284 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | static public function autocreate_session_callback(&$account) |
| 77 | 77 | { |
| 78 | - unset($account); // not used, but required by function signature |
|
| 78 | + unset($account); // not used, but required by function signature |
|
| 79 | 79 | if (self::ERROR_LOG) |
| 80 | 80 | { |
| 81 | 81 | $pw = self::ERROR_LOG > 1 ? $_SERVER['PHP_AUTH_PW'] : '**********'; |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; |
| 88 | 88 | // Support for basic auth when using PHP CGI (what about digest auth?) |
| 89 | - if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],'Basic ') === 0) |
|
| 89 | + if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 'Basic ') === 0) |
|
| 90 | 90 | { |
| 91 | - $hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],6)); |
|
| 91 | + $hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)); |
|
| 92 | 92 | if (strpos($hash, ':') !== false) |
| 93 | 93 | { |
| 94 | 94 | list($username, $password) = explode(':', $hash, 2); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | - elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm,$_SERVER['PHP_AUTH_DIGEST'],$username,$password)) |
|
| 97 | + elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm, $_SERVER['PHP_AUTH_DIGEST'], $username, $password)) |
|
| 98 | 98 | { |
| 99 | 99 | unset($password); |
| 100 | 100 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | $realm .= ': '.$GLOBALS['egw']->session->reason; |
| 117 | 117 | } |
| 118 | - header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"'); |
|
| 118 | + header('WWW-Authenticate: Basic realm="'.$realm.'"'); // draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"'); |
|
| 119 | 119 | self::digest_header($realm); |
| 120 | 120 | header('HTTP/1.1 401 Unauthorized'); |
| 121 | 121 | header('X-WebDAV-Status: 401 Unauthorized', true); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | // replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts |
| 140 | 140 | if (strpos($password, '\\x') !== false) |
| 141 | 141 | { |
| 142 | - $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){ |
|
| 142 | + $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) { |
|
| 143 | 143 | return chr(hexdec($matches[1])); |
| 144 | 144 | }, $password); |
| 145 | 145 | } |
@@ -161,24 +161,24 @@ discard block |
||
| 161 | 161 | * @param string &$user_pw =null stored cleartext password, if $username given AND function returns true |
| 162 | 162 | * @return boolean true if digest auth is available, false otherwise |
| 163 | 163 | */ |
| 164 | - static public function digest_auth_available($realm,$username=null,&$user_pw=null) |
|
| 164 | + static public function digest_auth_available($realm, $username = null, &$user_pw = null) |
|
| 165 | 165 | { |
| 166 | 166 | // we currently require plaintext passwords! |
| 167 | 167 | if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') || |
| 168 | 168 | $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain') |
| 169 | 169 | { |
| 170 | 170 | if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
| 171 | - return false; // no plain-text passwords used |
|
| 171 | + return false; // no plain-text passwords used |
|
| 172 | 172 | } |
| 173 | 173 | // check for specific user, if given |
| 174 | - if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username,'account_pwd','u')) || |
|
| 175 | - $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}')) |
|
| 174 | + if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username, 'account_pwd', 'u')) || |
|
| 175 | + $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw, 0, 7) != '{PLAIN}')) |
|
| 176 | 176 | { |
| 177 | 177 | unset($user_pw); |
| 178 | 178 | if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
| 179 | - return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
|
| 179 | + return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
|
| 180 | 180 | } |
| 181 | - if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7); |
|
| 181 | + if (substr($user_pw, 0, 7) == '{PLAIN}') $user_pw = substr($user_pw, 7); |
|
| 182 | 182 | |
| 183 | 183 | if (self::ERROR_LOG) |
| 184 | 184 | { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param string $realm |
| 195 | 195 | * @param string &$nonce=null on return |
| 196 | 196 | */ |
| 197 | - static public function digest_header($realm,&$nonce=null) |
|
| 197 | + static public function digest_header($realm, &$nonce = null) |
|
| 198 | 198 | { |
| 199 | 199 | if (self::digest_auth_available($realm)) |
| 200 | 200 | { |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | * @param string &$password on return cleartext password |
| 214 | 214 | * @return boolean true if digest is correct, false otherwise |
| 215 | 215 | */ |
| 216 | - static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null) |
|
| 216 | + static public function is_valid($realm, $auth_digest = null, &$username = null, &$password = null) |
|
| 217 | 217 | { |
| 218 | 218 | if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
| 219 | 219 | |
| 220 | 220 | $data = self::parse_digest($auth_digest); |
| 221 | 221 | |
| 222 | - if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null))) |
|
| 222 | + if (!$data || !($A1 = self::get_digest_A1($realm, $username = $data['username'], $password = null))) |
|
| 223 | 223 | { |
| 224 | 224 | error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE"); |
| 225 | 225 | return false; |
@@ -240,16 +240,16 @@ discard block |
||
| 240 | 240 | * @param string &$password=null password to use or if null, on return stored password |
| 241 | 241 | * @return string|boolean false if $password not given and can NOT be read |
| 242 | 242 | */ |
| 243 | - static private function get_digest_A1($realm,$username,&$password=null) |
|
| 243 | + static private function get_digest_A1($realm, $username, &$password = null) |
|
| 244 | 244 | { |
| 245 | 245 | $user_pw = null; |
| 246 | - if (empty($username) || empty($realm) || !self::digest_auth_available($realm,$username,$user_pw)) |
|
| 246 | + if (empty($username) || empty($realm) || !self::digest_auth_available($realm, $username, $user_pw)) |
|
| 247 | 247 | { |
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | 250 | if (is_null($password)) $password = $user_pw; |
| 251 | 251 | |
| 252 | - $A1 = md5($username . ':' . $realm . ':' . $password); |
|
| 252 | + $A1 = md5($username.':'.$realm.':'.$password); |
|
| 253 | 253 | if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
| 254 | 254 | return $A1; |
| 255 | 255 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $keys = implode('|', array_keys($needed_parts)); |
| 266 | 266 | |
| 267 | 267 | $matches = null; |
| 268 | - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 268 | + preg_match_all('@('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
| 269 | 269 | |
| 270 | 270 | foreach ($matches as $m) |
| 271 | 271 | { |
@@ -41,7 +41,6 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * Calling this method with an empty array for frame-src, sets no defaults but "'self'"! |
| 43 | 43 | * |
| 44 | - * @param string|array $set =array() URL (incl. protocol!) |
|
| 45 | 44 | * @param string $source valid CSP source types like 'script-src', 'style-src', 'connect-src', 'frame-src', ... |
| 46 | 45 | * @param string|array $attrs 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!) |
| 47 | 46 | */ |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'script-src' => array("'unsafe-eval'"), |
| 34 | 34 | 'style-src' => array("'unsafe-inline'"), |
| 35 | 35 | 'connect-src' => array(), |
| 36 | - 'frame-src' => null, // NOT array(), to allow setting no default frame-src! |
|
| 36 | + 'frame-src' => null, // NOT array(), to allow setting no default frame-src! |
|
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $attrs = array('www.egroupware.org'); |
| 56 | 56 | if (($app_additional = Api\Hooks::process('csp-frame-src'))) |
| 57 | 57 | { |
| 58 | - foreach($app_additional as $addtional) |
|
| 58 | + foreach ($app_additional as $addtional) |
|
| 59 | 59 | { |
| 60 | 60 | if ($addtional) $attrs = array_unique(array_merge($attrs, $addtional)); |
| 61 | 61 | } |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | self::$sources[$source] = array(); |
| 65 | 65 | } |
| 66 | - foreach((array)$attrs as $attr) |
|
| 66 | + foreach ((array)$attrs as $attr) |
|
| 67 | 67 | { |
| 68 | 68 | if (in_array($attr, array('none', 'self', 'unsafe-eval', 'unsafe-inline'))) |
| 69 | 69 | { |
| 70 | - $attr = "'$attr'"; // automatic add quotes |
|
| 70 | + $attr = "'$attr'"; // automatic add quotes |
|
| 71 | 71 | } |
| 72 | 72 | if (!in_array($attr, self::$sources[$source])) |
| 73 | 73 | { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @param string|array $set =array() 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!) |
| 90 | 90 | */ |
| 91 | - public static function add_script_src($set=null) |
|
| 91 | + public static function add_script_src($set = null) |
|
| 92 | 92 | { |
| 93 | 93 | self::add('script-src', $set); |
| 94 | 94 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param string|array $set =array() 'unsafe-inline' (without quotes!) and/or URL (incl. protocol!) |
| 102 | 102 | */ |
| 103 | - public static function add_style_src($set=null) |
|
| 103 | + public static function add_style_src($set = null) |
|
| 104 | 104 | { |
| 105 | 105 | self::add('style-src', $set); |
| 106 | 106 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param string|array $set =array() URL (incl. protocol!) |
| 112 | 112 | */ |
| 113 | - public static function add_connect_src($set=null) |
|
| 113 | + public static function add_connect_src($set = null) |
|
| 114 | 114 | { |
| 115 | 115 | self::add('connect-src', $set); |
| 116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param string|array $set =array() URL (incl. protocol!) |
| 124 | 124 | * @return string with attributes eg. "'unsafe-inline'" |
| 125 | 125 | */ |
| 126 | - public static function add_frame_src($set=null) |
|
| 126 | + public static function add_frame_src($set = null) |
|
| 127 | 127 | { |
| 128 | 128 | self::add('frame-src', $set); |
| 129 | 129 | } |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public static function send() |
| 137 | 137 | { |
| 138 | - self::add('frame-src', null); // set defaults for frame-src |
|
| 138 | + self::add('frame-src', null); // set defaults for frame-src |
|
| 139 | 139 | |
| 140 | 140 | $policies = array(); |
| 141 | - foreach(self::$sources as $source => $urls) |
|
| 141 | + foreach (self::$sources as $source => $urls) |
|
| 142 | 142 | { |
| 143 | 143 | $policies[] = "$source 'self' ".implode(' ', $urls); |
| 144 | 144 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // recommendaton ist to not send regular AND deprecated headers together, as they can cause unexpected behavior |
| 153 | 153 | if ($user_agent == 'chrome' && $version < 25 || $user_agent == 'safari' && $version < 7) |
| 154 | 154 | { |
| 155 | - header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
| 155 | + header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
|
| 156 | 156 | } |
| 157 | 157 | elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie') // Edge is reported as 'edge'! |
| 158 | 158 | { |
@@ -57,7 +57,10 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | foreach($app_additional as $addtional) |
| 59 | 59 | { |
| 60 | - if ($addtional) $attrs = array_unique(array_merge($attrs, $addtional)); |
|
| 60 | + if ($addtional) |
|
| 61 | + { |
|
| 62 | + $attrs = array_unique(array_merge($attrs, $addtional)); |
|
| 63 | + } |
|
| 61 | 64 | } |
| 62 | 65 | } |
| 63 | 66 | } |
@@ -154,10 +157,13 @@ discard block |
||
| 154 | 157 | { |
| 155 | 158 | header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS |
| 156 | 159 | } |
| 157 | - elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie') // Edge is reported as 'edge'! |
|
| 160 | + elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie') |
|
| 161 | + { |
|
| 162 | + // Edge is reported as 'edge'! |
|
| 158 | 163 | { |
| 159 | 164 | header("X-Content-Security-Policy: $csp"); |
| 160 | 165 | } |
| 166 | + } |
|
| 161 | 167 | else |
| 162 | 168 | { |
| 163 | 169 | header("Content-Security-Policy: $csp"); |
@@ -254,7 +254,7 @@ |
||
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * Static function to build pgp encryption sidebox menu |
| 257 | - * @param type $appname application name |
|
| 257 | + * @param string $appname application name |
|
| 258 | 258 | */ |
| 259 | 259 | public static function pgp_encryption_menu($appname) |
| 260 | 260 | { |
@@ -64,22 +64,22 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (!isset(self::$locations)) self::read(); |
| 66 | 66 | $hooks = self::$locations[$location]; |
| 67 | - if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook |
|
| 67 | + if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook |
|
| 68 | 68 | |
| 69 | 69 | $apps = array_keys($hooks); |
| 70 | 70 | if (!$no_permission_check) |
| 71 | 71 | { |
| 72 | 72 | // on install of a new egroupware both hook-apps and user apps may be empty/not set |
| 73 | - $apps = array_intersect((array)$apps,array_keys((array)$GLOBALS['egw_info']['user']['apps'])); |
|
| 73 | + $apps = array_intersect((array)$apps, array_keys((array)$GLOBALS['egw_info']['user']['apps'])); |
|
| 74 | 74 | } |
| 75 | 75 | if ($order) |
| 76 | 76 | { |
| 77 | - $apps = array_unique(array_merge((array)$order,$apps)); |
|
| 77 | + $apps = array_unique(array_merge((array)$order, $apps)); |
|
| 78 | 78 | } |
| 79 | 79 | $results = array(); |
| 80 | - foreach((array)$apps as $appname) |
|
| 80 | + foreach ((array)$apps as $appname) |
|
| 81 | 81 | { |
| 82 | - $results[$appname] = self::single($args,$appname,$no_permission_check); |
|
| 82 | + $results[$appname] = self::single($args, $appname, $no_permission_check); |
|
| 83 | 83 | } |
| 84 | 84 | return $results; |
| 85 | 85 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $ret = array(); |
| 118 | - foreach((array)self::$locations[$location][$appname] as $hook) |
|
| 118 | + foreach ((array)self::$locations[$location][$appname] as $hook) |
|
| 119 | 119 | { |
| 120 | 120 | try { |
| 121 | 121 | // old style file hook |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // hooks only existing in filesystem used by setup |
| 152 | - if (!$ret && $try_unregistered && file_exists(EGW_SERVER_ROOT.($hook='/'.$appname.'/inc/hook_'.$location.'.inc.php'))) |
|
| 152 | + if (!$ret && $try_unregistered && file_exists(EGW_SERVER_ROOT.($hook = '/'.$appname.'/inc/hook_'.$location.'.inc.php'))) |
|
| 153 | 153 | { |
| 154 | 154 | include(EGW_SERVER_ROOT.$hook); |
| 155 | 155 | return true; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param boolean $return_methods =false true: return hook-method(s) |
| 182 | 182 | * @return int|array the number of found hooks or for $return_methods array with methods |
| 183 | 183 | */ |
| 184 | - public static function exists($location, $app, $return_methods=false) |
|
| 184 | + public static function exists($location, $app, $return_methods = false) |
|
| 185 | 185 | { |
| 186 | 186 | if (!isset(self::$locations)) self::read(); |
| 187 | 187 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @param boolan $force_rescan =false true: do not use instance cache |
| 210 | 210 | */ |
| 211 | - public static function read($force_rescan=false) |
|
| 211 | + public static function read($force_rescan = false) |
|
| 212 | 212 | { |
| 213 | 213 | //$starttime = microtime(true); |
| 214 | 214 | if ($force_rescan) Cache::unsetInstance(__CLASS__, 'locations'); |
@@ -224,18 +224,18 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | // read all apps using just filesystem data |
| 226 | 226 | $locations = array(); |
| 227 | - foreach(array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname) |
|
| 227 | + foreach (array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname) |
|
| 228 | 228 | { |
| 229 | 229 | if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue; |
| 230 | 230 | |
| 231 | - $f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php'; |
|
| 231 | + $f = EGW_SERVER_ROOT.'/'.$appname.'/setup/setup.inc.php'; |
|
| 232 | 232 | $setup_info = array($appname => array()); |
| 233 | - if(@file_exists($f)) include($f); |
|
| 233 | + if (@file_exists($f)) include($f); |
|
| 234 | 234 | |
| 235 | 235 | // some apps have setup_info for more then themselfs (eg. api for groupdav) |
| 236 | - foreach($setup_info as $appname => $data) |
|
| 236 | + foreach ($setup_info as $appname => $data) |
|
| 237 | 237 | { |
| 238 | - foreach((array)$data['hooks'] as $location => $methods) |
|
| 238 | + foreach ((array)$data['hooks'] as $location => $methods) |
|
| 239 | 239 | { |
| 240 | 240 | if (is_int($location)) |
| 241 | 241 | { |
@@ -62,9 +62,16 @@ discard block |
||
| 62 | 62 | //echo "<p>".__METHOD__.'('.array2string($args).','.array2string($order).','.array2string($no_permission_check).")</p>\n"; |
| 63 | 63 | $location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args; |
| 64 | 64 | |
| 65 | - if (!isset(self::$locations)) self::read(); |
|
| 65 | + if (!isset(self::$locations)) |
|
| 66 | + { |
|
| 67 | + self::read(); |
|
| 68 | + } |
|
| 66 | 69 | $hooks = self::$locations[$location]; |
| 67 | - if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook |
|
| 70 | + if (!isset($hooks) || empty($hooks)) |
|
| 71 | + { |
|
| 72 | + return array(); |
|
| 73 | + } |
|
| 74 | + // not a single app implements that hook |
|
| 68 | 75 | |
| 69 | 76 | $apps = array_keys($hooks); |
| 70 | 77 | if (!$no_permission_check) |
@@ -99,9 +106,15 @@ discard block |
||
| 99 | 106 | { |
| 100 | 107 | //error_log(__METHOD__."(".array2string($args).",'$appname','$no_permission_check','$try_unregistered')"); |
| 101 | 108 | |
| 102 | - if (!isset(self::$locations)) self::read(); |
|
| 109 | + if (!isset(self::$locations)) |
|
| 110 | + { |
|
| 111 | + self::read(); |
|
| 112 | + } |
|
| 103 | 113 | |
| 104 | - if (!is_array($args)) $args = array('location' => $args); |
|
| 114 | + if (!is_array($args)) |
|
| 115 | + { |
|
| 116 | + $args = array('location' => $args); |
|
| 117 | + } |
|
| 105 | 118 | $location = isset($args['hook_location']) ? $args['hook_location'] : $args['location']; |
| 106 | 119 | |
| 107 | 120 | if (!$appname) |
@@ -135,7 +148,10 @@ discard block |
||
| 135 | 148 | // static method of an autoloadable class |
| 136 | 149 | if (isset($method) && class_exists($class)) |
| 137 | 150 | { |
| 138 | - if (is_callable($hook)) $ret[] = call_user_func($hook, $args); |
|
| 151 | + if (is_callable($hook)) |
|
| 152 | + { |
|
| 153 | + $ret[] = call_user_func($hook, $args); |
|
| 154 | + } |
|
| 139 | 155 | } |
| 140 | 156 | // app.class.method or not autoloadable class |
| 141 | 157 | else |
@@ -155,7 +171,10 @@ discard block |
||
| 155 | 171 | return true; |
| 156 | 172 | } |
| 157 | 173 | |
| 158 | - if (!$ret) return false; |
|
| 174 | + if (!$ret) |
|
| 175 | + { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 159 | 178 | |
| 160 | 179 | return count($ret) == 1 ? $ret[0] : $ret; |
| 161 | 180 | } |
@@ -168,7 +187,10 @@ discard block |
||
| 168 | 187 | */ |
| 169 | 188 | public static function count($location) |
| 170 | 189 | { |
| 171 | - if (!isset(self::$locations)) self::read(); |
|
| 190 | + if (!isset(self::$locations)) |
|
| 191 | + { |
|
| 192 | + self::read(); |
|
| 193 | + } |
|
| 172 | 194 | |
| 173 | 195 | return count(self::$locations[$location]); |
| 174 | 196 | } |
@@ -183,7 +205,10 @@ discard block |
||
| 183 | 205 | */ |
| 184 | 206 | public static function exists($location, $app, $return_methods=false) |
| 185 | 207 | { |
| 186 | - if (!isset(self::$locations)) self::read(); |
|
| 208 | + if (!isset(self::$locations)) |
|
| 209 | + { |
|
| 210 | + self::read(); |
|
| 211 | + } |
|
| 187 | 212 | |
| 188 | 213 | //error_log(__METHOD__.__LINE__.array2string(self::$locations[$location])); |
| 189 | 214 | return $return_methods ? self::$locations[$location][$app] : count(self::$locations[$location][$app]); |
@@ -197,7 +222,10 @@ discard block |
||
| 197 | 222 | */ |
| 198 | 223 | public static function implemented($location) |
| 199 | 224 | { |
| 200 | - if (!isset(self::$locations)) self::read(); |
|
| 225 | + if (!isset(self::$locations)) |
|
| 226 | + { |
|
| 227 | + self::read(); |
|
| 228 | + } |
|
| 201 | 229 | |
| 202 | 230 | //error_log(__METHOD__.__LINE__.array2string(self::$locations[$location])); |
| 203 | 231 | return isset(self::$locations[$location]) ? array_keys(self::$locations[$location]) : array(); |
@@ -211,7 +239,10 @@ discard block |
||
| 211 | 239 | */ |
| 212 | 240 | static public function disable($hook) |
| 213 | 241 | { |
| 214 | - if (!isset(self::$locations)) self::read(); |
|
| 242 | + if (!isset(self::$locations)) |
|
| 243 | + { |
|
| 244 | + self::read(); |
|
| 245 | + } |
|
| 215 | 246 | |
| 216 | 247 | $ret = isset(self::$locations[$hook]); |
| 217 | 248 | |
@@ -228,7 +259,10 @@ discard block |
||
| 228 | 259 | public static function read($force_rescan=false) |
| 229 | 260 | { |
| 230 | 261 | //$starttime = microtime(true); |
| 231 | - if ($force_rescan) Cache::unsetInstance(__CLASS__, 'locations'); |
|
| 262 | + if ($force_rescan) |
|
| 263 | + { |
|
| 264 | + Cache::unsetInstance(__CLASS__, 'locations'); |
|
| 265 | + } |
|
| 232 | 266 | |
| 233 | 267 | self::$locations = Cache::getInstance(__CLASS__, 'locations', function() |
| 234 | 268 | { |
@@ -243,11 +277,17 @@ discard block |
||
| 243 | 277 | $locations = array(); |
| 244 | 278 | foreach(array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname) |
| 245 | 279 | { |
| 246 | - if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue; |
|
| 280 | + if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) |
|
| 281 | + { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 247 | 284 | |
| 248 | 285 | $f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php'; |
| 249 | 286 | $setup_info = array($appname => array()); |
| 250 | - if(@file_exists($f)) include($f); |
|
| 287 | + if(@file_exists($f)) |
|
| 288 | + { |
|
| 289 | + include($f); |
|
| 290 | + } |
|
| 251 | 291 | |
| 252 | 292 | // some apps have setup_info for more then themselfs (eg. api for groupdav) |
| 253 | 293 | foreach($setup_info as $appname => $data) |
@@ -275,7 +315,10 @@ discard block |
||
| 275 | 315 | */ |
| 276 | 316 | public static function pgp_encryption_menu($appname) |
| 277 | 317 | { |
| 278 | - if (Header\UserAgent::mobile()) return; |
|
| 318 | + if (Header\UserAgent::mobile()) |
|
| 319 | + { |
|
| 320 | + return; |
|
| 321 | + } |
|
| 279 | 322 | |
| 280 | 323 | // PGP Encryption (Mailvelope plugin) restore/backup menu |
| 281 | 324 | $file = Array( |
@@ -278,7 +278,7 @@ |
||
| 278 | 278 | if (Header\UserAgent::mobile()) return; |
| 279 | 279 | |
| 280 | 280 | // PGP Encryption (Mailvelope plugin) restore/backup menu |
| 281 | - $file = Array( |
|
| 281 | + $file = array( |
|
| 282 | 282 | 'Backup/Restore ...' => 'javascript:app.'.$appname.'.mailvelopeCreateBackupRestoreDialog();', |
| 283 | 283 | 'sendToBottom' => true |
| 284 | 284 | ); |