@@ -254,6 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @param string program name |
| 256 | 256 | * @param string optional search path, defaults to $PATH |
| 257 | + * @param string $name |
|
| 257 | 258 | * @return bool true if executable program found in path |
| 258 | 259 | */ |
| 259 | 260 | function _can_execute($name, $path = false) |
@@ -319,6 +320,7 @@ discard block |
||
| 319 | 320 | * try to detect the mime type of a file |
| 320 | 321 | * |
| 321 | 322 | * @param string file path |
| 323 | + * @param string $fspath |
|
| 322 | 324 | * @return string guessed mime type |
| 323 | 325 | */ |
| 324 | 326 | function _mimetype($fspath) |
@@ -416,7 +418,7 @@ discard block |
||
| 416 | 418 | * GET method handler |
| 417 | 419 | * |
| 418 | 420 | * @param array parameter passing array |
| 419 | - * @return bool true on success |
|
| 421 | + * @return null|boolean true on success |
|
| 420 | 422 | */ |
| 421 | 423 | function GET(&$options) |
| 422 | 424 | { |
@@ -446,7 +448,7 @@ discard block |
||
| 446 | 448 | * See RFC 2518, Section 8.4 on GET/HEAD for collections |
| 447 | 449 | * |
| 448 | 450 | * @param string directory path |
| 449 | - * @return void function has to handle HTTP response itself |
|
| 451 | + * @return null|false function has to handle HTTP response itself |
|
| 450 | 452 | */ |
| 451 | 453 | function GetDir($fspath, &$options) |
| 452 | 454 | { |
@@ -533,7 +535,7 @@ discard block |
||
| 533 | 535 | * MKCOL method handler |
| 534 | 536 | * |
| 535 | 537 | * @param array general parameter passing array |
| 536 | - * @return bool true on success |
|
| 538 | + * @return string true on success |
|
| 537 | 539 | */ |
| 538 | 540 | function MKCOL($options) |
| 539 | 541 | { |
@@ -570,7 +572,7 @@ discard block |
||
| 570 | 572 | * DELETE method handler |
| 571 | 573 | * |
| 572 | 574 | * @param array general parameter passing array |
| 573 | - * @return bool true on success |
|
| 575 | + * @return string true on success |
|
| 574 | 576 | */ |
| 575 | 577 | function DELETE($options) |
| 576 | 578 | { |
@@ -600,7 +602,7 @@ discard block |
||
| 600 | 602 | * MOVE method handler |
| 601 | 603 | * |
| 602 | 604 | * @param array general parameter passing array |
| 603 | - * @return bool true on success |
|
| 605 | + * @return string true on success |
|
| 604 | 606 | */ |
| 605 | 607 | function MOVE($options) |
| 606 | 608 | { |
@@ -611,7 +613,7 @@ discard block |
||
| 611 | 613 | * COPY method handler |
| 612 | 614 | * |
| 613 | 615 | * @param array general parameter passing array |
| 614 | - * @return bool true on success |
|
| 616 | + * @return string true on success |
|
| 615 | 617 | */ |
| 616 | 618 | function COPY($options, $del=false) |
| 617 | 619 | { |
@@ -751,7 +753,7 @@ discard block |
||
| 751 | 753 | * PROPPATCH method handler |
| 752 | 754 | * |
| 753 | 755 | * @param array general parameter passing array |
| 754 | - * @return bool true on success |
|
| 756 | + * @return string true on success |
|
| 755 | 757 | */ |
| 756 | 758 | function PROPPATCH(&$options) |
| 757 | 759 | { |
@@ -790,7 +792,7 @@ discard block |
||
| 790 | 792 | * LOCK method handler |
| 791 | 793 | * |
| 792 | 794 | * @param array general parameter passing array |
| 793 | - * @return bool true on success |
|
| 795 | + * @return string|boolean true on success |
|
| 794 | 796 | */ |
| 795 | 797 | function LOCK(&$options) |
| 796 | 798 | { |
@@ -848,7 +850,7 @@ discard block |
||
| 848 | 850 | * UNLOCK method handler |
| 849 | 851 | * |
| 850 | 852 | * @param array general parameter passing array |
| 851 | - * @return bool true on success |
|
| 853 | + * @return string true on success |
|
| 852 | 854 | */ |
| 853 | 855 | function UNLOCK(&$options) |
| 854 | 856 | { |
@@ -44,793 +44,793 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | class HTTP_WebDAV_Server_Filesystem extends HTTP_WebDAV_Server |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * Root directory for WebDAV access |
|
| 49 | - * |
|
| 50 | - * Defaults to webserver document root (set by ServeRequest) |
|
| 51 | - * |
|
| 52 | - * @access private |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 55 | - var $base = ""; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * MySQL Host where property and locking information is stored |
|
| 59 | - * |
|
| 60 | - * @access private |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - var $db_host = "localhost"; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * MySQL database for property/locking information storage |
|
| 67 | - * |
|
| 68 | - * @access private |
|
| 69 | - * @var string |
|
| 70 | - */ |
|
| 71 | - var $db_name = "webdav"; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * MySQL table name prefix |
|
| 75 | - * |
|
| 76 | - * @access private |
|
| 77 | - * @var string |
|
| 78 | - */ |
|
| 79 | - var $db_prefix = ""; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * MySQL user for property/locking db access |
|
| 83 | - * |
|
| 84 | - * @access private |
|
| 85 | - * @var string |
|
| 86 | - */ |
|
| 87 | - var $db_user = "root"; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * MySQL password for property/locking db access |
|
| 91 | - * |
|
| 92 | - * @access private |
|
| 93 | - * @var string |
|
| 94 | - */ |
|
| 95 | - var $db_passwd = ""; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Serve a webdav request |
|
| 99 | - * |
|
| 100 | - * @access public |
|
| 101 | - * @param string |
|
| 102 | - */ |
|
| 103 | - function ServeRequest($base = false) |
|
| 104 | - { |
|
| 105 | - // special treatment for litmus compliance test |
|
| 106 | - // reply on its identifier header |
|
| 107 | - // not needed for the test itself but eases debugging |
|
| 108 | - if (isset($this->_SERVER['HTTP_X_LITMUS'])) { |
|
| 109 | - error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']); |
|
| 110 | - header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // set root directory, defaults to webserver document root if not set |
|
| 114 | - if ($base) { |
|
| 115 | - $this->base = realpath($base); // TODO throw if not a directory |
|
| 116 | - } else if (!$this->base) { |
|
| 117 | - $this->base = $this->_SERVER['DOCUMENT_ROOT']; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - // establish connection to property/locking db |
|
| 121 | - mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error()); |
|
| 122 | - mysql_select_db($this->db_name) or die(mysql_error()); |
|
| 123 | - // TODO throw on connection problems |
|
| 124 | - |
|
| 125 | - // let the base class do all the work |
|
| 126 | - parent::ServeRequest(); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * No authentication is needed here |
|
| 131 | - * |
|
| 132 | - * @access private |
|
| 133 | - * @param string HTTP Authentication type (Basic, Digest, ...) |
|
| 134 | - * @param string Username |
|
| 135 | - * @param string Password |
|
| 136 | - * @return bool true on successful authentication |
|
| 137 | - */ |
|
| 138 | - function check_auth($type, $user, $pass) |
|
| 139 | - { |
|
| 140 | - return true; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * PROPFIND method handler |
|
| 146 | - * |
|
| 147 | - * @param array general parameter passing array |
|
| 148 | - * @param array return array for file properties |
|
| 149 | - * @return bool true on success |
|
| 150 | - */ |
|
| 151 | - function PROPFIND(&$options, &$files) |
|
| 152 | - { |
|
| 153 | - // get absolute fs path to requested resource |
|
| 154 | - $fspath = $this->base . $options["path"]; |
|
| 155 | - |
|
| 156 | - // sanity check |
|
| 157 | - if (!file_exists($fspath)) { |
|
| 158 | - return false; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // prepare property array |
|
| 162 | - $files["files"] = array(); |
|
| 163 | - |
|
| 164 | - // store information for the requested path itself |
|
| 165 | - $files["files"][] = $this->fileinfo($options["path"]); |
|
| 166 | - |
|
| 167 | - // information for contained resources requested? |
|
| 168 | - if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) { |
|
| 169 | - |
|
| 170 | - // make sure path ends with '/' |
|
| 171 | - $options["path"] = $this->_slashify($options["path"]); |
|
| 172 | - |
|
| 173 | - // try to open directory |
|
| 174 | - $handle = opendir($fspath); |
|
| 175 | - |
|
| 176 | - if ($handle) { |
|
| 177 | - // ok, now get all its contents |
|
| 178 | - while ($filename = readdir($handle)) { |
|
| 179 | - if ($filename != "." && $filename != "..") { |
|
| 180 | - $files["files"][] = $this->fileinfo($options["path"].$filename); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - // TODO recursion needed if "Depth: infinite" |
|
| 184 | - closedir($handle); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // ok, all done |
|
| 189 | - return true; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Get properties for a single file/resource |
|
| 194 | - * |
|
| 195 | - * @param string resource path |
|
| 196 | - * @return array resource properties |
|
| 197 | - */ |
|
| 198 | - function fileinfo($path) |
|
| 199 | - { |
|
| 200 | - // map URI path to filesystem path |
|
| 201 | - $fspath = $this->base . $path; |
|
| 202 | - |
|
| 203 | - // create result array |
|
| 204 | - $info = array(); |
|
| 205 | - // TODO remove slash append code when base clase is able to do it itself |
|
| 206 | - $info["path"] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
| 207 | - $info["props"] = array(); |
|
| 208 | - |
|
| 209 | - // no special beautified displayname here ... |
|
| 210 | - $info["props"][] = $this->mkprop("displayname", strtoupper($path)); |
|
| 211 | - |
|
| 212 | - // creation and modification time |
|
| 213 | - $info["props"][] = $this->mkprop("creationdate", filectime($fspath)); |
|
| 214 | - $info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath)); |
|
| 215 | - |
|
| 216 | - // Microsoft extensions: last access time and 'hidden' status |
|
| 217 | - $info["props"][] = $this->mkprop("lastaccessed", fileatime($fspath)); |
|
| 218 | - $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1))); |
|
| 219 | - |
|
| 220 | - // type and size (caller already made sure that path exists) |
|
| 221 | - if (is_dir($fspath)) { |
|
| 222 | - // directory (WebDAV collection) |
|
| 223 | - $info["props"][] = $this->mkprop("resourcetype", "collection"); |
|
| 224 | - $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory"); |
|
| 225 | - } else { |
|
| 226 | - // plain file (WebDAV resource) |
|
| 227 | - $info["props"][] = $this->mkprop("resourcetype", ""); |
|
| 228 | - if ($this->_is_readable($fspath)) { |
|
| 229 | - $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath)); |
|
| 230 | - } else { |
|
| 231 | - $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable"); |
|
| 232 | - } |
|
| 233 | - $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath)); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // get additional properties from database |
|
| 237 | - $query = "SELECT ns, name, value |
|
| 47 | + /** |
|
| 48 | + * Root directory for WebDAV access |
|
| 49 | + * |
|
| 50 | + * Defaults to webserver document root (set by ServeRequest) |
|
| 51 | + * |
|
| 52 | + * @access private |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | + var $base = ""; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * MySQL Host where property and locking information is stored |
|
| 59 | + * |
|
| 60 | + * @access private |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + var $db_host = "localhost"; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * MySQL database for property/locking information storage |
|
| 67 | + * |
|
| 68 | + * @access private |
|
| 69 | + * @var string |
|
| 70 | + */ |
|
| 71 | + var $db_name = "webdav"; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * MySQL table name prefix |
|
| 75 | + * |
|
| 76 | + * @access private |
|
| 77 | + * @var string |
|
| 78 | + */ |
|
| 79 | + var $db_prefix = ""; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * MySQL user for property/locking db access |
|
| 83 | + * |
|
| 84 | + * @access private |
|
| 85 | + * @var string |
|
| 86 | + */ |
|
| 87 | + var $db_user = "root"; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * MySQL password for property/locking db access |
|
| 91 | + * |
|
| 92 | + * @access private |
|
| 93 | + * @var string |
|
| 94 | + */ |
|
| 95 | + var $db_passwd = ""; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Serve a webdav request |
|
| 99 | + * |
|
| 100 | + * @access public |
|
| 101 | + * @param string |
|
| 102 | + */ |
|
| 103 | + function ServeRequest($base = false) |
|
| 104 | + { |
|
| 105 | + // special treatment for litmus compliance test |
|
| 106 | + // reply on its identifier header |
|
| 107 | + // not needed for the test itself but eases debugging |
|
| 108 | + if (isset($this->_SERVER['HTTP_X_LITMUS'])) { |
|
| 109 | + error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']); |
|
| 110 | + header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // set root directory, defaults to webserver document root if not set |
|
| 114 | + if ($base) { |
|
| 115 | + $this->base = realpath($base); // TODO throw if not a directory |
|
| 116 | + } else if (!$this->base) { |
|
| 117 | + $this->base = $this->_SERVER['DOCUMENT_ROOT']; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + // establish connection to property/locking db |
|
| 121 | + mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error()); |
|
| 122 | + mysql_select_db($this->db_name) or die(mysql_error()); |
|
| 123 | + // TODO throw on connection problems |
|
| 124 | + |
|
| 125 | + // let the base class do all the work |
|
| 126 | + parent::ServeRequest(); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * No authentication is needed here |
|
| 131 | + * |
|
| 132 | + * @access private |
|
| 133 | + * @param string HTTP Authentication type (Basic, Digest, ...) |
|
| 134 | + * @param string Username |
|
| 135 | + * @param string Password |
|
| 136 | + * @return bool true on successful authentication |
|
| 137 | + */ |
|
| 138 | + function check_auth($type, $user, $pass) |
|
| 139 | + { |
|
| 140 | + return true; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * PROPFIND method handler |
|
| 146 | + * |
|
| 147 | + * @param array general parameter passing array |
|
| 148 | + * @param array return array for file properties |
|
| 149 | + * @return bool true on success |
|
| 150 | + */ |
|
| 151 | + function PROPFIND(&$options, &$files) |
|
| 152 | + { |
|
| 153 | + // get absolute fs path to requested resource |
|
| 154 | + $fspath = $this->base . $options["path"]; |
|
| 155 | + |
|
| 156 | + // sanity check |
|
| 157 | + if (!file_exists($fspath)) { |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // prepare property array |
|
| 162 | + $files["files"] = array(); |
|
| 163 | + |
|
| 164 | + // store information for the requested path itself |
|
| 165 | + $files["files"][] = $this->fileinfo($options["path"]); |
|
| 166 | + |
|
| 167 | + // information for contained resources requested? |
|
| 168 | + if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) { |
|
| 169 | + |
|
| 170 | + // make sure path ends with '/' |
|
| 171 | + $options["path"] = $this->_slashify($options["path"]); |
|
| 172 | + |
|
| 173 | + // try to open directory |
|
| 174 | + $handle = opendir($fspath); |
|
| 175 | + |
|
| 176 | + if ($handle) { |
|
| 177 | + // ok, now get all its contents |
|
| 178 | + while ($filename = readdir($handle)) { |
|
| 179 | + if ($filename != "." && $filename != "..") { |
|
| 180 | + $files["files"][] = $this->fileinfo($options["path"].$filename); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + // TODO recursion needed if "Depth: infinite" |
|
| 184 | + closedir($handle); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // ok, all done |
|
| 189 | + return true; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Get properties for a single file/resource |
|
| 194 | + * |
|
| 195 | + * @param string resource path |
|
| 196 | + * @return array resource properties |
|
| 197 | + */ |
|
| 198 | + function fileinfo($path) |
|
| 199 | + { |
|
| 200 | + // map URI path to filesystem path |
|
| 201 | + $fspath = $this->base . $path; |
|
| 202 | + |
|
| 203 | + // create result array |
|
| 204 | + $info = array(); |
|
| 205 | + // TODO remove slash append code when base clase is able to do it itself |
|
| 206 | + $info["path"] = is_dir($fspath) ? $this->_slashify($path) : $path; |
|
| 207 | + $info["props"] = array(); |
|
| 208 | + |
|
| 209 | + // no special beautified displayname here ... |
|
| 210 | + $info["props"][] = $this->mkprop("displayname", strtoupper($path)); |
|
| 211 | + |
|
| 212 | + // creation and modification time |
|
| 213 | + $info["props"][] = $this->mkprop("creationdate", filectime($fspath)); |
|
| 214 | + $info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath)); |
|
| 215 | + |
|
| 216 | + // Microsoft extensions: last access time and 'hidden' status |
|
| 217 | + $info["props"][] = $this->mkprop("lastaccessed", fileatime($fspath)); |
|
| 218 | + $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1))); |
|
| 219 | + |
|
| 220 | + // type and size (caller already made sure that path exists) |
|
| 221 | + if (is_dir($fspath)) { |
|
| 222 | + // directory (WebDAV collection) |
|
| 223 | + $info["props"][] = $this->mkprop("resourcetype", "collection"); |
|
| 224 | + $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory"); |
|
| 225 | + } else { |
|
| 226 | + // plain file (WebDAV resource) |
|
| 227 | + $info["props"][] = $this->mkprop("resourcetype", ""); |
|
| 228 | + if ($this->_is_readable($fspath)) { |
|
| 229 | + $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath)); |
|
| 230 | + } else { |
|
| 231 | + $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable"); |
|
| 232 | + } |
|
| 233 | + $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath)); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // get additional properties from database |
|
| 237 | + $query = "SELECT ns, name, value |
|
| 238 | 238 | FROM {$this->db_prefix}properties |
| 239 | 239 | WHERE path = '$path'"; |
| 240 | - $res = mysql_query($query); |
|
| 241 | - while ($row = mysql_fetch_assoc($res)) { |
|
| 242 | - $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]); |
|
| 243 | - } |
|
| 244 | - mysql_free_result($res); |
|
| 245 | - |
|
| 246 | - return $info; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * detect if a given program is found in the search PATH |
|
| 251 | - * |
|
| 252 | - * helper function used by _mimetype() to detect if the |
|
| 253 | - * external 'file' utility is available |
|
| 254 | - * |
|
| 255 | - * @param string program name |
|
| 256 | - * @param string optional search path, defaults to $PATH |
|
| 257 | - * @return bool true if executable program found in path |
|
| 258 | - */ |
|
| 259 | - function _can_execute($name, $path = false) |
|
| 260 | - { |
|
| 261 | - // path defaults to PATH from environment if not set |
|
| 262 | - if ($path === false) { |
|
| 263 | - $path = getenv("PATH"); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - // check method depends on operating system |
|
| 267 | - if (!strncmp(PHP_OS, "WIN", 3)) { |
|
| 268 | - // on Windows an appropriate COM or EXE file needs to exist |
|
| 269 | - $exts = array(".exe", ".com"); |
|
| 270 | - $check_fn = "file_exists"; |
|
| 271 | - } else { |
|
| 272 | - // anywhere else we look for an executable file of that name |
|
| 273 | - $exts = array(""); |
|
| 274 | - $check_fn = "is_executable"; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - // now check the directories in the path for the program |
|
| 278 | - foreach (explode(PATH_SEPARATOR, $path) as $dir) { |
|
| 279 | - // skip invalid path entries |
|
| 280 | - if (!file_exists($dir)) continue; |
|
| 281 | - if (!is_dir($dir)) continue; |
|
| 282 | - |
|
| 283 | - // and now look for the file |
|
| 284 | - foreach ($exts as $ext) { |
|
| 285 | - if ($check_fn("$dir/$name".$ext)) return true; |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return false; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Check if path is readable by current user |
|
| 294 | - * |
|
| 295 | - * Allow extending classes to overwrite it |
|
| 296 | - * |
|
| 297 | - * @param string $fspath |
|
| 298 | - * @return boolean |
|
| 299 | - */ |
|
| 300 | - function _is_readable($fspath) |
|
| 301 | - { |
|
| 302 | - return is_readable($fspath); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Check if path is writable by current user |
|
| 307 | - * |
|
| 308 | - * Allow extending classes to overwrite it |
|
| 309 | - * |
|
| 310 | - * @param string $fspath |
|
| 311 | - * @return boolean |
|
| 312 | - */ |
|
| 313 | - function _is_writable($fspath) |
|
| 314 | - { |
|
| 315 | - return is_writable($fspath); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * try to detect the mime type of a file |
|
| 320 | - * |
|
| 321 | - * @param string file path |
|
| 322 | - * @return string guessed mime type |
|
| 323 | - */ |
|
| 324 | - function _mimetype($fspath) |
|
| 325 | - { |
|
| 326 | - if (is_dir($fspath)) { |
|
| 327 | - // directories are easy |
|
| 328 | - return "httpd/unix-directory"; |
|
| 329 | - } else if (function_exists("mime_content_type")) { |
|
| 330 | - // use mime magic extension if available |
|
| 331 | - $mime_type = mime_content_type($fspath); |
|
| 332 | - } else if ($this->_can_execute("file")) { |
|
| 333 | - // it looks like we have a 'file' command, |
|
| 334 | - // lets see it it does have mime support |
|
| 335 | - $fp = popen("file -i '$fspath' 2>/dev/null", "r"); |
|
| 336 | - $reply = fgets($fp); |
|
| 337 | - pclose($fp); |
|
| 338 | - |
|
| 339 | - // popen will not return an error if the binary was not found |
|
| 340 | - // and find may not have mime support using "-i" |
|
| 341 | - // so we test the format of the returned string |
|
| 342 | - |
|
| 343 | - // the reply begins with the requested filename |
|
| 344 | - if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) { |
|
| 345 | - $reply = substr($reply, strlen($fspath)+2); |
|
| 346 | - // followed by the mime type (maybe including options) |
|
| 347 | - if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) { |
|
| 348 | - $mime_type = $matches[0]; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - if (empty($mime_type)) { |
|
| 354 | - // Fallback solution: try to guess the type by the file extension |
|
| 355 | - // TODO: add more ... |
|
| 356 | - // TODO: it has been suggested to delegate mimetype detection |
|
| 357 | - // to apache but this has at least three issues: |
|
| 358 | - // - works only with apache |
|
| 359 | - // - needs file to be within the document tree |
|
| 360 | - // - requires apache mod_magic |
|
| 361 | - // TODO: can we use the registry for this on Windows? |
|
| 362 | - // OTOH if the server is Windos the clients are likely to |
|
| 363 | - // be Windows, too, and tend do ignore the Content-Type |
|
| 364 | - // anyway (overriding it with information taken from |
|
| 365 | - // the registry) |
|
| 366 | - // TODO: have a seperate PEAR class for mimetype detection? |
|
| 367 | - switch (strtolower(strrchr(basename($fspath), "."))) { |
|
| 368 | - case ".html": |
|
| 369 | - $mime_type = "text/html"; |
|
| 370 | - break; |
|
| 371 | - case ".gif": |
|
| 372 | - $mime_type = "image/gif"; |
|
| 373 | - break; |
|
| 374 | - case ".jpg": |
|
| 375 | - $mime_type = "image/jpeg"; |
|
| 376 | - break; |
|
| 377 | - default: |
|
| 378 | - $mime_type = "application/octet-stream"; |
|
| 379 | - break; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $mime_type; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * HEAD method handler |
|
| 388 | - * |
|
| 389 | - * @param array parameter passing array |
|
| 390 | - * @return bool true on success |
|
| 391 | - */ |
|
| 392 | - function HEAD(&$options) |
|
| 393 | - { |
|
| 394 | - // get absolute fs path to requested resource |
|
| 395 | - $fspath = $this->base . $options["path"]; |
|
| 396 | - |
|
| 397 | - // sanity check |
|
| 398 | - if (!file_exists($fspath)) return false; |
|
| 399 | - |
|
| 400 | - // detect resource type |
|
| 401 | - $options['mimetype'] = $this->_mimetype($fspath); |
|
| 402 | - |
|
| 403 | - // detect modification time |
|
| 404 | - // see rfc2518, section 13.7 |
|
| 405 | - // some clients seem to treat this as a reverse rule |
|
| 406 | - // requiering a Last-Modified header if the getlastmodified header was set |
|
| 407 | - $options['mtime'] = filemtime($fspath); |
|
| 408 | - |
|
| 409 | - // detect resource size |
|
| 410 | - $options['size'] = filesize($fspath); |
|
| 411 | - |
|
| 412 | - return true; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * GET method handler |
|
| 417 | - * |
|
| 418 | - * @param array parameter passing array |
|
| 419 | - * @return bool true on success |
|
| 420 | - */ |
|
| 421 | - function GET(&$options) |
|
| 422 | - { |
|
| 423 | - // get absolute fs path to requested resource |
|
| 424 | - $fspath = $this->base . $options["path"]; |
|
| 425 | - |
|
| 426 | - // is this a collection? |
|
| 427 | - if (is_dir($fspath)) { |
|
| 428 | - return $this->GetDir($fspath, $options); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - // the header output is the same as for HEAD |
|
| 432 | - if (!$this->HEAD($options)) { |
|
| 433 | - return false; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - // no need to check result here, it is handled by the base class |
|
| 437 | - $options['stream'] = fopen($fspath, "r"); |
|
| 438 | - |
|
| 439 | - return true; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * GET method handler for directories |
|
| 444 | - * |
|
| 445 | - * This is a very simple mod_index lookalike. |
|
| 446 | - * See RFC 2518, Section 8.4 on GET/HEAD for collections |
|
| 447 | - * |
|
| 448 | - * @param string directory path |
|
| 449 | - * @return void function has to handle HTTP response itself |
|
| 450 | - */ |
|
| 451 | - function GetDir($fspath, &$options) |
|
| 452 | - { |
|
| 453 | - $path = $this->_slashify($options["path"]); |
|
| 454 | - if ($path != $options["path"]) { |
|
| 455 | - header("Location: ".$this->base_uri.$path); |
|
| 456 | - exit; |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - // fixed width directory column format |
|
| 460 | - $format = "%15s %-19s %-s\n"; |
|
| 461 | - |
|
| 462 | - if (!$this->_is_readable($fspath)) { |
|
| 463 | - return false; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - $handle = opendir($fspath); |
|
| 467 | - if (!$handle) { |
|
| 468 | - return false; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - echo "<html><head><title>Index of ".htmlspecialchars(urldecode($options['path']))."</title></head>\n"; |
|
| 472 | - |
|
| 473 | - echo "<h1>Index of ".htmlspecialchars($options['path'])."</h1>\n"; |
|
| 474 | - |
|
| 475 | - echo "<pre>"; |
|
| 476 | - printf($format, "Size", "Last modified", "Filename"); |
|
| 477 | - echo "<hr>"; |
|
| 478 | - |
|
| 479 | - while ($filename = readdir($handle)) { |
|
| 480 | - if ($filename != "." && $filename != "..") { |
|
| 481 | - $fullpath = $fspath.$filename; |
|
| 482 | - $name = htmlspecialchars($filename); |
|
| 483 | - printf($format, |
|
| 484 | - number_format(filesize($fullpath)), |
|
| 485 | - strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)), |
|
| 486 | - '<a href="'.$name.'">'.urldecode($name).'</a>'); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - echo "</pre>"; |
|
| 491 | - |
|
| 492 | - closedir($handle); |
|
| 493 | - |
|
| 494 | - echo "</html>\n"; |
|
| 495 | - |
|
| 496 | - exit; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * PUT method handler |
|
| 501 | - * |
|
| 502 | - * @param array parameter passing array |
|
| 503 | - * @return bool true on success |
|
| 504 | - */ |
|
| 505 | - function PUT(&$options) |
|
| 506 | - { |
|
| 507 | - $fspath = $this->base . $options["path"]; |
|
| 508 | - |
|
| 509 | - $dir = dirname($fspath); |
|
| 510 | - if (!file_exists($dir) || !is_dir($dir)) { |
|
| 511 | - return "409 Conflict"; // TODO right status code for both? |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - $options["new"] = ! file_exists($fspath); |
|
| 515 | - |
|
| 516 | - if ($options["new"] && !$this->_is_writable($dir)) { |
|
| 517 | - return "403 Forbidden"; |
|
| 518 | - } |
|
| 519 | - if (!$options["new"] && !$this->_is_writable($fspath)) { |
|
| 520 | - return "403 Forbidden"; |
|
| 521 | - } |
|
| 522 | - if (!$options["new"] && is_dir($fspath)) { |
|
| 523 | - return "403 Forbidden"; |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - $fp = fopen($fspath, "w"); |
|
| 527 | - |
|
| 528 | - return $fp; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * MKCOL method handler |
|
| 534 | - * |
|
| 535 | - * @param array general parameter passing array |
|
| 536 | - * @return bool true on success |
|
| 537 | - */ |
|
| 538 | - function MKCOL($options) |
|
| 539 | - { |
|
| 540 | - $path = $this->base .$options["path"]; |
|
| 541 | - $parent = dirname($path); |
|
| 542 | - $name = basename($path); |
|
| 543 | - |
|
| 544 | - if (!file_exists($parent)) { |
|
| 545 | - return "409 Conflict"; |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - if (!is_dir($parent)) { |
|
| 549 | - return "403 Forbidden"; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - if ( file_exists($parent."/".$name) ) { |
|
| 553 | - return "405 Method not allowed"; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 557 | - return "415 Unsupported media type"; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - $stat = mkdir($parent."/".$name, 0777); |
|
| 561 | - if (!$stat) { |
|
| 562 | - return "403 Forbidden"; |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - return ("201 Created"); |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * DELETE method handler |
|
| 571 | - * |
|
| 572 | - * @param array general parameter passing array |
|
| 573 | - * @return bool true on success |
|
| 574 | - */ |
|
| 575 | - function DELETE($options) |
|
| 576 | - { |
|
| 577 | - $path = $this->base . "/" .$options["path"]; |
|
| 578 | - |
|
| 579 | - if (!file_exists($path)) { |
|
| 580 | - return "404 Not found"; |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - if (is_dir($path)) { |
|
| 584 | - $query = "DELETE FROM {$this->db_prefix}properties |
|
| 240 | + $res = mysql_query($query); |
|
| 241 | + while ($row = mysql_fetch_assoc($res)) { |
|
| 242 | + $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]); |
|
| 243 | + } |
|
| 244 | + mysql_free_result($res); |
|
| 245 | + |
|
| 246 | + return $info; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * detect if a given program is found in the search PATH |
|
| 251 | + * |
|
| 252 | + * helper function used by _mimetype() to detect if the |
|
| 253 | + * external 'file' utility is available |
|
| 254 | + * |
|
| 255 | + * @param string program name |
|
| 256 | + * @param string optional search path, defaults to $PATH |
|
| 257 | + * @return bool true if executable program found in path |
|
| 258 | + */ |
|
| 259 | + function _can_execute($name, $path = false) |
|
| 260 | + { |
|
| 261 | + // path defaults to PATH from environment if not set |
|
| 262 | + if ($path === false) { |
|
| 263 | + $path = getenv("PATH"); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + // check method depends on operating system |
|
| 267 | + if (!strncmp(PHP_OS, "WIN", 3)) { |
|
| 268 | + // on Windows an appropriate COM or EXE file needs to exist |
|
| 269 | + $exts = array(".exe", ".com"); |
|
| 270 | + $check_fn = "file_exists"; |
|
| 271 | + } else { |
|
| 272 | + // anywhere else we look for an executable file of that name |
|
| 273 | + $exts = array(""); |
|
| 274 | + $check_fn = "is_executable"; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + // now check the directories in the path for the program |
|
| 278 | + foreach (explode(PATH_SEPARATOR, $path) as $dir) { |
|
| 279 | + // skip invalid path entries |
|
| 280 | + if (!file_exists($dir)) continue; |
|
| 281 | + if (!is_dir($dir)) continue; |
|
| 282 | + |
|
| 283 | + // and now look for the file |
|
| 284 | + foreach ($exts as $ext) { |
|
| 285 | + if ($check_fn("$dir/$name".$ext)) return true; |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return false; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Check if path is readable by current user |
|
| 294 | + * |
|
| 295 | + * Allow extending classes to overwrite it |
|
| 296 | + * |
|
| 297 | + * @param string $fspath |
|
| 298 | + * @return boolean |
|
| 299 | + */ |
|
| 300 | + function _is_readable($fspath) |
|
| 301 | + { |
|
| 302 | + return is_readable($fspath); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Check if path is writable by current user |
|
| 307 | + * |
|
| 308 | + * Allow extending classes to overwrite it |
|
| 309 | + * |
|
| 310 | + * @param string $fspath |
|
| 311 | + * @return boolean |
|
| 312 | + */ |
|
| 313 | + function _is_writable($fspath) |
|
| 314 | + { |
|
| 315 | + return is_writable($fspath); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * try to detect the mime type of a file |
|
| 320 | + * |
|
| 321 | + * @param string file path |
|
| 322 | + * @return string guessed mime type |
|
| 323 | + */ |
|
| 324 | + function _mimetype($fspath) |
|
| 325 | + { |
|
| 326 | + if (is_dir($fspath)) { |
|
| 327 | + // directories are easy |
|
| 328 | + return "httpd/unix-directory"; |
|
| 329 | + } else if (function_exists("mime_content_type")) { |
|
| 330 | + // use mime magic extension if available |
|
| 331 | + $mime_type = mime_content_type($fspath); |
|
| 332 | + } else if ($this->_can_execute("file")) { |
|
| 333 | + // it looks like we have a 'file' command, |
|
| 334 | + // lets see it it does have mime support |
|
| 335 | + $fp = popen("file -i '$fspath' 2>/dev/null", "r"); |
|
| 336 | + $reply = fgets($fp); |
|
| 337 | + pclose($fp); |
|
| 338 | + |
|
| 339 | + // popen will not return an error if the binary was not found |
|
| 340 | + // and find may not have mime support using "-i" |
|
| 341 | + // so we test the format of the returned string |
|
| 342 | + |
|
| 343 | + // the reply begins with the requested filename |
|
| 344 | + if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) { |
|
| 345 | + $reply = substr($reply, strlen($fspath)+2); |
|
| 346 | + // followed by the mime type (maybe including options) |
|
| 347 | + if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) { |
|
| 348 | + $mime_type = $matches[0]; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + if (empty($mime_type)) { |
|
| 354 | + // Fallback solution: try to guess the type by the file extension |
|
| 355 | + // TODO: add more ... |
|
| 356 | + // TODO: it has been suggested to delegate mimetype detection |
|
| 357 | + // to apache but this has at least three issues: |
|
| 358 | + // - works only with apache |
|
| 359 | + // - needs file to be within the document tree |
|
| 360 | + // - requires apache mod_magic |
|
| 361 | + // TODO: can we use the registry for this on Windows? |
|
| 362 | + // OTOH if the server is Windos the clients are likely to |
|
| 363 | + // be Windows, too, and tend do ignore the Content-Type |
|
| 364 | + // anyway (overriding it with information taken from |
|
| 365 | + // the registry) |
|
| 366 | + // TODO: have a seperate PEAR class for mimetype detection? |
|
| 367 | + switch (strtolower(strrchr(basename($fspath), "."))) { |
|
| 368 | + case ".html": |
|
| 369 | + $mime_type = "text/html"; |
|
| 370 | + break; |
|
| 371 | + case ".gif": |
|
| 372 | + $mime_type = "image/gif"; |
|
| 373 | + break; |
|
| 374 | + case ".jpg": |
|
| 375 | + $mime_type = "image/jpeg"; |
|
| 376 | + break; |
|
| 377 | + default: |
|
| 378 | + $mime_type = "application/octet-stream"; |
|
| 379 | + break; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return $mime_type; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * HEAD method handler |
|
| 388 | + * |
|
| 389 | + * @param array parameter passing array |
|
| 390 | + * @return bool true on success |
|
| 391 | + */ |
|
| 392 | + function HEAD(&$options) |
|
| 393 | + { |
|
| 394 | + // get absolute fs path to requested resource |
|
| 395 | + $fspath = $this->base . $options["path"]; |
|
| 396 | + |
|
| 397 | + // sanity check |
|
| 398 | + if (!file_exists($fspath)) return false; |
|
| 399 | + |
|
| 400 | + // detect resource type |
|
| 401 | + $options['mimetype'] = $this->_mimetype($fspath); |
|
| 402 | + |
|
| 403 | + // detect modification time |
|
| 404 | + // see rfc2518, section 13.7 |
|
| 405 | + // some clients seem to treat this as a reverse rule |
|
| 406 | + // requiering a Last-Modified header if the getlastmodified header was set |
|
| 407 | + $options['mtime'] = filemtime($fspath); |
|
| 408 | + |
|
| 409 | + // detect resource size |
|
| 410 | + $options['size'] = filesize($fspath); |
|
| 411 | + |
|
| 412 | + return true; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * GET method handler |
|
| 417 | + * |
|
| 418 | + * @param array parameter passing array |
|
| 419 | + * @return bool true on success |
|
| 420 | + */ |
|
| 421 | + function GET(&$options) |
|
| 422 | + { |
|
| 423 | + // get absolute fs path to requested resource |
|
| 424 | + $fspath = $this->base . $options["path"]; |
|
| 425 | + |
|
| 426 | + // is this a collection? |
|
| 427 | + if (is_dir($fspath)) { |
|
| 428 | + return $this->GetDir($fspath, $options); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + // the header output is the same as for HEAD |
|
| 432 | + if (!$this->HEAD($options)) { |
|
| 433 | + return false; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + // no need to check result here, it is handled by the base class |
|
| 437 | + $options['stream'] = fopen($fspath, "r"); |
|
| 438 | + |
|
| 439 | + return true; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * GET method handler for directories |
|
| 444 | + * |
|
| 445 | + * This is a very simple mod_index lookalike. |
|
| 446 | + * See RFC 2518, Section 8.4 on GET/HEAD for collections |
|
| 447 | + * |
|
| 448 | + * @param string directory path |
|
| 449 | + * @return void function has to handle HTTP response itself |
|
| 450 | + */ |
|
| 451 | + function GetDir($fspath, &$options) |
|
| 452 | + { |
|
| 453 | + $path = $this->_slashify($options["path"]); |
|
| 454 | + if ($path != $options["path"]) { |
|
| 455 | + header("Location: ".$this->base_uri.$path); |
|
| 456 | + exit; |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + // fixed width directory column format |
|
| 460 | + $format = "%15s %-19s %-s\n"; |
|
| 461 | + |
|
| 462 | + if (!$this->_is_readable($fspath)) { |
|
| 463 | + return false; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + $handle = opendir($fspath); |
|
| 467 | + if (!$handle) { |
|
| 468 | + return false; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + echo "<html><head><title>Index of ".htmlspecialchars(urldecode($options['path']))."</title></head>\n"; |
|
| 472 | + |
|
| 473 | + echo "<h1>Index of ".htmlspecialchars($options['path'])."</h1>\n"; |
|
| 474 | + |
|
| 475 | + echo "<pre>"; |
|
| 476 | + printf($format, "Size", "Last modified", "Filename"); |
|
| 477 | + echo "<hr>"; |
|
| 478 | + |
|
| 479 | + while ($filename = readdir($handle)) { |
|
| 480 | + if ($filename != "." && $filename != "..") { |
|
| 481 | + $fullpath = $fspath.$filename; |
|
| 482 | + $name = htmlspecialchars($filename); |
|
| 483 | + printf($format, |
|
| 484 | + number_format(filesize($fullpath)), |
|
| 485 | + strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)), |
|
| 486 | + '<a href="'.$name.'">'.urldecode($name).'</a>'); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + echo "</pre>"; |
|
| 491 | + |
|
| 492 | + closedir($handle); |
|
| 493 | + |
|
| 494 | + echo "</html>\n"; |
|
| 495 | + |
|
| 496 | + exit; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * PUT method handler |
|
| 501 | + * |
|
| 502 | + * @param array parameter passing array |
|
| 503 | + * @return bool true on success |
|
| 504 | + */ |
|
| 505 | + function PUT(&$options) |
|
| 506 | + { |
|
| 507 | + $fspath = $this->base . $options["path"]; |
|
| 508 | + |
|
| 509 | + $dir = dirname($fspath); |
|
| 510 | + if (!file_exists($dir) || !is_dir($dir)) { |
|
| 511 | + return "409 Conflict"; // TODO right status code for both? |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + $options["new"] = ! file_exists($fspath); |
|
| 515 | + |
|
| 516 | + if ($options["new"] && !$this->_is_writable($dir)) { |
|
| 517 | + return "403 Forbidden"; |
|
| 518 | + } |
|
| 519 | + if (!$options["new"] && !$this->_is_writable($fspath)) { |
|
| 520 | + return "403 Forbidden"; |
|
| 521 | + } |
|
| 522 | + if (!$options["new"] && is_dir($fspath)) { |
|
| 523 | + return "403 Forbidden"; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + $fp = fopen($fspath, "w"); |
|
| 527 | + |
|
| 528 | + return $fp; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * MKCOL method handler |
|
| 534 | + * |
|
| 535 | + * @param array general parameter passing array |
|
| 536 | + * @return bool true on success |
|
| 537 | + */ |
|
| 538 | + function MKCOL($options) |
|
| 539 | + { |
|
| 540 | + $path = $this->base .$options["path"]; |
|
| 541 | + $parent = dirname($path); |
|
| 542 | + $name = basename($path); |
|
| 543 | + |
|
| 544 | + if (!file_exists($parent)) { |
|
| 545 | + return "409 Conflict"; |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + if (!is_dir($parent)) { |
|
| 549 | + return "403 Forbidden"; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + if ( file_exists($parent."/".$name) ) { |
|
| 553 | + return "405 Method not allowed"; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 557 | + return "415 Unsupported media type"; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + $stat = mkdir($parent."/".$name, 0777); |
|
| 561 | + if (!$stat) { |
|
| 562 | + return "403 Forbidden"; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + return ("201 Created"); |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * DELETE method handler |
|
| 571 | + * |
|
| 572 | + * @param array general parameter passing array |
|
| 573 | + * @return bool true on success |
|
| 574 | + */ |
|
| 575 | + function DELETE($options) |
|
| 576 | + { |
|
| 577 | + $path = $this->base . "/" .$options["path"]; |
|
| 578 | + |
|
| 579 | + if (!file_exists($path)) { |
|
| 580 | + return "404 Not found"; |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + if (is_dir($path)) { |
|
| 584 | + $query = "DELETE FROM {$this->db_prefix}properties |
|
| 585 | 585 | WHERE path LIKE '".$this->_slashify($options["path"])."%'"; |
| 586 | - mysql_query($query); |
|
| 587 | - System::rm(array("-rf", $path)); |
|
| 588 | - } else { |
|
| 589 | - unlink($path); |
|
| 590 | - } |
|
| 591 | - $query = "DELETE FROM {$this->db_prefix}properties |
|
| 586 | + mysql_query($query); |
|
| 587 | + System::rm(array("-rf", $path)); |
|
| 588 | + } else { |
|
| 589 | + unlink($path); |
|
| 590 | + } |
|
| 591 | + $query = "DELETE FROM {$this->db_prefix}properties |
|
| 592 | 592 | WHERE path = '$options[path]'"; |
| 593 | - mysql_query($query); |
|
| 594 | - |
|
| 595 | - return "204 No Content"; |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * MOVE method handler |
|
| 601 | - * |
|
| 602 | - * @param array general parameter passing array |
|
| 603 | - * @return bool true on success |
|
| 604 | - */ |
|
| 605 | - function MOVE($options) |
|
| 606 | - { |
|
| 607 | - return $this->COPY($options, true); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * COPY method handler |
|
| 612 | - * |
|
| 613 | - * @param array general parameter passing array |
|
| 614 | - * @return bool true on success |
|
| 615 | - */ |
|
| 616 | - function COPY($options, $del=false) |
|
| 617 | - { |
|
| 618 | - // TODO Property updates still broken (Litmus should detect this?) |
|
| 619 | - |
|
| 620 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 621 | - return "415 Unsupported media type"; |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - // no copying to different WebDAV Servers yet |
|
| 625 | - if (isset($options["dest_url"])) { |
|
| 626 | - return "502 bad gateway"; |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - $source = $this->base . $options["path"]; |
|
| 630 | - if (!file_exists($source)) { |
|
| 631 | - return "404 Not found"; |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - if (is_dir($source)) { // resource is a collection |
|
| 635 | - switch ($options["depth"]) { |
|
| 636 | - case "infinity": // valid |
|
| 637 | - break; |
|
| 638 | - case "0": // valid for COPY only |
|
| 639 | - if ($del) { // MOVE? |
|
| 640 | - return "400 Bad request"; |
|
| 641 | - } |
|
| 642 | - break; |
|
| 643 | - case "1": // invalid for both COPY and MOVE |
|
| 644 | - default: |
|
| 645 | - return "400 Bad request"; |
|
| 646 | - } |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - $dest = $this->base . $options["dest"]; |
|
| 650 | - $destdir = dirname($dest); |
|
| 651 | - |
|
| 652 | - if (!file_exists($destdir) || !is_dir($destdir)) { |
|
| 653 | - return "409 Conflict"; |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - |
|
| 657 | - $new = !file_exists($dest); |
|
| 658 | - $existing_col = false; |
|
| 659 | - |
|
| 660 | - if (!$new) { |
|
| 661 | - if ($del && is_dir($dest)) { |
|
| 662 | - if (!$options["overwrite"]) { |
|
| 663 | - return "412 precondition failed"; |
|
| 664 | - } |
|
| 665 | - $dest .= basename($source); |
|
| 666 | - if (file_exists($dest)) { |
|
| 667 | - $options["dest"] .= basename($source); |
|
| 668 | - } else { |
|
| 669 | - $new = true; |
|
| 670 | - $existing_col = true; |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - if (!$new) { |
|
| 676 | - if ($options["overwrite"]) { |
|
| 677 | - $stat = $this->DELETE(array("path" => $options["dest"])); |
|
| 678 | - if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
| 679 | - return $stat; |
|
| 680 | - } |
|
| 681 | - } else { |
|
| 682 | - return "412 precondition failed"; |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - if ($del) { |
|
| 687 | - if (!rename($source, $dest)) { |
|
| 688 | - return "500 Internal server error"; |
|
| 689 | - } |
|
| 690 | - $destpath = $this->_unslashify($options["dest"]); |
|
| 691 | - if (is_dir($source)) { |
|
| 692 | - $query = "UPDATE {$this->db_prefix}properties |
|
| 593 | + mysql_query($query); |
|
| 594 | + |
|
| 595 | + return "204 No Content"; |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * MOVE method handler |
|
| 601 | + * |
|
| 602 | + * @param array general parameter passing array |
|
| 603 | + * @return bool true on success |
|
| 604 | + */ |
|
| 605 | + function MOVE($options) |
|
| 606 | + { |
|
| 607 | + return $this->COPY($options, true); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + /** |
|
| 611 | + * COPY method handler |
|
| 612 | + * |
|
| 613 | + * @param array general parameter passing array |
|
| 614 | + * @return bool true on success |
|
| 615 | + */ |
|
| 616 | + function COPY($options, $del=false) |
|
| 617 | + { |
|
| 618 | + // TODO Property updates still broken (Litmus should detect this?) |
|
| 619 | + |
|
| 620 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 621 | + return "415 Unsupported media type"; |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + // no copying to different WebDAV Servers yet |
|
| 625 | + if (isset($options["dest_url"])) { |
|
| 626 | + return "502 bad gateway"; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + $source = $this->base . $options["path"]; |
|
| 630 | + if (!file_exists($source)) { |
|
| 631 | + return "404 Not found"; |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + if (is_dir($source)) { // resource is a collection |
|
| 635 | + switch ($options["depth"]) { |
|
| 636 | + case "infinity": // valid |
|
| 637 | + break; |
|
| 638 | + case "0": // valid for COPY only |
|
| 639 | + if ($del) { // MOVE? |
|
| 640 | + return "400 Bad request"; |
|
| 641 | + } |
|
| 642 | + break; |
|
| 643 | + case "1": // invalid for both COPY and MOVE |
|
| 644 | + default: |
|
| 645 | + return "400 Bad request"; |
|
| 646 | + } |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + $dest = $this->base . $options["dest"]; |
|
| 650 | + $destdir = dirname($dest); |
|
| 651 | + |
|
| 652 | + if (!file_exists($destdir) || !is_dir($destdir)) { |
|
| 653 | + return "409 Conflict"; |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + |
|
| 657 | + $new = !file_exists($dest); |
|
| 658 | + $existing_col = false; |
|
| 659 | + |
|
| 660 | + if (!$new) { |
|
| 661 | + if ($del && is_dir($dest)) { |
|
| 662 | + if (!$options["overwrite"]) { |
|
| 663 | + return "412 precondition failed"; |
|
| 664 | + } |
|
| 665 | + $dest .= basename($source); |
|
| 666 | + if (file_exists($dest)) { |
|
| 667 | + $options["dest"] .= basename($source); |
|
| 668 | + } else { |
|
| 669 | + $new = true; |
|
| 670 | + $existing_col = true; |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + if (!$new) { |
|
| 676 | + if ($options["overwrite"]) { |
|
| 677 | + $stat = $this->DELETE(array("path" => $options["dest"])); |
|
| 678 | + if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
| 679 | + return $stat; |
|
| 680 | + } |
|
| 681 | + } else { |
|
| 682 | + return "412 precondition failed"; |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + if ($del) { |
|
| 687 | + if (!rename($source, $dest)) { |
|
| 688 | + return "500 Internal server error"; |
|
| 689 | + } |
|
| 690 | + $destpath = $this->_unslashify($options["dest"]); |
|
| 691 | + if (is_dir($source)) { |
|
| 692 | + $query = "UPDATE {$this->db_prefix}properties |
|
| 693 | 693 | SET path = REPLACE(path, '".$options["path"]."', '".$destpath."') |
| 694 | 694 | WHERE path LIKE '".$this->_slashify($options["path"])."%'"; |
| 695 | - mysql_query($query); |
|
| 696 | - } |
|
| 695 | + mysql_query($query); |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - $query = "UPDATE {$this->db_prefix}properties |
|
| 698 | + $query = "UPDATE {$this->db_prefix}properties |
|
| 699 | 699 | SET path = '".$destpath."' |
| 700 | 700 | WHERE path = '".$options["path"]."'"; |
| 701 | - mysql_query($query); |
|
| 702 | - } else { |
|
| 703 | - if (is_dir($source) && $options["depth"] == "infinity") { // no find for depth="0" |
|
| 704 | - $files = System::find($source); |
|
| 705 | - $files = array_reverse($files); |
|
| 706 | - } else { |
|
| 707 | - $files = array($source); |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - if (!is_array($files) || empty($files)) { |
|
| 711 | - return "500 Internal server error"; |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - |
|
| 715 | - foreach ($files as $file) { |
|
| 716 | - if (is_dir($file)) { |
|
| 717 | - $file = $this->_slashify($file); |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - $destfile = str_replace($source, $dest, $file); |
|
| 721 | - |
|
| 722 | - if (is_dir($file)) { |
|
| 723 | - if (!file_exists($destfile)) { |
|
| 724 | - if (!$this->_is_writable(dirname($destfile))) { |
|
| 725 | - return "403 Forbidden"; |
|
| 726 | - } |
|
| 727 | - if (!mkdir($destfile)) { |
|
| 728 | - return "409 Conflict"; |
|
| 729 | - } |
|
| 730 | - } else if (!is_dir($destfile)) { |
|
| 731 | - return "409 Conflict"; |
|
| 732 | - } |
|
| 733 | - } else { |
|
| 734 | - |
|
| 735 | - if (!copy($file, $destfile)) { |
|
| 736 | - return "409 Conflict"; |
|
| 737 | - } |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - $query = "INSERT INTO {$this->db_prefix}properties |
|
| 701 | + mysql_query($query); |
|
| 702 | + } else { |
|
| 703 | + if (is_dir($source) && $options["depth"] == "infinity") { // no find for depth="0" |
|
| 704 | + $files = System::find($source); |
|
| 705 | + $files = array_reverse($files); |
|
| 706 | + } else { |
|
| 707 | + $files = array($source); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + if (!is_array($files) || empty($files)) { |
|
| 711 | + return "500 Internal server error"; |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + |
|
| 715 | + foreach ($files as $file) { |
|
| 716 | + if (is_dir($file)) { |
|
| 717 | + $file = $this->_slashify($file); |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + $destfile = str_replace($source, $dest, $file); |
|
| 721 | + |
|
| 722 | + if (is_dir($file)) { |
|
| 723 | + if (!file_exists($destfile)) { |
|
| 724 | + if (!$this->_is_writable(dirname($destfile))) { |
|
| 725 | + return "403 Forbidden"; |
|
| 726 | + } |
|
| 727 | + if (!mkdir($destfile)) { |
|
| 728 | + return "409 Conflict"; |
|
| 729 | + } |
|
| 730 | + } else if (!is_dir($destfile)) { |
|
| 731 | + return "409 Conflict"; |
|
| 732 | + } |
|
| 733 | + } else { |
|
| 734 | + |
|
| 735 | + if (!copy($file, $destfile)) { |
|
| 736 | + return "409 Conflict"; |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + $query = "INSERT INTO {$this->db_prefix}properties |
|
| 742 | 742 | SELECT * |
| 743 | 743 | FROM {$this->db_prefix}properties |
| 744 | 744 | WHERE path = '".$options['path']."'"; |
| 745 | - } |
|
| 746 | - |
|
| 747 | - return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
| 748 | - } |
|
| 749 | - |
|
| 750 | - /** |
|
| 751 | - * PROPPATCH method handler |
|
| 752 | - * |
|
| 753 | - * @param array general parameter passing array |
|
| 754 | - * @return bool true on success |
|
| 755 | - */ |
|
| 756 | - function PROPPATCH(&$options) |
|
| 757 | - { |
|
| 758 | - global $prefs, $tab; |
|
| 759 | - |
|
| 760 | - $msg = ""; |
|
| 761 | - $path = $options["path"]; |
|
| 762 | - $dir = dirname($path)."/"; |
|
| 763 | - $base = basename($path); |
|
| 764 | - |
|
| 765 | - foreach ($options["props"] as $key => $prop) { |
|
| 766 | - if ($prop["ns"] == "DAV:") { |
|
| 767 | - $options["props"][$key]['status'] = "403 Forbidden"; |
|
| 768 | - } else { |
|
| 769 | - if (isset($prop["val"])) { |
|
| 770 | - $query = "REPLACE INTO {$this->db_prefix}properties |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + return ($new && !$existing_col) ? "201 Created" : "204 No Content"; |
|
| 748 | + } |
|
| 749 | + |
|
| 750 | + /** |
|
| 751 | + * PROPPATCH method handler |
|
| 752 | + * |
|
| 753 | + * @param array general parameter passing array |
|
| 754 | + * @return bool true on success |
|
| 755 | + */ |
|
| 756 | + function PROPPATCH(&$options) |
|
| 757 | + { |
|
| 758 | + global $prefs, $tab; |
|
| 759 | + |
|
| 760 | + $msg = ""; |
|
| 761 | + $path = $options["path"]; |
|
| 762 | + $dir = dirname($path)."/"; |
|
| 763 | + $base = basename($path); |
|
| 764 | + |
|
| 765 | + foreach ($options["props"] as $key => $prop) { |
|
| 766 | + if ($prop["ns"] == "DAV:") { |
|
| 767 | + $options["props"][$key]['status'] = "403 Forbidden"; |
|
| 768 | + } else { |
|
| 769 | + if (isset($prop["val"])) { |
|
| 770 | + $query = "REPLACE INTO {$this->db_prefix}properties |
|
| 771 | 771 | SET path = '$options[path]' |
| 772 | 772 | , name = '$prop[name]' |
| 773 | 773 | , ns= '$prop[ns]' |
| 774 | 774 | , value = '$prop[val]'"; |
| 775 | - } else { |
|
| 776 | - $query = "DELETE FROM {$this->db_prefix}properties |
|
| 775 | + } else { |
|
| 776 | + $query = "DELETE FROM {$this->db_prefix}properties |
|
| 777 | 777 | WHERE path = '$options[path]' |
| 778 | 778 | AND name = '$prop[name]' |
| 779 | 779 | AND ns = '$prop[ns]'"; |
| 780 | - } |
|
| 781 | - mysql_query($query); |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - return ""; |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * LOCK method handler |
|
| 791 | - * |
|
| 792 | - * @param array general parameter passing array |
|
| 793 | - * @return bool true on success |
|
| 794 | - */ |
|
| 795 | - function LOCK(&$options) |
|
| 796 | - { |
|
| 797 | - // get absolute fs path to requested resource |
|
| 798 | - $fspath = $this->base . $options["path"]; |
|
| 799 | - |
|
| 800 | - // TODO recursive locks on directories not supported yet |
|
| 801 | - // makes litmus test "32. lock_collection" fail |
|
| 802 | - if (is_dir($fspath) && !empty($options["depth"])) { |
|
| 803 | - return "409 Conflict"; |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - $options["timeout"] = time()+300; // 5min. hardcoded |
|
| 807 | - |
|
| 808 | - if (isset($options["update"])) { // Lock Update |
|
| 809 | - $where = "WHERE path = '$options[path]' AND token = '$options[update]'"; |
|
| 810 | - |
|
| 811 | - $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where"; |
|
| 812 | - $res = mysql_query($query); |
|
| 813 | - $row = mysql_fetch_assoc($res); |
|
| 814 | - mysql_free_result($res); |
|
| 815 | - |
|
| 816 | - if (is_array($row)) { |
|
| 817 | - $query = "UPDATE {$this->db_prefix}locks |
|
| 780 | + } |
|
| 781 | + mysql_query($query); |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + return ""; |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * LOCK method handler |
|
| 791 | + * |
|
| 792 | + * @param array general parameter passing array |
|
| 793 | + * @return bool true on success |
|
| 794 | + */ |
|
| 795 | + function LOCK(&$options) |
|
| 796 | + { |
|
| 797 | + // get absolute fs path to requested resource |
|
| 798 | + $fspath = $this->base . $options["path"]; |
|
| 799 | + |
|
| 800 | + // TODO recursive locks on directories not supported yet |
|
| 801 | + // makes litmus test "32. lock_collection" fail |
|
| 802 | + if (is_dir($fspath) && !empty($options["depth"])) { |
|
| 803 | + return "409 Conflict"; |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + $options["timeout"] = time()+300; // 5min. hardcoded |
|
| 807 | + |
|
| 808 | + if (isset($options["update"])) { // Lock Update |
|
| 809 | + $where = "WHERE path = '$options[path]' AND token = '$options[update]'"; |
|
| 810 | + |
|
| 811 | + $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where"; |
|
| 812 | + $res = mysql_query($query); |
|
| 813 | + $row = mysql_fetch_assoc($res); |
|
| 814 | + mysql_free_result($res); |
|
| 815 | + |
|
| 816 | + if (is_array($row)) { |
|
| 817 | + $query = "UPDATE {$this->db_prefix}locks |
|
| 818 | 818 | SET expires = '$options[timeout]' |
| 819 | 819 | , modified = ".time()." |
| 820 | 820 | $where"; |
| 821 | - mysql_query($query); |
|
| 821 | + mysql_query($query); |
|
| 822 | 822 | |
| 823 | - $options['owner'] = $row['owner']; |
|
| 824 | - $options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared"; |
|
| 825 | - $options['type'] = $row["exclusivelock"] ? "write" : "read"; |
|
| 823 | + $options['owner'] = $row['owner']; |
|
| 824 | + $options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared"; |
|
| 825 | + $options['type'] = $row["exclusivelock"] ? "write" : "read"; |
|
| 826 | 826 | |
| 827 | - return true; |
|
| 828 | - } else { |
|
| 829 | - return false; |
|
| 830 | - } |
|
| 831 | - } |
|
| 827 | + return true; |
|
| 828 | + } else { |
|
| 829 | + return false; |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | 832 | |
| 833 | - $query = "INSERT INTO {$this->db_prefix}locks |
|
| 833 | + $query = "INSERT INTO {$this->db_prefix}locks |
|
| 834 | 834 | SET token = '$options[locktoken]' |
| 835 | 835 | , path = '$options[path]' |
| 836 | 836 | , created = ".time()." |
@@ -838,76 +838,76 @@ discard block |
||
| 838 | 838 | , owner = '$options[owner]' |
| 839 | 839 | , expires = '$options[timeout]' |
| 840 | 840 | , exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0") |
| 841 | - ; |
|
| 842 | - mysql_query($query); |
|
| 843 | - |
|
| 844 | - return mysql_affected_rows() ? "200 OK" : "409 Conflict"; |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - /** |
|
| 848 | - * UNLOCK method handler |
|
| 849 | - * |
|
| 850 | - * @param array general parameter passing array |
|
| 851 | - * @return bool true on success |
|
| 852 | - */ |
|
| 853 | - function UNLOCK(&$options) |
|
| 854 | - { |
|
| 855 | - $query = "DELETE FROM {$this->db_prefix}locks |
|
| 841 | + ; |
|
| 842 | + mysql_query($query); |
|
| 843 | + |
|
| 844 | + return mysql_affected_rows() ? "200 OK" : "409 Conflict"; |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + /** |
|
| 848 | + * UNLOCK method handler |
|
| 849 | + * |
|
| 850 | + * @param array general parameter passing array |
|
| 851 | + * @return bool true on success |
|
| 852 | + */ |
|
| 853 | + function UNLOCK(&$options) |
|
| 854 | + { |
|
| 855 | + $query = "DELETE FROM {$this->db_prefix}locks |
|
| 856 | 856 | WHERE path = '$options[path]' |
| 857 | 857 | AND token = '$options[token]'"; |
| 858 | - mysql_query($query); |
|
| 859 | - |
|
| 860 | - return mysql_affected_rows() ? "204 No Content" : "409 Conflict"; |
|
| 861 | - } |
|
| 862 | - |
|
| 863 | - /** |
|
| 864 | - * checkLock() helper |
|
| 865 | - * |
|
| 866 | - * @param string resource path to check for locks |
|
| 867 | - * @return bool true on success |
|
| 868 | - */ |
|
| 869 | - function checkLock($path) |
|
| 870 | - { |
|
| 871 | - $result = false; |
|
| 872 | - |
|
| 873 | - $query = "SELECT owner, token, created, modified, expires, exclusivelock |
|
| 858 | + mysql_query($query); |
|
| 859 | + |
|
| 860 | + return mysql_affected_rows() ? "204 No Content" : "409 Conflict"; |
|
| 861 | + } |
|
| 862 | + |
|
| 863 | + /** |
|
| 864 | + * checkLock() helper |
|
| 865 | + * |
|
| 866 | + * @param string resource path to check for locks |
|
| 867 | + * @return bool true on success |
|
| 868 | + */ |
|
| 869 | + function checkLock($path) |
|
| 870 | + { |
|
| 871 | + $result = false; |
|
| 872 | + |
|
| 873 | + $query = "SELECT owner, token, created, modified, expires, exclusivelock |
|
| 874 | 874 | FROM {$this->db_prefix}locks |
| 875 | 875 | WHERE path = '$path' |
| 876 | 876 | "; |
| 877 | - $res = mysql_query($query); |
|
| 878 | - |
|
| 879 | - if ($res) { |
|
| 880 | - $row = mysql_fetch_array($res); |
|
| 881 | - mysql_free_result($res); |
|
| 882 | - |
|
| 883 | - if ($row) { |
|
| 884 | - $result = array( "type" => "write", |
|
| 885 | - "scope" => $row["exclusivelock"] ? "exclusive" : "shared", |
|
| 886 | - "depth" => 0, |
|
| 887 | - "owner" => $row['owner'], |
|
| 888 | - "token" => $row['token'], |
|
| 889 | - "created" => $row['created'], |
|
| 890 | - "modified" => $row['modified'], |
|
| 891 | - "expires" => $row['expires'] |
|
| 892 | - ); |
|
| 893 | - } |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - return $result; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - |
|
| 900 | - /** |
|
| 901 | - * create database tables for property and lock storage |
|
| 902 | - * |
|
| 903 | - * @param void |
|
| 904 | - * @return bool true on success |
|
| 905 | - */ |
|
| 906 | - function create_database() |
|
| 907 | - { |
|
| 908 | - // TODO |
|
| 909 | - return false; |
|
| 910 | - } |
|
| 877 | + $res = mysql_query($query); |
|
| 878 | + |
|
| 879 | + if ($res) { |
|
| 880 | + $row = mysql_fetch_array($res); |
|
| 881 | + mysql_free_result($res); |
|
| 882 | + |
|
| 883 | + if ($row) { |
|
| 884 | + $result = array( "type" => "write", |
|
| 885 | + "scope" => $row["exclusivelock"] ? "exclusive" : "shared", |
|
| 886 | + "depth" => 0, |
|
| 887 | + "owner" => $row['owner'], |
|
| 888 | + "token" => $row['token'], |
|
| 889 | + "created" => $row['created'], |
|
| 890 | + "modified" => $row['modified'], |
|
| 891 | + "expires" => $row['expires'] |
|
| 892 | + ); |
|
| 893 | + } |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + return $result; |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + |
|
| 900 | + /** |
|
| 901 | + * create database tables for property and lock storage |
|
| 902 | + * |
|
| 903 | + * @param void |
|
| 904 | + * @return bool true on success |
|
| 905 | + */ |
|
| 906 | + function create_database() |
|
| 907 | + { |
|
| 908 | + // TODO |
|
| 909 | + return false; |
|
| 910 | + } |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | |
@@ -365,18 +365,18 @@ discard block |
||
| 365 | 365 | // the registry) |
| 366 | 366 | // TODO: have a seperate PEAR class for mimetype detection? |
| 367 | 367 | switch (strtolower(strrchr(basename($fspath), "."))) { |
| 368 | - case ".html": |
|
| 369 | - $mime_type = "text/html"; |
|
| 370 | - break; |
|
| 371 | - case ".gif": |
|
| 372 | - $mime_type = "image/gif"; |
|
| 373 | - break; |
|
| 374 | - case ".jpg": |
|
| 375 | - $mime_type = "image/jpeg"; |
|
| 376 | - break; |
|
| 377 | - default: |
|
| 378 | - $mime_type = "application/octet-stream"; |
|
| 379 | - break; |
|
| 368 | + case ".html": |
|
| 369 | + $mime_type = "text/html"; |
|
| 370 | + break; |
|
| 371 | + case ".gif": |
|
| 372 | + $mime_type = "image/gif"; |
|
| 373 | + break; |
|
| 374 | + case ".jpg": |
|
| 375 | + $mime_type = "image/jpeg"; |
|
| 376 | + break; |
|
| 377 | + default: |
|
| 378 | + $mime_type = "application/octet-stream"; |
|
| 379 | + break; |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -633,16 +633,16 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | if (is_dir($source)) { // resource is a collection |
| 635 | 635 | switch ($options["depth"]) { |
| 636 | - case "infinity": // valid |
|
| 637 | - break; |
|
| 638 | - case "0": // valid for COPY only |
|
| 639 | - if ($del) { // MOVE? |
|
| 640 | - return "400 Bad request"; |
|
| 641 | - } |
|
| 642 | - break; |
|
| 643 | - case "1": // invalid for both COPY and MOVE |
|
| 644 | - default: |
|
| 645 | - return "400 Bad request"; |
|
| 636 | + case "infinity": // valid |
|
| 637 | + break; |
|
| 638 | + case "0": // valid for COPY only |
|
| 639 | + if ($del) { // MOVE? |
|
| 640 | + return "400 Bad request"; |
|
| 641 | + } |
|
| 642 | + break; |
|
| 643 | + case "1": // invalid for both COPY and MOVE |
|
| 644 | + default: |
|
| 645 | + return "400 Bad request"; |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | function PROPFIND(&$options, &$files) |
| 152 | 152 | { |
| 153 | 153 | // get absolute fs path to requested resource |
| 154 | - $fspath = $this->base . $options["path"]; |
|
| 154 | + $fspath = $this->base.$options["path"]; |
|
| 155 | 155 | |
| 156 | 156 | // sanity check |
| 157 | 157 | if (!file_exists($fspath)) { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | function fileinfo($path) |
| 199 | 199 | { |
| 200 | 200 | // map URI path to filesystem path |
| 201 | - $fspath = $this->base . $path; |
|
| 201 | + $fspath = $this->base.$path; |
|
| 202 | 202 | |
| 203 | 203 | // create result array |
| 204 | 204 | $info = array(); |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | $info["props"][] = $this->mkprop("displayname", strtoupper($path)); |
| 211 | 211 | |
| 212 | 212 | // creation and modification time |
| 213 | - $info["props"][] = $this->mkprop("creationdate", filectime($fspath)); |
|
| 213 | + $info["props"][] = $this->mkprop("creationdate", filectime($fspath)); |
|
| 214 | 214 | $info["props"][] = $this->mkprop("getlastmodified", filemtime($fspath)); |
| 215 | 215 | |
| 216 | 216 | // Microsoft extensions: last access time and 'hidden' status |
| 217 | - $info["props"][] = $this->mkprop("lastaccessed", fileatime($fspath)); |
|
| 217 | + $info["props"][] = $this->mkprop("lastaccessed", fileatime($fspath)); |
|
| 218 | 218 | $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1))); |
| 219 | 219 | |
| 220 | 220 | // type and size (caller already made sure that path exists) |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | // so we test the format of the returned string |
| 342 | 342 | |
| 343 | 343 | // the reply begins with the requested filename |
| 344 | - if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) { |
|
| 345 | - $reply = substr($reply, strlen($fspath)+2); |
|
| 344 | + if (!strncmp($reply, "$fspath: ", strlen($fspath) + 2)) { |
|
| 345 | + $reply = substr($reply, strlen($fspath) + 2); |
|
| 346 | 346 | // followed by the mime type (maybe including options) |
| 347 | 347 | if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) { |
| 348 | 348 | $mime_type = $matches[0]; |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | function HEAD(&$options) |
| 393 | 393 | { |
| 394 | 394 | // get absolute fs path to requested resource |
| 395 | - $fspath = $this->base . $options["path"]; |
|
| 395 | + $fspath = $this->base.$options["path"]; |
|
| 396 | 396 | |
| 397 | 397 | // sanity check |
| 398 | 398 | if (!file_exists($fspath)) return false; |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | function GET(&$options) |
| 422 | 422 | { |
| 423 | 423 | // get absolute fs path to requested resource |
| 424 | - $fspath = $this->base . $options["path"]; |
|
| 424 | + $fspath = $this->base.$options["path"]; |
|
| 425 | 425 | |
| 426 | 426 | // is this a collection? |
| 427 | 427 | if (is_dir($fspath)) { |
@@ -504,14 +504,14 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | function PUT(&$options) |
| 506 | 506 | { |
| 507 | - $fspath = $this->base . $options["path"]; |
|
| 507 | + $fspath = $this->base.$options["path"]; |
|
| 508 | 508 | |
| 509 | 509 | $dir = dirname($fspath); |
| 510 | 510 | if (!file_exists($dir) || !is_dir($dir)) { |
| 511 | 511 | return "409 Conflict"; // TODO right status code for both? |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $options["new"] = ! file_exists($fspath); |
|
| 514 | + $options["new"] = !file_exists($fspath); |
|
| 515 | 515 | |
| 516 | 516 | if ($options["new"] && !$this->_is_writable($dir)) { |
| 517 | 517 | return "403 Forbidden"; |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | */ |
| 538 | 538 | function MKCOL($options) |
| 539 | 539 | { |
| 540 | - $path = $this->base .$options["path"]; |
|
| 540 | + $path = $this->base.$options["path"]; |
|
| 541 | 541 | $parent = dirname($path); |
| 542 | 542 | $name = basename($path); |
| 543 | 543 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | return "403 Forbidden"; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - if ( file_exists($parent."/".$name) ) { |
|
| 552 | + if (file_exists($parent."/".$name)) { |
|
| 553 | 553 | return "405 Method not allowed"; |
| 554 | 554 | } |
| 555 | 555 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | */ |
| 575 | 575 | function DELETE($options) |
| 576 | 576 | { |
| 577 | - $path = $this->base . "/" .$options["path"]; |
|
| 577 | + $path = $this->base."/".$options["path"]; |
|
| 578 | 578 | |
| 579 | 579 | if (!file_exists($path)) { |
| 580 | 580 | return "404 Not found"; |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | * @param array general parameter passing array |
| 614 | 614 | * @return bool true on success |
| 615 | 615 | */ |
| 616 | - function COPY($options, $del=false) |
|
| 616 | + function COPY($options, $del = false) |
|
| 617 | 617 | { |
| 618 | 618 | // TODO Property updates still broken (Litmus should detect this?) |
| 619 | 619 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | return "502 bad gateway"; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - $source = $this->base . $options["path"]; |
|
| 629 | + $source = $this->base.$options["path"]; |
|
| 630 | 630 | if (!file_exists($source)) { |
| 631 | 631 | return "404 Not found"; |
| 632 | 632 | } |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - $dest = $this->base . $options["dest"]; |
|
| 649 | + $dest = $this->base.$options["dest"]; |
|
| 650 | 650 | $destdir = dirname($dest); |
| 651 | 651 | |
| 652 | 652 | if (!file_exists($destdir) || !is_dir($destdir)) { |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | function LOCK(&$options) |
| 796 | 796 | { |
| 797 | 797 | // get absolute fs path to requested resource |
| 798 | - $fspath = $this->base . $options["path"]; |
|
| 798 | + $fspath = $this->base.$options["path"]; |
|
| 799 | 799 | |
| 800 | 800 | // TODO recursive locks on directories not supported yet |
| 801 | 801 | // makes litmus test "32. lock_collection" fail |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | return "409 Conflict"; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | - $options["timeout"] = time()+300; // 5min. hardcoded |
|
| 806 | + $options["timeout"] = time() + 300; // 5min. hardcoded |
|
| 807 | 807 | |
| 808 | 808 | if (isset($options["update"])) { // Lock Update |
| 809 | 809 | $where = "WHERE path = '$options[path]' AND token = '$options[update]'"; |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | |
| 823 | 823 | $options['owner'] = $row['owner']; |
| 824 | 824 | $options['scope'] = $row["exclusivelock"] ? "exclusive" : "shared"; |
| 825 | - $options['type'] = $row["exclusivelock"] ? "write" : "read"; |
|
| 825 | + $options['type'] = $row["exclusivelock"] ? "write" : "read"; |
|
| 826 | 826 | |
| 827 | 827 | return true; |
| 828 | 828 | } else { |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | , modified = ".time()." |
| 838 | 838 | , owner = '$options[owner]' |
| 839 | 839 | , expires = '$options[timeout]' |
| 840 | - , exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0") |
|
| 840 | + , exclusivelock = ".($options['scope'] === "exclusive" ? "1" : "0") |
|
| 841 | 841 | ; |
| 842 | 842 | mysql_query($query); |
| 843 | 843 | |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | mysql_free_result($res); |
| 882 | 882 | |
| 883 | 883 | if ($row) { |
| 884 | - $result = array( "type" => "write", |
|
| 884 | + $result = array("type" => "write", |
|
| 885 | 885 | "scope" => $row["exclusivelock"] ? "exclusive" : "shared", |
| 886 | 886 | "depth" => 0, |
| 887 | 887 | "owner" => $row['owner'], |
@@ -105,15 +105,19 @@ discard block |
||
| 105 | 105 | // special treatment for litmus compliance test |
| 106 | 106 | // reply on its identifier header |
| 107 | 107 | // not needed for the test itself but eases debugging |
| 108 | - if (isset($this->_SERVER['HTTP_X_LITMUS'])) { |
|
| 108 | + if (isset($this->_SERVER['HTTP_X_LITMUS'])) |
|
| 109 | + { |
|
| 109 | 110 | error_log("Litmus test ".$this->_SERVER['HTTP_X_LITMUS']); |
| 110 | 111 | header("X-Litmus-reply: ".$this->_SERVER['HTTP_X_LITMUS']); |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | 114 | // set root directory, defaults to webserver document root if not set |
| 114 | - if ($base) { |
|
| 115 | + if ($base) |
|
| 116 | + { |
|
| 115 | 117 | $this->base = realpath($base); // TODO throw if not a directory |
| 116 | - } else if (!$this->base) { |
|
| 118 | + } |
|
| 119 | + else if (!$this->base) |
|
| 120 | + { |
|
| 117 | 121 | $this->base = $this->_SERVER['DOCUMENT_ROOT']; |
| 118 | 122 | } |
| 119 | 123 | |
@@ -154,7 +158,8 @@ discard block |
||
| 154 | 158 | $fspath = $this->base . $options["path"]; |
| 155 | 159 | |
| 156 | 160 | // sanity check |
| 157 | - if (!file_exists($fspath)) { |
|
| 161 | + if (!file_exists($fspath)) |
|
| 162 | + { |
|
| 158 | 163 | return false; |
| 159 | 164 | } |
| 160 | 165 | |
@@ -165,7 +170,8 @@ discard block |
||
| 165 | 170 | $files["files"][] = $this->fileinfo($options["path"]); |
| 166 | 171 | |
| 167 | 172 | // information for contained resources requested? |
| 168 | - if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) { |
|
| 173 | + if (!empty($options["depth"]) && is_dir($fspath) && $this->_is_readable($fspath)) |
|
| 174 | + { |
|
| 169 | 175 | |
| 170 | 176 | // make sure path ends with '/' |
| 171 | 177 | $options["path"] = $this->_slashify($options["path"]); |
@@ -173,10 +179,13 @@ discard block |
||
| 173 | 179 | // try to open directory |
| 174 | 180 | $handle = opendir($fspath); |
| 175 | 181 | |
| 176 | - if ($handle) { |
|
| 182 | + if ($handle) |
|
| 183 | + { |
|
| 177 | 184 | // ok, now get all its contents |
| 178 | - while ($filename = readdir($handle)) { |
|
| 179 | - if ($filename != "." && $filename != "..") { |
|
| 185 | + while ($filename = readdir($handle)) |
|
| 186 | + { |
|
| 187 | + if ($filename != "." && $filename != "..") |
|
| 188 | + { |
|
| 180 | 189 | $files["files"][] = $this->fileinfo($options["path"].$filename); |
| 181 | 190 | } |
| 182 | 191 | } |
@@ -218,16 +227,22 @@ discard block |
||
| 218 | 227 | $info["props"][] = $this->mkprop("ishidden", ('.' === substr(basename($fspath), 0, 1))); |
| 219 | 228 | |
| 220 | 229 | // type and size (caller already made sure that path exists) |
| 221 | - if (is_dir($fspath)) { |
|
| 230 | + if (is_dir($fspath)) |
|
| 231 | + { |
|
| 222 | 232 | // directory (WebDAV collection) |
| 223 | 233 | $info["props"][] = $this->mkprop("resourcetype", "collection"); |
| 224 | 234 | $info["props"][] = $this->mkprop("getcontenttype", "httpd/unix-directory"); |
| 225 | - } else { |
|
| 235 | + } |
|
| 236 | + else |
|
| 237 | + { |
|
| 226 | 238 | // plain file (WebDAV resource) |
| 227 | 239 | $info["props"][] = $this->mkprop("resourcetype", ""); |
| 228 | - if ($this->_is_readable($fspath)) { |
|
| 240 | + if ($this->_is_readable($fspath)) |
|
| 241 | + { |
|
| 229 | 242 | $info["props"][] = $this->mkprop("getcontenttype", $this->_mimetype($fspath)); |
| 230 | - } else { |
|
| 243 | + } |
|
| 244 | + else |
|
| 245 | + { |
|
| 231 | 246 | $info["props"][] = $this->mkprop("getcontenttype", "application/x-non-readable"); |
| 232 | 247 | } |
| 233 | 248 | $info["props"][] = $this->mkprop("getcontentlength", filesize($fspath)); |
@@ -238,7 +253,8 @@ discard block |
||
| 238 | 253 | FROM {$this->db_prefix}properties |
| 239 | 254 | WHERE path = '$path'"; |
| 240 | 255 | $res = mysql_query($query); |
| 241 | - while ($row = mysql_fetch_assoc($res)) { |
|
| 256 | + while ($row = mysql_fetch_assoc($res)) |
|
| 257 | + { |
|
| 242 | 258 | $info["props"][] = $this->mkprop($row["ns"], $row["name"], $row["value"]); |
| 243 | 259 | } |
| 244 | 260 | mysql_free_result($res); |
@@ -259,30 +275,45 @@ discard block |
||
| 259 | 275 | function _can_execute($name, $path = false) |
| 260 | 276 | { |
| 261 | 277 | // path defaults to PATH from environment if not set |
| 262 | - if ($path === false) { |
|
| 278 | + if ($path === false) |
|
| 279 | + { |
|
| 263 | 280 | $path = getenv("PATH"); |
| 264 | 281 | } |
| 265 | 282 | |
| 266 | 283 | // check method depends on operating system |
| 267 | - if (!strncmp(PHP_OS, "WIN", 3)) { |
|
| 284 | + if (!strncmp(PHP_OS, "WIN", 3)) |
|
| 285 | + { |
|
| 268 | 286 | // on Windows an appropriate COM or EXE file needs to exist |
| 269 | 287 | $exts = array(".exe", ".com"); |
| 270 | 288 | $check_fn = "file_exists"; |
| 271 | - } else { |
|
| 289 | + } |
|
| 290 | + else |
|
| 291 | + { |
|
| 272 | 292 | // anywhere else we look for an executable file of that name |
| 273 | 293 | $exts = array(""); |
| 274 | 294 | $check_fn = "is_executable"; |
| 275 | 295 | } |
| 276 | 296 | |
| 277 | 297 | // now check the directories in the path for the program |
| 278 | - foreach (explode(PATH_SEPARATOR, $path) as $dir) { |
|
| 298 | + foreach (explode(PATH_SEPARATOR, $path) as $dir) |
|
| 299 | + { |
|
| 279 | 300 | // skip invalid path entries |
| 280 | - if (!file_exists($dir)) continue; |
|
| 281 | - if (!is_dir($dir)) continue; |
|
| 301 | + if (!file_exists($dir)) |
|
| 302 | + { |
|
| 303 | + continue; |
|
| 304 | + } |
|
| 305 | + if (!is_dir($dir)) |
|
| 306 | + { |
|
| 307 | + continue; |
|
| 308 | + } |
|
| 282 | 309 | |
| 283 | 310 | // and now look for the file |
| 284 | - foreach ($exts as $ext) { |
|
| 285 | - if ($check_fn("$dir/$name".$ext)) return true; |
|
| 311 | + foreach ($exts as $ext) |
|
| 312 | + { |
|
| 313 | + if ($check_fn("$dir/$name".$ext)) |
|
| 314 | + { |
|
| 315 | + return true; |
|
| 316 | + } |
|
| 286 | 317 | } |
| 287 | 318 | } |
| 288 | 319 | |
@@ -323,13 +354,18 @@ discard block |
||
| 323 | 354 | */ |
| 324 | 355 | function _mimetype($fspath) |
| 325 | 356 | { |
| 326 | - if (is_dir($fspath)) { |
|
| 357 | + if (is_dir($fspath)) |
|
| 358 | + { |
|
| 327 | 359 | // directories are easy |
| 328 | 360 | return "httpd/unix-directory"; |
| 329 | - } else if (function_exists("mime_content_type")) { |
|
| 361 | + } |
|
| 362 | + else if (function_exists("mime_content_type")) |
|
| 363 | + { |
|
| 330 | 364 | // use mime magic extension if available |
| 331 | 365 | $mime_type = mime_content_type($fspath); |
| 332 | - } else if ($this->_can_execute("file")) { |
|
| 366 | + } |
|
| 367 | + else if ($this->_can_execute("file")) |
|
| 368 | + { |
|
| 333 | 369 | // it looks like we have a 'file' command, |
| 334 | 370 | // lets see it it does have mime support |
| 335 | 371 | $fp = popen("file -i '$fspath' 2>/dev/null", "r"); |
@@ -341,16 +377,19 @@ discard block |
||
| 341 | 377 | // so we test the format of the returned string |
| 342 | 378 | |
| 343 | 379 | // the reply begins with the requested filename |
| 344 | - if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) { |
|
| 380 | + if (!strncmp($reply, "$fspath: ", strlen($fspath)+2)) |
|
| 381 | + { |
|
| 345 | 382 | $reply = substr($reply, strlen($fspath)+2); |
| 346 | 383 | // followed by the mime type (maybe including options) |
| 347 | - if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) { |
|
| 384 | + if (preg_match('|^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*|', $reply, $matches)) |
|
| 385 | + { |
|
| 348 | 386 | $mime_type = $matches[0]; |
| 349 | 387 | } |
| 350 | 388 | } |
| 351 | 389 | } |
| 352 | 390 | |
| 353 | - if (empty($mime_type)) { |
|
| 391 | + if (empty($mime_type)) |
|
| 392 | + { |
|
| 354 | 393 | // Fallback solution: try to guess the type by the file extension |
| 355 | 394 | // TODO: add more ... |
| 356 | 395 | // TODO: it has been suggested to delegate mimetype detection |
@@ -364,7 +403,8 @@ discard block |
||
| 364 | 403 | // anyway (overriding it with information taken from |
| 365 | 404 | // the registry) |
| 366 | 405 | // TODO: have a seperate PEAR class for mimetype detection? |
| 367 | - switch (strtolower(strrchr(basename($fspath), "."))) { |
|
| 406 | + switch (strtolower(strrchr(basename($fspath), "."))) |
|
| 407 | + { |
|
| 368 | 408 | case ".html": |
| 369 | 409 | $mime_type = "text/html"; |
| 370 | 410 | break; |
@@ -395,7 +435,10 @@ discard block |
||
| 395 | 435 | $fspath = $this->base . $options["path"]; |
| 396 | 436 | |
| 397 | 437 | // sanity check |
| 398 | - if (!file_exists($fspath)) return false; |
|
| 438 | + if (!file_exists($fspath)) |
|
| 439 | + { |
|
| 440 | + return false; |
|
| 441 | + } |
|
| 399 | 442 | |
| 400 | 443 | // detect resource type |
| 401 | 444 | $options['mimetype'] = $this->_mimetype($fspath); |
@@ -424,12 +467,14 @@ discard block |
||
| 424 | 467 | $fspath = $this->base . $options["path"]; |
| 425 | 468 | |
| 426 | 469 | // is this a collection? |
| 427 | - if (is_dir($fspath)) { |
|
| 470 | + if (is_dir($fspath)) |
|
| 471 | + { |
|
| 428 | 472 | return $this->GetDir($fspath, $options); |
| 429 | 473 | } |
| 430 | 474 | |
| 431 | 475 | // the header output is the same as for HEAD |
| 432 | - if (!$this->HEAD($options)) { |
|
| 476 | + if (!$this->HEAD($options)) |
|
| 477 | + { |
|
| 433 | 478 | return false; |
| 434 | 479 | } |
| 435 | 480 | |
@@ -451,7 +496,8 @@ discard block |
||
| 451 | 496 | function GetDir($fspath, &$options) |
| 452 | 497 | { |
| 453 | 498 | $path = $this->_slashify($options["path"]); |
| 454 | - if ($path != $options["path"]) { |
|
| 499 | + if ($path != $options["path"]) |
|
| 500 | + { |
|
| 455 | 501 | header("Location: ".$this->base_uri.$path); |
| 456 | 502 | exit; |
| 457 | 503 | } |
@@ -459,12 +505,14 @@ discard block |
||
| 459 | 505 | // fixed width directory column format |
| 460 | 506 | $format = "%15s %-19s %-s\n"; |
| 461 | 507 | |
| 462 | - if (!$this->_is_readable($fspath)) { |
|
| 508 | + if (!$this->_is_readable($fspath)) |
|
| 509 | + { |
|
| 463 | 510 | return false; |
| 464 | 511 | } |
| 465 | 512 | |
| 466 | 513 | $handle = opendir($fspath); |
| 467 | - if (!$handle) { |
|
| 514 | + if (!$handle) |
|
| 515 | + { |
|
| 468 | 516 | return false; |
| 469 | 517 | } |
| 470 | 518 | |
@@ -476,8 +524,10 @@ discard block |
||
| 476 | 524 | printf($format, "Size", "Last modified", "Filename"); |
| 477 | 525 | echo "<hr>"; |
| 478 | 526 | |
| 479 | - while ($filename = readdir($handle)) { |
|
| 480 | - if ($filename != "." && $filename != "..") { |
|
| 527 | + while ($filename = readdir($handle)) |
|
| 528 | + { |
|
| 529 | + if ($filename != "." && $filename != "..") |
|
| 530 | + { |
|
| 481 | 531 | $fullpath = $fspath.$filename; |
| 482 | 532 | $name = htmlspecialchars($filename); |
| 483 | 533 | printf($format, |
@@ -507,19 +557,23 @@ discard block |
||
| 507 | 557 | $fspath = $this->base . $options["path"]; |
| 508 | 558 | |
| 509 | 559 | $dir = dirname($fspath); |
| 510 | - if (!file_exists($dir) || !is_dir($dir)) { |
|
| 560 | + if (!file_exists($dir) || !is_dir($dir)) |
|
| 561 | + { |
|
| 511 | 562 | return "409 Conflict"; // TODO right status code for both? |
| 512 | 563 | } |
| 513 | 564 | |
| 514 | 565 | $options["new"] = ! file_exists($fspath); |
| 515 | 566 | |
| 516 | - if ($options["new"] && !$this->_is_writable($dir)) { |
|
| 567 | + if ($options["new"] && !$this->_is_writable($dir)) |
|
| 568 | + { |
|
| 517 | 569 | return "403 Forbidden"; |
| 518 | 570 | } |
| 519 | - if (!$options["new"] && !$this->_is_writable($fspath)) { |
|
| 571 | + if (!$options["new"] && !$this->_is_writable($fspath)) |
|
| 572 | + { |
|
| 520 | 573 | return "403 Forbidden"; |
| 521 | 574 | } |
| 522 | - if (!$options["new"] && is_dir($fspath)) { |
|
| 575 | + if (!$options["new"] && is_dir($fspath)) |
|
| 576 | + { |
|
| 523 | 577 | return "403 Forbidden"; |
| 524 | 578 | } |
| 525 | 579 | |
@@ -541,24 +595,30 @@ discard block |
||
| 541 | 595 | $parent = dirname($path); |
| 542 | 596 | $name = basename($path); |
| 543 | 597 | |
| 544 | - if (!file_exists($parent)) { |
|
| 598 | + if (!file_exists($parent)) |
|
| 599 | + { |
|
| 545 | 600 | return "409 Conflict"; |
| 546 | 601 | } |
| 547 | 602 | |
| 548 | - if (!is_dir($parent)) { |
|
| 603 | + if (!is_dir($parent)) |
|
| 604 | + { |
|
| 549 | 605 | return "403 Forbidden"; |
| 550 | 606 | } |
| 551 | 607 | |
| 552 | - if ( file_exists($parent."/".$name) ) { |
|
| 608 | + if ( file_exists($parent."/".$name) ) |
|
| 609 | + { |
|
| 553 | 610 | return "405 Method not allowed"; |
| 554 | 611 | } |
| 555 | 612 | |
| 556 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 613 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) |
|
| 614 | + { |
|
| 615 | +// no body parsing yet |
|
| 557 | 616 | return "415 Unsupported media type"; |
| 558 | 617 | } |
| 559 | 618 | |
| 560 | 619 | $stat = mkdir($parent."/".$name, 0777); |
| 561 | - if (!$stat) { |
|
| 620 | + if (!$stat) |
|
| 621 | + { |
|
| 562 | 622 | return "403 Forbidden"; |
| 563 | 623 | } |
| 564 | 624 | |
@@ -576,16 +636,20 @@ discard block |
||
| 576 | 636 | { |
| 577 | 637 | $path = $this->base . "/" .$options["path"]; |
| 578 | 638 | |
| 579 | - if (!file_exists($path)) { |
|
| 639 | + if (!file_exists($path)) |
|
| 640 | + { |
|
| 580 | 641 | return "404 Not found"; |
| 581 | 642 | } |
| 582 | 643 | |
| 583 | - if (is_dir($path)) { |
|
| 644 | + if (is_dir($path)) |
|
| 645 | + { |
|
| 584 | 646 | $query = "DELETE FROM {$this->db_prefix}properties |
| 585 | 647 | WHERE path LIKE '".$this->_slashify($options["path"])."%'"; |
| 586 | 648 | mysql_query($query); |
| 587 | 649 | System::rm(array("-rf", $path)); |
| 588 | - } else { |
|
| 650 | + } |
|
| 651 | + else |
|
| 652 | + { |
|
| 589 | 653 | unlink($path); |
| 590 | 654 | } |
| 591 | 655 | $query = "DELETE FROM {$this->db_prefix}properties |
@@ -617,26 +681,35 @@ discard block |
||
| 617 | 681 | { |
| 618 | 682 | // TODO Property updates still broken (Litmus should detect this?) |
| 619 | 683 | |
| 620 | - if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet |
|
| 684 | + if (!empty($this->_SERVER["CONTENT_LENGTH"])) |
|
| 685 | + { |
|
| 686 | +// no body parsing yet |
|
| 621 | 687 | return "415 Unsupported media type"; |
| 622 | 688 | } |
| 623 | 689 | |
| 624 | 690 | // no copying to different WebDAV Servers yet |
| 625 | - if (isset($options["dest_url"])) { |
|
| 691 | + if (isset($options["dest_url"])) |
|
| 692 | + { |
|
| 626 | 693 | return "502 bad gateway"; |
| 627 | 694 | } |
| 628 | 695 | |
| 629 | 696 | $source = $this->base . $options["path"]; |
| 630 | - if (!file_exists($source)) { |
|
| 697 | + if (!file_exists($source)) |
|
| 698 | + { |
|
| 631 | 699 | return "404 Not found"; |
| 632 | 700 | } |
| 633 | 701 | |
| 634 | - if (is_dir($source)) { // resource is a collection |
|
| 635 | - switch ($options["depth"]) { |
|
| 702 | + if (is_dir($source)) |
|
| 703 | + { |
|
| 704 | +// resource is a collection |
|
| 705 | + switch ($options["depth"]) |
|
| 706 | + { |
|
| 636 | 707 | case "infinity": // valid |
| 637 | 708 | break; |
| 638 | 709 | case "0": // valid for COPY only |
| 639 | - if ($del) { // MOVE? |
|
| 710 | + if ($del) |
|
| 711 | + { |
|
| 712 | +// MOVE? |
|
| 640 | 713 | return "400 Bad request"; |
| 641 | 714 | } |
| 642 | 715 | break; |
@@ -649,7 +722,8 @@ discard block |
||
| 649 | 722 | $dest = $this->base . $options["dest"]; |
| 650 | 723 | $destdir = dirname($dest); |
| 651 | 724 | |
| 652 | - if (!file_exists($destdir) || !is_dir($destdir)) { |
|
| 725 | + if (!file_exists($destdir) || !is_dir($destdir)) |
|
| 726 | + { |
|
| 653 | 727 | return "409 Conflict"; |
| 654 | 728 | } |
| 655 | 729 | |
@@ -657,38 +731,52 @@ discard block |
||
| 657 | 731 | $new = !file_exists($dest); |
| 658 | 732 | $existing_col = false; |
| 659 | 733 | |
| 660 | - if (!$new) { |
|
| 661 | - if ($del && is_dir($dest)) { |
|
| 662 | - if (!$options["overwrite"]) { |
|
| 734 | + if (!$new) |
|
| 735 | + { |
|
| 736 | + if ($del && is_dir($dest)) |
|
| 737 | + { |
|
| 738 | + if (!$options["overwrite"]) |
|
| 739 | + { |
|
| 663 | 740 | return "412 precondition failed"; |
| 664 | 741 | } |
| 665 | 742 | $dest .= basename($source); |
| 666 | - if (file_exists($dest)) { |
|
| 743 | + if (file_exists($dest)) |
|
| 744 | + { |
|
| 667 | 745 | $options["dest"] .= basename($source); |
| 668 | - } else { |
|
| 746 | + } |
|
| 747 | + else |
|
| 748 | + { |
|
| 669 | 749 | $new = true; |
| 670 | 750 | $existing_col = true; |
| 671 | 751 | } |
| 672 | 752 | } |
| 673 | 753 | } |
| 674 | 754 | |
| 675 | - if (!$new) { |
|
| 676 | - if ($options["overwrite"]) { |
|
| 755 | + if (!$new) |
|
| 756 | + { |
|
| 757 | + if ($options["overwrite"]) |
|
| 758 | + { |
|
| 677 | 759 | $stat = $this->DELETE(array("path" => $options["dest"])); |
| 678 | - if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) { |
|
| 760 | + if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) |
|
| 761 | + { |
|
| 679 | 762 | return $stat; |
| 680 | 763 | } |
| 681 | - } else { |
|
| 764 | + } |
|
| 765 | + else |
|
| 766 | + { |
|
| 682 | 767 | return "412 precondition failed"; |
| 683 | 768 | } |
| 684 | 769 | } |
| 685 | 770 | |
| 686 | - if ($del) { |
|
| 687 | - if (!rename($source, $dest)) { |
|
| 771 | + if ($del) |
|
| 772 | + { |
|
| 773 | + if (!rename($source, $dest)) |
|
| 774 | + { |
|
| 688 | 775 | return "500 Internal server error"; |
| 689 | 776 | } |
| 690 | 777 | $destpath = $this->_unslashify($options["dest"]); |
| 691 | - if (is_dir($source)) { |
|
| 778 | + if (is_dir($source)) |
|
| 779 | + { |
|
| 692 | 780 | $query = "UPDATE {$this->db_prefix}properties |
| 693 | 781 | SET path = REPLACE(path, '".$options["path"]."', '".$destpath."') |
| 694 | 782 | WHERE path LIKE '".$this->_slashify($options["path"])."%'"; |
@@ -699,40 +787,58 @@ discard block |
||
| 699 | 787 | SET path = '".$destpath."' |
| 700 | 788 | WHERE path = '".$options["path"]."'"; |
| 701 | 789 | mysql_query($query); |
| 702 | - } else { |
|
| 703 | - if (is_dir($source) && $options["depth"] == "infinity") { // no find for depth="0" |
|
| 790 | + } |
|
| 791 | + else |
|
| 792 | + { |
|
| 793 | + if (is_dir($source) && $options["depth"] == "infinity") |
|
| 794 | + { |
|
| 795 | +// no find for depth="0" |
|
| 704 | 796 | $files = System::find($source); |
| 705 | 797 | $files = array_reverse($files); |
| 706 | - } else { |
|
| 798 | + } |
|
| 799 | + else |
|
| 800 | + { |
|
| 707 | 801 | $files = array($source); |
| 708 | 802 | } |
| 709 | 803 | |
| 710 | - if (!is_array($files) || empty($files)) { |
|
| 804 | + if (!is_array($files) || empty($files)) |
|
| 805 | + { |
|
| 711 | 806 | return "500 Internal server error"; |
| 712 | 807 | } |
| 713 | 808 | |
| 714 | 809 | |
| 715 | - foreach ($files as $file) { |
|
| 716 | - if (is_dir($file)) { |
|
| 810 | + foreach ($files as $file) |
|
| 811 | + { |
|
| 812 | + if (is_dir($file)) |
|
| 813 | + { |
|
| 717 | 814 | $file = $this->_slashify($file); |
| 718 | 815 | } |
| 719 | 816 | |
| 720 | 817 | $destfile = str_replace($source, $dest, $file); |
| 721 | 818 | |
| 722 | - if (is_dir($file)) { |
|
| 723 | - if (!file_exists($destfile)) { |
|
| 724 | - if (!$this->_is_writable(dirname($destfile))) { |
|
| 819 | + if (is_dir($file)) |
|
| 820 | + { |
|
| 821 | + if (!file_exists($destfile)) |
|
| 822 | + { |
|
| 823 | + if (!$this->_is_writable(dirname($destfile))) |
|
| 824 | + { |
|
| 725 | 825 | return "403 Forbidden"; |
| 726 | 826 | } |
| 727 | - if (!mkdir($destfile)) { |
|
| 827 | + if (!mkdir($destfile)) |
|
| 828 | + { |
|
| 728 | 829 | return "409 Conflict"; |
| 729 | 830 | } |
| 730 | - } else if (!is_dir($destfile)) { |
|
| 831 | + } |
|
| 832 | + else if (!is_dir($destfile)) |
|
| 833 | + { |
|
| 731 | 834 | return "409 Conflict"; |
| 732 | 835 | } |
| 733 | - } else { |
|
| 836 | + } |
|
| 837 | + else |
|
| 838 | + { |
|
| 734 | 839 | |
| 735 | - if (!copy($file, $destfile)) { |
|
| 840 | + if (!copy($file, $destfile)) |
|
| 841 | + { |
|
| 736 | 842 | return "409 Conflict"; |
| 737 | 843 | } |
| 738 | 844 | } |
@@ -762,17 +868,24 @@ discard block |
||
| 762 | 868 | $dir = dirname($path)."/"; |
| 763 | 869 | $base = basename($path); |
| 764 | 870 | |
| 765 | - foreach ($options["props"] as $key => $prop) { |
|
| 766 | - if ($prop["ns"] == "DAV:") { |
|
| 871 | + foreach ($options["props"] as $key => $prop) |
|
| 872 | + { |
|
| 873 | + if ($prop["ns"] == "DAV:") |
|
| 874 | + { |
|
| 767 | 875 | $options["props"][$key]['status'] = "403 Forbidden"; |
| 768 | - } else { |
|
| 769 | - if (isset($prop["val"])) { |
|
| 876 | + } |
|
| 877 | + else |
|
| 878 | + { |
|
| 879 | + if (isset($prop["val"])) |
|
| 880 | + { |
|
| 770 | 881 | $query = "REPLACE INTO {$this->db_prefix}properties |
| 771 | 882 | SET path = '$options[path]' |
| 772 | 883 | , name = '$prop[name]' |
| 773 | 884 | , ns= '$prop[ns]' |
| 774 | 885 | , value = '$prop[val]'"; |
| 775 | - } else { |
|
| 886 | + } |
|
| 887 | + else |
|
| 888 | + { |
|
| 776 | 889 | $query = "DELETE FROM {$this->db_prefix}properties |
| 777 | 890 | WHERE path = '$options[path]' |
| 778 | 891 | AND name = '$prop[name]' |
@@ -799,13 +912,16 @@ discard block |
||
| 799 | 912 | |
| 800 | 913 | // TODO recursive locks on directories not supported yet |
| 801 | 914 | // makes litmus test "32. lock_collection" fail |
| 802 | - if (is_dir($fspath) && !empty($options["depth"])) { |
|
| 915 | + if (is_dir($fspath) && !empty($options["depth"])) |
|
| 916 | + { |
|
| 803 | 917 | return "409 Conflict"; |
| 804 | 918 | } |
| 805 | 919 | |
| 806 | 920 | $options["timeout"] = time()+300; // 5min. hardcoded |
| 807 | 921 | |
| 808 | - if (isset($options["update"])) { // Lock Update |
|
| 922 | + if (isset($options["update"])) |
|
| 923 | + { |
|
| 924 | +// Lock Update |
|
| 809 | 925 | $where = "WHERE path = '$options[path]' AND token = '$options[update]'"; |
| 810 | 926 | |
| 811 | 927 | $query = "SELECT owner, exclusivelock FROM {$this->db_prefix}locks $where"; |
@@ -813,7 +929,8 @@ discard block |
||
| 813 | 929 | $row = mysql_fetch_assoc($res); |
| 814 | 930 | mysql_free_result($res); |
| 815 | 931 | |
| 816 | - if (is_array($row)) { |
|
| 932 | + if (is_array($row)) |
|
| 933 | + { |
|
| 817 | 934 | $query = "UPDATE {$this->db_prefix}locks |
| 818 | 935 | SET expires = '$options[timeout]' |
| 819 | 936 | , modified = ".time()." |
@@ -825,7 +942,9 @@ discard block |
||
| 825 | 942 | $options['type'] = $row["exclusivelock"] ? "write" : "read"; |
| 826 | 943 | |
| 827 | 944 | return true; |
| 828 | - } else { |
|
| 945 | + } |
|
| 946 | + else |
|
| 947 | + { |
|
| 829 | 948 | return false; |
| 830 | 949 | } |
| 831 | 950 | } |
@@ -876,11 +995,13 @@ discard block |
||
| 876 | 995 | "; |
| 877 | 996 | $res = mysql_query($query); |
| 878 | 997 | |
| 879 | - if ($res) { |
|
| 998 | + if ($res) |
|
| 999 | + { |
|
| 880 | 1000 | $row = mysql_fetch_array($res); |
| 881 | 1001 | mysql_free_result($res); |
| 882 | 1002 | |
| 883 | - if ($row) { |
|
| 1003 | + if ($row) |
|
| 1004 | + { |
|
| 884 | 1005 | $result = array( "type" => "write", |
| 885 | 1006 | "scope" => $row["exclusivelock"] ? "exclusive" : "shared", |
| 886 | 1007 | "depth" => 0, |
@@ -689,13 +689,13 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | $destpath = $this->_unslashify($options["dest"]); |
| 691 | 691 | if (is_dir($source)) { |
| 692 | - $query = "UPDATE {$this->db_prefix}properties |
|
| 692 | + $query = "update {$this->db_prefix}properties |
|
| 693 | 693 | SET path = REPLACE(path, '".$options["path"]."', '".$destpath."') |
| 694 | 694 | WHERE path LIKE '".$this->_slashify($options["path"])."%'"; |
| 695 | 695 | mysql_query($query); |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $query = "UPDATE {$this->db_prefix}properties |
|
| 698 | + $query = "update {$this->db_prefix}properties |
|
| 699 | 699 | SET path = '".$destpath."' |
| 700 | 700 | WHERE path = '".$options["path"]."'"; |
| 701 | 701 | mysql_query($query); |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | mysql_free_result($res); |
| 815 | 815 | |
| 816 | 816 | if (is_array($row)) { |
| 817 | - $query = "UPDATE {$this->db_prefix}locks |
|
| 817 | + $query = "update {$this->db_prefix}locks |
|
| 818 | 818 | SET expires = '$options[timeout]' |
| 819 | 819 | , modified = ".time()." |
| 820 | 820 | $where"; |
@@ -87,6 +87,7 @@ |
||
| 87 | 87 | * constructor |
| 88 | 88 | * |
| 89 | 89 | * @param string path of stream to read |
| 90 | + * @param string $path |
|
| 90 | 91 | * @access public |
| 91 | 92 | */ |
| 92 | 93 | function __construct($path) |
@@ -43,209 +43,209 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_lockinfo |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * success state flag |
|
| 48 | - * |
|
| 49 | - * @var bool |
|
| 50 | - * @access public |
|
| 51 | - */ |
|
| 52 | - var $success = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * lock type, currently only "write" |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - var $locktype = ""; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * lock scope, "shared" or "exclusive" |
|
| 64 | - * |
|
| 65 | - * @var string |
|
| 66 | - * @access public |
|
| 67 | - */ |
|
| 68 | - var $lockscope = ""; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * lock owner information |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - * @access public |
|
| 75 | - */ |
|
| 76 | - var $owner = ""; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * flag that is set during lock owner read |
|
| 80 | - * |
|
| 81 | - * @var bool |
|
| 82 | - * @access private |
|
| 83 | - */ |
|
| 84 | - var $collect_owner = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * constructor |
|
| 88 | - * |
|
| 89 | - * @param string path of stream to read |
|
| 90 | - * @access public |
|
| 91 | - */ |
|
| 92 | - function __construct($path) |
|
| 93 | - { |
|
| 94 | - // we assume success unless problems occur |
|
| 95 | - $this->success = true; |
|
| 96 | - |
|
| 97 | - // remember if any input was parsed |
|
| 98 | - $had_input = false; |
|
| 99 | - |
|
| 100 | - // open stream |
|
| 101 | - $f_in = fopen($path, "r"); |
|
| 102 | - if (!$f_in) { |
|
| 103 | - $this->success = false; |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // create namespace aware parser |
|
| 108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | - |
|
| 110 | - // set tag and data handlers |
|
| 111 | - xml_set_element_handler($xml_parser, |
|
| 112 | - array(&$this, "_startElement"), |
|
| 113 | - array(&$this, "_endElement")); |
|
| 114 | - xml_set_character_data_handler($xml_parser, |
|
| 115 | - array(&$this, "_data")); |
|
| 116 | - |
|
| 117 | - // we want a case sensitive parser |
|
| 118 | - xml_parser_set_option($xml_parser, |
|
| 119 | - XML_OPTION_CASE_FOLDING, false); |
|
| 120 | - |
|
| 121 | - // parse input |
|
| 122 | - while ($this->success && !feof($f_in)) { |
|
| 123 | - $line = fgets($f_in); |
|
| 124 | - if (is_string($line)) { |
|
| 125 | - $had_input = true; |
|
| 126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // finish parsing |
|
| 131 | - if ($had_input) { |
|
| 132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // check if required tags where found |
|
| 136 | - $this->success &= !empty($this->locktype); |
|
| 137 | - $this->success &= !empty($this->lockscope); |
|
| 138 | - |
|
| 139 | - // free parser resource |
|
| 140 | - xml_parser_free($xml_parser); |
|
| 141 | - |
|
| 142 | - // close input stream |
|
| 143 | - fclose($f_in); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * tag start handler |
|
| 149 | - * |
|
| 150 | - * @param resource parser |
|
| 151 | - * @param string tag name |
|
| 152 | - * @param array tag attributes |
|
| 153 | - * @return void |
|
| 154 | - * @access private |
|
| 155 | - */ |
|
| 156 | - function _startElement($parser, $name, $attrs) |
|
| 157 | - { |
|
| 158 | - // namespace handling |
|
| 159 | - if (strstr($name, " ")) { |
|
| 160 | - list($ns, $tag) = explode(" ", $name); |
|
| 161 | - } else { |
|
| 162 | - $ns = ""; |
|
| 163 | - $tag = $name; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - if ($this->collect_owner) { |
|
| 168 | - // everything within the <owner> tag needs to be collected |
|
| 169 | - $ns_short = ""; |
|
| 170 | - $ns_attr = ""; |
|
| 171 | - if ($ns) { |
|
| 172 | - if ($ns == "DAV:") { |
|
| 173 | - $ns_short = "D:"; |
|
| 174 | - } else { |
|
| 175 | - $ns_attr = " xmlns='$ns'"; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | - } else if ($ns == "DAV:") { |
|
| 180 | - // parse only the essential tags |
|
| 181 | - switch ($tag) { |
|
| 182 | - case "write": |
|
| 183 | - $this->locktype = $tag; |
|
| 184 | - break; |
|
| 185 | - case "exclusive": |
|
| 186 | - case "shared": |
|
| 187 | - $this->lockscope = $tag; |
|
| 188 | - break; |
|
| 189 | - case "owner": |
|
| 190 | - $this->collect_owner = true; |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * data handler |
|
| 198 | - * |
|
| 199 | - * @param resource parser |
|
| 200 | - * @param string data |
|
| 201 | - * @return void |
|
| 202 | - * @access private |
|
| 203 | - */ |
|
| 204 | - function _data($parser, $data) |
|
| 205 | - { |
|
| 206 | - // only the <owner> tag has data content |
|
| 207 | - if ($this->collect_owner) { |
|
| 208 | - $this->owner .= $data; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * tag end handler |
|
| 214 | - * |
|
| 215 | - * @param resource parser |
|
| 216 | - * @param string tag name |
|
| 217 | - * @return void |
|
| 218 | - * @access private |
|
| 219 | - */ |
|
| 220 | - function _endElement($parser, $name) |
|
| 221 | - { |
|
| 222 | - // namespace handling |
|
| 223 | - if (strstr($name, " ")) { |
|
| 224 | - list($ns, $tag) = explode(" ", $name); |
|
| 225 | - } else { |
|
| 226 | - $ns = ""; |
|
| 227 | - $tag = $name; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // <owner> finished? |
|
| 231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | - $this->collect_owner = false; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // within <owner> we have to collect everything |
|
| 236 | - if ($this->collect_owner) { |
|
| 237 | - $ns_short = ""; |
|
| 238 | - $ns_attr = ""; |
|
| 239 | - if ($ns) { |
|
| 240 | - if ($ns == "DAV:") { |
|
| 241 | - $ns_short = "D:"; |
|
| 242 | - } else { |
|
| 243 | - $ns_attr = " xmlns='$ns'"; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | - } |
|
| 248 | - } |
|
| 46 | + /** |
|
| 47 | + * success state flag |
|
| 48 | + * |
|
| 49 | + * @var bool |
|
| 50 | + * @access public |
|
| 51 | + */ |
|
| 52 | + var $success = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * lock type, currently only "write" |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + var $locktype = ""; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * lock scope, "shared" or "exclusive" |
|
| 64 | + * |
|
| 65 | + * @var string |
|
| 66 | + * @access public |
|
| 67 | + */ |
|
| 68 | + var $lockscope = ""; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * lock owner information |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + * @access public |
|
| 75 | + */ |
|
| 76 | + var $owner = ""; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * flag that is set during lock owner read |
|
| 80 | + * |
|
| 81 | + * @var bool |
|
| 82 | + * @access private |
|
| 83 | + */ |
|
| 84 | + var $collect_owner = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * constructor |
|
| 88 | + * |
|
| 89 | + * @param string path of stream to read |
|
| 90 | + * @access public |
|
| 91 | + */ |
|
| 92 | + function __construct($path) |
|
| 93 | + { |
|
| 94 | + // we assume success unless problems occur |
|
| 95 | + $this->success = true; |
|
| 96 | + |
|
| 97 | + // remember if any input was parsed |
|
| 98 | + $had_input = false; |
|
| 99 | + |
|
| 100 | + // open stream |
|
| 101 | + $f_in = fopen($path, "r"); |
|
| 102 | + if (!$f_in) { |
|
| 103 | + $this->success = false; |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // create namespace aware parser |
|
| 108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 109 | + |
|
| 110 | + // set tag and data handlers |
|
| 111 | + xml_set_element_handler($xml_parser, |
|
| 112 | + array(&$this, "_startElement"), |
|
| 113 | + array(&$this, "_endElement")); |
|
| 114 | + xml_set_character_data_handler($xml_parser, |
|
| 115 | + array(&$this, "_data")); |
|
| 116 | + |
|
| 117 | + // we want a case sensitive parser |
|
| 118 | + xml_parser_set_option($xml_parser, |
|
| 119 | + XML_OPTION_CASE_FOLDING, false); |
|
| 120 | + |
|
| 121 | + // parse input |
|
| 122 | + while ($this->success && !feof($f_in)) { |
|
| 123 | + $line = fgets($f_in); |
|
| 124 | + if (is_string($line)) { |
|
| 125 | + $had_input = true; |
|
| 126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // finish parsing |
|
| 131 | + if ($had_input) { |
|
| 132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // check if required tags where found |
|
| 136 | + $this->success &= !empty($this->locktype); |
|
| 137 | + $this->success &= !empty($this->lockscope); |
|
| 138 | + |
|
| 139 | + // free parser resource |
|
| 140 | + xml_parser_free($xml_parser); |
|
| 141 | + |
|
| 142 | + // close input stream |
|
| 143 | + fclose($f_in); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * tag start handler |
|
| 149 | + * |
|
| 150 | + * @param resource parser |
|
| 151 | + * @param string tag name |
|
| 152 | + * @param array tag attributes |
|
| 153 | + * @return void |
|
| 154 | + * @access private |
|
| 155 | + */ |
|
| 156 | + function _startElement($parser, $name, $attrs) |
|
| 157 | + { |
|
| 158 | + // namespace handling |
|
| 159 | + if (strstr($name, " ")) { |
|
| 160 | + list($ns, $tag) = explode(" ", $name); |
|
| 161 | + } else { |
|
| 162 | + $ns = ""; |
|
| 163 | + $tag = $name; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + if ($this->collect_owner) { |
|
| 168 | + // everything within the <owner> tag needs to be collected |
|
| 169 | + $ns_short = ""; |
|
| 170 | + $ns_attr = ""; |
|
| 171 | + if ($ns) { |
|
| 172 | + if ($ns == "DAV:") { |
|
| 173 | + $ns_short = "D:"; |
|
| 174 | + } else { |
|
| 175 | + $ns_attr = " xmlns='$ns'"; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
| 179 | + } else if ($ns == "DAV:") { |
|
| 180 | + // parse only the essential tags |
|
| 181 | + switch ($tag) { |
|
| 182 | + case "write": |
|
| 183 | + $this->locktype = $tag; |
|
| 184 | + break; |
|
| 185 | + case "exclusive": |
|
| 186 | + case "shared": |
|
| 187 | + $this->lockscope = $tag; |
|
| 188 | + break; |
|
| 189 | + case "owner": |
|
| 190 | + $this->collect_owner = true; |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * data handler |
|
| 198 | + * |
|
| 199 | + * @param resource parser |
|
| 200 | + * @param string data |
|
| 201 | + * @return void |
|
| 202 | + * @access private |
|
| 203 | + */ |
|
| 204 | + function _data($parser, $data) |
|
| 205 | + { |
|
| 206 | + // only the <owner> tag has data content |
|
| 207 | + if ($this->collect_owner) { |
|
| 208 | + $this->owner .= $data; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * tag end handler |
|
| 214 | + * |
|
| 215 | + * @param resource parser |
|
| 216 | + * @param string tag name |
|
| 217 | + * @return void |
|
| 218 | + * @access private |
|
| 219 | + */ |
|
| 220 | + function _endElement($parser, $name) |
|
| 221 | + { |
|
| 222 | + // namespace handling |
|
| 223 | + if (strstr($name, " ")) { |
|
| 224 | + list($ns, $tag) = explode(" ", $name); |
|
| 225 | + } else { |
|
| 226 | + $ns = ""; |
|
| 227 | + $tag = $name; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // <owner> finished? |
|
| 231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 232 | + $this->collect_owner = false; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // within <owner> we have to collect everything |
|
| 236 | + if ($this->collect_owner) { |
|
| 237 | + $ns_short = ""; |
|
| 238 | + $ns_attr = ""; |
|
| 239 | + if ($ns) { |
|
| 240 | + if ($ns == "DAV:") { |
|
| 241 | + $ns_short = "D:"; |
|
| 242 | + } else { |
|
| 243 | + $ns_attr = " xmlns='$ns'"; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | ?> |
@@ -179,16 +179,16 @@ |
||
| 179 | 179 | } else if ($ns == "DAV:") { |
| 180 | 180 | // parse only the essential tags |
| 181 | 181 | switch ($tag) { |
| 182 | - case "write": |
|
| 183 | - $this->locktype = $tag; |
|
| 184 | - break; |
|
| 185 | - case "exclusive": |
|
| 186 | - case "shared": |
|
| 187 | - $this->lockscope = $tag; |
|
| 188 | - break; |
|
| 189 | - case "owner": |
|
| 190 | - $this->collect_owner = true; |
|
| 191 | - break; |
|
| 182 | + case "write": |
|
| 183 | + $this->locktype = $tag; |
|
| 184 | + break; |
|
| 185 | + case "exclusive": |
|
| 186 | + case "shared": |
|
| 187 | + $this->lockscope = $tag; |
|
| 188 | + break; |
|
| 189 | + case "owner": |
|
| 190 | + $this->collect_owner = true; |
|
| 191 | + break; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -99,7 +99,8 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | // open stream |
| 101 | 101 | $f_in = fopen($path, "r"); |
| 102 | - if (!$f_in) { |
|
| 102 | + if (!$f_in) |
|
| 103 | + { |
|
| 103 | 104 | $this->success = false; |
| 104 | 105 | return; |
| 105 | 106 | } |
@@ -119,16 +120,19 @@ discard block |
||
| 119 | 120 | XML_OPTION_CASE_FOLDING, false); |
| 120 | 121 | |
| 121 | 122 | // parse input |
| 122 | - while ($this->success && !feof($f_in)) { |
|
| 123 | + while ($this->success && !feof($f_in)) |
|
| 124 | + { |
|
| 123 | 125 | $line = fgets($f_in); |
| 124 | - if (is_string($line)) { |
|
| 126 | + if (is_string($line)) |
|
| 127 | + { |
|
| 125 | 128 | $had_input = true; |
| 126 | 129 | $this->success &= xml_parse($xml_parser, $line, false); |
| 127 | 130 | } |
| 128 | 131 | } |
| 129 | 132 | |
| 130 | 133 | // finish parsing |
| 131 | - if ($had_input) { |
|
| 134 | + if ($had_input) |
|
| 135 | + { |
|
| 132 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
| 133 | 137 | } |
| 134 | 138 | |
@@ -156,29 +160,40 @@ discard block |
||
| 156 | 160 | function _startElement($parser, $name, $attrs) |
| 157 | 161 | { |
| 158 | 162 | // namespace handling |
| 159 | - if (strstr($name, " ")) { |
|
| 163 | + if (strstr($name, " ")) |
|
| 164 | + { |
|
| 160 | 165 | list($ns, $tag) = explode(" ", $name); |
| 161 | - } else { |
|
| 166 | + } |
|
| 167 | + else |
|
| 168 | + { |
|
| 162 | 169 | $ns = ""; |
| 163 | 170 | $tag = $name; |
| 164 | 171 | } |
| 165 | 172 | |
| 166 | 173 | |
| 167 | - if ($this->collect_owner) { |
|
| 174 | + if ($this->collect_owner) |
|
| 175 | + { |
|
| 168 | 176 | // everything within the <owner> tag needs to be collected |
| 169 | 177 | $ns_short = ""; |
| 170 | 178 | $ns_attr = ""; |
| 171 | - if ($ns) { |
|
| 172 | - if ($ns == "DAV:") { |
|
| 179 | + if ($ns) |
|
| 180 | + { |
|
| 181 | + if ($ns == "DAV:") |
|
| 182 | + { |
|
| 173 | 183 | $ns_short = "D:"; |
| 174 | - } else { |
|
| 184 | + } |
|
| 185 | + else |
|
| 186 | + { |
|
| 175 | 187 | $ns_attr = " xmlns='$ns'"; |
| 176 | 188 | } |
| 177 | 189 | } |
| 178 | 190 | $this->owner .= "<$ns_short$tag$ns_attr>"; |
| 179 | - } else if ($ns == "DAV:") { |
|
| 191 | + } |
|
| 192 | + else if ($ns == "DAV:") |
|
| 193 | + { |
|
| 180 | 194 | // parse only the essential tags |
| 181 | - switch ($tag) { |
|
| 195 | + switch ($tag) |
|
| 196 | + { |
|
| 182 | 197 | case "write": |
| 183 | 198 | $this->locktype = $tag; |
| 184 | 199 | break; |
@@ -204,7 +219,8 @@ discard block |
||
| 204 | 219 | function _data($parser, $data) |
| 205 | 220 | { |
| 206 | 221 | // only the <owner> tag has data content |
| 207 | - if ($this->collect_owner) { |
|
| 222 | + if ($this->collect_owner) |
|
| 223 | + { |
|
| 208 | 224 | $this->owner .= $data; |
| 209 | 225 | } |
| 210 | 226 | } |
@@ -220,26 +236,35 @@ discard block |
||
| 220 | 236 | function _endElement($parser, $name) |
| 221 | 237 | { |
| 222 | 238 | // namespace handling |
| 223 | - if (strstr($name, " ")) { |
|
| 239 | + if (strstr($name, " ")) |
|
| 240 | + { |
|
| 224 | 241 | list($ns, $tag) = explode(" ", $name); |
| 225 | - } else { |
|
| 242 | + } |
|
| 243 | + else |
|
| 244 | + { |
|
| 226 | 245 | $ns = ""; |
| 227 | 246 | $tag = $name; |
| 228 | 247 | } |
| 229 | 248 | |
| 230 | 249 | // <owner> finished? |
| 231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
| 250 | + if (($ns == "DAV:") && ($tag == "owner")) |
|
| 251 | + { |
|
| 232 | 252 | $this->collect_owner = false; |
| 233 | 253 | } |
| 234 | 254 | |
| 235 | 255 | // within <owner> we have to collect everything |
| 236 | - if ($this->collect_owner) { |
|
| 256 | + if ($this->collect_owner) |
|
| 257 | + { |
|
| 237 | 258 | $ns_short = ""; |
| 238 | 259 | $ns_attr = ""; |
| 239 | - if ($ns) { |
|
| 240 | - if ($ns == "DAV:") { |
|
| 260 | + if ($ns) |
|
| 261 | + { |
|
| 262 | + if ($ns == "DAV:") |
|
| 263 | + { |
|
| 241 | 264 | $ns_short = "D:"; |
| 242 | - } else { |
|
| 265 | + } |
|
| 266 | + else |
|
| 267 | + { |
|
| 243 | 268 | $ns_attr = " xmlns='$ns'"; |
| 244 | 269 | } |
| 245 | 270 | } |
@@ -95,6 +95,7 @@ |
||
| 95 | 95 | * |
| 96 | 96 | * @param string path of input stream |
| 97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
| 98 | + * @param string $path |
|
| 98 | 99 | * @access public |
| 99 | 100 | */ |
| 100 | 101 | function __construct($path, $store_request=false) |
@@ -43,198 +43,198 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class _parse_proppatch |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * |
|
| 49 | - * @var |
|
| 50 | - * @access |
|
| 51 | - */ |
|
| 52 | - var $success; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * |
|
| 56 | - * |
|
| 57 | - * @var |
|
| 58 | - * @access |
|
| 59 | - */ |
|
| 60 | - var $props; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * |
|
| 64 | - * |
|
| 65 | - * @var |
|
| 66 | - * @access |
|
| 67 | - */ |
|
| 68 | - var $depth; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * |
|
| 72 | - * |
|
| 73 | - * @var |
|
| 74 | - * @access |
|
| 75 | - */ |
|
| 76 | - var $mode; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * |
|
| 80 | - * |
|
| 81 | - * @var |
|
| 82 | - * @access |
|
| 83 | - */ |
|
| 84 | - var $current; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 91 | - var $request; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * constructor |
|
| 95 | - * |
|
| 96 | - * @param string path of input stream |
|
| 97 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | - * @access public |
|
| 99 | - */ |
|
| 100 | - function __construct($path, $store_request=false) |
|
| 101 | - { |
|
| 102 | - $this->success = true; |
|
| 103 | - |
|
| 104 | - $this->depth = 0; |
|
| 105 | - $this->props = array(); |
|
| 106 | - $had_input = false; |
|
| 107 | - |
|
| 108 | - $f_in = fopen($path, "r"); |
|
| 109 | - if (!$f_in) { |
|
| 110 | - $this->success = false; |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | - |
|
| 116 | - xml_set_element_handler($xml_parser, |
|
| 117 | - array(&$this, "_startElement"), |
|
| 118 | - array(&$this, "_endElement")); |
|
| 119 | - |
|
| 120 | - xml_set_character_data_handler($xml_parser, |
|
| 121 | - array(&$this, "_data")); |
|
| 122 | - |
|
| 123 | - xml_parser_set_option($xml_parser, |
|
| 124 | - XML_OPTION_CASE_FOLDING, false); |
|
| 125 | - |
|
| 126 | - while($this->success && !feof($f_in)) { |
|
| 127 | - $line = fgets($f_in); |
|
| 128 | - if ($store_request) $this->request .= $line; |
|
| 129 | - if (is_string($line)) { |
|
| 130 | - $had_input = true; |
|
| 131 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if($had_input) { |
|
| 136 | - $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - xml_parser_free($xml_parser); |
|
| 140 | - |
|
| 141 | - fclose($f_in); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * tag start handler |
|
| 146 | - * |
|
| 147 | - * @param resource parser |
|
| 148 | - * @param string tag name |
|
| 149 | - * @param array tag attributes |
|
| 150 | - * @return void |
|
| 151 | - * @access private |
|
| 152 | - */ |
|
| 153 | - function _startElement($parser, $name, $attrs) |
|
| 154 | - { |
|
| 155 | - if (strstr($name, " ")) { |
|
| 156 | - list($ns, $tag) = explode(" ", $name); |
|
| 157 | - if ($ns == "") |
|
| 158 | - $this->success = false; |
|
| 159 | - } else { |
|
| 160 | - $ns = ""; |
|
| 161 | - $tag = $name; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if ($this->depth == 1) { |
|
| 165 | - $this->mode = $tag; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ($this->depth == 3) { |
|
| 169 | - $prop = array("name" => $tag); |
|
| 170 | - $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | - if ($this->mode == "set") { |
|
| 172 | - $this->current["val"] = ""; // default set val |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if ($this->depth >= 4) { |
|
| 177 | - $this->current["val"] .= "<$tag"; |
|
| 178 | - if (isset($attr)) { |
|
| 179 | - foreach ($attr as $key => $val) { |
|
| 180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $this->current["val"] .= ">"; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - $this->depth++; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * tag end handler |
|
| 193 | - * |
|
| 194 | - * @param resource parser |
|
| 195 | - * @param string tag name |
|
| 196 | - * @return void |
|
| 197 | - * @access private |
|
| 198 | - */ |
|
| 199 | - function _endElement($parser, $name) |
|
| 200 | - { |
|
| 201 | - if (strstr($name, " ")) { |
|
| 202 | - list($ns, $tag) = explode(" ", $name); |
|
| 203 | - if ($ns == "") |
|
| 204 | - $this->success = false; |
|
| 205 | - } else { |
|
| 206 | - $ns = ""; |
|
| 207 | - $tag = $name; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $this->depth--; |
|
| 211 | - |
|
| 212 | - if ($this->depth >= 4) { |
|
| 213 | - $this->current["val"] .= "</$tag>"; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if ($this->depth == 3) { |
|
| 217 | - if (isset($this->current)) { |
|
| 218 | - $this->props[] = $this->current; |
|
| 219 | - unset($this->current); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * input data handler |
|
| 226 | - * |
|
| 227 | - * @param resource parser |
|
| 228 | - * @param string data |
|
| 229 | - * @return void |
|
| 230 | - * @access private |
|
| 231 | - */ |
|
| 232 | - function _data($parser, $data) |
|
| 233 | - { |
|
| 234 | - if (isset($this->current)) { |
|
| 235 | - $this->current["val"] .= $data; |
|
| 236 | - } |
|
| 237 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * |
|
| 49 | + * @var |
|
| 50 | + * @access |
|
| 51 | + */ |
|
| 52 | + var $success; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * |
|
| 56 | + * |
|
| 57 | + * @var |
|
| 58 | + * @access |
|
| 59 | + */ |
|
| 60 | + var $props; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * |
|
| 64 | + * |
|
| 65 | + * @var |
|
| 66 | + * @access |
|
| 67 | + */ |
|
| 68 | + var $depth; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * |
|
| 72 | + * |
|
| 73 | + * @var |
|
| 74 | + * @access |
|
| 75 | + */ |
|
| 76 | + var $mode; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * |
|
| 80 | + * |
|
| 81 | + * @var |
|
| 82 | + * @access |
|
| 83 | + */ |
|
| 84 | + var $current; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * On return whole request, if $store_request == true was specified in constructor |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | + var $request; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * constructor |
|
| 95 | + * |
|
| 96 | + * @param string path of input stream |
|
| 97 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
| 98 | + * @access public |
|
| 99 | + */ |
|
| 100 | + function __construct($path, $store_request=false) |
|
| 101 | + { |
|
| 102 | + $this->success = true; |
|
| 103 | + |
|
| 104 | + $this->depth = 0; |
|
| 105 | + $this->props = array(); |
|
| 106 | + $had_input = false; |
|
| 107 | + |
|
| 108 | + $f_in = fopen($path, "r"); |
|
| 109 | + if (!$f_in) { |
|
| 110 | + $this->success = false; |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
| 115 | + |
|
| 116 | + xml_set_element_handler($xml_parser, |
|
| 117 | + array(&$this, "_startElement"), |
|
| 118 | + array(&$this, "_endElement")); |
|
| 119 | + |
|
| 120 | + xml_set_character_data_handler($xml_parser, |
|
| 121 | + array(&$this, "_data")); |
|
| 122 | + |
|
| 123 | + xml_parser_set_option($xml_parser, |
|
| 124 | + XML_OPTION_CASE_FOLDING, false); |
|
| 125 | + |
|
| 126 | + while($this->success && !feof($f_in)) { |
|
| 127 | + $line = fgets($f_in); |
|
| 128 | + if ($store_request) $this->request .= $line; |
|
| 129 | + if (is_string($line)) { |
|
| 130 | + $had_input = true; |
|
| 131 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if($had_input) { |
|
| 136 | + $this->success &= xml_parse($xml_parser, "", true); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + xml_parser_free($xml_parser); |
|
| 140 | + |
|
| 141 | + fclose($f_in); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * tag start handler |
|
| 146 | + * |
|
| 147 | + * @param resource parser |
|
| 148 | + * @param string tag name |
|
| 149 | + * @param array tag attributes |
|
| 150 | + * @return void |
|
| 151 | + * @access private |
|
| 152 | + */ |
|
| 153 | + function _startElement($parser, $name, $attrs) |
|
| 154 | + { |
|
| 155 | + if (strstr($name, " ")) { |
|
| 156 | + list($ns, $tag) = explode(" ", $name); |
|
| 157 | + if ($ns == "") |
|
| 158 | + $this->success = false; |
|
| 159 | + } else { |
|
| 160 | + $ns = ""; |
|
| 161 | + $tag = $name; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if ($this->depth == 1) { |
|
| 165 | + $this->mode = $tag; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ($this->depth == 3) { |
|
| 169 | + $prop = array("name" => $tag); |
|
| 170 | + $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
| 171 | + if ($this->mode == "set") { |
|
| 172 | + $this->current["val"] = ""; // default set val |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if ($this->depth >= 4) { |
|
| 177 | + $this->current["val"] .= "<$tag"; |
|
| 178 | + if (isset($attr)) { |
|
| 179 | + foreach ($attr as $key => $val) { |
|
| 180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $this->current["val"] .= ">"; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + $this->depth++; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * tag end handler |
|
| 193 | + * |
|
| 194 | + * @param resource parser |
|
| 195 | + * @param string tag name |
|
| 196 | + * @return void |
|
| 197 | + * @access private |
|
| 198 | + */ |
|
| 199 | + function _endElement($parser, $name) |
|
| 200 | + { |
|
| 201 | + if (strstr($name, " ")) { |
|
| 202 | + list($ns, $tag) = explode(" ", $name); |
|
| 203 | + if ($ns == "") |
|
| 204 | + $this->success = false; |
|
| 205 | + } else { |
|
| 206 | + $ns = ""; |
|
| 207 | + $tag = $name; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $this->depth--; |
|
| 211 | + |
|
| 212 | + if ($this->depth >= 4) { |
|
| 213 | + $this->current["val"] .= "</$tag>"; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if ($this->depth == 3) { |
|
| 217 | + if (isset($this->current)) { |
|
| 218 | + $this->props[] = $this->current; |
|
| 219 | + unset($this->current); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * input data handler |
|
| 226 | + * |
|
| 227 | + * @param resource parser |
|
| 228 | + * @param string data |
|
| 229 | + * @return void |
|
| 230 | + * @access private |
|
| 231 | + */ |
|
| 232 | + function _data($parser, $data) |
|
| 233 | + { |
|
| 234 | + if (isset($this->current)) { |
|
| 235 | + $this->current["val"] .= $data; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /* |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
| 98 | 98 | * @access public |
| 99 | 99 | */ |
| 100 | - function __construct($path, $store_request=false) |
|
| 100 | + function __construct($path, $store_request = false) |
|
| 101 | 101 | { |
| 102 | 102 | $this->success = true; |
| 103 | 103 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | xml_parser_set_option($xml_parser, |
| 124 | 124 | XML_OPTION_CASE_FOLDING, false); |
| 125 | 125 | |
| 126 | - while($this->success && !feof($f_in)) { |
|
| 126 | + while ($this->success && !feof($f_in)) { |
|
| 127 | 127 | $line = fgets($f_in); |
| 128 | 128 | if ($store_request) $this->request .= $line; |
| 129 | 129 | if (is_string($line)) { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if($had_input) { |
|
| 135 | + if ($had_input) { |
|
| 136 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $prop = array("name" => $tag); |
| 170 | 170 | $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
| 171 | 171 | if ($this->mode == "set") { |
| 172 | - $this->current["val"] = ""; // default set val |
|
| 172 | + $this->current["val"] = ""; // default set val |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->current["val"] .= "<$tag"; |
| 178 | 178 | if (isset($attr)) { |
| 179 | 179 | foreach ($attr as $key => $val) { |
| 180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
| 180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"', '"', $val).'"'; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | $this->current["val"] .= ">"; |
@@ -106,7 +106,8 @@ discard block |
||
| 106 | 106 | $had_input = false; |
| 107 | 107 | |
| 108 | 108 | $f_in = fopen($path, "r"); |
| 109 | - if (!$f_in) { |
|
| 109 | + if (!$f_in) |
|
| 110 | + { |
|
| 110 | 111 | $this->success = false; |
| 111 | 112 | return; |
| 112 | 113 | } |
@@ -123,16 +124,22 @@ discard block |
||
| 123 | 124 | xml_parser_set_option($xml_parser, |
| 124 | 125 | XML_OPTION_CASE_FOLDING, false); |
| 125 | 126 | |
| 126 | - while($this->success && !feof($f_in)) { |
|
| 127 | + while($this->success && !feof($f_in)) |
|
| 128 | + { |
|
| 127 | 129 | $line = fgets($f_in); |
| 128 | - if ($store_request) $this->request .= $line; |
|
| 129 | - if (is_string($line)) { |
|
| 130 | + if ($store_request) |
|
| 131 | + { |
|
| 132 | + $this->request .= $line; |
|
| 133 | + } |
|
| 134 | + if (is_string($line)) |
|
| 135 | + { |
|
| 130 | 136 | $had_input = true; |
| 131 | 137 | $this->success &= xml_parse($xml_parser, $line, false); |
| 132 | 138 | } |
| 133 | 139 | } |
| 134 | 140 | |
| 135 | - if($had_input) { |
|
| 141 | + if($had_input) |
|
| 142 | + { |
|
| 136 | 143 | $this->success &= xml_parse($xml_parser, "", true); |
| 137 | 144 | } |
| 138 | 145 | |
@@ -152,31 +159,42 @@ discard block |
||
| 152 | 159 | */ |
| 153 | 160 | function _startElement($parser, $name, $attrs) |
| 154 | 161 | { |
| 155 | - if (strstr($name, " ")) { |
|
| 162 | + if (strstr($name, " ")) |
|
| 163 | + { |
|
| 156 | 164 | list($ns, $tag) = explode(" ", $name); |
| 157 | 165 | if ($ns == "") |
| 158 | - $this->success = false; |
|
| 159 | - } else { |
|
| 166 | + { |
|
| 167 | + $this->success = false; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + else |
|
| 171 | + { |
|
| 160 | 172 | $ns = ""; |
| 161 | 173 | $tag = $name; |
| 162 | 174 | } |
| 163 | 175 | |
| 164 | - if ($this->depth == 1) { |
|
| 176 | + if ($this->depth == 1) |
|
| 177 | + { |
|
| 165 | 178 | $this->mode = $tag; |
| 166 | 179 | } |
| 167 | 180 | |
| 168 | - if ($this->depth == 3) { |
|
| 181 | + if ($this->depth == 3) |
|
| 182 | + { |
|
| 169 | 183 | $prop = array("name" => $tag); |
| 170 | 184 | $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
| 171 | - if ($this->mode == "set") { |
|
| 185 | + if ($this->mode == "set") |
|
| 186 | + { |
|
| 172 | 187 | $this->current["val"] = ""; // default set val |
| 173 | 188 | } |
| 174 | 189 | } |
| 175 | 190 | |
| 176 | - if ($this->depth >= 4) { |
|
| 191 | + if ($this->depth >= 4) |
|
| 192 | + { |
|
| 177 | 193 | $this->current["val"] .= "<$tag"; |
| 178 | - if (isset($attr)) { |
|
| 179 | - foreach ($attr as $key => $val) { |
|
| 194 | + if (isset($attr)) |
|
| 195 | + { |
|
| 196 | + foreach ($attr as $key => $val) |
|
| 197 | + { |
|
| 180 | 198 | $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
| 181 | 199 | } |
| 182 | 200 | } |
@@ -198,23 +216,31 @@ discard block |
||
| 198 | 216 | */ |
| 199 | 217 | function _endElement($parser, $name) |
| 200 | 218 | { |
| 201 | - if (strstr($name, " ")) { |
|
| 219 | + if (strstr($name, " ")) |
|
| 220 | + { |
|
| 202 | 221 | list($ns, $tag) = explode(" ", $name); |
| 203 | 222 | if ($ns == "") |
| 204 | - $this->success = false; |
|
| 205 | - } else { |
|
| 223 | + { |
|
| 224 | + $this->success = false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + else |
|
| 228 | + { |
|
| 206 | 229 | $ns = ""; |
| 207 | 230 | $tag = $name; |
| 208 | 231 | } |
| 209 | 232 | |
| 210 | 233 | $this->depth--; |
| 211 | 234 | |
| 212 | - if ($this->depth >= 4) { |
|
| 235 | + if ($this->depth >= 4) |
|
| 236 | + { |
|
| 213 | 237 | $this->current["val"] .= "</$tag>"; |
| 214 | 238 | } |
| 215 | 239 | |
| 216 | - if ($this->depth == 3) { |
|
| 217 | - if (isset($this->current)) { |
|
| 240 | + if ($this->depth == 3) |
|
| 241 | + { |
|
| 242 | + if (isset($this->current)) |
|
| 243 | + { |
|
| 218 | 244 | $this->props[] = $this->current; |
| 219 | 245 | unset($this->current); |
| 220 | 246 | } |
@@ -231,7 +257,8 @@ discard block |
||
| 231 | 257 | */ |
| 232 | 258 | function _data($parser, $data) |
| 233 | 259 | { |
| 234 | - if (isset($this->current)) { |
|
| 260 | + if (isset($this->current)) |
|
| 261 | + { |
|
| 235 | 262 | $this->current["val"] .= $data; |
| 236 | 263 | } |
| 237 | 264 | } |
@@ -80,6 +80,7 @@ |
||
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Returns the maximum width/height of a thumbnail |
| 83 | + * @return integer|null |
|
| 83 | 84 | */ |
| 84 | 85 | function get_maxsize() |
| 85 | 86 | { |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if (!preg_match('/^[a-z0-9_-]+$/i',$app)) |
|
| 73 | + if (!preg_match('/^[a-z0-9_-]+$/i', $app)) |
|
| 74 | 74 | { |
| 75 | - die('Stop'); // just to prevent someone doing nasty things |
|
| 75 | + die('Stop'); // just to prevent someone doing nasty things |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $app; |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function get_maxsize() |
| 85 | 85 | { |
| 86 | - $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : |
|
| 87 | - $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
| 86 | + $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
| 88 | 87 | |
| 89 | 88 | // Another maximum size may be passed if thumbnails are turned on |
| 90 | 89 | if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize'])) |
@@ -150,7 +149,7 @@ discard block |
||
| 150 | 149 | } |
| 151 | 150 | $dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize); |
| 152 | 151 | $dst_dir = dirname($dst); |
| 153 | - if(file_exists($dst_dir)) |
|
| 152 | + if (file_exists($dst_dir)) |
|
| 154 | 153 | { |
| 155 | 154 | // Check whether the destination file already exists and is newer than |
| 156 | 155 | // the source file. Assume the file doesn't exist if thumbnailing is turned off. |
@@ -190,7 +189,7 @@ discard block |
||
| 190 | 189 | { |
| 191 | 190 | // Allow client to cache these, makes scrolling in filemanager much nicer |
| 192 | 191 | // setting maximum allow caching time of one year, if url contains (non-empty) moditication time |
| 193 | - Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
| 192 | + Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
| 194 | 193 | header('Content-Type: '.$output_mime); |
| 195 | 194 | readfile($dst); |
| 196 | 195 | return true; |
@@ -212,7 +211,7 @@ discard block |
||
| 212 | 211 | * @param int $minsize =null |
| 213 | 212 | * @return string |
| 214 | 213 | */ |
| 215 | -function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null) |
|
| 214 | +function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null) |
|
| 216 | 215 | { |
| 217 | 216 | // Use the egroupware file cache to store the thumbnails on a per instance basis |
| 218 | 217 | $cachefile = new Api\Cache\Files(array()); |
@@ -238,7 +237,7 @@ discard block |
||
| 238 | 237 | * TODO: As this is a general purpose function, it might probably be moved |
| 239 | 238 | * to some other php file or an "image utils" class. |
| 240 | 239 | */ |
| 241 | -function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0) |
|
| 240 | +function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0) |
|
| 242 | 241 | { |
| 243 | 242 | //Scale will contain the factor by which the image has to be scaled down |
| 244 | 243 | $scale = 1.0; |
@@ -299,7 +298,7 @@ discard block |
||
| 299 | 298 | * @param int $maxh the maximum height of the thumbnail |
| 300 | 299 | * @returns boolean|resource false or a gd_image |
| 301 | 300 | */ |
| 302 | -function gd_image_load($file,$maxw,$maxh) |
|
| 301 | +function gd_image_load($file, $maxw, $maxh) |
|
| 303 | 302 | { |
| 304 | 303 | // Get mime type |
| 305 | 304 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
@@ -307,9 +306,9 @@ discard block |
||
| 307 | 306 | if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
| 308 | 307 | |
| 309 | 308 | // Call the according gd constructor depending on the file type |
| 310 | - if($type == 'image') |
|
| 309 | + if ($type == 'image') |
|
| 311 | 310 | { |
| 312 | - if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file))) |
|
| 311 | + if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file))) |
|
| 313 | 312 | { |
| 314 | 313 | return $image; |
| 315 | 314 | } |
@@ -332,12 +331,12 @@ discard block |
||
| 332 | 331 | else if ($type == 'application') |
| 333 | 332 | { |
| 334 | 333 | $thumb = false; |
| 335 | - if(strpos($image_type,'vnd.oasis.opendocument.') === 0) |
|
| 334 | + if (strpos($image_type, 'vnd.oasis.opendocument.') === 0) |
|
| 336 | 335 | { |
| 337 | 336 | // OpenDocuments have thumbnails inside already |
| 338 | 337 | $thumb = get_opendocument_thumbnail($file); |
| 339 | 338 | } |
| 340 | - else if($image_type == 'pdf') |
|
| 339 | + else if ($image_type == 'pdf') |
|
| 341 | 340 | { |
| 342 | 341 | $thumb = get_pdf_thumbnail($file); |
| 343 | 342 | } |
@@ -347,7 +346,7 @@ discard block |
||
| 347 | 346 | //$thumb = get_msoffice_thumbnail($file); |
| 348 | 347 | } |
| 349 | 348 | // Mark it with mime type icon |
| 350 | - if($thumb) |
|
| 349 | + if ($thumb) |
|
| 351 | 350 | { |
| 352 | 351 | // Need to scale first, or the mark will be wrong size |
| 353 | 352 | $scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh); |
@@ -387,8 +386,8 @@ discard block |
||
| 387 | 386 | |
| 388 | 387 | // Image is already there, but we can't access them directly through VFS |
| 389 | 388 | $ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods'; |
| 390 | - $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-'); |
|
| 391 | - copy($file,$archive); |
|
| 389 | + $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-'); |
|
| 390 | + copy($file, $archive); |
|
| 392 | 391 | |
| 393 | 392 | $thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png'; |
| 394 | 393 | $image = imagecreatefromstring(file_get_contents($thumbnail_url)); |
@@ -442,7 +441,7 @@ discard block |
||
| 442 | 441 | */ |
| 443 | 442 | function get_pdf_thumbnail($file) |
| 444 | 443 | { |
| 445 | - if(!pdf_thumbnails_available()) return false; |
|
| 444 | + if (!pdf_thumbnails_available()) return false; |
|
| 446 | 445 | |
| 447 | 446 | // switch off max_excution_time, as some thumbnails take longer and |
| 448 | 447 | // will be startet over and over again, if they dont finish |
@@ -471,7 +470,7 @@ discard block |
||
| 471 | 470 | $target_height = imagesy($target_image); |
| 472 | 471 | |
| 473 | 472 | // Find mime image, if no tag image set |
| 474 | - if(!$tag_image && $mime) |
|
| 473 | + if (!$tag_image && $mime) |
|
| 475 | 474 | { |
| 476 | 475 | list($app, $icon) = explode('/', Vfs::mime_icon($mime), 2); |
| 477 | 476 | list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'], |
@@ -482,16 +481,16 @@ discard block |
||
| 482 | 481 | |
| 483 | 482 | // Find correct size - max 1/3 target |
| 484 | 483 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
| 485 | - if(!$tag_size) return; |
|
| 486 | - list($tag_width,$tag_height) = $tag_size; |
|
| 484 | + if (!$tag_size) return; |
|
| 485 | + list($tag_width, $tag_height) = $tag_size; |
|
| 487 | 486 | |
| 488 | 487 | // Put it in |
| 489 | - if($mime) |
|
| 488 | + if ($mime) |
|
| 490 | 489 | { |
| 491 | - imagecopyresampled($target_image,$tag_image, |
|
| 490 | + imagecopyresampled($target_image, $tag_image, |
|
| 492 | 491 | $target_width - $tag_width, |
| 493 | 492 | $target_height - $tag_height, |
| 494 | - 0,0, |
|
| 493 | + 0, 0, |
|
| 495 | 494 | $tag_width, |
| 496 | 495 | $tag_height, |
| 497 | 496 | imagesx($tag_image), |
@@ -545,7 +544,7 @@ discard block |
||
| 545 | 544 | function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh) |
| 546 | 545 | { |
| 547 | 546 | //Load the image |
| 548 | - if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false) |
|
| 547 | + if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false) |
|
| 549 | 548 | { |
| 550 | 549 | //Get the constraints of the image |
| 551 | 550 | $w = imagesx($img_src); |
@@ -575,14 +574,14 @@ discard block |
||
| 575 | 574 | */ |
| 576 | 575 | function gdVersion($user_ver = 0) |
| 577 | 576 | { |
| 578 | - if (! extension_loaded('gd')) { return; } |
|
| 577 | + if (!extension_loaded('gd')) { return; } |
|
| 579 | 578 | static $gd_ver = 0; |
| 580 | 579 | |
| 581 | 580 | // Just accept the specified setting if it's 1. |
| 582 | 581 | if ($user_ver == 1) { $gd_ver = 1; return 1; } |
| 583 | 582 | |
| 584 | 583 | // Use the static variable if function was called previously. |
| 585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
| 584 | + if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; } |
|
| 586 | 585 | |
| 587 | 586 | // Use the gd_info() function if possible. |
| 588 | 587 | if (function_exists('gd_info')) { |
@@ -244,10 +244,13 @@ discard block |
||
| 244 | 244 | $scale = 1.0; |
| 245 | 245 | |
| 246 | 246 | //Select the constraining dimension |
| 247 | - if ($w > $h) // landscape image: constraining factor $minh or $maxw |
|
| 247 | + if ($w > $h) |
|
| 248 | + { |
|
| 249 | + // landscape image: constraining factor $minh or $maxw |
|
| 248 | 250 | { |
| 249 | 251 | $scale = $minh ? $minh / $h : $maxw / $w; |
| 250 | 252 | } |
| 253 | + } |
|
| 251 | 254 | else // portrail image: constraining factor $minw or $maxh |
| 252 | 255 | { |
| 253 | 256 | $scale = $minw ? $minw / $w : $maxh / $h; |
@@ -304,7 +307,10 @@ discard block |
||
| 304 | 307 | // Get mime type |
| 305 | 308 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
| 306 | 309 | // if $file is not from vfs, use Api\MimeMagic::filename2mime to get mime-type from extension |
| 307 | - if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
| 310 | + if (!$type) |
|
| 311 | + { |
|
| 312 | + list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
| 313 | + } |
|
| 308 | 314 | |
| 309 | 315 | // Call the according gd constructor depending on the file type |
| 310 | 316 | if($type == 'image') |
@@ -442,7 +448,10 @@ discard block |
||
| 442 | 448 | */ |
| 443 | 449 | function get_pdf_thumbnail($file) |
| 444 | 450 | { |
| 445 | - if(!pdf_thumbnails_available()) return false; |
|
| 451 | + if(!pdf_thumbnails_available()) |
|
| 452 | + { |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 446 | 455 | |
| 447 | 456 | // switch off max_excution_time, as some thumbnails take longer and |
| 448 | 457 | // will be startet over and over again, if they dont finish |
@@ -482,7 +491,10 @@ discard block |
||
| 482 | 491 | |
| 483 | 492 | // Find correct size - max 1/3 target |
| 484 | 493 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
| 485 | - if(!$tag_size) return; |
|
| 494 | + if(!$tag_size) |
|
| 495 | + { |
|
| 496 | + return; |
|
| 497 | + } |
|
| 486 | 498 | list($tag_width,$tag_height) = $tag_size; |
| 487 | 499 | |
| 488 | 500 | // Put it in |
@@ -575,17 +587,24 @@ discard block |
||
| 575 | 587 | */ |
| 576 | 588 | function gdVersion($user_ver = 0) |
| 577 | 589 | { |
| 578 | - if (! extension_loaded('gd')) { return; } |
|
| 590 | + if (! extension_loaded('gd')) |
|
| 591 | + { |
|
| 592 | +return; } |
|
| 579 | 593 | static $gd_ver = 0; |
| 580 | 594 | |
| 581 | 595 | // Just accept the specified setting if it's 1. |
| 582 | - if ($user_ver == 1) { $gd_ver = 1; return 1; } |
|
| 596 | + if ($user_ver == 1) |
|
| 597 | + { |
|
| 598 | +$gd_ver = 1; return 1; } |
|
| 583 | 599 | |
| 584 | 600 | // Use the static variable if function was called previously. |
| 585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
| 601 | + if ($user_ver !=2 && $gd_ver > 0 ) |
|
| 602 | + { |
|
| 603 | +return $gd_ver; } |
|
| 586 | 604 | |
| 587 | 605 | // Use the gd_info() function if possible. |
| 588 | - if (function_exists('gd_info')) { |
|
| 606 | + if (function_exists('gd_info')) |
|
| 607 | + { |
|
| 589 | 608 | $ver_info = gd_info(); |
| 590 | 609 | $match = null; |
| 591 | 610 | preg_match('/\d/', $ver_info['GD Version'], $match); |
@@ -594,11 +613,15 @@ discard block |
||
| 594 | 613 | } |
| 595 | 614 | |
| 596 | 615 | // If phpinfo() is disabled use a specified / fail-safe choice... |
| 597 | - if (preg_match('/phpinfo/', ini_get('disable_functions'))) { |
|
| 598 | - if ($user_ver == 2) { |
|
| 616 | + if (preg_match('/phpinfo/', ini_get('disable_functions'))) |
|
| 617 | + { |
|
| 618 | + if ($user_ver == 2) |
|
| 619 | + { |
|
| 599 | 620 | $gd_ver = 2; |
| 600 | 621 | return 2; |
| 601 | - } else { |
|
| 622 | + } |
|
| 623 | + else |
|
| 624 | + { |
|
| 602 | 625 | $gd_ver = 1; |
| 603 | 626 | return 1; |
| 604 | 627 | } |
@@ -607,6 +630,9 @@ discard block |
||
| 607 | 630 | ob_start(); |
| 608 | 631 | phpinfo(8); |
| 609 | 632 | $info = stristr(ob_get_clean(), 'gd version'); |
| 610 | - if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0]; |
|
| 633 | + if (preg_match('/\d/', $info, $match)) |
|
| 634 | + { |
|
| 635 | + $gd_ver = $match[0]; |
|
| 636 | + } |
|
| 611 | 637 | return $match[0]; |
| 612 | 638 | } |
@@ -94,7 +94,6 @@ |
||
| 94 | 94 | /** |
| 95 | 95 | * imports entries according to given definition object. |
| 96 | 96 | * @param resource $_stream |
| 97 | - * @param string $_charset |
|
| 98 | 97 | * @param definition $_definition |
| 99 | 98 | */ |
| 100 | 99 | public function import( $_stream, definition $_definition ) { |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | private $user = null; |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | - * List of import errors |
|
| 86 | - */ |
|
| 87 | - protected $errors = array(); |
|
| 85 | + * List of import errors |
|
| 86 | + */ |
|
| 87 | + protected $errors = array(); |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * List of actions, and how many times that action was taken |
@@ -305,26 +305,26 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | - * Returns errors that were encountered during importing |
|
| 309 | - * Maximum of one error message per record, but you can append if you need to |
|
| 310 | - * |
|
| 311 | - * @return Array ( |
|
| 312 | - * record_# => error message |
|
| 313 | - * ) |
|
| 314 | - */ |
|
| 315 | - public function get_errors() { |
|
| 308 | + * Returns errors that were encountered during importing |
|
| 309 | + * Maximum of one error message per record, but you can append if you need to |
|
| 310 | + * |
|
| 311 | + * @return Array ( |
|
| 312 | + * record_# => error message |
|
| 313 | + * ) |
|
| 314 | + */ |
|
| 315 | + public function get_errors() { |
|
| 316 | 316 | return $this->errors; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | - * Returns a list of actions taken, and the number of records for that action. |
|
| 321 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 322 | - * |
|
| 323 | - * @return Array ( |
|
| 324 | - * action => record count |
|
| 325 | - * ) |
|
| 326 | - */ |
|
| 327 | - public function get_results() { |
|
| 320 | + * Returns a list of actions taken, and the number of records for that action. |
|
| 321 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 322 | + * |
|
| 323 | + * @return Array ( |
|
| 324 | + * action => record count |
|
| 325 | + * ) |
|
| 326 | + */ |
|
| 327 | + public function get_results() { |
|
| 328 | 328 | return $this->results; |
| 329 | 329 | } |
| 330 | 330 | } // end of iface_export_plugin |
@@ -10,28 +10,28 @@ discard block |
||
| 10 | 10 | * @version $Id: $ |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php'); |
|
| 13 | +require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php'); |
|
| 14 | 14 | require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php'); |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for addressbook |
| 19 | 19 | */ |
| 20 | -class import_events_csv implements iface_import_plugin { |
|
| 20 | +class import_events_csv implements iface_import_plugin { |
|
| 21 | 21 | |
| 22 | 22 | private static $plugin_options = array( |
| 23 | - 'fieldsep', // char |
|
| 24 | - 'charset', // string |
|
| 25 | - 'event_owner', // int account_id or -1 for leave untuched |
|
| 26 | - 'owner_joins_event', // bool |
|
| 27 | - 'update_cats', // string {override|add} overides record |
|
| 23 | + 'fieldsep', // char |
|
| 24 | + 'charset', // string |
|
| 25 | + 'event_owner', // int account_id or -1 for leave untuched |
|
| 26 | + 'owner_joins_event', // bool |
|
| 27 | + 'update_cats', // string {override|add} overides record |
|
| 28 | 28 | // with cat(s) from csv OR add the cat from |
| 29 | 29 | // csv file to exeisting cat(s) of record |
| 30 | - 'num_header_lines', // int number of header lines |
|
| 31 | - 'trash_users_records', // trashes all events of events owner before import |
|
| 32 | - 'field_conversion', // array( $csv_col_num => conversion) |
|
| 33 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
| 34 | - 'conditions', /* => array containing condition arrays: |
|
| 30 | + 'num_header_lines', // int number of header lines |
|
| 31 | + 'trash_users_records', // trashes all events of events owner before import |
|
| 32 | + 'field_conversion', // array( $csv_col_num => conversion) |
|
| 33 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
| 34 | + 'conditions', /* => array containing condition arrays: |
|
| 35 | 35 | 'type' => exists, // record['uid'] exists |
| 36 | 36 | 'true' => array( |
| 37 | 37 | 'action' => update, |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * actions wich could be done to data entries |
| 49 | 49 | */ |
| 50 | - private static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
| 50 | + private static $actions = array('none', 'update', 'insert', 'delete',); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * conditions for actions |
| 54 | 54 | * |
| 55 | 55 | * @var array |
| 56 | 56 | */ |
| 57 | - private static $conditions = array( 'exists', 'empty', ); |
|
| 57 | + private static $conditions = array('exists', 'empty',); |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @var definition |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param string $_charset |
| 98 | 98 | * @param definition $_definition |
| 99 | 99 | */ |
| 100 | - public function import( $_stream, definition $_definition ) { |
|
| 101 | - $import_csv = new import_csv( $_stream, array( |
|
| 100 | + public function import($_stream, definition $_definition) { |
|
| 101 | + $import_csv = new import_csv($_stream, array( |
|
| 102 | 102 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
| 103 | 103 | 'charset' => $_definition->plugin_options['charset'], |
| 104 | 104 | )); |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | $this->definition = $_definition; |
| 107 | 107 | |
| 108 | 108 | // user, is admin ? |
| 109 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 109 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 110 | 110 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
| 111 | 111 | |
| 112 | 112 | // dry run? |
| 113 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
| 113 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
| 114 | 114 | |
| 115 | 115 | // fetch the calendar bo |
| 116 | 116 | $this->bocalupdate = new calendar_boupdate(); |
@@ -122,24 +122,24 @@ discard block |
||
| 122 | 122 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
| 123 | 123 | |
| 124 | 124 | //check if file has a header lines |
| 125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
| 126 | - $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
|
| 125 | + if (isset($_definition->plugin_options['num_header_lines'])) { |
|
| 126 | + $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // set eventOwner |
| 130 | 130 | $plugin_options = $_definition->plugin_options; |
| 131 | - $plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ? |
|
| 131 | + $plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ? |
|
| 132 | 132 | $_definition->plugin_options['events_owner'] : $this->user; |
| 133 | 133 | $_definition->plugin_options = $plugin_options; |
| 134 | 134 | |
| 135 | 135 | // trash_users_records ? |
| 136 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
| 137 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
| 136 | + if ($_definition->plugin_options['trash_users_records'] === true) { |
|
| 137 | + if (!$_definition->plugin_options['dry_run']) { |
|
| 138 | 138 | $socal = new calendar_socal(); |
| 139 | - $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
|
| 140 | - unset( $socal ); |
|
| 139 | + $this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']); |
|
| 140 | + unset($socal); |
|
| 141 | 141 | } else { |
| 142 | - $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
|
| 142 | + $lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']); |
|
| 143 | 143 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -147,44 +147,44 @@ discard block |
||
| 147 | 147 | $this->errors = array(); |
| 148 | 148 | $this->results = array(); |
| 149 | 149 | |
| 150 | - while ( $record = $import_csv->get_record() ) { |
|
| 150 | + while ($record = $import_csv->get_record()) { |
|
| 151 | 151 | |
| 152 | 152 | // don't import empty events |
| 153 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
| 153 | + if (count(array_unique($record)) < 2) continue; |
|
| 154 | 154 | |
| 155 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
| 155 | + if ($_definition->plugin_options['events_owner'] != -1) { |
|
| 156 | 156 | $record['owner'] = $_definition->plugin_options['events_owner']; |
| 157 | - } else unset( $record['owner'] ); |
|
| 157 | + } else unset($record['owner']); |
|
| 158 | 158 | |
| 159 | - if ( $_definition->plugin_options['conditions'] ) { |
|
| 160 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
| 161 | - switch ( $condition['type'] ) { |
|
| 159 | + if ($_definition->plugin_options['conditions']) { |
|
| 160 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
| 161 | + switch ($condition['type']) { |
|
| 162 | 162 | // exists |
| 163 | 163 | case 'exists' : |
| 164 | 164 | |
| 165 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
| 165 | + if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) { |
|
| 166 | 166 | // apply action to event matching this exists condition |
| 167 | 167 | $record['id'] = $event['id']; |
| 168 | 168 | |
| 169 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
| 170 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
| 171 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
| 172 | - $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
|
| 169 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
| 170 | + if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']); |
|
| 171 | + if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']); |
|
| 172 | + $record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id']))); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // check if entry is modiefied |
| 176 | - $event = array_intersect_key( $event, $record ); |
|
| 177 | - $diff = array_diff( $event, $record ); |
|
| 178 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
| 176 | + $event = array_intersect_key($event, $record); |
|
| 177 | + $diff = array_diff($event, $record); |
|
| 178 | + if (!empty($diff)) $record['modified'] = time(); |
|
| 179 | 179 | |
| 180 | 180 | $action = $condition['true']; |
| 181 | 181 | } else $action = $condition['false']; |
| 182 | 182 | |
| 183 | - $this->action( $action['action'], $record ); |
|
| 183 | + $this->action($action['action'], $record); |
|
| 184 | 184 | break; |
| 185 | 185 | case 'empty' : |
| 186 | - $action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false']; |
|
| 187 | - $this->action( $action['action'], $record ); |
|
| 186 | + $action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false']; |
|
| 187 | + $this->action($action['action'], $record); |
|
| 188 | 188 | break; |
| 189 | 189 | |
| 190 | 190 | // not supported action |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | } else { |
| 198 | 198 | // unconditional insert |
| 199 | - $this->action( 'insert', $record ); |
|
| 199 | + $this->action('insert', $record); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * @param array $_data event data for the action |
| 209 | 209 | * @return bool success or not |
| 210 | 210 | */ |
| 211 | - private function action ( $_action, $_data ) { |
|
| 212 | - switch ( $_action ) { |
|
| 211 | + private function action($_action, $_data) { |
|
| 212 | + switch ($_action) { |
|
| 213 | 213 | case 'none' : |
| 214 | 214 | return true; |
| 215 | 215 | |
@@ -217,32 +217,32 @@ discard block |
||
| 217 | 217 | case 'insert' : |
| 218 | 218 | |
| 219 | 219 | // paticipants handling |
| 220 | - $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
|
| 220 | + $participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array(); |
|
| 221 | 221 | $_data['participants'] = array(); |
| 222 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
| 222 | + if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) { |
|
| 223 | 223 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
| 224 | 224 | } |
| 225 | - foreach( $participants as $participant ) { |
|
| 226 | - list( $participant, $status ) = explode( '=', $participant ); |
|
| 227 | - $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
|
| 228 | - $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
|
| 229 | - if ( $participant && is_numeric($participant ) ) { |
|
| 225 | + foreach ($participants as $participant) { |
|
| 226 | + list($participant, $status) = explode('=', $participant); |
|
| 227 | + $valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T'); |
|
| 228 | + $status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U'; |
|
| 229 | + if ($participant && is_numeric($participant)) { |
|
| 230 | 230 | $_data['participants'][$participant] = $status; |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | // no valid participants so far --> add the importing user/owner |
| 234 | - if ( empty( $_data['participants'] ) ) { |
|
| 234 | + if (empty($_data['participants'])) { |
|
| 235 | 235 | $_data['participants'][$this->user] = 'A'; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // are we serious? |
| 239 | - if ( $this->dry_run ) { |
|
| 239 | + if ($this->dry_run) { |
|
| 240 | 240 | print_r($_data); |
| 241 | 241 | $this->results[$_action]++; |
| 242 | 242 | } else { |
| 243 | 243 | $messages = array(); |
| 244 | - $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
| 245 | - if(!$result) { |
|
| 244 | + $result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
| 245 | + if (!$result) { |
|
| 246 | 246 | $this->errors = implode(',', $messages); |
| 247 | 247 | } else { |
| 248 | 248 | $this->results[$_action]++; |
@@ -17,7 +17,8 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for addressbook |
| 19 | 19 | */ |
| 20 | -class import_events_csv implements iface_import_plugin { |
|
| 20 | +class import_events_csv implements iface_import_plugin |
|
| 21 | +{ |
|
| 21 | 22 | |
| 22 | 23 | private static $plugin_options = array( |
| 23 | 24 | 'fieldsep', // char |
@@ -97,7 +98,8 @@ discard block |
||
| 97 | 98 | * @param string $_charset |
| 98 | 99 | * @param definition $_definition |
| 99 | 100 | */ |
| 100 | - public function import( $_stream, definition $_definition ) { |
|
| 101 | + public function import( $_stream, definition $_definition ) |
|
| 102 | + { |
|
| 101 | 103 | $import_csv = new import_csv( $_stream, array( |
| 102 | 104 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
| 103 | 105 | 'charset' => $_definition->plugin_options['charset'], |
@@ -122,7 +124,8 @@ discard block |
||
| 122 | 124 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
| 123 | 125 | |
| 124 | 126 | //check if file has a header lines |
| 125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
| 127 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) ) |
|
| 128 | + { |
|
| 126 | 129 | $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
| 127 | 130 | } |
| 128 | 131 | |
@@ -133,12 +136,16 @@ discard block |
||
| 133 | 136 | $_definition->plugin_options = $plugin_options; |
| 134 | 137 | |
| 135 | 138 | // trash_users_records ? |
| 136 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
| 137 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
| 139 | + if ( $_definition->plugin_options['trash_users_records'] === true ) |
|
| 140 | + { |
|
| 141 | + if ( !$_definition->plugin_options['dry_run'] ) |
|
| 142 | + { |
|
| 138 | 143 | $socal = new calendar_socal(); |
| 139 | 144 | $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
| 140 | 145 | unset( $socal ); |
| 141 | - } else { |
|
| 146 | + } |
|
| 147 | + else |
|
| 148 | + { |
|
| 142 | 149 | $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
| 143 | 150 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
| 144 | 151 | } |
@@ -147,38 +154,63 @@ discard block |
||
| 147 | 154 | $this->errors = array(); |
| 148 | 155 | $this->results = array(); |
| 149 | 156 | |
| 150 | - while ( $record = $import_csv->get_record() ) { |
|
| 157 | + while ( $record = $import_csv->get_record() ) |
|
| 158 | + { |
|
| 151 | 159 | |
| 152 | 160 | // don't import empty events |
| 153 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
| 161 | + if( count( array_unique( $record ) ) < 2 ) |
|
| 162 | + { |
|
| 163 | + continue; |
|
| 164 | + } |
|
| 154 | 165 | |
| 155 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
| 166 | + if ( $_definition->plugin_options['events_owner'] != -1 ) |
|
| 167 | + { |
|
| 156 | 168 | $record['owner'] = $_definition->plugin_options['events_owner']; |
| 157 | - } else unset( $record['owner'] ); |
|
| 169 | + } |
|
| 170 | + else { |
|
| 171 | + unset( $record['owner'] ); |
|
| 172 | + } |
|
| 158 | 173 | |
| 159 | - if ( $_definition->plugin_options['conditions'] ) { |
|
| 160 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
| 161 | - switch ( $condition['type'] ) { |
|
| 174 | + if ( $_definition->plugin_options['conditions'] ) |
|
| 175 | + { |
|
| 176 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
| 177 | + { |
|
| 178 | + switch ( $condition['type'] ) |
|
| 179 | + { |
|
| 162 | 180 | // exists |
| 163 | 181 | case 'exists' : |
| 164 | 182 | |
| 165 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
| 183 | + if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) |
|
| 184 | + { |
|
| 166 | 185 | // apply action to event matching this exists condition |
| 167 | 186 | $record['id'] = $event['id']; |
| 168 | 187 | |
| 169 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
| 170 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
| 171 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
| 188 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
| 189 | + { |
|
| 190 | + if ( !is_array( $event['cat_id'] ) ) |
|
| 191 | + { |
|
| 192 | + $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
| 193 | + } |
|
| 194 | + if ( !is_array( $record['cat_id'] ) ) |
|
| 195 | + { |
|
| 196 | + $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
| 197 | + } |
|
| 172 | 198 | $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
| 173 | 199 | } |
| 174 | 200 | |
| 175 | 201 | // check if entry is modiefied |
| 176 | 202 | $event = array_intersect_key( $event, $record ); |
| 177 | 203 | $diff = array_diff( $event, $record ); |
| 178 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
| 204 | + if( !empty( $diff ) ) |
|
| 205 | + { |
|
| 206 | + $record['modified'] = time(); |
|
| 207 | + } |
|
| 179 | 208 | |
| 180 | 209 | $action = $condition['true']; |
| 181 | - } else $action = $condition['false']; |
|
| 210 | + } |
|
| 211 | + else { |
|
| 212 | + $action = $condition['false']; |
|
| 213 | + } |
|
| 182 | 214 | |
| 183 | 215 | $this->action( $action['action'], $record ); |
| 184 | 216 | break; |
@@ -192,9 +224,14 @@ discard block |
||
| 192 | 224 | throw new Exception('condition not supported!!!'); |
| 193 | 225 | break; |
| 194 | 226 | } |
| 195 | - if ($action['last']) break; |
|
| 227 | + if ($action['last']) |
|
| 228 | + { |
|
| 229 | + break; |
|
| 230 | + } |
|
| 196 | 231 | } |
| 197 | - } else { |
|
| 232 | + } |
|
| 233 | + else |
|
| 234 | + { |
|
| 198 | 235 | // unconditional insert |
| 199 | 236 | $this->action( 'insert', $record ); |
| 200 | 237 | } |
@@ -208,8 +245,10 @@ discard block |
||
| 208 | 245 | * @param array $_data event data for the action |
| 209 | 246 | * @return bool success or not |
| 210 | 247 | */ |
| 211 | - private function action ( $_action, $_data ) { |
|
| 212 | - switch ( $_action ) { |
|
| 248 | + private function action ( $_action, $_data ) |
|
| 249 | + { |
|
| 250 | + switch ( $_action ) |
|
| 251 | + { |
|
| 213 | 252 | case 'none' : |
| 214 | 253 | return true; |
| 215 | 254 | |
@@ -219,32 +258,42 @@ discard block |
||
| 219 | 258 | // paticipants handling |
| 220 | 259 | $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
| 221 | 260 | $_data['participants'] = array(); |
| 222 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
| 261 | + if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) |
|
| 262 | + { |
|
| 223 | 263 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
| 224 | 264 | } |
| 225 | - foreach( $participants as $participant ) { |
|
| 265 | + foreach( $participants as $participant ) |
|
| 266 | + { |
|
| 226 | 267 | list( $participant, $status ) = explode( '=', $participant ); |
| 227 | 268 | $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
| 228 | 269 | $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
| 229 | - if ( $participant && is_numeric($participant ) ) { |
|
| 270 | + if ( $participant && is_numeric($participant ) ) |
|
| 271 | + { |
|
| 230 | 272 | $_data['participants'][$participant] = $status; |
| 231 | 273 | } |
| 232 | 274 | } |
| 233 | 275 | // no valid participants so far --> add the importing user/owner |
| 234 | - if ( empty( $_data['participants'] ) ) { |
|
| 276 | + if ( empty( $_data['participants'] ) ) |
|
| 277 | + { |
|
| 235 | 278 | $_data['participants'][$this->user] = 'A'; |
| 236 | 279 | } |
| 237 | 280 | |
| 238 | 281 | // are we serious? |
| 239 | - if ( $this->dry_run ) { |
|
| 282 | + if ( $this->dry_run ) |
|
| 283 | + { |
|
| 240 | 284 | print_r($_data); |
| 241 | 285 | $this->results[$_action]++; |
| 242 | - } else { |
|
| 286 | + } |
|
| 287 | + else |
|
| 288 | + { |
|
| 243 | 289 | $messages = array(); |
| 244 | 290 | $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
| 245 | - if(!$result) { |
|
| 291 | + if(!$result) |
|
| 292 | + { |
|
| 246 | 293 | $this->errors = implode(',', $messages); |
| 247 | - } else { |
|
| 294 | + } |
|
| 295 | + else |
|
| 296 | + { |
|
| 248 | 297 | $this->results[$_action]++; |
| 249 | 298 | } |
| 250 | 299 | return $result; |
@@ -259,7 +308,8 @@ discard block |
||
| 259 | 308 | * |
| 260 | 309 | * @return string name |
| 261 | 310 | */ |
| 262 | - public static function get_name() { |
|
| 311 | + public static function get_name() |
|
| 312 | + { |
|
| 263 | 313 | return lang('Calendar CSV export'); |
| 264 | 314 | } |
| 265 | 315 | |
@@ -268,7 +318,8 @@ discard block |
||
| 268 | 318 | * |
| 269 | 319 | * @return string descriprion |
| 270 | 320 | */ |
| 271 | - public static function get_description() { |
|
| 321 | + public static function get_description() |
|
| 322 | + { |
|
| 272 | 323 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
| 273 | 324 | } |
| 274 | 325 | |
@@ -277,7 +328,8 @@ discard block |
||
| 277 | 328 | * |
| 278 | 329 | * @return string suffix (comma seperated) |
| 279 | 330 | */ |
| 280 | - public static function get_filesuffix() { |
|
| 331 | + public static function get_filesuffix() |
|
| 332 | + { |
|
| 281 | 333 | return 'csv'; |
| 282 | 334 | } |
| 283 | 335 | |
@@ -293,7 +345,8 @@ discard block |
||
| 293 | 345 | * preserv => array, |
| 294 | 346 | * ) |
| 295 | 347 | */ |
| 296 | - public function get_options_etpl() { |
|
| 348 | + public function get_options_etpl() |
|
| 349 | + { |
|
| 297 | 350 | // lets do it! |
| 298 | 351 | } |
| 299 | 352 | |
@@ -302,7 +355,8 @@ discard block |
||
| 302 | 355 | * |
| 303 | 356 | * @return string etemplate name |
| 304 | 357 | */ |
| 305 | - public function get_selectors_etpl() { |
|
| 358 | + public function get_selectors_etpl() |
|
| 359 | + { |
|
| 306 | 360 | // lets do it! |
| 307 | 361 | } |
| 308 | 362 | |
@@ -314,7 +368,8 @@ discard block |
||
| 314 | 368 | * record_# => error message |
| 315 | 369 | * ) |
| 316 | 370 | */ |
| 317 | - public function get_errors() { |
|
| 371 | + public function get_errors() |
|
| 372 | + { |
|
| 318 | 373 | return $this->errors; |
| 319 | 374 | } |
| 320 | 375 | |
@@ -326,7 +381,8 @@ discard block |
||
| 326 | 381 | * action => record count |
| 327 | 382 | * ) |
| 328 | 383 | */ |
| 329 | - public function get_results() { |
|
| 384 | + public function get_results() |
|
| 385 | + { |
|
| 330 | 386 | return $this->results; |
| 331 | 387 | } |
| 332 | 388 | } // end of iface_export_plugin |
@@ -519,6 +519,7 @@ discard block |
||
| 519 | 519 | * @param array $new_event Event after the change |
| 520 | 520 | * @param string $role we treat CHAIR like event owners |
| 521 | 521 | * @param string $status of current user |
| 522 | + * @param integer $msg_type |
|
| 522 | 523 | * @return boolean true = update requested, false otherwise |
| 523 | 524 | */ |
| 524 | 525 | public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
@@ -594,7 +595,7 @@ discard block |
||
| 594 | 595 | /** |
| 595 | 596 | * Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified |
| 596 | 597 | * |
| 597 | - * @param int|string $user_or_email |
|
| 598 | + * @param string $user_or_email |
|
| 598 | 599 | * @param string $ical_method ='REQUEST' |
| 599 | 600 | * @param string $role ='REQ-PARTICIPANT' |
| 600 | 601 | * @return boolean true if user requested to be notified, false if not |
@@ -645,8 +646,7 @@ discard block |
||
| 645 | 646 | * Get iCal/iMip method from internal nummeric msg-type plus optional notification message and verbose name |
| 646 | 647 | * |
| 647 | 648 | * @param int $msg_type see MSG_* defines |
| 648 | - * @param string& $action=null on return verbose name |
|
| 649 | - * @param string& $msg=null on return notification message |
|
| 649 | + * @param string& $action on return verbose name |
|
| 650 | 650 | */ |
| 651 | 651 | function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
| 652 | 652 | { |
@@ -1011,6 +1011,9 @@ discard block |
||
| 1011 | 1011 | return true; |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | + /** |
|
| 1015 | + * @param integer $added |
|
| 1016 | + */ |
|
| 1014 | 1017 | function get_update_message($event,$added) |
| 1015 | 1018 | { |
| 1016 | 1019 | $nul = null; |
@@ -1300,8 +1303,8 @@ discard block |
||
| 1300 | 1303 | * |
| 1301 | 1304 | * @param int $right self::CAT_ACL_{ADD|STATUS} |
| 1302 | 1305 | * @param int|array $event |
| 1303 | - * @return boolean true if use has the right, false if not |
|
| 1304 | - * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
| 1306 | + * @return null|boolean true if use has the right, false if not |
|
| 1307 | + * @return null|boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
| 1305 | 1308 | * null = cat has no acl |
| 1306 | 1309 | */ |
| 1307 | 1310 | function check_cat_acl($right,$event) |
@@ -1386,6 +1389,8 @@ discard block |
||
| 1386 | 1389 | * Check if current user has a given right on a category (if it's restricted!) |
| 1387 | 1390 | * |
| 1388 | 1391 | * @param int $cat_id |
| 1392 | + * @param integer $right |
|
| 1393 | + * @param integer $user |
|
| 1389 | 1394 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1390 | 1395 | * null = cat has no acl |
| 1391 | 1396 | */ |
@@ -1647,7 +1652,7 @@ discard block |
||
| 1647 | 1652 | * @param string $action |
| 1648 | 1653 | * @param array $event_arr |
| 1649 | 1654 | * @param array $disinvited |
| 1650 | - * @return array |
|
| 1655 | + * @return string |
|
| 1651 | 1656 | */ |
| 1652 | 1657 | function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
| 1653 | 1658 | { |
@@ -1504,22 +1504,22 @@ discard block |
||
| 1504 | 1504 | // check the old list against the new list |
| 1505 | 1505 | foreach ($old_event['participants'] as $userid => $status) |
| 1506 | 1506 | { |
| 1507 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1508 | - // Attendee will be deleted this way |
|
| 1509 | - $new_event['participants'][$userid] = 'G'; |
|
| 1510 | - } |
|
| 1511 | - elseif ($new_event['participants'][$userid] == $status) |
|
| 1512 | - { |
|
| 1513 | - // Same status -- nothing to do. |
|
| 1514 | - unset($new_event['participants'][$userid]); |
|
| 1515 | - } |
|
| 1507 | + if (!isset($new_event['participants'][$userid])){ |
|
| 1508 | + // Attendee will be deleted this way |
|
| 1509 | + $new_event['participants'][$userid] = 'G'; |
|
| 1510 | + } |
|
| 1511 | + elseif ($new_event['participants'][$userid] == $status) |
|
| 1512 | + { |
|
| 1513 | + // Same status -- nothing to do. |
|
| 1514 | + unset($new_event['participants'][$userid]); |
|
| 1515 | + } |
|
| 1516 | 1516 | } |
| 1517 | 1517 | // write the changes |
| 1518 | 1518 | foreach ($new_event['participants'] as $userid => $status) |
| 1519 | 1519 | { |
| 1520 | 1520 | $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
| 1521 | 1521 | } |
| 1522 | - } |
|
| 1522 | + } |
|
| 1523 | 1523 | |
| 1524 | 1524 | /** |
| 1525 | 1525 | * deletes an event |
@@ -2493,24 +2493,24 @@ discard block |
||
| 2493 | 2493 | /** |
| 2494 | 2494 | * classifies an incoming event from the eGW point-of-view |
| 2495 | 2495 | * |
| 2496 | - * exceptions: unlike other calendar apps eGW does not create an event exception |
|
| 2497 | - * if just the participant state changes - therefore we have to distinguish between |
|
| 2498 | - * real exceptions and status only exceptions |
|
| 2499 | - * |
|
| 2500 | - * @param array $event the event to check |
|
| 2501 | - * |
|
| 2502 | - * @return array |
|
| 2503 | - * type => |
|
| 2504 | - * SINGLE a single event |
|
| 2505 | - * SERIES-MASTER the series master |
|
| 2506 | - * SERIES-EXCEPTION event is a real exception |
|
| 2507 | - * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
| 2508 | - * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
| 2509 | - * stored_event => if event already exists in the database array with event data or false |
|
| 2510 | - * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
| 2511 | - * the corresponding series master event array |
|
| 2512 | - * NOTE: this param is false if event is of type SERIES-MASTER |
|
| 2513 | - */ |
|
| 2496 | + * exceptions: unlike other calendar apps eGW does not create an event exception |
|
| 2497 | + * if just the participant state changes - therefore we have to distinguish between |
|
| 2498 | + * real exceptions and status only exceptions |
|
| 2499 | + * |
|
| 2500 | + * @param array $event the event to check |
|
| 2501 | + * |
|
| 2502 | + * @return array |
|
| 2503 | + * type => |
|
| 2504 | + * SINGLE a single event |
|
| 2505 | + * SERIES-MASTER the series master |
|
| 2506 | + * SERIES-EXCEPTION event is a real exception |
|
| 2507 | + * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
| 2508 | + * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
| 2509 | + * stored_event => if event already exists in the database array with event data or false |
|
| 2510 | + * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
| 2511 | + * the corresponding series master event array |
|
| 2512 | + * NOTE: this param is false if event is of type SERIES-MASTER |
|
| 2513 | + */ |
|
| 2514 | 2514 | function get_event_info($event) |
| 2515 | 2515 | { |
| 2516 | 2516 | $type = 'SINGLE'; // default |
@@ -2681,16 +2681,16 @@ discard block |
||
| 2681 | 2681 | 'stored_event' => $stored_event, |
| 2682 | 2682 | 'master_event' => $master_event, |
| 2683 | 2683 | ); |
| 2684 | - } |
|
| 2685 | - |
|
| 2686 | - /** |
|
| 2687 | - * Translates all timestamps for a given event from server-time to user-time. |
|
| 2688 | - * The update() and save() methods expect timestamps in user-time. |
|
| 2689 | - * @param &$event the event we are working on |
|
| 2690 | - * |
|
| 2691 | - */ |
|
| 2692 | - function server2usertime (&$event) |
|
| 2693 | - { |
|
| 2684 | + } |
|
| 2685 | + |
|
| 2686 | + /** |
|
| 2687 | + * Translates all timestamps for a given event from server-time to user-time. |
|
| 2688 | + * The update() and save() methods expect timestamps in user-time. |
|
| 2689 | + * @param &$event the event we are working on |
|
| 2690 | + * |
|
| 2691 | + */ |
|
| 2692 | + function server2usertime (&$event) |
|
| 2693 | + { |
|
| 2694 | 2694 | // we run all dates through date2usertime, to adjust to user-time |
| 2695 | 2695 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2696 | 2696 | { |
@@ -2713,7 +2713,7 @@ discard block |
||
| 2713 | 2713 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2714 | 2714 | } |
| 2715 | 2715 | } |
| 2716 | - } |
|
| 2716 | + } |
|
| 2717 | 2717 | /** |
| 2718 | 2718 | * Delete events that are more than $age years old |
| 2719 | 2719 | * |
@@ -1708,12 +1708,12 @@ discard block |
||
| 1708 | 1708 | */ |
| 1709 | 1709 | function event2array($event) |
| 1710 | 1710 | { |
| 1711 | - $var['title'] = Array( |
|
| 1711 | + $var['title'] = array( |
|
| 1712 | 1712 | 'field' => lang('Title'), |
| 1713 | 1713 | 'data' => $event['title'] |
| 1714 | 1714 | ); |
| 1715 | 1715 | |
| 1716 | - $var['description'] = Array( |
|
| 1716 | + $var['description'] = array( |
|
| 1717 | 1717 | 'field' => lang('Description'), |
| 1718 | 1718 | 'data' => $event['description'] |
| 1719 | 1719 | ); |
@@ -1722,48 +1722,48 @@ discard block |
||
| 1722 | 1722 | { |
| 1723 | 1723 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1724 | 1724 | } |
| 1725 | - $var['category'] = Array( |
|
| 1725 | + $var['category'] = array( |
|
| 1726 | 1726 | 'field' => lang('Category'), |
| 1727 | 1727 | 'data' => implode(', ',$cat_string) |
| 1728 | 1728 | ); |
| 1729 | 1729 | |
| 1730 | - $var['location'] = Array( |
|
| 1730 | + $var['location'] = array( |
|
| 1731 | 1731 | 'field' => lang('Location'), |
| 1732 | 1732 | 'data' => $event['location'] |
| 1733 | 1733 | ); |
| 1734 | 1734 | |
| 1735 | - $var['startdate'] = Array( |
|
| 1735 | + $var['startdate'] = array( |
|
| 1736 | 1736 | 'field' => lang('Start Date/Time'), |
| 1737 | 1737 | 'data' => $this->format_date($event['start']), |
| 1738 | 1738 | ); |
| 1739 | 1739 | |
| 1740 | - $var['enddate'] = Array( |
|
| 1740 | + $var['enddate'] = array( |
|
| 1741 | 1741 | 'field' => lang('End Date/Time'), |
| 1742 | 1742 | 'data' => $this->format_date($event['end']), |
| 1743 | 1743 | ); |
| 1744 | 1744 | |
| 1745 | - $pri = Array( |
|
| 1745 | + $pri = array( |
|
| 1746 | 1746 | 0 => lang('None'), |
| 1747 | 1747 | 1 => lang('Low'), |
| 1748 | 1748 | 2 => lang('Normal'), |
| 1749 | 1749 | 3 => lang('High') |
| 1750 | 1750 | ); |
| 1751 | - $var['priority'] = Array( |
|
| 1751 | + $var['priority'] = array( |
|
| 1752 | 1752 | 'field' => lang('Priority'), |
| 1753 | 1753 | 'data' => $pri[$event['priority']] |
| 1754 | 1754 | ); |
| 1755 | 1755 | |
| 1756 | - $var['owner'] = Array( |
|
| 1756 | + $var['owner'] = array( |
|
| 1757 | 1757 | 'field' => lang('Owner'), |
| 1758 | 1758 | 'data' => Api\Accounts::username($event['owner']) |
| 1759 | 1759 | ); |
| 1760 | 1760 | |
| 1761 | - $var['updated'] = Array( |
|
| 1761 | + $var['updated'] = array( |
|
| 1762 | 1762 | 'field' => lang('Updated'), |
| 1763 | 1763 | 'data' => $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier']) |
| 1764 | 1764 | ); |
| 1765 | 1765 | |
| 1766 | - $var['access'] = Array( |
|
| 1766 | + $var['access'] = array( |
|
| 1767 | 1767 | 'field' => lang('Access'), |
| 1768 | 1768 | 'data' => $event['public'] ? lang('Public') : lang('Private') |
| 1769 | 1769 | ); |
@@ -1772,13 +1772,13 @@ discard block |
||
| 1772 | 1772 | { |
| 1773 | 1773 | $participants = $this->participants($event,true); |
| 1774 | 1774 | } |
| 1775 | - $var['participants'] = Array( |
|
| 1775 | + $var['participants'] = array( |
|
| 1776 | 1776 | 'field' => lang('Participants'), |
| 1777 | 1777 | 'data' => $participants |
| 1778 | 1778 | ); |
| 1779 | 1779 | |
| 1780 | 1780 | // Repeated Events |
| 1781 | - $var['recur_type'] = Array( |
|
| 1781 | + $var['recur_type'] = array( |
|
| 1782 | 1782 | 'field' => lang('Repetition'), |
| 1783 | 1783 | 'data' => ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '', |
| 1784 | 1784 | ); |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | * @param Api\DateTime $instance_date For recurring events, this is the date we |
| 1829 | 1829 | * are dealing with |
| 1830 | 1830 | */ |
| 1831 | - function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null) |
|
| 1831 | + function check_move_alarms(array &$event, array $old_event = null, Api\DateTime $instance_date = null) |
|
| 1832 | 1832 | { |
| 1833 | 1833 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 1834 | 1834 | |
@@ -85,11 +85,17 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) |
|
| 89 | + { |
|
| 90 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | parent::__construct(); // calling the parent constructor |
| 91 | 94 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 95 | + if ($this->debug > 0) |
|
| 96 | + { |
|
| 97 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 98 | + } |
|
| 93 | 99 | } |
| 94 | 100 | |
| 95 | 101 | /** |
@@ -119,7 +125,10 @@ discard block |
||
| 119 | 125 | function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
| 120 | 126 | { |
| 121 | 127 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 122 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
| 128 | + if (!is_array($messages)) |
|
| 129 | + { |
|
| 130 | + $messages = $messages ? (array)$messages : array(); |
|
| 131 | + } |
|
| 123 | 132 | |
| 124 | 133 | if ($this->debug > 1 || $this->debug == 'update') |
| 125 | 134 | { |
@@ -139,10 +148,13 @@ discard block |
||
| 139 | 148 | |
| 140 | 149 | $status_reset_to_unknown = false; |
| 141 | 150 | |
| 142 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
| 151 | + if (($new_event = !$event['id'])) |
|
| 152 | + { |
|
| 153 | + // some defaults for new entries |
|
| 143 | 154 | { |
| 144 | 155 | // if no owner given, set user to owner |
| 145 | 156 | if (!$event['owner']) $event['owner'] = $this->user; |
| 157 | + } |
|
| 146 | 158 | // set owner as participant if none is given |
| 147 | 159 | if (!is_array($event['participants']) || !count($event['participants'])) |
| 148 | 160 | { |
@@ -182,7 +194,10 @@ discard block |
||
| 182 | 194 | // check category based ACL |
| 183 | 195 | if ($event['category']) |
| 184 | 196 | { |
| 185 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 197 | + if (!is_array($event['category'])) |
|
| 198 | + { |
|
| 199 | + $event['category'] = explode(',',$event['category']); |
|
| 200 | + } |
|
| 186 | 201 | if (!$old_event || !isset($old_event['category'])) |
| 187 | 202 | { |
| 188 | 203 | $old_event['category'] = array(); |
@@ -234,13 +249,16 @@ discard block |
||
| 234 | 249 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) && |
| 235 | 250 | (($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding)) |
| 236 | 251 | { |
| 237 | - if ($checked_excluding) // warn user if not all recurrences have been checked |
|
| 252 | + if ($checked_excluding) |
|
| 253 | + { |
|
| 254 | + // warn user if not all recurrences have been checked |
|
| 238 | 255 | { |
| 239 | 256 | $conflicts['warning'] = array( |
| 240 | 257 | 'start' => $checked_excluding, |
| 241 | 258 | 'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)), |
| 242 | 259 | ); |
| 243 | 260 | } |
| 261 | + } |
|
| 244 | 262 | return $conflicts; |
| 245 | 263 | } |
| 246 | 264 | |
@@ -304,7 +322,10 @@ discard block |
||
| 304 | 322 | $types_with_quantity = array(); |
| 305 | 323 | foreach($this->resources as $type => $data) |
| 306 | 324 | { |
| 307 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 325 | + if ($data['max_quantity']) |
|
| 326 | + { |
|
| 327 | + $types_with_quantity[] = $type; |
|
| 328 | + } |
|
| 308 | 329 | } |
| 309 | 330 | // get all NOT rejected participants and evtl. their quantity |
| 310 | 331 | $quantity = $users = array(); |
@@ -312,12 +333,19 @@ discard block |
||
| 312 | 333 | { |
| 313 | 334 | $q = $r = null; |
| 314 | 335 | calendar_so::split_status($status,$q,$r); |
| 315 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 336 | + if ($status[0] == 'R') |
|
| 337 | + { |
|
| 338 | + continue; |
|
| 339 | + } |
|
| 340 | + // ignore rejected participants |
|
| 316 | 341 | |
| 317 | - if ($uid < 0) // group, check it's members too |
|
| 342 | + if ($uid < 0) |
|
| 343 | + { |
|
| 344 | + // group, check it's members too |
|
| 318 | 345 | { |
| 319 | 346 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
| 320 | 347 | } |
| 348 | + } |
|
| 321 | 349 | $users[] = $uid; |
| 322 | 350 | if (in_array($uid[0],$types_with_quantity)) |
| 323 | 351 | { |
@@ -348,18 +376,24 @@ discard block |
||
| 348 | 376 | $startts = $date->format('ts'); |
| 349 | 377 | |
| 350 | 378 | // skip past events or recurrences |
| 351 | - if ($startts+$duration < $this->now_su) continue; |
|
| 379 | + if ($startts+$duration < $this->now_su) |
|
| 380 | + { |
|
| 381 | + continue; |
|
| 382 | + } |
|
| 352 | 383 | |
| 353 | 384 | // abort check if configured limits are exceeded |
| 354 | 385 | if ($event['recur_type'] && |
| 355 | 386 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 356 | 387 | microtime(true) > $start+$max_check_time || // max check time exceeded |
| 357 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
| 388 | + $startts > $this->config['horizont'])) |
|
| 389 | + { |
|
| 390 | + // we are behind horizon for which recurrences are rendered |
|
| 358 | 391 | { |
| 359 | 392 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 360 | 393 | { |
| 361 | 394 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 362 | 395 | $checked, microtime(true)-$start, $date); |
| 396 | + } |
|
| 363 | 397 | } |
| 364 | 398 | $checked_excluding = $date; |
| 365 | 399 | break; |
@@ -383,10 +417,13 @@ discard block |
||
| 383 | 417 | { |
| 384 | 418 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 385 | 419 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 386 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 420 | + $overlap['non_blocking']) |
|
| 421 | + { |
|
| 422 | + // that's a non_blocking event |
|
| 387 | 423 | { |
| 388 | 424 | continue; |
| 389 | 425 | } |
| 426 | + } |
|
| 390 | 427 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 391 | 428 | { |
| 392 | 429 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -506,7 +543,11 @@ discard block |
||
| 506 | 543 | */ |
| 507 | 544 | public function check_acl_invite($uid) |
| 508 | 545 | { |
| 509 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 546 | + if (!is_numeric($uid)) |
|
| 547 | + { |
|
| 548 | + return true; |
|
| 549 | + } |
|
| 550 | + // nothing implemented for resources so far |
|
| 510 | 551 | |
| 511 | 552 | if (!$this->require_acl_invite) |
| 512 | 553 | { |
@@ -846,14 +887,20 @@ discard block |
||
| 846 | 887 | $startdate = new Api\DateTime($event['start']); |
| 847 | 888 | $enddate = new Api\DateTime($event['end']); |
| 848 | 889 | $modified = new Api\DateTime($event['modified']); |
| 849 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
| 890 | + if ($old_event) |
|
| 891 | + { |
|
| 892 | + $olddate = new Api\DateTime($old_event['start']); |
|
| 893 | + } |
|
| 850 | 894 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 851 | 895 | $owner_prefs = $ics = null; |
| 852 | 896 | foreach($to_notify as $userid => $statusid) |
| 853 | 897 | { |
| 854 | 898 | $res_info = $quantity = $role = null; |
| 855 | 899 | calendar_so::split_status($statusid, $quantity, $role); |
| 856 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 900 | + if ($this->debug > 0) |
|
| 901 | + { |
|
| 902 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 903 | + } |
|
| 857 | 904 | |
| 858 | 905 | if (!is_numeric($userid)) |
| 859 | 906 | { |
@@ -872,7 +919,11 @@ discard block |
||
| 872 | 919 | |
| 873 | 920 | if (!isset($userid)) |
| 874 | 921 | { |
| 875 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 922 | + if (empty($res_info['email'])) |
|
| 923 | + { |
|
| 924 | + continue; |
|
| 925 | + } |
|
| 926 | + // no way to notify |
|
| 876 | 927 | // check if event-owner wants non-EGroupware users notified |
| 877 | 928 | if (is_null($owner_prefs)) |
| 878 | 929 | { |
@@ -946,7 +997,10 @@ discard block |
||
| 946 | 997 | $details['to-lastname'] = isset($tln)? $tln: ''; |
| 947 | 998 | |
| 948 | 999 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 949 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1000 | + if (!isset($part_prefs['common']['tz'])) |
|
| 1001 | + { |
|
| 1002 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1003 | + } |
|
| 950 | 1004 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 951 | 1005 | $timeformat = $part_prefs['common']['timeformat']; |
| 952 | 1006 | switch($timeformat) |
@@ -981,9 +1035,12 @@ discard block |
||
| 981 | 1035 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 982 | 1036 | { |
| 983 | 1037 | case 'ical': |
| 984 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1038 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 1039 | + { |
|
| 1040 | + // need different ical for organizer notification |
|
| 985 | 1041 | { |
| 986 | 1042 | $calendar_ical = new calendar_ical(); |
| 1043 | + } |
|
| 987 | 1044 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 988 | 1045 | // we need to pass $event[id] so iCal class reads event again, |
| 989 | 1046 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -997,7 +1054,10 @@ discard block |
||
| 997 | 1054 | 'encoding' => '8bit', |
| 998 | 1055 | 'type' => 'text/calendar; method='.$method, |
| 999 | 1056 | ); |
| 1000 | - if ($m_type != $msg_type) unset($ics); |
|
| 1057 | + if ($m_type != $msg_type) |
|
| 1058 | + { |
|
| 1059 | + unset($ics); |
|
| 1060 | + } |
|
| 1001 | 1061 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 1002 | 1062 | // fall through |
| 1003 | 1063 | case 'extended': |
@@ -1048,7 +1108,9 @@ discard block |
||
| 1048 | 1108 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 1049 | 1109 | $notification->set_popuplinks(array($details['link_arr'])); |
| 1050 | 1110 | |
| 1051 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1111 | + if(is_array($attachment)) |
|
| 1112 | + { |
|
| 1113 | +$notification->set_attachments(array($attachment)); } |
|
| 1052 | 1114 | $notification->send(); |
| 1053 | 1115 | foreach(notifications::errors(true) as $error) |
| 1054 | 1116 | { |
@@ -1084,7 +1146,10 @@ discard block |
||
| 1084 | 1146 | Api\Translation::init(); |
| 1085 | 1147 | } |
| 1086 | 1148 | // restore timezone, in case we had to reset it to server-timezone |
| 1087 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1149 | + if ($restore_tz) |
|
| 1150 | + { |
|
| 1151 | + date_default_timezone_set($restore_tz); |
|
| 1152 | + } |
|
| 1088 | 1153 | |
| 1089 | 1154 | return true; |
| 1090 | 1155 | } |
@@ -1119,10 +1184,13 @@ discard block |
||
| 1119 | 1184 | { |
| 1120 | 1185 | $to_notify = $event['participants']; |
| 1121 | 1186 | } |
| 1122 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1187 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
| 1188 | + { |
|
| 1189 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1123 | 1190 | { |
| 1124 | 1191 | $to_notify[$alarm['owner']] = 'A'; |
| 1125 | 1192 | } |
| 1193 | + } |
|
| 1126 | 1194 | else |
| 1127 | 1195 | { |
| 1128 | 1196 | return False; // no rights |
@@ -1171,14 +1239,20 @@ discard block |
||
| 1171 | 1239 | if ($event['id']) |
| 1172 | 1240 | { |
| 1173 | 1241 | // invalidate the read-cache if it contains the event we store now |
| 1174 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1242 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1243 | + { |
|
| 1244 | + self::$cached_event = array(); |
|
| 1245 | + } |
|
| 1175 | 1246 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
| 1176 | 1247 | } |
| 1177 | 1248 | else |
| 1178 | 1249 | { |
| 1179 | 1250 | $old_event = null; |
| 1180 | 1251 | } |
| 1181 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1252 | + if (!isset($event['whole_day'])) |
|
| 1253 | + { |
|
| 1254 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1255 | + } |
|
| 1182 | 1256 | |
| 1183 | 1257 | // set recur-enddate/range-end to real end-date of last recurrence |
| 1184 | 1258 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
@@ -1255,7 +1329,10 @@ discard block |
||
| 1255 | 1329 | foreach($timestamps as $ts) |
| 1256 | 1330 | { |
| 1257 | 1331 | // we convert here from user-time to timestamps in server-time! |
| 1258 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1332 | + if (isset($event[$ts])) |
|
| 1333 | + { |
|
| 1334 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1335 | + } |
|
| 1259 | 1336 | } |
| 1260 | 1337 | // convert tzid name to integer tz_id, of set user default |
| 1261 | 1338 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1305,7 +1382,10 @@ discard block |
||
| 1305 | 1382 | if (!isset($event['alarm'][$id])) |
| 1306 | 1383 | { |
| 1307 | 1384 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1308 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1385 | + if ($alarm['time'] < time()) |
|
| 1386 | + { |
|
| 1387 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1388 | + } |
|
| 1309 | 1389 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1310 | 1390 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1311 | 1391 | $old_event['participants'][$alarm['owner']]; |
@@ -1361,7 +1441,10 @@ discard block |
||
| 1361 | 1441 | |
| 1362 | 1442 | // Update history |
| 1363 | 1443 | $tracking = new calendar_tracking($this); |
| 1364 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1444 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1445 | + { |
|
| 1446 | + $event['id']=$cal_id; |
|
| 1447 | + } |
|
| 1365 | 1448 | $tracking->track($event, $old_event); |
| 1366 | 1449 | |
| 1367 | 1450 | return $cal_id; |
@@ -1378,9 +1461,12 @@ discard block |
||
| 1378 | 1461 | */ |
| 1379 | 1462 | function check_status_perms($uid,$event) |
| 1380 | 1463 | { |
| 1381 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1464 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1465 | + { |
|
| 1466 | + // for contact we use the owner of the event |
|
| 1382 | 1467 | { |
| 1383 | 1468 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1469 | + } |
|
| 1384 | 1470 | |
| 1385 | 1471 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
| 1386 | 1472 | } |
@@ -1391,13 +1477,19 @@ discard block |
||
| 1391 | 1477 | return $access; |
| 1392 | 1478 | } |
| 1393 | 1479 | // no access or denied access because of category acl --> regular check |
| 1394 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1480 | + if (!is_numeric($uid)) |
|
| 1481 | + { |
|
| 1482 | + // this is eg. for resources (r123) |
|
| 1395 | 1483 | { |
| 1396 | 1484 | $resource = $this->resource_info($uid); |
| 1485 | + } |
|
| 1397 | 1486 | |
| 1398 | 1487 | return Acl::EDIT & $resource['rights']; |
| 1399 | 1488 | } |
| 1400 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1489 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1490 | + { |
|
| 1491 | + return false; |
|
| 1492 | + } |
|
| 1401 | 1493 | |
| 1402 | 1494 | // regular user and groups (need to check memberships too) |
| 1403 | 1495 | if (!isset($event['participants'][$uid])) |
@@ -1421,7 +1513,10 @@ discard block |
||
| 1421 | 1513 | */ |
| 1422 | 1514 | function check_cat_acl($right,$event) |
| 1423 | 1515 | { |
| 1424 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1516 | + if (!is_array($event)) |
|
| 1517 | + { |
|
| 1518 | + $event = $this->read($event); |
|
| 1519 | + } |
|
| 1425 | 1520 | |
| 1426 | 1521 | $ret = null; |
| 1427 | 1522 | if ($event['category']) |
@@ -1478,7 +1573,10 @@ discard block |
||
| 1478 | 1573 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1479 | 1574 | { |
| 1480 | 1575 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1481 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1576 | + if (!isset(self::$cat_rights_cache)) |
|
| 1577 | + { |
|
| 1578 | + self::get_cat_rights($cat_id); |
|
| 1579 | + } |
|
| 1482 | 1580 | |
| 1483 | 1581 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1484 | 1582 | { |
@@ -1490,7 +1588,10 @@ discard block |
||
| 1490 | 1588 | else |
| 1491 | 1589 | { |
| 1492 | 1590 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1493 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1591 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1592 | + { |
|
| 1593 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1594 | + } |
|
| 1494 | 1595 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1495 | 1596 | } |
| 1496 | 1597 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1523,7 +1624,10 @@ discard block |
||
| 1523 | 1624 | foreach($cat_rights as $uid => $value) |
| 1524 | 1625 | { |
| 1525 | 1626 | $all |= $value; |
| 1526 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1627 | + if (in_array($uid,$memberships)) |
|
| 1628 | + { |
|
| 1629 | + $own |= $value; |
|
| 1630 | + } |
|
| 1527 | 1631 | } |
| 1528 | 1632 | } |
| 1529 | 1633 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1570,13 +1674,16 @@ discard block |
||
| 1570 | 1674 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1571 | 1675 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1572 | 1676 | { |
| 1573 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1677 | + if ($status == 'R') |
|
| 1678 | + { |
|
| 1679 | + // remove alarms belonging to rejected participants |
|
| 1574 | 1680 | { |
| 1575 | 1681 | foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1576 | 1682 | { |
| 1577 | 1683 | if ((string)$alarm['owner'] === (string)$uid) |
| 1578 | 1684 | { |
| 1579 | 1685 | $this->so->delete_alarm($id); |
| 1686 | + } |
|
| 1580 | 1687 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1581 | 1688 | } |
| 1582 | 1689 | } |
@@ -1590,8 +1697,15 @@ discard block |
||
| 1590 | 1697 | ); |
| 1591 | 1698 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1592 | 1699 | { |
| 1593 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1594 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1700 | + if (!is_array($event)) |
|
| 1701 | + { |
|
| 1702 | + $event = $this->read($cal_id); |
|
| 1703 | + } |
|
| 1704 | + if (isset($recur_date)) |
|
| 1705 | + { |
|
| 1706 | + $event = $this->read($event['id'],$recur_date); |
|
| 1707 | + } |
|
| 1708 | + //re-read the actually edited recurring event |
|
| 1595 | 1709 | $this->send_update($status2msg[$status],$event['participants'],$event); |
| 1596 | 1710 | } |
| 1597 | 1711 | |
@@ -1614,12 +1728,16 @@ discard block |
||
| 1614 | 1728 | */ |
| 1615 | 1729 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1616 | 1730 | { |
| 1617 | - if (!isset($new_event['participants'])) return; |
|
| 1731 | + if (!isset($new_event['participants'])) |
|
| 1732 | + { |
|
| 1733 | + return; |
|
| 1734 | + } |
|
| 1618 | 1735 | |
| 1619 | 1736 | // check the old list against the new list |
| 1620 | 1737 | foreach ($old_event['participants'] as $userid => $status) |
| 1621 | - { |
|
| 1622 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1738 | + { |
|
| 1739 | + if (!isset($new_event['participants'][$userid])) |
|
| 1740 | + { |
|
| 1623 | 1741 | // Attendee will be deleted this way |
| 1624 | 1742 | $new_event['participants'][$userid] = 'G'; |
| 1625 | 1743 | } |
@@ -1702,7 +1820,10 @@ discard block |
||
| 1702 | 1820 | } |
| 1703 | 1821 | else |
| 1704 | 1822 | { |
| 1705 | - if (!($exception = $this->read($id))) continue; |
|
| 1823 | + if (!($exception = $this->read($id))) |
|
| 1824 | + { |
|
| 1825 | + continue; |
|
| 1826 | + } |
|
| 1706 | 1827 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1707 | 1828 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1708 | 1829 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1773,7 +1894,10 @@ discard block |
||
| 1773 | 1894 | $event_arr = $this->event2array($event); |
| 1774 | 1895 | foreach($event_arr as $key => $val) |
| 1775 | 1896 | { |
| 1776 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1897 | + if ($key == 'recur_type') |
|
| 1898 | + { |
|
| 1899 | + $key = 'repetition'; |
|
| 1900 | + } |
|
| 1777 | 1901 | $details[$key] = $val['data']; |
| 1778 | 1902 | } |
| 1779 | 1903 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1945,7 +2069,10 @@ discard block |
||
| 1945 | 2069 | */ |
| 1946 | 2070 | function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null) |
| 1947 | 2071 | { |
| 1948 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 2072 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 2073 | + { |
|
| 2074 | + return; |
|
| 2075 | + } |
|
| 1949 | 2076 | |
| 1950 | 2077 | $time = new Api\DateTime($event['start']); |
| 1951 | 2078 | if(!is_array($event['alarm'])) |
@@ -2019,7 +2146,10 @@ discard block |
||
| 2019 | 2146 | if (is_array($old_event) || $old_event > 0) |
| 2020 | 2147 | { |
| 2021 | 2148 | // preserve categories without users read access |
| 2022 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2149 | + if (!is_array($old_event)) |
|
| 2150 | + { |
|
| 2151 | + $old_event = $this->read($old_event); |
|
| 2152 | + } |
|
| 2023 | 2153 | $old_categories = explode(',',$old_event['category']); |
| 2024 | 2154 | $old_cats_preserve = array(); |
| 2025 | 2155 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2110,7 +2240,10 @@ discard block |
||
| 2110 | 2240 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 2111 | 2241 | } |
| 2112 | 2242 | |
| 2113 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2243 | + if (!isset($event['recurrence'])) |
|
| 2244 | + { |
|
| 2245 | + $event['recurrence'] = 0; |
|
| 2246 | + } |
|
| 2114 | 2247 | |
| 2115 | 2248 | if ($filter == 'master') |
| 2116 | 2249 | { |
@@ -2164,19 +2297,26 @@ discard block |
||
| 2164 | 2297 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2165 | 2298 | } |
| 2166 | 2299 | } |
| 2167 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2300 | + } |
|
| 2301 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2168 | 2302 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2169 | 2303 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2170 | 2304 | { |
| 2171 | 2305 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2172 | 2306 | } |
| 2173 | 2307 | } |
| 2174 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2308 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2309 | + { |
|
| 2310 | + return $matchingEvents; |
|
| 2311 | + } |
|
| 2175 | 2312 | } |
| 2176 | 2313 | unset($event['id']); |
| 2177 | 2314 | |
| 2178 | 2315 | // No chance to find a master without [U]ID |
| 2179 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2316 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2317 | + { |
|
| 2318 | + return $matchingEvents; |
|
| 2319 | + } |
|
| 2180 | 2320 | |
| 2181 | 2321 | // only query calendars of users, we have READ-grants from |
| 2182 | 2322 | $users = array(); |
@@ -2185,17 +2325,23 @@ discard block |
||
| 2185 | 2325 | $user = trim($user); |
| 2186 | 2326 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
| 2187 | 2327 | { |
| 2188 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2328 | + if ($user && !in_array($user,$users)) |
|
| 2329 | + { |
|
| 2330 | + // already added? |
|
| 2189 | 2331 | { |
| 2190 | 2332 | $users[] = $user; |
| 2191 | 2333 | } |
| 2334 | + } |
|
| 2192 | 2335 | } |
| 2193 | 2336 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2194 | 2337 | { |
| 2195 | 2338 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2196 | 2339 | } |
| 2197 | 2340 | // the further code is only for real users |
| 2198 | - if (!is_numeric($user)) continue; |
|
| 2341 | + if (!is_numeric($user)) |
|
| 2342 | + { |
|
| 2343 | + continue; |
|
| 2344 | + } |
|
| 2199 | 2345 | |
| 2200 | 2346 | // for groups we have to include the members |
| 2201 | 2347 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2275,7 +2421,10 @@ discard block |
||
| 2275 | 2421 | } |
| 2276 | 2422 | foreach ($matchFields as $key) |
| 2277 | 2423 | { |
| 2278 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2424 | + if (isset($event[$key])) |
|
| 2425 | + { |
|
| 2426 | + $query['cal_'.$key] = $event[$key]; |
|
| 2427 | + } |
|
| 2279 | 2428 | } |
| 2280 | 2429 | } |
| 2281 | 2430 | |
@@ -2315,7 +2464,10 @@ discard block |
||
| 2315 | 2464 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2316 | 2465 | } |
| 2317 | 2466 | |
| 2318 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2467 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2468 | + { |
|
| 2469 | + continue; |
|
| 2470 | + } |
|
| 2319 | 2471 | |
| 2320 | 2472 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2321 | 2473 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2482,13 +2634,16 @@ discard block |
||
| 2482 | 2634 | foreach ($event['participants'] as $attendee => $status) |
| 2483 | 2635 | { |
| 2484 | 2636 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2485 | - $attendee != $egwEvent['owner']) // || |
|
| 2637 | + $attendee != $egwEvent['owner']) |
|
| 2638 | + { |
|
| 2639 | + // || |
|
| 2486 | 2640 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2487 | 2641 | { |
| 2488 | 2642 | if ($this->log) |
| 2489 | 2643 | { |
| 2490 | 2644 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2491 | 2645 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2646 | + } |
|
| 2492 | 2647 | } |
| 2493 | 2648 | continue 2; |
| 2494 | 2649 | } |
@@ -2810,7 +2965,10 @@ discard block |
||
| 2810 | 2965 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2811 | 2966 | { |
| 2812 | 2967 | // we convert here from server-time to timestamps in user-time! |
| 2813 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 2968 | + if (isset($event[$ts])) |
|
| 2969 | + { |
|
| 2970 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 2971 | + } |
|
| 2814 | 2972 | } |
| 2815 | 2973 | // same with the recur exceptions |
| 2816 | 2974 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2838,9 +2996,12 @@ discard block |
||
| 2838 | 2996 | */ |
| 2839 | 2997 | function purge($age) |
| 2840 | 2998 | { |
| 2841 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 2999 | + if (is_numeric($age) && $age > 0) |
|
| 3000 | + { |
|
| 3001 | + // just make sure bogus values dont delete everything |
|
| 2842 | 3002 | { |
| 2843 | 3003 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2844 | 3004 | } |
| 3005 | + } |
|
| 2845 | 3006 | } |
| 2846 | 3007 | } |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | 18 | // types of messsages send by calendar_boupdate::send_update |
| 19 | -define('MSG_DELETED',0); |
|
| 20 | -define('MSG_MODIFIED',1); |
|
| 21 | -define('MSG_ADDED',2); |
|
| 22 | -define('MSG_REJECTED',3); |
|
| 23 | -define('MSG_TENTATIVE',4); |
|
| 24 | -define('MSG_ACCEPTED',5); |
|
| 25 | -define('MSG_ALARM',6); |
|
| 26 | -define('MSG_DISINVITE',7); |
|
| 27 | -define('MSG_DELEGATED',8); |
|
| 19 | +define('MSG_DELETED', 0); |
|
| 20 | +define('MSG_MODIFIED', 1); |
|
| 21 | +define('MSG_ADDED', 2); |
|
| 22 | +define('MSG_REJECTED', 3); |
|
| 23 | +define('MSG_TENTATIVE', 4); |
|
| 24 | +define('MSG_ACCEPTED', 5); |
|
| 25 | +define('MSG_ALARM', 6); |
|
| 26 | +define('MSG_DISINVITE', 7); |
|
| 27 | +define('MSG_DELEGATED', 8); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Class to access AND manipulate all calendar data (business object) |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
| 89 | 89 | |
| 90 | - parent::__construct(); // calling the parent constructor |
|
| 90 | + parent::__construct(); // calling the parent constructor |
|
| 91 | 91 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 92 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
| 117 | 117 | * ++++++++ ++++++++ |
| 118 | 118 | */ |
| 119 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
| 119 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
| 120 | 120 | { |
| 121 | 121 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 122 | 122 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if ($this->debug > 1 || $this->debug == 'update') |
| 125 | 125 | { |
| 126 | 126 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
| 127 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
| 127 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
| 128 | 128 | } |
| 129 | 129 | // check some minimum requirements: |
| 130 | 130 | // - new events need start, end and title |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // check if user has the permission to update / create the event |
| 155 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 156 | - $new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) && |
|
| 157 | - !$this->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 155 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 156 | + $new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) && |
|
| 157 | + !$this->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 158 | 158 | { |
| 159 | - $messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner'])); |
|
| 159 | + $messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner'])); |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | if ($new_event) |
@@ -165,24 +165,24 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | else |
| 167 | 167 | { |
| 168 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
| 168 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // do we need to check, if user is allowed to invite the invited participants |
| 172 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
| 172 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
| 173 | 173 | { |
| 174 | 174 | // report removed participants back to user |
| 175 | - foreach($removed as $key => $account_id) |
|
| 175 | + foreach ($removed as $key => $account_id) |
|
| 176 | 176 | { |
| 177 | 177 | $removed[$key] = $this->participant_name($account_id); |
| 178 | 178 | } |
| 179 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
| 180 | - ': '.implode(', ',$removed); |
|
| 179 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
| 180 | + ': '.implode(', ', $removed); |
|
| 181 | 181 | } |
| 182 | 182 | // check category based ACL |
| 183 | 183 | if ($event['category']) |
| 184 | 184 | { |
| 185 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 185 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
| 186 | 186 | if (!$old_event || !isset($old_event['category'])) |
| 187 | 187 | { |
| 188 | 188 | $old_event['category'] = array(); |
@@ -191,38 +191,38 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $old_event['category'] = explode(',', $old_event['category']); |
| 193 | 193 | } |
| 194 | - foreach($event['category'] as $key => $cat_id) |
|
| 194 | + foreach ($event['category'] as $key => $cat_id) |
|
| 195 | 195 | { |
| 196 | 196 | // check if user is allowed to update event categories |
| 197 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
| 198 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
| 197 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
| 198 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
| 199 | 199 | { |
| 200 | 200 | unset($event['category'][$key]); |
| 201 | 201 | // report removed category to user |
| 202 | 202 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
| 203 | - continue; // no further check, as cat was removed |
|
| 203 | + continue; // no further check, as cat was removed |
|
| 204 | 204 | } |
| 205 | 205 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
| 206 | 206 | if (!$status_reset_to_unknown && |
| 207 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
| 207 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
| 208 | 208 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
| 209 | 209 | { |
| 210 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 210 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 211 | 211 | { |
| 212 | 212 | $q = $r = null; |
| 213 | - calendar_so::split_status($status,$q,$r); |
|
| 213 | + calendar_so::split_status($status, $q, $r); |
|
| 214 | 214 | if ($status != 'U') |
| 215 | 215 | { |
| 216 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 216 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 217 | 217 | // todo: report reset status to user |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - $status_reset_to_unknown = true; // once is enough |
|
| 220 | + $status_reset_to_unknown = true; // once is enough |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | if ($removed_cats) |
| 224 | 224 | { |
| 225 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
| 225 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
| 226 | 226 | } |
| 227 | 227 | if ($status_reset_to_unknown) |
| 228 | 228 | { |
@@ -258,30 +258,30 @@ discard block |
||
| 258 | 258 | $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); |
| 259 | 259 | //error_log("new $cal_id=". array2string($event)); |
| 260 | 260 | |
| 261 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
| 261 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
| 262 | 262 | { |
| 263 | 263 | // Restored, bring back links |
| 264 | 264 | Link::restore('calendar', $cal_id); |
| 265 | 265 | } |
| 266 | 266 | if ($this->log_file) |
| 267 | 267 | { |
| 268 | - $this->log2file($event2save,$event,$old_event); |
|
| 268 | + $this->log2file($event2save, $event, $old_event); |
|
| 269 | 269 | } |
| 270 | 270 | // send notifications |
| 271 | - if(!$skip_notification) |
|
| 271 | + if (!$skip_notification) |
|
| 272 | 272 | { |
| 273 | 273 | if ($new_event) |
| 274 | 274 | { |
| 275 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
| 275 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
| 276 | 276 | } |
| 277 | 277 | else // update existing event |
| 278 | 278 | { |
| 279 | - $this->check4update($event,$old_event); |
|
| 279 | + $this->check4update($event, $old_event); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // notify the link-class about the update, as other apps may be subscribt to it |
| 284 | - Link::notify_update('calendar',$cal_id,$event); |
|
| 284 | + Link::notify_update('calendar', $cal_id, $event); |
|
| 285 | 285 | |
| 286 | 286 | return $cal_id; |
| 287 | 287 | } |
@@ -299,27 +299,27 @@ discard block |
||
| 299 | 299 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
| 300 | 300 | * @return array or events |
| 301 | 301 | */ |
| 302 | - function conflicts(array $event, &$checked_excluding=null) |
|
| 302 | + function conflicts(array $event, &$checked_excluding = null) |
|
| 303 | 303 | { |
| 304 | 304 | $types_with_quantity = array(); |
| 305 | - foreach($this->resources as $type => $data) |
|
| 305 | + foreach ($this->resources as $type => $data) |
|
| 306 | 306 | { |
| 307 | 307 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
| 308 | 308 | } |
| 309 | 309 | // get all NOT rejected participants and evtl. their quantity |
| 310 | 310 | $quantity = $users = array(); |
| 311 | - foreach($event['participants'] as $uid => $status) |
|
| 311 | + foreach ($event['participants'] as $uid => $status) |
|
| 312 | 312 | { |
| 313 | 313 | $q = $r = null; |
| 314 | - calendar_so::split_status($status,$q,$r); |
|
| 315 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 314 | + calendar_so::split_status($status, $q, $r); |
|
| 315 | + if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 316 | 316 | |
| 317 | 317 | if ($uid < 0) // group, check it's members too |
| 318 | 318 | { |
| 319 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
| 319 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
| 320 | 320 | } |
| 321 | 321 | $users[] = $uid; |
| 322 | - if (in_array($uid[0],$types_with_quantity)) |
|
| 322 | + if (in_array($uid[0], $types_with_quantity)) |
|
| 323 | 323 | { |
| 324 | 324 | $quantity[$uid] = $q; |
| 325 | 325 | } |
@@ -342,58 +342,58 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | $checked = 0; |
| 344 | 344 | $start = microtime(true); |
| 345 | - $duration = $event['end']-$event['start']; |
|
| 346 | - foreach($recurences as $date) |
|
| 345 | + $duration = $event['end'] - $event['start']; |
|
| 346 | + foreach ($recurences as $date) |
|
| 347 | 347 | { |
| 348 | 348 | $startts = $date->format('ts'); |
| 349 | 349 | |
| 350 | 350 | // skip past events or recurrences |
| 351 | - if ($startts+$duration < $this->now_su) continue; |
|
| 351 | + if ($startts + $duration < $this->now_su) continue; |
|
| 352 | 352 | |
| 353 | 353 | // abort check if configured limits are exceeded |
| 354 | 354 | if ($event['recur_type'] && |
| 355 | 355 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 356 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
| 356 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
| 357 | 357 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
| 358 | 358 | { |
| 359 | 359 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 360 | 360 | { |
| 361 | 361 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 362 | - $checked, microtime(true)-$start, $date); |
|
| 362 | + $checked, microtime(true) - $start, $date); |
|
| 363 | 363 | } |
| 364 | 364 | $checked_excluding = $date; |
| 365 | 365 | break; |
| 366 | 366 | } |
| 367 | - $overlapping_events =& $this->search(array( |
|
| 367 | + $overlapping_events = & $this->search(array( |
|
| 368 | 368 | 'start' => $startts, |
| 369 | - 'end' => $startts+$duration, |
|
| 369 | + 'end' => $startts + $duration, |
|
| 370 | 370 | 'users' => $users, |
| 371 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 372 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
| 371 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 372 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
| 373 | 373 | 'query' => array( |
| 374 | 374 | 'cal_non_blocking' => 0, |
| 375 | 375 | ), |
| 376 | - 'no_integration' => true, // do NOT use integration of other apps |
|
| 376 | + 'no_integration' => true, // do NOT use integration of other apps |
|
| 377 | 377 | )); |
| 378 | 378 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 379 | 379 | { |
| 380 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
| 380 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
| 381 | 381 | } |
| 382 | - foreach((array) $overlapping_events as $k => $overlap) |
|
| 382 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
| 383 | 383 | { |
| 384 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 385 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 384 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 385 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 386 | 386 | $overlap['non_blocking']) // that's a non_blocking event |
| 387 | 387 | { |
| 388 | 388 | continue; |
| 389 | 389 | } |
| 390 | 390 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 391 | 391 | { |
| 392 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
| 392 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
| 393 | 393 | } |
| 394 | 394 | // check if the overlap is with a rejected participant or within the allowed quantity |
| 395 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
| 396 | - foreach($common_parts as $n => $uid) |
|
| 395 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
| 396 | + foreach ($common_parts as $n => $uid) |
|
| 397 | 397 | { |
| 398 | 398 | $status = $overlap['participants'][$uid]; |
| 399 | 399 | calendar_so::split_status($status, $q, $r); |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | unset($common_parts[$n]); |
| 403 | 403 | continue; |
| 404 | 404 | } |
| 405 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
| 405 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
| 406 | 406 | { |
| 407 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 407 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 408 | 408 | } |
| 409 | 409 | if (!isset($max_quantity[$uid])) |
| 410 | 410 | { |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $quantity[$uid] += $q; |
| 415 | 415 | if ($quantity[$uid] <= $max_quantity[$uid]) |
| 416 | 416 | { |
| 417 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
| 417 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
| 418 | 418 | unset($common_parts[$n]); |
| 419 | 419 | continue; |
| 420 | 420 | } |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | { |
| 425 | 425 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 426 | 426 | { |
| 427 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
| 427 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
| 428 | 428 | } |
| 429 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
| 429 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
| 434 | 434 | // check if we are withing the allowed quantity and if not add all events using that resource |
| 435 | 435 | // seems this function is doing very strange things, it gives empty conflicts |
| 436 | - foreach($max_quantity as $uid => $max) |
|
| 436 | + foreach ($max_quantity as $uid => $max) |
|
| 437 | 437 | { |
| 438 | 438 | if ($quantity[$uid] > $max) |
| 439 | 439 | { |
| 440 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 440 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 441 | 441 | { |
| 442 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
| 442 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | if (count($conflicts)) |
| 449 | 449 | { |
| 450 | - foreach($conflicts as $key => $conflict) |
|
| 450 | + foreach ($conflicts as $key => $conflict) |
|
| 451 | 451 | { |
| 452 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 453 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
| 452 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 453 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
| 454 | 454 | { |
| 455 | 455 | $conflicts[$key] = array( |
| 456 | 456 | 'id' => $conflict['id'], |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 465 | 465 | { |
| 466 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
| 466 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | return $conflicts; |
@@ -475,22 +475,22 @@ discard block |
||
| 475 | 475 | * @param array $old_event =null old event with already invited participants |
| 476 | 476 | * @return array removed participants because of missing invite grants |
| 477 | 477 | */ |
| 478 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
| 478 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
| 479 | 479 | { |
| 480 | 480 | if (!$this->require_acl_invite) |
| 481 | 481 | { |
| 482 | - return array(); // nothing to check, everyone can invite everyone else |
|
| 482 | + return array(); // nothing to check, everyone can invite everyone else |
|
| 483 | 483 | } |
| 484 | 484 | if ($event['id'] && is_null($old_event)) |
| 485 | 485 | { |
| 486 | 486 | $old_event = $this->read($event['id']); |
| 487 | 487 | } |
| 488 | 488 | $removed = array(); |
| 489 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
| 489 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
| 490 | 490 | { |
| 491 | 491 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
| 492 | 492 | { |
| 493 | - unset($event['participants'][$uid]); // remove participant |
|
| 493 | + unset($event['participants'][$uid]); // remove participant |
|
| 494 | 494 | $removed[] = $uid; |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -506,19 +506,19 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | public function check_acl_invite($uid) |
| 508 | 508 | { |
| 509 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 509 | + if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 510 | 510 | |
| 511 | 511 | if (!$this->require_acl_invite) |
| 512 | 512 | { |
| 513 | - $ret = true; // no grant required |
|
| 513 | + $ret = true; // no grant required |
|
| 514 | 514 | } |
| 515 | 515 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
| 516 | 516 | { |
| 517 | - $ret = true; // grant only required for groups |
|
| 517 | + $ret = true; // grant only required for groups |
|
| 518 | 518 | } |
| 519 | 519 | else |
| 520 | 520 | { |
| 521 | - $ret = $this->check_perms(self::ACL_INVITE,0,$uid); |
|
| 521 | + $ret = $this->check_perms(self::ACL_INVITE, 0, $uid); |
|
| 522 | 522 | } |
| 523 | 523 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
| 524 | 524 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @param array $old_event the event before the update |
| 533 | 533 | * @todo check if there is a real change, not assume every save is a change |
| 534 | 534 | */ |
| 535 | - function check4update($new_event,$old_event) |
|
| 535 | + function check4update($new_event, $old_event) |
|
| 536 | 536 | { |
| 537 | 537 | //error_log(__METHOD__."($new_event[title])"); |
| 538 | 538 | $modified = $added = $deleted = array(); |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
| 541 | 541 | |
| 542 | 542 | // Find modified and deleted participants ... |
| 543 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
| 543 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
| 544 | 544 | { |
| 545 | - if(isset($new_event['participants'][$old_userid])) |
|
| 545 | + if (isset($new_event['participants'][$old_userid])) |
|
| 546 | 546 | { |
| 547 | 547 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
| 548 | 548 | } |
@@ -552,27 +552,27 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | // Find new participants ... |
| 555 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
| 555 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
| 556 | 556 | { |
| 557 | - if(!isset($old_event['participants'][$new_userid])) |
|
| 557 | + if (!isset($old_event['participants'][$new_userid])) |
|
| 558 | 558 | { |
| 559 | 559 | $added[$new_userid] = 'U'; |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
| 563 | - if(count($added) || count($modified) || count($deleted)) |
|
| 563 | + if (count($added) || count($modified) || count($deleted)) |
|
| 564 | 564 | { |
| 565 | - if(count($added)) |
|
| 565 | + if (count($added)) |
|
| 566 | 566 | { |
| 567 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
| 567 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
| 568 | 568 | } |
| 569 | - if(count($modified)) |
|
| 569 | + if (count($modified)) |
|
| 570 | 570 | { |
| 571 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
| 571 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
| 572 | 572 | } |
| 573 | - if(count($deleted)) |
|
| 573 | + if (count($deleted)) |
|
| 574 | 574 | { |
| 575 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
| 575 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -589,11 +589,11 @@ discard block |
||
| 589 | 589 | * @param string $status of current user |
| 590 | 590 | * @return boolean true = update requested, false otherwise |
| 591 | 591 | */ |
| 592 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
| 592 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
| 593 | 593 | { |
| 594 | 594 | if ($msg_type == MSG_ALARM) |
| 595 | 595 | { |
| 596 | - return True; // always True for now |
|
| 596 | + return True; // always True for now |
|
| 597 | 597 | } |
| 598 | 598 | $want_update = 0; |
| 599 | 599 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | // |
| 602 | 602 | $msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED; |
| 603 | 603 | |
| 604 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
| 604 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
| 605 | 605 | { |
| 606 | 606 | case 'responses': |
| 607 | 607 | ++$want_update; |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | default: |
| 616 | 616 | if (is_array($new_event) && is_array($old_event)) |
| 617 | 617 | { |
| 618 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
| 619 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
| 618 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
| 619 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
| 620 | 620 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
| 621 | 621 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
| 622 | 622 | { |
@@ -636,13 +636,13 @@ discard block |
||
| 636 | 636 | if (!is_numeric($userid) && $role == 'CHAIR' && |
| 637 | 637 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
| 638 | 638 | { |
| 639 | - switch($msg_type) |
|
| 639 | + switch ($msg_type) |
|
| 640 | 640 | { |
| 641 | 641 | case MSG_DELETED: // treat deleting event as rejection to organizer |
| 642 | 642 | $msg_type = MSG_REJECTED; |
| 643 | 643 | break; |
| 644 | 644 | case MSG_ADDED: // new events use added, but organizer needs status |
| 645 | - switch($status[0]) |
|
| 645 | + switch ($status[0]) |
|
| 646 | 646 | { |
| 647 | 647 | case 'A': $msg_type = MSG_ACCEPTED; break; |
| 648 | 648 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * @param string $role ='REQ-PARTICIPANT' |
| 668 | 668 | * @return boolean true if user requested to be notified, false if not |
| 669 | 669 | */ |
| 670 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
| 670 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
| 671 | 671 | { |
| 672 | 672 | // check if email is from a user |
| 673 | 673 | if (is_numeric($user_or_email)) |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | ) |
| 692 | 692 | ); |
| 693 | 693 | } |
| 694 | - switch($ical_method) |
|
| 694 | + switch ($ical_method) |
|
| 695 | 695 | { |
| 696 | 696 | default: |
| 697 | 697 | case 'REQUEST': |
@@ -716,9 +716,9 @@ discard block |
||
| 716 | 716 | * @param string& $action=null on return verbose name |
| 717 | 717 | * @param string& $msg=null on return notification message |
| 718 | 718 | */ |
| 719 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
| 719 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
| 720 | 720 | { |
| 721 | - switch($msg_type) |
|
| 721 | + switch ($msg_type) |
|
| 722 | 722 | { |
| 723 | 723 | case MSG_DELETED: |
| 724 | 724 | $action = 'Canceled'; |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | $msg = $this->cal_prefs['notify'.$pref]; |
| 771 | 771 | if (empty($msg)) |
| 772 | 772 | { |
| 773 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 773 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 774 | 774 | } |
| 775 | 775 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
| 776 | 776 | return $method; |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | * @param int $user =0 User who started the notify, default current user |
| 787 | 787 | * @return bool true/false |
| 788 | 788 | */ |
| 789 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
| 789 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
| 790 | 790 | { |
| 791 | 791 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
| 792 | 792 | if (!is_array($to_notify)) |
@@ -798,11 +798,11 @@ discard block |
||
| 798 | 798 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
| 799 | 799 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
| 800 | 800 | { |
| 801 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 801 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
| 805 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 805 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 806 | 806 | { |
| 807 | 807 | return False; |
| 808 | 808 | } |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | $restore_tz = $tz; |
| 813 | 813 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
| 814 | 814 | } |
| 815 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 815 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 816 | 816 | |
| 817 | 817 | if (!$user) |
| 818 | 818 | { |
@@ -828,16 +828,16 @@ discard block |
||
| 828 | 828 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
| 829 | 829 | |
| 830 | 830 | // add all group-members to the notification, unless they are already participants |
| 831 | - foreach($to_notify as $userid => $statusid) |
|
| 831 | + foreach ($to_notify as $userid => $statusid) |
|
| 832 | 832 | { |
| 833 | 833 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
| 834 | 834 | ($members = $GLOBALS['egw']->accounts->members($userid, true))) |
| 835 | 835 | { |
| 836 | - foreach($members as $member) |
|
| 836 | + foreach ($members as $member) |
|
| 837 | 837 | { |
| 838 | 838 | if (!isset($to_notify[$member])) |
| 839 | 839 | { |
| 840 | - $to_notify[$member] = 'G'; // Group-invitation |
|
| 840 | + $to_notify[$member] = 'G'; // Group-invitation |
|
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
| 850 | 850 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 851 | 851 | $owner_prefs = $ics = null; |
| 852 | - foreach($to_notify as $userid => $statusid) |
|
| 852 | + foreach ($to_notify as $userid => $statusid) |
|
| 853 | 853 | { |
| 854 | 854 | $res_info = $quantity = $role = null; |
| 855 | 855 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -872,14 +872,14 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | if (!isset($userid)) |
| 874 | 874 | { |
| 875 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 875 | + if (empty($res_info['email'])) continue; // no way to notify |
|
| 876 | 876 | // check if event-owner wants non-EGroupware users notified |
| 877 | 877 | if (is_null($owner_prefs)) |
| 878 | 878 | { |
| 879 | 879 | $preferences = new Api\Preferences($owner); |
| 880 | 880 | $owner_prefs = $preferences->read_repository(); |
| 881 | 881 | } |
| 882 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 882 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 883 | 883 | (empty($owner_prefs['calendar']['notify_externals']) || |
| 884 | 884 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
| 885 | 885 | { |
@@ -891,12 +891,12 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
| 893 | 893 | { |
| 894 | - continue; // dont notify rejected participants or groups |
|
| 894 | + continue; // dont notify rejected participants or groups |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 897 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 898 | 898 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
| 899 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
| 899 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
| 900 | 900 | $msg_type == MSG_ALARM) |
| 901 | 901 | { |
| 902 | 902 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | $preferences = new Api\Preferences($userid); |
| 906 | 906 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
| 907 | 907 | $fullname = Api\Accounts::username($userid); |
| 908 | - $tfn = Api\Accounts::id2name($userid,'account_firstname'); |
|
| 909 | - $tln = Api\Accounts::id2name($userid,'account_lastname'); |
|
| 908 | + $tfn = Api\Accounts::id2name($userid, 'account_firstname'); |
|
| 909 | + $tln = Api\Accounts::id2name($userid, 'account_lastname'); |
|
| 910 | 910 | } |
| 911 | 911 | else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
| 912 | 912 | { |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | } |
| 918 | 918 | $part_prefs = $owner_prefs; |
| 919 | 919 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
| 920 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 920 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 921 | 921 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
| 922 | 922 | } |
| 923 | 923 | $m_type = $msg_type; |
@@ -942,14 +942,14 @@ discard block |
||
| 942 | 942 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 943 | 943 | $action, $event_arr, $disinvited); |
| 944 | 944 | $details['to-fullname'] = $fullname; |
| 945 | - $details['to-firstname'] = isset($tfn)? $tfn: ''; |
|
| 946 | - $details['to-lastname'] = isset($tln)? $tln: ''; |
|
| 945 | + $details['to-firstname'] = isset($tfn) ? $tfn : ''; |
|
| 946 | + $details['to-lastname'] = isset($tln) ? $tln : ''; |
|
| 947 | 947 | |
| 948 | 948 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 949 | 949 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
| 950 | 950 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 951 | 951 | $timeformat = $part_prefs['common']['timeformat']; |
| 952 | - switch($timeformat) |
|
| 952 | + switch ($timeformat) |
|
| 953 | 953 | { |
| 954 | 954 | case '24': |
| 955 | 955 | $timeformat = 'H:i'; |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | $timeformat = 'h:i a'; |
| 959 | 959 | break; |
| 960 | 960 | } |
| 961 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
| 961 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
| 962 | 962 | |
| 963 | 963 | $startdate->setTimezone($timezone); |
| 964 | 964 | $details['startdate'] = $startdate->format($timeformat); |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | $details['enddate'] = $enddate->format($timeformat); |
| 968 | 968 | |
| 969 | 969 | $modified->setTimezone($timezone); |
| 970 | - $details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']); |
|
| 970 | + $details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']); |
|
| 971 | 971 | |
| 972 | 972 | if ($old_event != False) |
| 973 | 973 | { |
@@ -976,15 +976,14 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
| 978 | 978 | |
| 979 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 979 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 980 | 980 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
| 981 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 981 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 982 | 982 | { |
| 983 | - case 'ical': |
|
| 984 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 983 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 985 | 984 | { |
| 986 | 985 | $calendar_ical = new calendar_ical(); |
| 987 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 986 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 988 | 987 | // we need to pass $event[id] so iCal class reads event again, |
| 989 | 988 | // as event is in user TZ, but iCal class expects server TZ! |
| 990 | 989 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1003,11 +1002,11 @@ discard block |
||
| 1003 | 1002 | case 'extended': |
| 1004 | 1003 | |
| 1005 | 1004 | $details_body = lang('Event Details follow').":\n"; |
| 1006 | - foreach($event_arr as $key => $val) |
|
| 1005 | + foreach ($event_arr as $key => $val) |
|
| 1007 | 1006 | { |
| 1008 | - if(!empty($details[$key])) |
|
| 1007 | + if (!empty($details[$key])) |
|
| 1009 | 1008 | { |
| 1010 | - switch($key) |
|
| 1009 | + switch ($key) |
|
| 1011 | 1010 | { |
| 1012 | 1011 | case 'access': |
| 1013 | 1012 | case 'priority': |
@@ -1016,7 +1015,7 @@ discard block |
||
| 1016 | 1015 | case 'title': |
| 1017 | 1016 | break; |
| 1018 | 1017 | default: |
| 1019 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
| 1018 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
| 1020 | 1019 | break; |
| 1021 | 1020 | } |
| 1022 | 1021 | } |
@@ -1024,7 +1023,7 @@ discard block |
||
| 1024 | 1023 | break; |
| 1025 | 1024 | } |
| 1026 | 1025 | // send via notification_app |
| 1027 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1026 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1028 | 1027 | { |
| 1029 | 1028 | try { |
| 1030 | 1029 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1048,9 +1047,9 @@ discard block |
||
| 1048 | 1047 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 1049 | 1048 | $notification->set_popuplinks(array($details['link_arr'])); |
| 1050 | 1049 | |
| 1051 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1050 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1052 | 1051 | $notification->send(); |
| 1053 | - foreach(notifications::errors(true) as $error) |
|
| 1052 | + foreach (notifications::errors(true) as $error) |
|
| 1054 | 1053 | { |
| 1055 | 1054 | error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error"); |
| 1056 | 1055 | } |
@@ -1089,14 +1088,14 @@ discard block |
||
| 1089 | 1088 | return true; |
| 1090 | 1089 | } |
| 1091 | 1090 | |
| 1092 | - function get_update_message($event,$added) |
|
| 1091 | + function get_update_message($event, $added) |
|
| 1093 | 1092 | { |
| 1094 | 1093 | $nul = null; |
| 1095 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
| 1094 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
| 1096 | 1095 | |
| 1097 | 1096 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
| 1098 | 1097 | |
| 1099 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 1098 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 1100 | 1099 | } |
| 1101 | 1100 | |
| 1102 | 1101 | /** |
@@ -1110,37 +1109,37 @@ discard block |
||
| 1110 | 1109 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
| 1111 | 1110 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
| 1112 | 1111 | |
| 1113 | - $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1114 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
| 1112 | + $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1113 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
| 1115 | 1114 | { |
| 1116 | - return False; // event not found |
|
| 1115 | + return False; // event not found |
|
| 1117 | 1116 | } |
| 1118 | 1117 | if ($alarm['all']) |
| 1119 | 1118 | { |
| 1120 | 1119 | $to_notify = $event['participants']; |
| 1121 | 1120 | } |
| 1122 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1121 | + elseif ($this->check_perms(Acl::READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1123 | 1122 | { |
| 1124 | 1123 | $to_notify[$alarm['owner']] = 'A'; |
| 1125 | 1124 | } |
| 1126 | 1125 | else |
| 1127 | 1126 | { |
| 1128 | - return False; // no rights |
|
| 1127 | + return False; // no rights |
|
| 1129 | 1128 | } |
| 1130 | 1129 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
| 1131 | 1130 | Api\Translation::add_app('calendar'); |
| 1132 | 1131 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
| 1133 | 1132 | |
| 1134 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
| 1133 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
| 1135 | 1134 | |
| 1136 | 1135 | // create a new alarm for recuring events for the next event, if one exists |
| 1137 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
| 1136 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
| 1138 | 1137 | { |
| 1139 | 1138 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
| 1140 | 1139 | unset($alarm['times']); |
| 1141 | 1140 | unset($alarm['next']); |
| 1142 | 1141 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
| 1143 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1142 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1144 | 1143 | } |
| 1145 | 1144 | return $ret; |
| 1146 | 1145 | } |
@@ -1156,14 +1155,14 @@ discard block |
||
| 1156 | 1155 | * Please note: you should ALLWAYS update timestamps, as they are required for sync! |
| 1157 | 1156 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
| 1158 | 1157 | */ |
| 1159 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
| 1158 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
| 1160 | 1159 | { |
| 1161 | 1160 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
| 1162 | 1161 | |
| 1163 | 1162 | // check if user has the permission to update / create the event |
| 1164 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 1165 | - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && |
|
| 1166 | - !$this->check_perms(Acl::ADD,0,$event['owner']))) |
|
| 1163 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 1164 | + !$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) && |
|
| 1165 | + !$this->check_perms(Acl::ADD, 0, $event['owner']))) |
|
| 1167 | 1166 | { |
| 1168 | 1167 | return false; |
| 1169 | 1168 | } |
@@ -1184,7 +1183,7 @@ discard block |
||
| 1184 | 1183 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
| 1185 | 1184 | { |
| 1186 | 1185 | $event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
| 1187 | - $event['recur_enddate']->setTime(23,59,59); |
|
| 1186 | + $event['recur_enddate']->setTime(23, 59, 59); |
|
| 1188 | 1187 | $rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName()); |
| 1189 | 1188 | $rrule->rewind(); |
| 1190 | 1189 | $enddate = $rrule->current(); |
@@ -1243,19 +1242,19 @@ discard block |
||
| 1243 | 1242 | |
| 1244 | 1243 | $event['recur_enddate'] = $save_event['recur_enddate'] = $time; |
| 1245 | 1244 | } |
| 1246 | - $timestamps = array('modified','created'); |
|
| 1245 | + $timestamps = array('modified', 'created'); |
|
| 1247 | 1246 | // all-day events are handled in server time |
| 1248 | 1247 | // $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName(); |
| 1249 | 1248 | } |
| 1250 | 1249 | else |
| 1251 | 1250 | { |
| 1252 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
| 1251 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
| 1253 | 1252 | } |
| 1254 | 1253 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
| 1255 | - foreach($timestamps as $ts) |
|
| 1254 | + foreach ($timestamps as $ts) |
|
| 1256 | 1255 | { |
| 1257 | 1256 | // we convert here from user-time to timestamps in server-time! |
| 1258 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1257 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
| 1259 | 1258 | } |
| 1260 | 1259 | // convert tzid name to integer tz_id, of set user default |
| 1261 | 1260 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1265,7 +1264,7 @@ discard block |
||
| 1265 | 1264 | // same with the recur exceptions |
| 1266 | 1265 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 1267 | 1266 | { |
| 1268 | - foreach($event['recur_exception'] as &$date) |
|
| 1267 | + foreach ($event['recur_exception'] as &$date) |
|
| 1269 | 1268 | { |
| 1270 | 1269 | if ($event['whole_day']) |
| 1271 | 1270 | { |
@@ -1274,7 +1273,7 @@ discard block |
||
| 1274 | 1273 | } |
| 1275 | 1274 | else |
| 1276 | 1275 | { |
| 1277 | - $date = $this->date2ts($date,true); |
|
| 1276 | + $date = $this->date2ts($date, true); |
|
| 1278 | 1277 | } |
| 1279 | 1278 | } |
| 1280 | 1279 | unset($date); |
@@ -1282,7 +1281,7 @@ discard block |
||
| 1282 | 1281 | // same with the alarms |
| 1283 | 1282 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
| 1284 | 1283 | { |
| 1285 | - foreach($event['alarm'] as $id => &$alarm) |
|
| 1284 | + foreach ($event['alarm'] as $id => &$alarm) |
|
| 1286 | 1285 | { |
| 1287 | 1286 | // remove alarms belonging to not longer existing or rejected participants |
| 1288 | 1287 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1300,15 +1299,14 @@ discard block |
||
| 1300 | 1299 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
| 1301 | 1300 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
| 1302 | 1301 | { |
| 1303 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
| 1302 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
| 1304 | 1303 | { |
| 1305 | 1304 | if (!isset($event['alarm'][$id])) |
| 1306 | 1305 | { |
| 1307 | 1306 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1308 | 1307 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
| 1309 | 1308 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1310 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
| 1311 | - $old_event['participants'][$alarm['owner']]; |
|
| 1309 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
| 1312 | 1310 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
| 1313 | 1311 | { |
| 1314 | 1312 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1335,9 +1333,9 @@ discard block |
||
| 1335 | 1333 | $event['created'] = $this->now; |
| 1336 | 1334 | $event['creator'] = $this->user; |
| 1337 | 1335 | } |
| 1338 | - $set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate']+1 : false; |
|
| 1336 | + $set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] + 1 : false; |
|
| 1339 | 1337 | $set_recurrences_start = 0; |
| 1340 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1338 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1341 | 1339 | { |
| 1342 | 1340 | $save_event['id'] = $cal_id; |
| 1343 | 1341 | // unset participants to enforce the default stati for all added recurrences |
@@ -1348,7 +1346,7 @@ discard block |
||
| 1348 | 1346 | // create links for new participants from addressbook, if configured |
| 1349 | 1347 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
| 1350 | 1348 | { |
| 1351 | - foreach($event['participants'] as $uid => $status) |
|
| 1349 | + foreach ($event['participants'] as $uid => $status) |
|
| 1352 | 1350 | { |
| 1353 | 1351 | $user_type = $user_id = null; |
| 1354 | 1352 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1361,7 +1359,7 @@ discard block |
||
| 1361 | 1359 | |
| 1362 | 1360 | // Update history |
| 1363 | 1361 | $tracking = new calendar_tracking($this); |
| 1364 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1362 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
| 1365 | 1363 | $tracking->track($event, $old_event); |
| 1366 | 1364 | |
| 1367 | 1365 | return $cal_id; |
@@ -1376,16 +1374,16 @@ discard block |
||
| 1376 | 1374 | * @param array|int $event event array or id of the event |
| 1377 | 1375 | * @return boolean |
| 1378 | 1376 | */ |
| 1379 | - function check_status_perms($uid,$event) |
|
| 1377 | + function check_status_perms($uid, $event) |
|
| 1380 | 1378 | { |
| 1381 | 1379 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
| 1382 | 1380 | { |
| 1383 | 1381 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1384 | 1382 | |
| 1385 | - return $this->check_perms(Acl::EDIT,0,$event['owner']); |
|
| 1383 | + return $this->check_perms(Acl::EDIT, 0, $event['owner']); |
|
| 1386 | 1384 | } |
| 1387 | 1385 | // check if we have a category Acl for the event or not (null) |
| 1388 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
| 1386 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
| 1389 | 1387 | if (!is_null($access)) |
| 1390 | 1388 | { |
| 1391 | 1389 | return $access; |
@@ -1395,17 +1393,17 @@ discard block |
||
| 1395 | 1393 | { |
| 1396 | 1394 | $resource = $this->resource_info($uid); |
| 1397 | 1395 | |
| 1398 | - return Acl::EDIT & $resource['rights']; |
|
| 1396 | + return Acl::EDIT&$resource['rights']; |
|
| 1399 | 1397 | } |
| 1400 | 1398 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1401 | 1399 | |
| 1402 | 1400 | // regular user and groups (need to check memberships too) |
| 1403 | 1401 | if (!isset($event['participants'][$uid])) |
| 1404 | 1402 | { |
| 1405 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
| 1403 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
| 1406 | 1404 | } |
| 1407 | 1405 | $memberships[] = $uid; |
| 1408 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid); |
|
| 1406 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid); |
|
| 1409 | 1407 | } |
| 1410 | 1408 | |
| 1411 | 1409 | /** |
@@ -1419,16 +1417,16 @@ discard block |
||
| 1419 | 1417 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1420 | 1418 | * null = cat has no acl |
| 1421 | 1419 | */ |
| 1422 | - function check_cat_acl($right,$event) |
|
| 1420 | + function check_cat_acl($right, $event) |
|
| 1423 | 1421 | { |
| 1424 | 1422 | if (!is_array($event)) $event = $this->read($event); |
| 1425 | 1423 | |
| 1426 | 1424 | $ret = null; |
| 1427 | 1425 | if ($event['category']) |
| 1428 | 1426 | { |
| 1429 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
| 1427 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
| 1430 | 1428 | { |
| 1431 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
| 1429 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
| 1432 | 1430 | if ($access === true) |
| 1433 | 1431 | { |
| 1434 | 1432 | $ret = true; |
@@ -1436,7 +1434,7 @@ discard block |
||
| 1436 | 1434 | } |
| 1437 | 1435 | if ($access === false) |
| 1438 | 1436 | { |
| 1439 | - $ret = false; // cat denies access --> check further cats |
|
| 1437 | + $ret = false; // cat denies access --> check further cats |
|
| 1440 | 1438 | } |
| 1441 | 1439 | } |
| 1442 | 1440 | } |
@@ -1457,12 +1455,12 @@ discard block |
||
| 1457 | 1455 | * @param int $cat_id =null null to return array with all cats |
| 1458 | 1456 | * @return array with account_id => right pairs |
| 1459 | 1457 | */ |
| 1460 | - public static function get_cat_rights($cat_id=null) |
|
| 1458 | + public static function get_cat_rights($cat_id = null) |
|
| 1461 | 1459 | { |
| 1462 | 1460 | if (!isset(self::$cat_rights_cache)) |
| 1463 | 1461 | { |
| 1464 | - self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights', |
|
| 1465 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
| 1462 | + self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights', |
|
| 1463 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
| 1466 | 1464 | } |
| 1467 | 1465 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
| 1468 | 1466 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1475,7 +1473,7 @@ discard block |
||
| 1475 | 1473 | * @param int $user |
| 1476 | 1474 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
| 1477 | 1475 | */ |
| 1478 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
| 1476 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
| 1479 | 1477 | { |
| 1480 | 1478 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1481 | 1479 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1485,15 +1483,15 @@ discard block |
||
| 1485 | 1483 | if ($rights) |
| 1486 | 1484 | { |
| 1487 | 1485 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
| 1488 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
| 1486 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
| 1489 | 1487 | } |
| 1490 | 1488 | else |
| 1491 | 1489 | { |
| 1492 | 1490 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1493 | 1491 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
| 1494 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
| 1492 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
| 1495 | 1493 | } |
| 1496 | - Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
| 1494 | + Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
| 1497 | 1495 | } |
| 1498 | 1496 | } |
| 1499 | 1497 | |
@@ -1504,9 +1502,9 @@ discard block |
||
| 1504 | 1502 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1505 | 1503 | * null = cat has no acl |
| 1506 | 1504 | */ |
| 1507 | - public static function has_cat_right($right,$cat_id,$user) |
|
| 1505 | + public static function has_cat_right($right, $cat_id, $user) |
|
| 1508 | 1506 | { |
| 1509 | - static $cache=null; |
|
| 1507 | + static $cache = null; |
|
| 1510 | 1508 | |
| 1511 | 1509 | if (!isset($cache[$cat_id])) |
| 1512 | 1510 | { |
@@ -1514,21 +1512,21 @@ discard block |
||
| 1514 | 1512 | $cat_rights = self::get_cat_rights($cat_id); |
| 1515 | 1513 | if (!is_null($cat_rights)) |
| 1516 | 1514 | { |
| 1517 | - static $memberships=null; |
|
| 1515 | + static $memberships = null; |
|
| 1518 | 1516 | if (is_null($memberships)) |
| 1519 | 1517 | { |
| 1520 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
| 1518 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 1521 | 1519 | $memberships[] = $user; |
| 1522 | 1520 | } |
| 1523 | - foreach($cat_rights as $uid => $value) |
|
| 1521 | + foreach ($cat_rights as $uid => $value) |
|
| 1524 | 1522 | { |
| 1525 | 1523 | $all |= $value; |
| 1526 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1524 | + if (in_array($uid, $memberships)) $own |= $value; |
|
| 1527 | 1525 | } |
| 1528 | 1526 | } |
| 1529 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
| 1527 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
| 1530 | 1528 | { |
| 1531 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
| 1529 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
| 1532 | 1530 | } |
| 1533 | 1531 | } |
| 1534 | 1532 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1548,13 +1546,13 @@ discard block |
||
| 1548 | 1546 | * @param boolean $skip_notification =false true: do not send notification messages |
| 1549 | 1547 | * @return int number of changed recurrences |
| 1550 | 1548 | */ |
| 1551 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
| 1549 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
| 1552 | 1550 | { |
| 1553 | 1551 | unset($updateTS); |
| 1554 | 1552 | |
| 1555 | 1553 | $cal_id = is_array($event) ? $event['id'] : $event; |
| 1556 | 1554 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
| 1557 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
| 1555 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
| 1558 | 1556 | { |
| 1559 | 1557 | return false; |
| 1560 | 1558 | } |
@@ -1563,16 +1561,16 @@ discard block |
||
| 1563 | 1561 | if ($this->log) |
| 1564 | 1562 | { |
| 1565 | 1563 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1566 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
| 1564 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
| 1567 | 1565 | } |
| 1568 | 1566 | $old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server'); |
| 1569 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
| 1570 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
| 1571 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
| 1567 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
| 1568 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
| 1569 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
| 1572 | 1570 | { |
| 1573 | 1571 | if ($status == 'R') // remove alarms belonging to rejected participants |
| 1574 | 1572 | { |
| 1575 | - foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1573 | + foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1576 | 1574 | { |
| 1577 | 1575 | if ((string)$alarm['owner'] === (string)$uid) |
| 1578 | 1576 | { |
@@ -1591,8 +1589,8 @@ discard block |
||
| 1591 | 1589 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1592 | 1590 | { |
| 1593 | 1591 | if (!is_array($event)) $event = $this->read($cal_id); |
| 1594 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1595 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
| 1592 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
| 1593 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
| 1596 | 1594 | } |
| 1597 | 1595 | |
| 1598 | 1596 | // Update history |
@@ -1612,14 +1610,14 @@ discard block |
||
| 1612 | 1610 | * @param int $recur_date =0 date to change, or 0 = all since now |
| 1613 | 1611 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
| 1614 | 1612 | */ |
| 1615 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
| 1613 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
| 1616 | 1614 | { |
| 1617 | 1615 | if (!isset($new_event['participants'])) return; |
| 1618 | 1616 | |
| 1619 | 1617 | // check the old list against the new list |
| 1620 | 1618 | foreach ($old_event['participants'] as $userid => $status) |
| 1621 | 1619 | { |
| 1622 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1620 | + if (!isset($new_event['participants'][$userid])) { |
|
| 1623 | 1621 | // Attendee will be deleted this way |
| 1624 | 1622 | $new_event['participants'][$userid] = 'G'; |
| 1625 | 1623 | } |
@@ -1632,7 +1630,7 @@ discard block |
||
| 1632 | 1630 | // write the changes |
| 1633 | 1631 | foreach ($new_event['participants'] as $userid => $status) |
| 1634 | 1632 | { |
| 1635 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
| 1633 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
| 1636 | 1634 | } |
| 1637 | 1635 | } |
| 1638 | 1636 | |
@@ -1647,43 +1645,43 @@ discard block |
||
| 1647 | 1645 | * @param int &$exceptions_kept=null on return number of kept exceptions |
| 1648 | 1646 | * @return boolean true on success, false on error (usually permission denied) |
| 1649 | 1647 | */ |
| 1650 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
| 1651 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
| 1648 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
| 1649 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
| 1652 | 1650 | { |
| 1653 | 1651 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
| 1654 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
| 1655 | - !$ignore_acl && !$this->check_perms(Acl::DELETE,$event)) |
|
| 1652 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
| 1653 | + !$ignore_acl && !$this->check_perms(Acl::DELETE, $event)) |
|
| 1656 | 1654 | { |
| 1657 | 1655 | return false; |
| 1658 | 1656 | } |
| 1659 | 1657 | |
| 1660 | 1658 | // Don't send notification if the event has already been deleted |
| 1661 | - if(!$event['deleted'] && !$skip_notification) |
|
| 1659 | + if (!$event['deleted'] && !$skip_notification) |
|
| 1662 | 1660 | { |
| 1663 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
| 1661 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
| 1664 | 1662 | } |
| 1665 | 1663 | |
| 1666 | 1664 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
| 1667 | 1665 | { |
| 1668 | 1666 | $config = Api\Config::read('phpgwapi'); |
| 1669 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1667 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1670 | 1668 | { |
| 1671 | 1669 | $this->so->delete($cal_id); |
| 1672 | 1670 | |
| 1673 | 1671 | // delete all links to the event |
| 1674 | - Link::unlink(0,'calendar',$cal_id); |
|
| 1672 | + Link::unlink(0, 'calendar', $cal_id); |
|
| 1675 | 1673 | } |
| 1676 | 1674 | elseif ($config['calendar_delete_history']) |
| 1677 | 1675 | { |
| 1678 | 1676 | // mark all links to the event as deleted, but keep them |
| 1679 | - Link::unlink(0,'calendar',$cal_id,'','','',true); |
|
| 1677 | + Link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
| 1680 | 1678 | |
| 1681 | 1679 | $event['deleted'] = $this->now; |
| 1682 | 1680 | $this->save($event, $ignore_acl); |
| 1683 | 1681 | // Actually delete alarms |
| 1684 | 1682 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1685 | 1683 | { |
| 1686 | - foreach($event['alarm'] as $id => $alarm) |
|
| 1684 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 1687 | 1685 | { |
| 1688 | 1686 | $this->delete_alarm($id); |
| 1689 | 1687 | } |
@@ -1705,7 +1703,7 @@ discard block |
||
| 1705 | 1703 | if (!($exception = $this->read($id))) continue; |
| 1706 | 1704 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1707 | 1705 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1708 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
| 1706 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
| 1709 | 1707 | ++$exceptions_kept; |
| 1710 | 1708 | } |
| 1711 | 1709 | } |
@@ -1717,9 +1715,9 @@ discard block |
||
| 1717 | 1715 | if ($event['alarm']) |
| 1718 | 1716 | { |
| 1719 | 1717 | $next_recurrance = null; |
| 1720 | - foreach($event['alarm'] as &$alarm) |
|
| 1718 | + foreach ($event['alarm'] as &$alarm) |
|
| 1721 | 1719 | { |
| 1722 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
| 1720 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
| 1723 | 1721 | { |
| 1724 | 1722 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
| 1725 | 1723 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1727,12 +1725,12 @@ discard block |
||
| 1727 | 1725 | { |
| 1728 | 1726 | $checkdate = $recur_date; |
| 1729 | 1727 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
| 1730 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
| 1728 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
| 1731 | 1729 | { |
| 1732 | 1730 | $next_recurrance = $this->date2ts($e['start']); |
| 1733 | 1731 | } |
| 1734 | 1732 | } |
| 1735 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1733 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1736 | 1734 | $alarm['cal_id'] = $cal_id; |
| 1737 | 1735 | unset($alarm['times']); |
| 1738 | 1736 | unset($alarm['next']); |
@@ -1746,7 +1744,7 @@ discard block |
||
| 1746 | 1744 | $event = $this->read($cal_id); |
| 1747 | 1745 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
| 1748 | 1746 | $event['recur_exception'][] = $recur_date; |
| 1749 | - $this->save($event);// updates the content-history |
|
| 1747 | + $this->save($event); // updates the content-history |
|
| 1750 | 1748 | } |
| 1751 | 1749 | if ($event['reference']) |
| 1752 | 1750 | { |
@@ -1764,19 +1762,19 @@ discard block |
||
| 1764 | 1762 | * @param array $disinvited |
| 1765 | 1763 | * @return array |
| 1766 | 1764 | */ |
| 1767 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
| 1765 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
| 1768 | 1766 | { |
| 1769 | 1767 | $details = array( // event-details for the notify-msg |
| 1770 | 1768 | 'id' => $event['id'], |
| 1771 | 1769 | 'action' => lang($action), |
| 1772 | 1770 | ); |
| 1773 | 1771 | $event_arr = $this->event2array($event); |
| 1774 | - foreach($event_arr as $key => $val) |
|
| 1772 | + foreach ($event_arr as $key => $val) |
|
| 1775 | 1773 | { |
| 1776 | 1774 | if ($key == 'recur_type') $key = 'repetition'; |
| 1777 | 1775 | $details[$key] = $val['data']; |
| 1778 | 1776 | } |
| 1779 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
| 1777 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
| 1780 | 1778 | |
| 1781 | 1779 | $event_arr['link']['field'] = lang('URL'); |
| 1782 | 1780 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1797,7 +1795,7 @@ discard block |
||
| 1797 | 1795 | */ |
| 1798 | 1796 | $link_arr = array(); |
| 1799 | 1797 | $link_arr['text'] = $event['title']; |
| 1800 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1798 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1801 | 1799 | 'cal_id' => $event['id'], |
| 1802 | 1800 | 'date' => $eventStart_arr['full'], |
| 1803 | 1801 | ); |
@@ -1805,11 +1803,11 @@ discard block |
||
| 1805 | 1803 | $details['link_arr'] = $link_arr; |
| 1806 | 1804 | |
| 1807 | 1805 | $dis = array(); |
| 1808 | - foreach($disinvited as $uid) |
|
| 1806 | + foreach ($disinvited as $uid) |
|
| 1809 | 1807 | { |
| 1810 | 1808 | $dis[] = $this->participant_name($uid); |
| 1811 | 1809 | } |
| 1812 | - $details['disinvited'] = implode(', ',$dis); |
|
| 1810 | + $details['disinvited'] = implode(', ', $dis); |
|
| 1813 | 1811 | return $details; |
| 1814 | 1812 | } |
| 1815 | 1813 | |
@@ -1833,13 +1831,13 @@ discard block |
||
| 1833 | 1831 | 'data' => $event['description'] |
| 1834 | 1832 | ); |
| 1835 | 1833 | |
| 1836 | - foreach(explode(',',$event['category']) as $cat_id) |
|
| 1834 | + foreach (explode(',', $event['category']) as $cat_id) |
|
| 1837 | 1835 | { |
| 1838 | 1836 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1839 | 1837 | } |
| 1840 | 1838 | $var['category'] = Array( |
| 1841 | 1839 | 'field' => lang('Category'), |
| 1842 | - 'data' => implode(', ',$cat_string) |
|
| 1840 | + 'data' => implode(', ', $cat_string) |
|
| 1843 | 1841 | ); |
| 1844 | 1842 | |
| 1845 | 1843 | $var['location'] = Array( |
@@ -1885,7 +1883,7 @@ discard block |
||
| 1885 | 1883 | |
| 1886 | 1884 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
| 1887 | 1885 | { |
| 1888 | - $participants = $this->participants($event,true); |
|
| 1886 | + $participants = $this->participants($event, true); |
|
| 1889 | 1887 | } |
| 1890 | 1888 | $var['participants'] = Array( |
| 1891 | 1889 | 'field' => lang('Participants'), |
@@ -1908,26 +1906,26 @@ discard block |
||
| 1908 | 1906 | * @param array $old_event =null event-data in the DB before calling save |
| 1909 | 1907 | * @param string $type ='update' |
| 1910 | 1908 | */ |
| 1911 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
| 1909 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
| 1912 | 1910 | { |
| 1913 | - if (!($f = fopen($this->log_file,'a'))) |
|
| 1911 | + if (!($f = fopen($this->log_file, 'a'))) |
|
| 1914 | 1912 | { |
| 1915 | 1913 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
| 1916 | 1914 | return false; |
| 1917 | 1915 | } |
| 1918 | - fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1919 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
| 1920 | - foreach(array('start','end') as $name) |
|
| 1916 | + fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1917 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
| 1918 | + foreach (array('start', 'end') as $name) |
|
| 1921 | 1919 | { |
| 1922 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1923 | - $this->format_date($event_saved[$name]) .' / '. |
|
| 1920 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1921 | + $this->format_date($event_saved[$name]).' / '. |
|
| 1924 | 1922 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
| 1925 | 1923 | } |
| 1926 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
| 1924 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
| 1927 | 1925 | { |
| 1928 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
| 1926 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
| 1929 | 1927 | } |
| 1930 | - fwrite($f,"\n"); |
|
| 1928 | + fwrite($f, "\n"); |
|
| 1931 | 1929 | fclose($f); |
| 1932 | 1930 | |
| 1933 | 1931 | return true; |
@@ -1948,14 +1946,14 @@ discard block |
||
| 1948 | 1946 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 1949 | 1947 | |
| 1950 | 1948 | $time = new Api\DateTime($event['start']); |
| 1951 | - if(!is_array($event['alarm'])) |
|
| 1949 | + if (!is_array($event['alarm'])) |
|
| 1952 | 1950 | { |
| 1953 | 1951 | $event['alarm'] = $this->so->read_alarms($event['id']); |
| 1954 | 1952 | } |
| 1955 | 1953 | |
| 1956 | - foreach($event['alarm'] as &$alarm) |
|
| 1954 | + foreach ($event['alarm'] as &$alarm) |
|
| 1957 | 1955 | { |
| 1958 | - if($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1956 | + if ($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1959 | 1957 | { |
| 1960 | 1958 | calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts')); |
| 1961 | 1959 | } |
@@ -1975,14 +1973,14 @@ discard block |
||
| 1975 | 1973 | * @param boolean $update_modified =true call update modified, default true |
| 1976 | 1974 | * @return string id of the alarm, or false on error (eg. no perms) |
| 1977 | 1975 | */ |
| 1978 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 1976 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 1979 | 1977 | { |
| 1980 | - if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1978 | + if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1981 | 1979 | { |
| 1982 | 1980 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
| 1983 | - return false; // no rights to add the alarm |
|
| 1981 | + return false; // no rights to add the alarm |
|
| 1984 | 1982 | } |
| 1985 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
| 1983 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
| 1986 | 1984 | |
| 1987 | 1985 | return $this->so->save_alarm($cal_id, $alarm, $update_modified); |
| 1988 | 1986 | } |
@@ -1995,11 +1993,11 @@ discard block |
||
| 1995 | 1993 | */ |
| 1996 | 1994 | function delete_alarm($id) |
| 1997 | 1995 | { |
| 1998 | - list(,$cal_id) = explode(':',$id); |
|
| 1996 | + list(,$cal_id) = explode(':', $id); |
|
| 1999 | 1997 | |
| 2000 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1998 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2001 | 1999 | { |
| 2002 | - return false; // no rights to delete the alarm |
|
| 2000 | + return false; // no rights to delete the alarm |
|
| 2003 | 2001 | } |
| 2004 | 2002 | |
| 2005 | 2003 | return $this->so->delete_alarm($id); |
@@ -2014,13 +2012,13 @@ discard block |
||
| 2014 | 2012 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
| 2015 | 2013 | * @return array category ids (found, added and preserved categories) |
| 2016 | 2014 | */ |
| 2017 | - function find_or_add_categories($catname_list, $old_event=null) |
|
| 2015 | + function find_or_add_categories($catname_list, $old_event = null) |
|
| 2018 | 2016 | { |
| 2019 | 2017 | if (is_array($old_event) || $old_event > 0) |
| 2020 | 2018 | { |
| 2021 | 2019 | // preserve categories without users read access |
| 2022 | 2020 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
| 2023 | - $old_categories = explode(',',$old_event['category']); |
|
| 2021 | + $old_categories = explode(',', $old_event['category']); |
|
| 2024 | 2022 | $old_cats_preserve = array(); |
| 2025 | 2023 | if (is_array($old_categories) && count($old_categories) > 0) |
| 2026 | 2024 | { |
@@ -2074,7 +2072,7 @@ discard block |
||
| 2074 | 2072 | { |
| 2075 | 2073 | if (!is_array($cat_id_list)) |
| 2076 | 2074 | { |
| 2077 | - $cat_id_list = explode(',',$cat_id_list); |
|
| 2075 | + $cat_id_list = explode(',', $cat_id_list); |
|
| 2078 | 2076 | } |
| 2079 | 2077 | $cat_list = array(); |
| 2080 | 2078 | foreach ($cat_id_list as $cat_id) |
@@ -2099,7 +2097,7 @@ discard block |
||
| 2099 | 2097 | * master -> try to find a releated series master |
| 2100 | 2098 | * @return array calendar_ids of matching entries |
| 2101 | 2099 | */ |
| 2102 | - function find_event($event, $filter='exact') |
|
| 2100 | + function find_event($event, $filter = 'exact') |
|
| 2103 | 2101 | { |
| 2104 | 2102 | $matchingEvents = array(); |
| 2105 | 2103 | $query = array(); |
@@ -2107,14 +2105,14 @@ discard block |
||
| 2107 | 2105 | if ($this->log) |
| 2108 | 2106 | { |
| 2109 | 2107 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2110 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
| 2108 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
| 2111 | 2109 | } |
| 2112 | 2110 | |
| 2113 | 2111 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
| 2114 | 2112 | |
| 2115 | 2113 | if ($filter == 'master') |
| 2116 | 2114 | { |
| 2117 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
| 2115 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
| 2118 | 2116 | $query['cal_recurrence'] = 0; |
| 2119 | 2117 | } |
| 2120 | 2118 | elseif ($filter == 'exact') |
@@ -2135,14 +2133,14 @@ discard block |
||
| 2135 | 2133 | if ($this->log) |
| 2136 | 2134 | { |
| 2137 | 2135 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2138 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
| 2136 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
| 2139 | 2137 | } |
| 2140 | 2138 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
| 2141 | 2139 | { |
| 2142 | 2140 | if ($this->log) |
| 2143 | 2141 | { |
| 2144 | 2142 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2145 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2143 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2146 | 2144 | } |
| 2147 | 2145 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
| 2148 | 2146 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2161,7 +2159,7 @@ discard block |
||
| 2161 | 2159 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
| 2162 | 2160 | if (in_array($event['recurrence'], $exceptions)) |
| 2163 | 2161 | { |
| 2164 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
| 2162 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
| 2165 | 2163 | } |
| 2166 | 2164 | } |
| 2167 | 2165 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2180,19 +2178,19 @@ discard block |
||
| 2180 | 2178 | |
| 2181 | 2179 | // only query calendars of users, we have READ-grants from |
| 2182 | 2180 | $users = array(); |
| 2183 | - foreach(array_keys($this->grants) as $user) |
|
| 2181 | + foreach (array_keys($this->grants) as $user) |
|
| 2184 | 2182 | { |
| 2185 | 2183 | $user = trim($user); |
| 2186 | - if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
|
| 2184 | + if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user)) |
|
| 2187 | 2185 | { |
| 2188 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2186 | + if ($user && !in_array($user, $users)) // already added? |
|
| 2189 | 2187 | { |
| 2190 | 2188 | $users[] = $user; |
| 2191 | 2189 | } |
| 2192 | 2190 | } |
| 2193 | 2191 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2194 | 2192 | { |
| 2195 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2193 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2196 | 2194 | } |
| 2197 | 2195 | // the further code is only for real users |
| 2198 | 2196 | if (!is_numeric($user)) continue; |
@@ -2203,7 +2201,7 @@ discard block |
||
| 2203 | 2201 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 2204 | 2202 | if (is_array($members)) |
| 2205 | 2203 | { |
| 2206 | - foreach($members as $member) |
|
| 2204 | + foreach ($members as $member) |
|
| 2207 | 2205 | { |
| 2208 | 2206 | // use only members which gave the user a read-grant |
| 2209 | 2207 | if (!in_array($member, $users) && |
@@ -2219,7 +2217,7 @@ discard block |
||
| 2219 | 2217 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 2220 | 2218 | if (is_array($memberships)) |
| 2221 | 2219 | { |
| 2222 | - foreach($memberships as $group) |
|
| 2220 | + foreach ($memberships as $group) |
|
| 2223 | 2221 | { |
| 2224 | 2222 | if (!in_array($group, $users)) |
| 2225 | 2223 | { |
@@ -2245,24 +2243,24 @@ discard block |
||
| 2245 | 2243 | |
| 2246 | 2244 | // check length with some tolerance |
| 2247 | 2245 | $length = $event['end'] - $event['start'] - $delta; |
| 2248 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
| 2246 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
| 2249 | 2247 | $length += 2 * $delta; |
| 2250 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
| 2251 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
| 2252 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
| 2248 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
| 2249 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
| 2250 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
| 2253 | 2251 | } |
| 2254 | 2252 | elseif (isset($event['start'])) |
| 2255 | 2253 | { |
| 2256 | 2254 | if ($filter == 'relax') |
| 2257 | 2255 | { |
| 2258 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
| 2259 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
| 2256 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
| 2257 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
| 2260 | 2258 | } |
| 2261 | 2259 | else |
| 2262 | 2260 | { |
| 2263 | 2261 | // we accept a tiny tolerance |
| 2264 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
| 2265 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
| 2262 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
| 2263 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
| 2266 | 2264 | } |
| 2267 | 2265 | } |
| 2268 | 2266 | if ($filter == 'relax') |
@@ -2285,14 +2283,14 @@ discard block |
||
| 2285 | 2283 | if ($this->log) |
| 2286 | 2284 | { |
| 2287 | 2285 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2288 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
| 2286 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
| 2289 | 2287 | } |
| 2290 | 2288 | } |
| 2291 | 2289 | |
| 2292 | 2290 | if ($this->log) |
| 2293 | 2291 | { |
| 2294 | 2292 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2295 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
| 2293 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
| 2296 | 2294 | } |
| 2297 | 2295 | if (!count($users) || !($foundEvents = |
| 2298 | 2296 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2300,19 +2298,19 @@ discard block |
||
| 2300 | 2298 | if ($this->log) |
| 2301 | 2299 | { |
| 2302 | 2300 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2303 | - "[NO MATCH]\n",3,$this->logfile); |
|
| 2301 | + "[NO MATCH]\n", 3, $this->logfile); |
|
| 2304 | 2302 | } |
| 2305 | 2303 | return $matchingEvents; |
| 2306 | 2304 | } |
| 2307 | 2305 | |
| 2308 | 2306 | $pseudos = array(); |
| 2309 | 2307 | |
| 2310 | - foreach($foundEvents as $egwEvent) |
|
| 2308 | + foreach ($foundEvents as $egwEvent) |
|
| 2311 | 2309 | { |
| 2312 | 2310 | if ($this->log) |
| 2313 | 2311 | { |
| 2314 | 2312 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2315 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2313 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2316 | 2314 | } |
| 2317 | 2315 | |
| 2318 | 2316 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2386,7 +2384,7 @@ discard block |
||
| 2386 | 2384 | if (in_array($event['recurrence'], $exceptions)) |
| 2387 | 2385 | { |
| 2388 | 2386 | // We found a pseudo exception |
| 2389 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
| 2387 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
| 2390 | 2388 | break; |
| 2391 | 2389 | } |
| 2392 | 2390 | } |
@@ -2404,7 +2402,7 @@ discard block |
||
| 2404 | 2402 | if ($this->log) |
| 2405 | 2403 | { |
| 2406 | 2404 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2407 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
| 2405 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
| 2408 | 2406 | } |
| 2409 | 2407 | continue; |
| 2410 | 2408 | } |
@@ -2416,7 +2414,7 @@ discard block |
||
| 2416 | 2414 | if ($this->log) |
| 2417 | 2415 | { |
| 2418 | 2416 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2419 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
| 2417 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
| 2420 | 2418 | } |
| 2421 | 2419 | continue; |
| 2422 | 2420 | } |
@@ -2437,8 +2435,8 @@ discard block |
||
| 2437 | 2435 | if ($this->log) |
| 2438 | 2436 | { |
| 2439 | 2437 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2440 | - "() event[$key] differ: '" . $event[$key] . |
|
| 2441 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
| 2438 | + "() event[$key] differ: '".$event[$key]. |
|
| 2439 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
| 2442 | 2440 | } |
| 2443 | 2441 | continue 2; // next foundEvent |
| 2444 | 2442 | } |
@@ -2456,7 +2454,7 @@ discard block |
||
| 2456 | 2454 | if ($this->log) |
| 2457 | 2455 | { |
| 2458 | 2456 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2459 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
| 2457 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
| 2460 | 2458 | } |
| 2461 | 2459 | continue 2; |
| 2462 | 2460 | } |
@@ -2468,7 +2466,7 @@ discard block |
||
| 2468 | 2466 | { |
| 2469 | 2467 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2470 | 2468 | '() event has additional categories:' |
| 2471 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
| 2469 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
| 2472 | 2470 | } |
| 2473 | 2471 | continue; |
| 2474 | 2472 | } |
@@ -2488,7 +2486,7 @@ discard block |
||
| 2488 | 2486 | if ($this->log) |
| 2489 | 2487 | { |
| 2490 | 2488 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2491 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
| 2489 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
| 2492 | 2490 | } |
| 2493 | 2491 | continue 2; |
| 2494 | 2492 | } |
@@ -2511,8 +2509,8 @@ discard block |
||
| 2511 | 2509 | if ($this->log) |
| 2512 | 2510 | { |
| 2513 | 2511 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2514 | - '() missing event[participants]: ' . |
|
| 2515 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
| 2512 | + '() missing event[participants]: '. |
|
| 2513 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
| 2516 | 2514 | } |
| 2517 | 2515 | continue; |
| 2518 | 2516 | } |
@@ -2524,7 +2522,7 @@ discard block |
||
| 2524 | 2522 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
| 2525 | 2523 | { |
| 2526 | 2524 | // We found a pseudo Exception |
| 2527 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
| 2525 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
| 2528 | 2526 | continue; |
| 2529 | 2527 | } |
| 2530 | 2528 | } |
@@ -2546,7 +2544,7 @@ discard block |
||
| 2546 | 2544 | if ($this->log) |
| 2547 | 2545 | { |
| 2548 | 2546 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2549 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
| 2547 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
| 2550 | 2548 | } |
| 2551 | 2549 | continue 2; |
| 2552 | 2550 | } |
@@ -2556,8 +2554,8 @@ discard block |
||
| 2556 | 2554 | if ($this->log) |
| 2557 | 2555 | { |
| 2558 | 2556 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2559 | - '() missing event[recur_exception]: ' . |
|
| 2560 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
| 2557 | + '() missing event[recur_exception]: '. |
|
| 2558 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
| 2561 | 2559 | } |
| 2562 | 2560 | continue; |
| 2563 | 2561 | } |
@@ -2572,8 +2570,8 @@ discard block |
||
| 2572 | 2570 | if ($this->log) |
| 2573 | 2571 | { |
| 2574 | 2572 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2575 | - "() events[$key] differ: " . $event[$key] . |
|
| 2576 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
| 2573 | + "() events[$key] differ: ".$event[$key]. |
|
| 2574 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
| 2577 | 2575 | } |
| 2578 | 2576 | continue 2; |
| 2579 | 2577 | } |
@@ -2589,7 +2587,7 @@ discard block |
||
| 2589 | 2587 | if ($this->log) |
| 2590 | 2588 | { |
| 2591 | 2589 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2592 | - "() new exception for series found.\n",3,$this->logfile); |
|
| 2590 | + "() new exception for series found.\n", 3, $this->logfile); |
|
| 2593 | 2591 | } |
| 2594 | 2592 | $matchingEvents = array(); |
| 2595 | 2593 | } |
@@ -2600,7 +2598,7 @@ discard block |
||
| 2600 | 2598 | if ($this->log) |
| 2601 | 2599 | { |
| 2602 | 2600 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2603 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
| 2601 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
| 2604 | 2602 | } |
| 2605 | 2603 | return $matches; |
| 2606 | 2604 | } |
@@ -2673,7 +2671,7 @@ discard block |
||
| 2673 | 2671 | if ($this->log) |
| 2674 | 2672 | { |
| 2675 | 2673 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2676 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
| 2674 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
| 2677 | 2675 | } |
| 2678 | 2676 | $type = 'SERIES-EXCEPTION'; |
| 2679 | 2677 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2694,7 +2692,7 @@ discard block |
||
| 2694 | 2692 | } |
| 2695 | 2693 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
| 2696 | 2694 | { |
| 2697 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2695 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2698 | 2696 | $recurrence_event = $master_event; |
| 2699 | 2697 | $recurrence_event['start'] = $event['start']; |
| 2700 | 2698 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2711,8 +2709,8 @@ discard block |
||
| 2711 | 2709 | if ($this->log) |
| 2712 | 2710 | { |
| 2713 | 2711 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2714 | - '() try occurrence ' . $egw_rrule->current() |
|
| 2715 | - . " ($occurrence)\n",3,$this->logfile); |
|
| 2712 | + '() try occurrence '.$egw_rrule->current() |
|
| 2713 | + . " ($occurrence)\n", 3, $this->logfile); |
|
| 2716 | 2714 | } |
| 2717 | 2715 | if ($event['start'] == $occurrence) |
| 2718 | 2716 | { |
@@ -2745,8 +2743,8 @@ discard block |
||
| 2745 | 2743 | // default if we cannot find a proof for a fundamental change |
| 2746 | 2744 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
| 2747 | 2745 | // check for changed data |
| 2748 | - foreach (array('start','end','uid','title','location','description', |
|
| 2749 | - 'priority','public','special','non_blocking') as $key) |
|
| 2746 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
| 2747 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
| 2750 | 2748 | { |
| 2751 | 2749 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
| 2752 | 2750 | { |
@@ -2804,10 +2802,10 @@ discard block |
||
| 2804 | 2802 | * @param &$event the event we are working on |
| 2805 | 2803 | * |
| 2806 | 2804 | */ |
| 2807 | - function server2usertime (&$event) |
|
| 2805 | + function server2usertime(&$event) |
|
| 2808 | 2806 | { |
| 2809 | 2807 | // we run all dates through date2usertime, to adjust to user-time |
| 2810 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
| 2808 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
| 2811 | 2809 | { |
| 2812 | 2810 | // we convert here from server-time to timestamps in user-time! |
| 2813 | 2811 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2815,7 +2813,7 @@ discard block |
||
| 2815 | 2813 | // same with the recur exceptions |
| 2816 | 2814 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 2817 | 2815 | { |
| 2818 | - foreach($event['recur_exception'] as $n => $date) |
|
| 2816 | + foreach ($event['recur_exception'] as $n => $date) |
|
| 2819 | 2817 | { |
| 2820 | 2818 | $event['recur_exception'][$n] = $this->date2usertime($date); |
| 2821 | 2819 | } |
@@ -2823,7 +2821,7 @@ discard block |
||
| 2823 | 2821 | // same with the alarms |
| 2824 | 2822 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 2825 | 2823 | { |
| 2826 | - foreach($event['alarm'] as $id => $alarm) |
|
| 2824 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 2827 | 2825 | { |
| 2828 | 2826 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2829 | 2827 | } |
@@ -2840,7 +2838,7 @@ discard block |
||
| 2840 | 2838 | { |
| 2841 | 2839 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
| 2842 | 2840 | { |
| 2843 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
| 2841 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
| 2844 | 2842 | } |
| 2845 | 2843 | } |
| 2846 | 2844 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Exports records as defined in $_definition |
| 29 | 29 | * |
| 30 | - * @param egw_record $_definition |
|
| 30 | + * @param importexport_definition $_definition |
|
| 31 | 31 | */ |
| 32 | 32 | public function export( $_stream, importexport_definition $_definition) { |
| 33 | 33 | $options = $_definition->plugin_options; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | protected function get_selects() |
| 368 | 368 | { |
| 369 | - $this->selects['priority'] = Array( |
|
| 369 | + $this->selects['priority'] = array( |
|
| 370 | 370 | 0 => lang('None'), |
| 371 | 371 | 1 => lang('Low'), |
| 372 | 372 | 2 => lang('Normal'), |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | /** |
| 395 | 395 | * Adjust automatically generated field filters |
| 396 | 396 | */ |
| 397 | - public function get_filter_fields(Array &$filters) |
|
| 397 | + public function get_filter_fields(array &$filters) |
|
| 398 | 398 | { |
| 399 | 399 | |
| 400 | 400 | // Calendar SO doesn't support filtering by column, so we have to remove pretty much everything |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param egw_record $_definition |
| 31 | 31 | */ |
| 32 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 32 | + public function export($_stream, importexport_definition $_definition) { |
|
| 33 | 33 | $options = $_definition->plugin_options; |
| 34 | 34 | |
| 35 | 35 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
| 36 | 36 | if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
| 37 | 37 | // Custom fields need to be specifically requested |
| 38 | 38 | $cfs = array(); |
| 39 | - foreach($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
| 40 | - if($key[0] == '#') $cfs[] = substr($key,1); |
|
| 39 | + foreach ($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
| 40 | + if ($key[0] == '#') $cfs[] = substr($key, 1); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $query = array( |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'num_rows' => -1, |
| 46 | 46 | 'csv_export' => true |
| 47 | 47 | ); |
| 48 | - switch($options['selection']) |
|
| 48 | + switch ($options['selection']) |
|
| 49 | 49 | { |
| 50 | 50 | case 'criteria': |
| 51 | 51 | $query = array( |
@@ -55,33 +55,33 @@ discard block |
||
| 55 | 55 | 'users' => $options['criteria']['owner'], |
| 56 | 56 | 'cfs' => $cfs // Otherwise we shouldn't get any custom fields |
| 57 | 57 | ); |
| 58 | - if($options['criteria']['start']) |
|
| 58 | + if ($options['criteria']['start']) |
|
| 59 | 59 | { |
| 60 | 60 | $query['start'] = $options['criteria']['start']; |
| 61 | 61 | } |
| 62 | - if($options['criteria']['end']) |
|
| 62 | + if ($options['criteria']['end']) |
|
| 63 | 63 | { |
| 64 | - $query['end'] = strtotime('+1 day',$options['criteria']['end'])-1; |
|
| 64 | + $query['end'] = strtotime('+1 day', $options['criteria']['end']) - 1; |
|
| 65 | 65 | } |
| 66 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 66 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 67 | 67 | $query['offset'] = 0; |
| 68 | 68 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
| 69 | 69 | } |
| 70 | - $events =& $this->bo->search($query); |
|
| 70 | + $events = & $this->bo->search($query); |
|
| 71 | 71 | break; |
| 72 | 72 | case 'search_results': |
| 73 | 73 | $states = $this->bo->cal_prefs['saved_states']; |
| 74 | 74 | $query = Api\Cache::getSession('calendar', 'calendar_list'); |
| 75 | - $query['num_rows'] = -1; // all |
|
| 76 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 75 | + $query['num_rows'] = -1; // all |
|
| 76 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 77 | 77 | $query['start'] = 0; |
| 78 | 78 | $query['cfs'] = $cfs; |
| 79 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
| 79 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
| 80 | 80 | { |
| 81 | 81 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
| 82 | 82 | } |
| 83 | 83 | $ui = new calendar_uilist(); |
| 84 | - if($states['view'] == 'listview') |
|
| 84 | + if ($states['view'] == 'listview') |
|
| 85 | 85 | { |
| 86 | 86 | $ui->get_rows($query, $events, $unused); |
| 87 | 87 | } |
@@ -98,35 +98,35 @@ discard block |
||
| 98 | 98 | $filter = $_definition->filter; |
| 99 | 99 | |
| 100 | 100 | // Handle ranges |
| 101 | - foreach($filter as $field => $value) |
|
| 101 | + foreach ($filter as $field => $value) |
|
| 102 | 102 | { |
| 103 | - if($field == 'filter' && $value) |
|
| 103 | + if ($field == 'filter' && $value) |
|
| 104 | 104 | { |
| 105 | 105 | $query['filter'] = $value; |
| 106 | 106 | continue; |
| 107 | 107 | } |
| 108 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 108 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 109 | 109 | { |
| 110 | 110 | $query['query']["cal_$field"] = $value; |
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 115 | - if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
| 116 | - if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
| 115 | + if ($value['from']) $query['sql_filter'][] = "cal_$field >= ".(int)$value['from']; |
|
| 116 | + if ($value['to']) $query['sql_filter'][] = "cal_$field <= ".(int)$value['to']; |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | - if($query['sql_filter'] && is_array($query['sql_filter'])) |
|
| 119 | + if ($query['sql_filter'] && is_array($query['sql_filter'])) |
|
| 120 | 120 | { |
| 121 | 121 | // Set as an extra parameter |
| 122 | - $sql_filter = implode(' AND ',$query['sql_filter']); |
|
| 122 | + $sql_filter = implode(' AND ', $query['sql_filter']); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | case 'all': |
| 126 | 126 | $events = $this->bo->search($query + array( |
| 127 | 127 | 'offset' => 0, |
| 128 | 128 | 'order' => 'cal_start', |
| 129 | - ),$sql_filter); |
|
| 129 | + ), $sql_filter); |
|
| 130 | 130 | break; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -145,30 +145,30 @@ discard block |
||
| 145 | 145 | // Get rid of yearly recurring events that don't belong |
| 146 | 146 | //if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue; |
| 147 | 147 | // Add in participants |
| 148 | - if($options['mapping']['participants']) |
|
| 148 | + if ($options['mapping']['participants']) |
|
| 149 | 149 | { |
| 150 | - $event['participants'] = implode(", ",$this->bo->participants($event,true)); |
|
| 150 | + $event['participants'] = implode(", ", $this->bo->participants($event, true)); |
|
| 151 | 151 | } |
| 152 | 152 | if (is_array($event)) |
| 153 | 153 | { |
| 154 | 154 | $record->set_record($event); |
| 155 | - if($options['mapping']['recurrence']) |
|
| 155 | + if ($options['mapping']['recurrence']) |
|
| 156 | 156 | { |
| 157 | 157 | $rrule = calendar_rrule::event2rrule($event); |
| 158 | 158 | $record->recurrence = $rrule->__toString(); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Standard stuff |
| 162 | - if($options['convert']) |
|
| 162 | + if ($options['convert']) |
|
| 163 | 163 | { |
| 164 | 164 | importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects); |
| 165 | 165 | } |
| 166 | 166 | else |
| 167 | 167 | { |
| 168 | 168 | // Implode arrays, so they don't say 'Array' |
| 169 | - foreach($record->get_record_array() as $key => $value) |
|
| 169 | + foreach ($record->get_record_array() as $key => $value) |
|
| 170 | 170 | { |
| 171 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 171 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | $export_object->export_record($record); |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $states = $this->bo->cal_prefs['saved_states']; |
| 231 | 231 | $list = Api\Cache::getSession('calendar', 'calendar_list'); |
| 232 | 232 | |
| 233 | - $start= new Api\DateTime($list['startdate']); |
|
| 233 | + $start = new Api\DateTime($list['startdate']); |
|
| 234 | 234 | $end = new Api\DateTime($list['enddate']); |
| 235 | 235 | |
| 236 | 236 | if ($states['view'] == 'listview') |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | // Use UI to get dates |
| 241 | 241 | $ui = new calendar_uilist(); |
| 242 | - $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 243 | - $ui->get_rows($list,$rows,$readonlys); |
|
| 242 | + $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 243 | + $ui->get_rows($list, $rows, $readonlys); |
|
| 244 | 244 | $start = $ui->first ? $ui->first : new Api\DateTime($ui->date); |
| 245 | 245 | $end = $ui->last; |
| 246 | 246 | |
| 247 | 247 | // Special handling |
| 248 | - if($list['filter'] == 'all') $start = $end = null; |
|
| 249 | - if($list['filter'] == 'before') |
|
| 248 | + if ($list['filter'] == 'all') $start = $end = null; |
|
| 249 | + if ($list['filter'] == 'before') |
|
| 250 | 250 | { |
| 251 | 251 | $end = $start; |
| 252 | 252 | $start = null; |
| 253 | 253 | } |
| 254 | 254 | $ui = null; |
| 255 | 255 | } |
| 256 | - else if(!$end) |
|
| 256 | + else if (!$end) |
|
| 257 | 257 | { |
| 258 | - $end = '+1 ' . $states['view']; |
|
| 259 | - $end = strtotime($end, $start->format('ts'))-1; |
|
| 258 | + $end = '+1 '.$states['view']; |
|
| 259 | + $end = strtotime($end, $start->format('ts')) - 1; |
|
| 260 | 260 | } |
| 261 | 261 | $prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]); |
| 262 | 262 | $data = array( |
@@ -322,17 +322,17 @@ discard block |
||
| 322 | 322 | ); |
| 323 | 323 | $filters = array_reverse($filters, true); |
| 324 | 324 | |
| 325 | - foreach($filters as $field_name => &$settings) |
|
| 325 | + foreach ($filters as $field_name => &$settings) |
|
| 326 | 326 | { |
| 327 | 327 | // Can't filter on a custom field |
| 328 | - if(strpos($field_name, '#') === 0) |
|
| 328 | + if (strpos($field_name, '#') === 0) |
|
| 329 | 329 | { |
| 330 | 330 | unset($filters[$field_name]); |
| 331 | 331 | continue; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Pass on select options |
| 335 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 335 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | } |
@@ -16,9 +16,11 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * export CSV plugin of calendar |
| 18 | 18 | */ |
| 19 | -class calendar_export_csv implements importexport_iface_export_plugin { |
|
| 19 | +class calendar_export_csv implements importexport_iface_export_plugin |
|
| 20 | +{ |
|
| 20 | 21 | |
| 21 | - public function __construct() { |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 22 | 24 | Api\Translation::add_app('calendar'); |
| 23 | 25 | $this->bo = new calendar_bo(); |
| 24 | 26 | $this->get_selects(); |
@@ -29,15 +31,23 @@ discard block |
||
| 29 | 31 | * |
| 30 | 32 | * @param egw_record $_definition |
| 31 | 33 | */ |
| 32 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 34 | + public function export( $_stream, importexport_definition $_definition) |
|
| 35 | + { |
|
| 33 | 36 | $options = $_definition->plugin_options; |
| 34 | 37 | |
| 35 | 38 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
| 36 | - if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
|
| 39 | + if (!$limit_exception) |
|
| 40 | + { |
|
| 41 | + $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
|
| 42 | + } |
|
| 37 | 43 | // Custom fields need to be specifically requested |
| 38 | 44 | $cfs = array(); |
| 39 | - foreach($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
| 40 | - if($key[0] == '#') $cfs[] = substr($key,1); |
|
| 45 | + foreach($options['mapping'] + (array)$_definition->filter as $key => $label) |
|
| 46 | + { |
|
| 47 | + if($key[0] == '#') |
|
| 48 | + { |
|
| 49 | + $cfs[] = substr($key,1); |
|
| 50 | + } |
|
| 41 | 51 | } |
| 42 | 52 | |
| 43 | 53 | $query = array( |
@@ -63,7 +73,8 @@ discard block |
||
| 63 | 73 | { |
| 64 | 74 | $query['end'] = strtotime('+1 day',$options['criteria']['end'])-1; |
| 65 | 75 | } |
| 66 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 76 | + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
| 77 | + { |
|
| 67 | 78 | $query['offset'] = 0; |
| 68 | 79 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
| 69 | 80 | } |
@@ -84,7 +95,7 @@ discard block |
||
| 84 | 95 | if($states['view'] == 'listview') |
| 85 | 96 | { |
| 86 | 97 | $ui->get_rows($query, $events, $unused); |
| 87 | - } |
|
| 98 | + } |
|
| 88 | 99 | else |
| 89 | 100 | { |
| 90 | 101 | $query['filter'] = 'custom'; |
@@ -112,8 +123,14 @@ discard block |
||
| 112 | 123 | } |
| 113 | 124 | |
| 114 | 125 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 115 | - if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
| 116 | - if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
| 126 | + if($value['from']) |
|
| 127 | + { |
|
| 128 | + $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
| 129 | + } |
|
| 130 | + if($value['to']) |
|
| 131 | + { |
|
| 132 | + $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
| 133 | + } |
|
| 117 | 134 | |
| 118 | 135 | } |
| 119 | 136 | if($query['sql_filter'] && is_array($query['sql_filter'])) |
@@ -168,7 +185,10 @@ discard block |
||
| 168 | 185 | // Implode arrays, so they don't say 'Array' |
| 169 | 186 | foreach($record->get_record_array() as $key => $value) |
| 170 | 187 | { |
| 171 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 188 | + if(is_array($value)) |
|
| 189 | + { |
|
| 190 | + $record->$key = implode(',', $value); |
|
| 191 | + } |
|
| 172 | 192 | } |
| 173 | 193 | } |
| 174 | 194 | $export_object->export_record($record); |
@@ -245,7 +265,10 @@ discard block |
||
| 245 | 265 | $end = $ui->last; |
| 246 | 266 | |
| 247 | 267 | // Special handling |
| 248 | - if($list['filter'] == 'all') $start = $end = null; |
|
| 268 | + if($list['filter'] == 'all') |
|
| 269 | + { |
|
| 270 | + $start = $end = null; |
|
| 271 | + } |
|
| 249 | 272 | if($list['filter'] == 'before') |
| 250 | 273 | { |
| 251 | 274 | $end = $start; |
@@ -332,7 +355,10 @@ discard block |
||
| 332 | 355 | } |
| 333 | 356 | |
| 334 | 357 | // Pass on select options |
| 335 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 358 | + if($this->selects[$field_name]) |
|
| 359 | + { |
|
| 360 | + $settings['values'] = $this->selects[$field_name]; |
|
| 361 | + } |
|
| 336 | 362 | } |
| 337 | 363 | |
| 338 | 364 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * default 0 => export whole series (or events, if not recurring) |
| 195 | 195 | * @param string $principalURL ='' Used for CalDAV exports |
| 196 | 196 | * @param string $charset ='UTF-8' encoding of the vcalendar, default UTF-8 |
| 197 | - * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY |
|
| 197 | + * @param integer $current_user =0 uid of current user to only export that one as participant for method=REPLY |
|
| 198 | 198 | * @return string|boolean string with iCal or false on error (e.g. no permission to read the event) |
| 199 | 199 | */ |
| 200 | 200 | function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0) |
@@ -1094,16 +1094,15 @@ discard block |
||
| 1094 | 1094 | * Import an iCal |
| 1095 | 1095 | * |
| 1096 | 1096 | * @param string|resource $_vcalData |
| 1097 | - * @param int $cal_id=-1 must be -1 for new entries! |
|
| 1098 | - * @param string $etag=null if an etag is given, it has to match the current etag or the import will fail |
|
| 1099 | - * @param boolean $merge=false merge data with existing entry |
|
| 1100 | - * @param int $recur_date=0 if set, import the recurrence at this timestamp, |
|
| 1097 | + * @param int $cal_id must be -1 for new entries! |
|
| 1098 | + * @param int $recur_date if set, import the recurrence at this timestamp, |
|
| 1101 | 1099 | * default 0 => import whole series (or events, if not recurring) |
| 1102 | 1100 | * @param string $principalURL='' Used for CalDAV imports |
| 1103 | - * @param int $user=null account_id of owner, default null |
|
| 1104 | 1101 | * @param string $charset The encoding charset for $text. Defaults to |
| 1105 | 1102 | * utf-8 for new format, iso-8859-1 for old format. |
| 1106 | - * @param string $caldav_name=null name from CalDAV client or null (to use default) |
|
| 1103 | + * @param string $caldav_name name from CalDAV client or null (to use default) |
|
| 1104 | + * @param integer $etag |
|
| 1105 | + * @param integer $user |
|
| 1107 | 1106 | * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden" |
| 1108 | 1107 | */ |
| 1109 | 1108 | function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false) |
@@ -3182,6 +3181,10 @@ discard block |
||
| 3182 | 3181 | return $event; |
| 3183 | 3182 | } |
| 3184 | 3183 | |
| 3184 | + /** |
|
| 3185 | + * @param integer $contentID |
|
| 3186 | + * @param string $charset |
|
| 3187 | + */ |
|
| 3185 | 3188 | function search($_vcalData, $contentID=null, $relax=false, $charset=null) |
| 3186 | 3189 | { |
| 3187 | 3190 | if (($events = $this->icaltoegw($_vcalData, $charset))) |
@@ -3221,6 +3224,7 @@ discard block |
||
| 3221 | 3224 | * @param string $method ='PUBLISH' or eg. 'REPLY' |
| 3222 | 3225 | * @param array $extra =null extra attributes to add |
| 3223 | 3226 | * X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy |
| 3227 | + * @return string|null |
|
| 3224 | 3228 | */ |
| 3225 | 3229 | function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
| 3226 | 3230 | { |
@@ -483,15 +483,15 @@ discard block |
||
| 483 | 483 | { |
| 484 | 484 | $user = $this->resource_info($this->user); |
| 485 | 485 | $attributes['ATTENDEE'][] = 'mailto:' . $user['email']; |
| 486 | - $parameters['ATTENDEE'][] = array( |
|
| 487 | - 'CN' => $user['name'], |
|
| 488 | - 'ROLE' => 'REQ-PARTICIPANT', |
|
| 486 | + $parameters['ATTENDEE'][] = array( |
|
| 487 | + 'CN' => $user['name'], |
|
| 488 | + 'ROLE' => 'REQ-PARTICIPANT', |
|
| 489 | 489 | 'PARTSTAT' => 'NEEDS-ACTION', |
| 490 | 490 | 'CUTYPE' => 'INDIVIDUAL', |
| 491 | 491 | 'RSVP' => 'TRUE', |
| 492 | 492 | 'X-EGROUPWARE-UID' => (string)$this->user, |
| 493 | - ); |
|
| 494 | - $event['participants'][$this->user] = true; |
|
| 493 | + ); |
|
| 494 | + $event['participants'][$this->user] = true; |
|
| 495 | 495 | } |
| 496 | 496 | break; |
| 497 | 497 | case 'r': |
@@ -543,24 +543,24 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | - case 'ORGANIZER': |
|
| 547 | - if (!$organizerURL) |
|
| 548 | - { |
|
| 549 | - $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
| 550 | - . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
| 551 | - $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
| 552 | - if ($version == '1.0') |
|
| 553 | - { |
|
| 554 | - $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
| 555 | - } |
|
| 556 | - else |
|
| 557 | - { |
|
| 558 | - $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
| 559 | - } |
|
| 560 | - $organizerUID = $event['owner']; |
|
| 561 | - if (!isset($event['participants'][$event['owner']])) |
|
| 562 | - { |
|
| 563 | - $options = array( |
|
| 546 | + case 'ORGANIZER': |
|
| 547 | + if (!$organizerURL) |
|
| 548 | + { |
|
| 549 | + $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
| 550 | + . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
| 551 | + $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
| 552 | + if ($version == '1.0') |
|
| 553 | + { |
|
| 554 | + $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
| 555 | + } |
|
| 556 | + else |
|
| 557 | + { |
|
| 558 | + $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
| 559 | + } |
|
| 560 | + $organizerUID = $event['owner']; |
|
| 561 | + if (!isset($event['participants'][$event['owner']])) |
|
| 562 | + { |
|
| 563 | + $options = array( |
|
| 564 | 564 | 'ROLE' => 'CHAIR', |
| 565 | 565 | 'PARTSTAT' => 'DELEGATED', |
| 566 | 566 | 'CUTYPE' => 'INDIVIDUAL', |
@@ -570,20 +570,20 @@ discard block |
||
| 570 | 570 | if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail; |
| 571 | 571 | if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner']; |
| 572 | 572 | $attributes['ATTENDEE'][] = $organizerURL; |
| 573 | - $parameters['ATTENDEE'][] = $options; |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - // do NOT use ORGANIZER for events without further participants or a different organizer |
|
| 577 | - if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
| 578 | - { |
|
| 579 | - $attributes['ORGANIZER'] = $organizerURL; |
|
| 580 | - $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
| 581 | - if (!empty($organizerUID)) |
|
| 582 | - { |
|
| 583 | - $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
| 584 | - } |
|
| 585 | - } |
|
| 586 | - break; |
|
| 573 | + $parameters['ATTENDEE'][] = $options; |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + // do NOT use ORGANIZER for events without further participants or a different organizer |
|
| 577 | + if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
| 578 | + { |
|
| 579 | + $attributes['ORGANIZER'] = $organizerURL; |
|
| 580 | + $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
| 581 | + if (!empty($organizerUID)) |
|
| 582 | + { |
|
| 583 | + $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | + break; |
|
| 587 | 587 | |
| 588 | 588 | case 'DTSTART': |
| 589 | 589 | if (empty($event['whole_day'])) |
@@ -992,12 +992,12 @@ discard block |
||
| 992 | 992 | foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) |
| 993 | 993 | { |
| 994 | 994 | $valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset); |
| 995 | - $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
| 996 | - $parameters[$key][$valueID] : $parameters[$key], |
|
| 997 | - Api\Translation::charset(),$charset); |
|
| 998 | - $valuesData = (array) Api\Translation::convert($values[$key], |
|
| 999 | - Api\Translation::charset(),$charset); |
|
| 1000 | - $content = $valueData . implode(';', $valuesData); |
|
| 995 | + $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
| 996 | + $parameters[$key][$valueID] : $parameters[$key], |
|
| 997 | + Api\Translation::charset(),$charset); |
|
| 998 | + $valuesData = (array) Api\Translation::convert($values[$key], |
|
| 999 | + Api\Translation::charset(),$charset); |
|
| 1000 | + $content = $valueData . implode(';', $valuesData); |
|
| 1001 | 1001 | |
| 1002 | 1002 | if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) || |
| 1003 | 1003 | ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))) |
@@ -2233,7 +2233,7 @@ discard block |
||
| 2233 | 2233 | * @param string|resource $_vcalData |
| 2234 | 2234 | * @param string $principalURL ='' Used for CalDAV imports |
| 2235 | 2235 | * @param string $charset The encoding charset for $text. Defaults to |
| 2236 | - * utf-8 for new format, iso-8859-1 for old format. |
|
| 2236 | + * utf-8 for new format, iso-8859-1 for old format. |
|
| 2237 | 2237 | * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure |
| 2238 | 2238 | */ |
| 2239 | 2239 | function icaltoegw($_vcalData, $principalURL='', $charset=null) |
@@ -2784,10 +2784,10 @@ discard block |
||
| 2784 | 2784 | // fall throught |
| 2785 | 2785 | case 'ATTENDEE': |
| 2786 | 2786 | if (isset($attributes['params']['PARTSTAT'])) |
| 2787 | - { |
|
| 2788 | - $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
| 2789 | - } |
|
| 2790 | - if (isset($attributes['params']['STATUS'])) |
|
| 2787 | + { |
|
| 2788 | + $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
| 2789 | + } |
|
| 2790 | + if (isset($attributes['params']['STATUS'])) |
|
| 2791 | 2791 | { |
| 2792 | 2792 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
| 2793 | 2793 | if (empty($status)) $status = 'X'; |
@@ -3178,7 +3178,7 @@ discard block |
||
| 3178 | 3178 | array2string($event)."\n",3,$this->logfile); |
| 3179 | 3179 | } |
| 3180 | 3180 | //Horde::logMessage("vevent2egw:\n" . print_r($event, true), |
| 3181 | - // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
| 3181 | + // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
| 3182 | 3182 | return $event; |
| 3183 | 3183 | } |
| 3184 | 3184 | |
@@ -64,39 +64,39 @@ discard block |
||
| 64 | 64 | * @var array $priority_egw2ical conversion of the priority egw => ical |
| 65 | 65 | */ |
| 66 | 66 | var $priority_egw2ical = array( |
| 67 | - 0 => 0, // undefined |
|
| 68 | - 1 => 9, // low |
|
| 69 | - 2 => 5, // normal |
|
| 70 | - 3 => 1, // high |
|
| 67 | + 0 => 0, // undefined |
|
| 68 | + 1 => 9, // low |
|
| 69 | + 2 => 5, // normal |
|
| 70 | + 3 => 1, // high |
|
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * @var array $priority_ical2egw conversion of the priority ical => egw |
| 75 | 75 | */ |
| 76 | 76 | var $priority_ical2egw = array( |
| 77 | - 0 => 0, // undefined |
|
| 78 | - 9 => 1, 8 => 1, 7 => 1, 6 => 1, // low |
|
| 79 | - 5 => 2, // normal |
|
| 80 | - 4 => 3, 3 => 3, 2 => 3, 1 => 3, // high |
|
| 77 | + 0 => 0, // undefined |
|
| 78 | + 9 => 1, 8 => 1, 7 => 1, 6 => 1, // low |
|
| 79 | + 5 => 2, // normal |
|
| 80 | + 4 => 3, 3 => 3, 2 => 3, 1 => 3, // high |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @var array $priority_egw2funambol conversion of the priority egw => funambol |
| 85 | 85 | */ |
| 86 | 86 | var $priority_egw2funambol = array( |
| 87 | - 0 => 1, // undefined (mapped to normal since undefined does not exist) |
|
| 88 | - 1 => 0, // low |
|
| 89 | - 2 => 1, // normal |
|
| 90 | - 3 => 2, // high |
|
| 87 | + 0 => 1, // undefined (mapped to normal since undefined does not exist) |
|
| 88 | + 1 => 0, // low |
|
| 89 | + 2 => 1, // normal |
|
| 90 | + 3 => 2, // high |
|
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @var array $priority_funambol2egw conversion of the priority funambol => egw |
| 95 | 95 | */ |
| 96 | 96 | var $priority_funambol2egw = array( |
| 97 | - 0 => 1, // low |
|
| 98 | - 1 => 2, // normal |
|
| 99 | - 2 => 3, // high |
|
| 97 | + 0 => 1, // low |
|
| 98 | + 1 => 2, // normal |
|
| 99 | + 2 => 3, // high |
|
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @var boolean |
| 167 | 167 | */ |
| 168 | 168 | var $log = false; |
| 169 | - var $logfile="/tmp/log-vcal"; |
|
| 169 | + var $logfile = "/tmp/log-vcal"; |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Conflict callback |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY |
| 204 | 204 | * @return string|boolean string with iCal or false on error (e.g. no permission to read the event) |
| 205 | 205 | */ |
| 206 | - function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0) |
|
| 206 | + function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0) |
|
| 207 | 207 | { |
| 208 | 208 | if ($this->log) |
| 209 | 209 | { |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
| 236 | 236 | |
| 237 | - if ($this->productManufacturer == '' ) |
|
| 237 | + if ($this->productManufacturer == '') |
|
| 238 | 238 | { // syncevolution is broken |
| 239 | 239 | $version = '2.0'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $vcal = new Horde_Icalendar; |
| 243 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 243 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 244 | 244 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 245 | 245 | $vcal->setAttribute('VERSION', $version); |
| 246 | 246 | if ($method) $vcal->setAttribute('METHOD', $method); |
@@ -270,15 +270,15 @@ discard block |
||
| 270 | 270 | if ($this->log) |
| 271 | 271 | { |
| 272 | 272 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 273 | - '() User does not have the permission to read event ' . $event['id']. "\n", |
|
| 274 | - 3,$this->logfile); |
|
| 273 | + '() User does not have the permission to read event '.$event['id']."\n", |
|
| 274 | + 3, $this->logfile); |
|
| 275 | 275 | } |
| 276 | 276 | return -1; // Permission denied |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | else |
| 280 | 280 | { |
| 281 | - $retval = false; // Entry does not exist |
|
| 281 | + $retval = false; // Entry does not exist |
|
| 282 | 282 | if ($this->log) |
| 283 | 283 | { |
| 284 | 284 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | if ($this->log) |
| 293 | 293 | { |
| 294 | 294 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 295 | - '() export event UID: ' . $event['uid'] . ".\n", |
|
| 295 | + '() export event UID: '.$event['uid'].".\n", |
|
| 296 | 296 | 3, $this->logfile); |
| 297 | 297 | } |
| 298 | 298 | |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | if ($this->log) |
| 318 | 318 | { |
| 319 | 319 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 320 | - '(' . $event['id']. ',' . $recurrence . ")\n" . |
|
| 321 | - array2string($event)."\n",3,$this->logfile); |
|
| 320 | + '('.$event['id'].','.$recurrence.")\n". |
|
| 321 | + array2string($event)."\n", 3, $this->logfile); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if ($recurrence) |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | { |
| 340 | 340 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 341 | 341 | "(, $recurrence) Gratuitous pseudo exception, skipped ...\n", |
| 342 | - 3,$this->logfile); |
|
| 342 | + 3, $this->logfile); |
|
| 343 | 343 | } |
| 344 | 344 | continue; // unsupported status only exception |
| 345 | 345 | } |
@@ -349,13 +349,13 @@ discard block |
||
| 349 | 349 | $days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule'); |
| 350 | 350 | if ($this->log) |
| 351 | 351 | { |
| 352 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
| 353 | - array2string($days)."\n",3,$this->logfile); |
|
| 352 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
| 353 | + array2string($days)."\n", 3, $this->logfile); |
|
| 354 | 354 | } |
| 355 | 355 | $recurrence = $days[$recurrence]; // use remote representation |
| 356 | 356 | } |
| 357 | 357 | // force single event |
| 358 | - foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name) |
|
| 358 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name) |
|
| 359 | 359 | { |
| 360 | 360 | unset($event[$name]); |
| 361 | 361 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // check if tzid of event (not only recuring ones) is already added to export |
| 366 | - if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added)) |
|
| 366 | + if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added)) |
|
| 367 | 367 | { |
| 368 | 368 | // check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz) |
| 369 | 369 | if (calendar_timezones::add_vtimezone($vcal, $tzid) || |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | { |
| 382 | 382 | // Append UID to DESCRIPTION |
| 383 | 383 | if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
| 384 | - $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
|
| 384 | + $event['description'] .= "\n[UID:".$event['uid']."]"; |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -402,14 +402,14 @@ discard block |
||
| 402 | 402 | $exceptions = array(); |
| 403 | 403 | |
| 404 | 404 | // dont use "virtual" exceptions created by participant status for GroupDAV or file export |
| 405 | - if (!in_array($this->productManufacturer,array('file','groupdav'))) |
|
| 405 | + if (!in_array($this->productManufacturer, array('file', 'groupdav'))) |
|
| 406 | 406 | { |
| 407 | 407 | $filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule'; |
| 408 | 408 | $exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter); |
| 409 | 409 | if ($this->log) |
| 410 | 410 | { |
| 411 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" . |
|
| 412 | - array2string($exceptions)."\n",3,$this->logfile); |
|
| 411 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n". |
|
| 412 | + array2string($exceptions)."\n", 3, $this->logfile); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | elseif (is_array($event['recur_exception'])) |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | if ($this->log) |
| 427 | 427 | { |
| 428 | 428 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 429 | - '(' . $event['id'] . ") [$icalFieldName] not supported\n", |
|
| 430 | - 3,$this->logfile); |
|
| 429 | + '('.$event['id'].") [$icalFieldName] not supported\n", |
|
| 430 | + 3, $this->logfile); |
|
| 431 | 431 | } |
| 432 | 432 | continue; |
| 433 | 433 | } |
@@ -444,23 +444,23 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | if (!($info = $this->resource_info($uid))) continue; |
| 446 | 446 | |
| 447 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
| 447 | + if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants |
|
| 448 | 448 | |
| 449 | 449 | if ($this->log) |
| 450 | 450 | { |
| 451 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 452 | - '()attendee:' . array2string($info) ."\n",3,$this->logfile); |
|
| 451 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 452 | + '()attendee:'.array2string($info)."\n", 3, $this->logfile); |
|
| 453 | 453 | } |
| 454 | 454 | $participantCN = str_replace(array('\\', ',', ';', ':'), |
| 455 | 455 | array('\\\\', '\\,', '\\;', '\\:'), |
| 456 | 456 | trim(empty($info['cn']) ? $info['name'] : $info['cn'])); |
| 457 | 457 | if ($version == '1.0') |
| 458 | 458 | { |
| 459 | - $participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>')); |
|
| 459 | + $participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>')); |
|
| 460 | 460 | } |
| 461 | 461 | else |
| 462 | 462 | { |
| 463 | - $participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email']; |
|
| 463 | + $participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email']; |
|
| 464 | 464 | } |
| 465 | 465 | // RSVP={TRUE|FALSE} // resonse expected, not set in eGW => status=U |
| 466 | 466 | $rsvp = $status == 'U' ? 'TRUE' : 'FALSE'; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | ($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members)) |
| 489 | 489 | { |
| 490 | 490 | $user = $this->resource_info($this->user); |
| 491 | - $attributes['ATTENDEE'][] = 'mailto:' . $user['email']; |
|
| 491 | + $attributes['ATTENDEE'][] = 'mailto:'.$user['email']; |
|
| 492 | 492 | $parameters['ATTENDEE'][] = array( |
| 493 | 493 | 'CN' => $user['name'], |
| 494 | 494 | 'ROLE' => 'REQ-PARTICIPANT', |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
| 531 | 531 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
| 532 | 532 | { |
| 533 | - $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
|
| 533 | + $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
|
| 534 | 534 | } |
| 535 | 535 | if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
| 536 | 536 | if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | break; |
| 541 | 541 | |
| 542 | 542 | case 'CLASS': |
| 543 | - if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
| 543 | + if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
| 544 | 544 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
| 545 | 545 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
| 546 | 546 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -552,16 +552,16 @@ discard block |
||
| 552 | 552 | case 'ORGANIZER': |
| 553 | 553 | if (!$organizerURL) |
| 554 | 554 | { |
| 555 | - $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
| 556 | - . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
| 557 | - $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
| 555 | + $organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname') |
|
| 556 | + . ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"'; |
|
| 557 | + $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email'); |
|
| 558 | 558 | if ($version == '1.0') |
| 559 | 559 | { |
| 560 | - $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
| 560 | + $organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>')); |
|
| 561 | 561 | } |
| 562 | 562 | else |
| 563 | 563 | { |
| 564 | - $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
| 564 | + $organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail; |
|
| 565 | 565 | } |
| 566 | 566 | $organizerUID = $event['owner']; |
| 567 | 567 | if (!isset($event['participants'][$event['owner']])) |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | case 'DTSTART': |
| 595 | 595 | if (empty($event['whole_day'])) |
| 596 | 596 | { |
| 597 | - $attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']); |
|
| 597 | + $attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']); |
|
| 598 | 598 | } |
| 599 | 599 | break; |
| 600 | 600 | |
@@ -605,27 +605,27 @@ discard block |
||
| 605 | 605 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
| 606 | 606 | $attributes['duration'] = $event['end'] - $event['start']; |
| 607 | 607 | else |
| 608 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 608 | + $attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']); |
|
| 609 | 609 | } |
| 610 | 610 | else |
| 611 | 611 | { |
| 612 | 612 | // write start + end of whole day events as dates |
| 613 | - $event['end-nextday'] = $event['end'] + 12*3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 |
|
| 614 | - foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t) |
|
| 613 | + $event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 |
|
| 614 | + foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t) |
|
| 615 | 615 | { |
| 616 | - $time = new Api\DateTime($event[$f],Api\DateTime::$server_timezone); |
|
| 617 | - $arr = Api\DateTime::to($time,'array'); |
|
| 618 | - $vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']), |
|
| 616 | + $time = new Api\DateTime($event[$f], Api\DateTime::$server_timezone); |
|
| 617 | + $arr = Api\DateTime::to($time, 'array'); |
|
| 618 | + $vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']), |
|
| 619 | 619 | array('VALUE' => 'DATE')); |
| 620 | 620 | } |
| 621 | 621 | unset($attributes['DTSTART']); |
| 622 | 622 | // Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event |
| 623 | - $vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE'); |
|
| 623 | + $vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE'); |
|
| 624 | 624 | } |
| 625 | 625 | break; |
| 626 | 626 | |
| 627 | 627 | case 'RRULE': |
| 628 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
| 628 | + if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
| 629 | 629 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
| 630 | 630 | $rrule = $rriter->generate_rrule($version); |
| 631 | 631 | if ($event['recur_enddate']) |
@@ -652,16 +652,16 @@ discard block |
||
| 652 | 652 | { |
| 653 | 653 | if ($event['recur_enddate'] && $tzid) |
| 654 | 654 | { |
| 655 | - $rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid); |
|
| 655 | + $rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid); |
|
| 656 | 656 | } |
| 657 | 657 | $attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL']; |
| 658 | 658 | } |
| 659 | 659 | else // $version == '2.0' |
| 660 | 660 | { |
| 661 | 661 | $attributes['RRULE'] = ''; |
| 662 | - foreach($rrule as $n => $v) |
|
| 662 | + foreach ($rrule as $n => $v) |
|
| 663 | 663 | { |
| 664 | - $attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v; |
|
| 664 | + $attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v; |
|
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | break; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | { |
| 677 | 677 | // current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here |
| 678 | 678 | // Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID |
| 679 | - $event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']); |
|
| 679 | + $event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']); |
|
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | 682 | else |
@@ -684,9 +684,9 @@ discard block |
||
| 684 | 684 | // use 'DATE' instead of 'DATE-TIME' on whole day events |
| 685 | 685 | foreach ($event['recur_exception'] as $id => $timestamp) |
| 686 | 686 | { |
| 687 | - $time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone); |
|
| 687 | + $time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone); |
|
| 688 | 688 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
| 689 | - $arr = Api\DateTime::to($time,'array'); |
|
| 689 | + $arr = Api\DateTime::to($time, 'array'); |
|
| 690 | 690 | $days[$id] = array( |
| 691 | 691 | 'year' => $arr['year'], |
| 692 | 692 | 'month' => $arr['month'], |
@@ -701,21 +701,21 @@ discard block |
||
| 701 | 701 | break; |
| 702 | 702 | |
| 703 | 703 | case 'PRIORITY': |
| 704 | - if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 704 | + if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 705 | 705 | if ($this->productManufacturer == 'funambol' && |
| 706 | 706 | (strpos($this->productName, 'outlook') !== false |
| 707 | 707 | || strpos($this->productName, 'pocket pc') !== false)) |
| 708 | 708 | { |
| 709 | - $attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']]; |
|
| 709 | + $attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']]; |
|
| 710 | 710 | } |
| 711 | 711 | else |
| 712 | 712 | { |
| 713 | - $attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']]; |
|
| 713 | + $attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']]; |
|
| 714 | 714 | } |
| 715 | 715 | break; |
| 716 | 716 | |
| 717 | 717 | case 'TRANSP': |
| 718 | - if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 718 | + if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 719 | 719 | if ($version == '1.0') |
| 720 | 720 | { |
| 721 | 721 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -754,13 +754,13 @@ discard block |
||
| 754 | 754 | // We handle a pseudo exception |
| 755 | 755 | if (empty($event['whole_day'])) |
| 756 | 756 | { |
| 757 | - $attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]); |
|
| 757 | + $attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]); |
|
| 758 | 758 | } |
| 759 | 759 | else |
| 760 | 760 | { |
| 761 | - $time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone); |
|
| 761 | + $time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone); |
|
| 762 | 762 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
| 763 | - $arr = Api\DateTime::to($time,'array'); |
|
| 763 | + $arr = Api\DateTime::to($time, 'array'); |
|
| 764 | 764 | $vevent->setAttribute($icalFieldName, array( |
| 765 | 765 | 'year' => $arr['year'], |
| 766 | 766 | 'month' => $arr['month'], |
@@ -772,17 +772,17 @@ discard block |
||
| 772 | 772 | elseif ($event['recurrence'] && $event['reference']) |
| 773 | 773 | { |
| 774 | 774 | // $event['reference'] is a calendar_id, not a timestamp |
| 775 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
| 775 | + if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
| 776 | 776 | |
| 777 | 777 | if (empty($revent['whole_day'])) |
| 778 | 778 | { |
| 779 | - $attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]); |
|
| 779 | + $attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]); |
|
| 780 | 780 | } |
| 781 | 781 | else |
| 782 | 782 | { |
| 783 | - $time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone); |
|
| 783 | + $time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone); |
|
| 784 | 784 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
| 785 | - $arr = Api\DateTime::to($time,'array'); |
|
| 785 | + $arr = Api\DateTime::to($time, 'array'); |
|
| 786 | 786 | $vevent->setAttribute($icalFieldName, array( |
| 787 | 787 | 'year' => $arr['year'], |
| 788 | 788 | 'month' => $arr['month'], |
@@ -806,9 +806,9 @@ discard block |
||
| 806 | 806 | $noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate']; |
| 807 | 807 | if ($this->log && $size > 0) |
| 808 | 808 | { |
| 809 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 810 | - "() $icalFieldName Size: $size, NoTruncate: " . |
|
| 811 | - ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); |
|
| 809 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 810 | + "() $icalFieldName Size: $size, NoTruncate: ". |
|
| 811 | + ($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile); |
|
| 812 | 812 | } |
| 813 | 813 | //Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " . |
| 814 | 814 | // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -826,8 +826,8 @@ discard block |
||
| 826 | 826 | { |
| 827 | 827 | if ($this->log) |
| 828 | 828 | { |
| 829 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 830 | - "() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile); |
|
| 829 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 830 | + "() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile); |
|
| 831 | 831 | } |
| 832 | 832 | //Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size", |
| 833 | 833 | // __FILE__, __LINE__, PEAR_LOG_WARNING); |
@@ -837,8 +837,8 @@ discard block |
||
| 837 | 837 | $value = substr($value, 0, $size - 1); |
| 838 | 838 | if ($this->log) |
| 839 | 839 | { |
| 840 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 841 | - "() $icalFieldName truncated to maximum size $size\n",3,$this->logfile); |
|
| 840 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 841 | + "() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile); |
|
| 842 | 842 | } |
| 843 | 843 | //Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size", |
| 844 | 844 | // __FILE__, __LINE__, PEAR_LOG_INFO); |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | // for CalDAV add all X-Properties previously parsed |
| 854 | 854 | if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file') |
| 855 | 855 | { |
| 856 | - foreach($event as $name => $value) |
|
| 856 | + foreach ($event as $name => $value) |
|
| 857 | 857 | { |
| 858 | 858 | if (substr($name, 0, 2) == '##') |
| 859 | 859 | { |
@@ -925,8 +925,8 @@ discard block |
||
| 925 | 925 | $values['AALARM']['repeat count'] = ''; |
| 926 | 926 | $values['AALARM']['display text'] = $description; |
| 927 | 927 | } |
| 928 | - $attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']); |
|
| 929 | - $attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']); |
|
| 928 | + $attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']); |
|
| 929 | + $attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']); |
|
| 930 | 930 | // lets take only the first alarm |
| 931 | 931 | break; |
| 932 | 932 | } |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | $alarmData['offset'] = false; |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - $valarm = Horde_Icalendar::newComponent('VALARM',$vevent); |
|
| 966 | + $valarm = Horde_Icalendar::newComponent('VALARM', $vevent); |
|
| 967 | 967 | if ($alarmData['offset'] !== false) |
| 968 | 968 | { |
| 969 | 969 | $valarm->setAttribute('TRIGGER', -$alarmData['offset'], |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | else |
| 973 | 973 | { |
| 974 | 974 | $params = array('VALUE' => 'DATE-TIME'); |
| 975 | - $value = self::getDateTime($alarmData['time'],$tzid,$params); |
|
| 975 | + $value = self::getDateTime($alarmData['time'], $tzid, $params); |
|
| 976 | 976 | $valarm->setAttribute('TRIGGER', $value, $params); |
| 977 | 977 | } |
| 978 | 978 | if (!empty($alarmData['uid'])) |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | // set evtl. existing attributes set by iCal clients not used by EGroupware |
| 984 | 984 | if (isset($alarmData['attrs'])) |
| 985 | 985 | { |
| 986 | - foreach($alarmData['attrs'] as $attr => $data) |
|
| 986 | + foreach ($alarmData['attrs'] as $attr => $data) |
|
| 987 | 987 | { |
| 988 | 988 | $valarm->setAttribute($attr, $data['value'], $data['params']); |
| 989 | 989 | } |
@@ -991,11 +991,11 @@ discard block |
||
| 991 | 991 | // set default ACTION and DESCRIPTION, if not set by a client |
| 992 | 992 | if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION'])) |
| 993 | 993 | { |
| 994 | - $valarm->setAttribute('ACTION','DISPLAY'); |
|
| 994 | + $valarm->setAttribute('ACTION', 'DISPLAY'); |
|
| 995 | 995 | } |
| 996 | 996 | if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION'])) |
| 997 | 997 | { |
| 998 | - $valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description); |
|
| 998 | + $valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description); |
|
| 999 | 999 | } |
| 1000 | 1000 | $vevent->addComponent($valarm); |
| 1001 | 1001 | } |
@@ -1003,15 +1003,15 @@ discard block |
||
| 1003 | 1003 | |
| 1004 | 1004 | foreach ($attributes as $key => $value) |
| 1005 | 1005 | { |
| 1006 | - foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) |
|
| 1006 | + foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData) |
|
| 1007 | 1007 | { |
| 1008 | - $valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset); |
|
| 1009 | - $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
| 1008 | + $valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset); |
|
| 1009 | + $paramData = (array)Api\Translation::convert(is_array($value) ? |
|
| 1010 | 1010 | $parameters[$key][$valueID] : $parameters[$key], |
| 1011 | - Api\Translation::charset(),$charset); |
|
| 1012 | - $valuesData = (array) Api\Translation::convert($values[$key], |
|
| 1013 | - Api\Translation::charset(),$charset); |
|
| 1014 | - $content = $valueData . implode(';', $valuesData); |
|
| 1011 | + Api\Translation::charset(), $charset); |
|
| 1012 | + $valuesData = (array)Api\Translation::convert($values[$key], |
|
| 1013 | + Api\Translation::charset(), $charset); |
|
| 1014 | + $content = $valueData.implode(';', $valuesData); |
|
| 1015 | 1015 | |
| 1016 | 1016 | if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) || |
| 1017 | 1017 | ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))) |
@@ -1061,10 +1061,10 @@ discard block |
||
| 1061 | 1061 | $retval = $events_exported ? $vcal->exportvCalendar() : false; |
| 1062 | 1062 | if ($this->log) |
| 1063 | 1063 | { |
| 1064 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 1065 | - "() '$this->productManufacturer','$this->productName'\n",3,$this->logfile); |
|
| 1066 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 1067 | - "()\n".array2string($retval)."\n",3,$this->logfile); |
|
| 1064 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 1065 | + "() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile); |
|
| 1066 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 1067 | + "()\n".array2string($retval)."\n", 3, $this->logfile); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | return $retval; |
| 1070 | 1070 | } |
@@ -1077,15 +1077,15 @@ discard block |
||
| 1077 | 1077 | * @param array &$params=null parameter array to set TZID |
| 1078 | 1078 | * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid |
| 1079 | 1079 | */ |
| 1080 | - static function getDateTime($time,$tzid,array &$params=null) |
|
| 1080 | + static function getDateTime($time, $tzid, array &$params = null) |
|
| 1081 | 1081 | { |
| 1082 | 1082 | if (empty($tzid) || $tzid == 'UTC') |
| 1083 | 1083 | { |
| 1084 | - return Api\DateTime::to($time,'ts'); |
|
| 1084 | + return Api\DateTime::to($time, 'ts'); |
|
| 1085 | 1085 | } |
| 1086 | - if (!is_a($time,'DateTime')) |
|
| 1086 | + if (!is_a($time, 'DateTime')) |
|
| 1087 | 1087 | { |
| 1088 | - $time = new Api\DateTime($time,Api\DateTime::$server_timezone); |
|
| 1088 | + $time = new Api\DateTime($time, Api\DateTime::$server_timezone); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | if (!isset(self::$tz_cache[$tzid])) |
| 1091 | 1091 | { |
@@ -1120,11 +1120,11 @@ discard block |
||
| 1120 | 1120 | * @param string $caldav_name=null name from CalDAV client or null (to use default) |
| 1121 | 1121 | * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden" |
| 1122 | 1122 | */ |
| 1123 | - function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false) |
|
| 1123 | + function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false) |
|
| 1124 | 1124 | { |
| 1125 | 1125 | //error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)"); |
| 1126 | 1126 | $this->events_imported = 0; |
| 1127 | - $replace = $delete_exceptions= false; |
|
| 1127 | + $replace = $delete_exceptions = false; |
|
| 1128 | 1128 | |
| 1129 | 1129 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
| 1130 | 1130 | |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | { |
| 1133 | 1133 | return false; |
| 1134 | 1134 | } |
| 1135 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1135 | + if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1136 | 1136 | |
| 1137 | 1137 | if ($cal_id > 0) |
| 1138 | 1138 | { |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | { |
| 1141 | 1141 | $replace = $recur_date == 0; |
| 1142 | 1142 | $events[0]['id'] = $cal_id; |
| 1143 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
| 1143 | + if (!is_null($etag)) $events[0]['etag'] = (int)$etag; |
|
| 1144 | 1144 | if ($recur_date) $events[0]['recurrence'] = $recur_date; |
| 1145 | 1145 | } |
| 1146 | 1146 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | { |
| 1193 | 1193 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 1194 | 1194 | ."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n" |
| 1195 | - . array2string($event)."\n",3,$this->logfile); |
|
| 1195 | + . array2string($event)."\n", 3, $this->logfile); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | $updated_id = false; |
@@ -1215,14 +1215,14 @@ discard block |
||
| 1215 | 1215 | { |
| 1216 | 1216 | if ($delete_exceptions) |
| 1217 | 1217 | { |
| 1218 | - $this->delete($id,0,false,$skip_notification); |
|
| 1218 | + $this->delete($id, 0, false, $skip_notification); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | else |
| 1221 | 1221 | { |
| 1222 | 1222 | if (!($exception = $this->read($id))) continue; |
| 1223 | 1223 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1224 | 1224 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1225 | - $this->update($exception, true,true,false,true,$msg,$skip_notification); |
|
| 1225 | + $this->update($exception, true, true, false, true, $msg, $skip_notification); |
|
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | } |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | { |
| 1240 | 1240 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 1241 | 1241 | . "(UPDATE Event)\n" |
| 1242 | - . array2string($event_info['stored_event'])."\n",3,$this->logfile); |
|
| 1242 | + . array2string($event_info['stored_event'])."\n", 3, $this->logfile); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | if (empty($event['uid'])) |
| 1245 | 1245 | { |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | if ($this->log) |
| 1262 | 1262 | { |
| 1263 | 1263 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1264 | - "() Restore status for $uid\n",3,$this->logfile); |
|
| 1264 | + "() Restore status for $uid\n", 3, $this->logfile); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | $event['participants'][$uid] = $event_info['stored_event']['participants'][$uid]; |
| 1267 | 1267 | } |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | if ($this->log) |
| 1286 | 1286 | { |
| 1287 | 1287 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1288 | - "()[MERGE]\n",3,$this->logfile); |
|
| 1288 | + "()[MERGE]\n", 3, $this->logfile); |
|
| 1289 | 1289 | } |
| 1290 | 1290 | // overwrite with server data for merge |
| 1291 | 1291 | foreach ($event_info['stored_event'] as $key => $value) |
@@ -1315,7 +1315,7 @@ discard block |
||
| 1315 | 1315 | else |
| 1316 | 1316 | { |
| 1317 | 1317 | // no merge |
| 1318 | - if(!isset($this->supportedFields['category']) || !isset($event['category'])) |
|
| 1318 | + if (!isset($this->supportedFields['category']) || !isset($event['category'])) |
|
| 1319 | 1319 | { |
| 1320 | 1320 | $event['category'] = $event_info['stored_event']['category']; |
| 1321 | 1321 | } |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | if ($this->log) |
| 1328 | 1328 | { |
| 1329 | 1329 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1330 | - "() No participants\n",3,$this->logfile); |
|
| 1330 | + "() No participants\n", 3, $this->logfile); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | // If this is an updated meeting, and the client doesn't support |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | if ($this->log) |
| 1347 | 1347 | { |
| 1348 | 1348 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1349 | - "() Restore resource $uid to status $status\n",3,$this->logfile); |
|
| 1349 | + "() Restore resource $uid to status $status\n", 3, $this->logfile); |
|
| 1350 | 1350 | } |
| 1351 | 1351 | // Add it back in |
| 1352 | 1352 | $event['participants'][$uid] = $status; |
@@ -1434,8 +1434,7 @@ discard block |
||
| 1434 | 1434 | } |
| 1435 | 1435 | // for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U') |
| 1436 | 1436 | $event['participants'][$user] = calendar_so::combine_status( |
| 1437 | - $user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : |
|
| 1438 | - ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1))); |
|
| 1437 | + $user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1))); |
|
| 1439 | 1438 | } |
| 1440 | 1439 | } |
| 1441 | 1440 | // check if an owner is set and the current user has add rights |
@@ -1500,9 +1499,9 @@ discard block |
||
| 1500 | 1499 | |
| 1501 | 1500 | if ($this->log) |
| 1502 | 1501 | { |
| 1503 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '(' |
|
| 1504 | - . $event_info['type'] . ")\n" |
|
| 1505 | - . array2string($event)."\n",3,$this->logfile); |
|
| 1502 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'(' |
|
| 1503 | + . $event_info['type'].")\n" |
|
| 1504 | + . array2string($event)."\n", 3, $this->logfile); |
|
| 1506 | 1505 | } |
| 1507 | 1506 | |
| 1508 | 1507 | // Android (any maybe others) delete recurrences by setting STATUS: CANCELLED |
@@ -1510,10 +1509,10 @@ discard block |
||
| 1510 | 1509 | if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) && |
| 1511 | 1510 | $event['status'] == 'CANCELLED') |
| 1512 | 1511 | { |
| 1513 | - if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification)) |
|
| 1512 | + if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification)) |
|
| 1514 | 1513 | { |
| 1515 | 1514 | // delete fails (because no rights), reject recurrence |
| 1516 | - $this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification); |
|
| 1515 | + $this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification); |
|
| 1517 | 1516 | } |
| 1518 | 1517 | continue; |
| 1519 | 1518 | } |
@@ -1525,7 +1524,7 @@ discard block |
||
| 1525 | 1524 | if ($this->log) |
| 1526 | 1525 | { |
| 1527 | 1526 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1528 | - "(): event SINGLE\n",3,$this->logfile); |
|
| 1527 | + "(): event SINGLE\n", 3, $this->logfile); |
|
| 1529 | 1528 | } |
| 1530 | 1529 | |
| 1531 | 1530 | // update the event |
@@ -1535,7 +1534,7 @@ discard block |
||
| 1535 | 1534 | $event['reference'] = 0; |
| 1536 | 1535 | $event_to_store = $event; // prevent $event from being changed by the update method |
| 1537 | 1536 | $this->server2usertime($event_to_store); |
| 1538 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
| 1537 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
| 1539 | 1538 | unset($event_to_store); |
| 1540 | 1539 | } |
| 1541 | 1540 | break; |
@@ -1544,7 +1543,7 @@ discard block |
||
| 1544 | 1543 | if ($this->log) |
| 1545 | 1544 | { |
| 1546 | 1545 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1547 | - "(): event SERIES-MASTER\n",3,$this->logfile); |
|
| 1546 | + "(): event SERIES-MASTER\n", 3, $this->logfile); |
|
| 1548 | 1547 | } |
| 1549 | 1548 | |
| 1550 | 1549 | // remove all known pseudo exceptions and update the event |
@@ -1554,8 +1553,8 @@ discard block |
||
| 1554 | 1553 | $days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter); |
| 1555 | 1554 | if ($this->log) |
| 1556 | 1555 | { |
| 1557 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" . |
|
| 1558 | - array2string($days)."\n",3,$this->logfile); |
|
| 1556 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n". |
|
| 1557 | + array2string($days)."\n", 3, $this->logfile); |
|
| 1559 | 1558 | } |
| 1560 | 1559 | if (is_array($days)) |
| 1561 | 1560 | { |
@@ -1573,7 +1572,7 @@ discard block |
||
| 1573 | 1572 | |
| 1574 | 1573 | $event_to_store = $event; // prevent $event from being changed by the update method |
| 1575 | 1574 | $this->server2usertime($event_to_store); |
| 1576 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
| 1575 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
| 1577 | 1576 | unset($event_to_store); |
| 1578 | 1577 | } |
| 1579 | 1578 | break; |
@@ -1583,7 +1582,7 @@ discard block |
||
| 1583 | 1582 | if ($this->log) |
| 1584 | 1583 | { |
| 1585 | 1584 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1586 | - "(): event SERIES-EXCEPTION\n",3,$this->logfile); |
|
| 1585 | + "(): event SERIES-EXCEPTION\n", 3, $this->logfile); |
|
| 1587 | 1586 | } |
| 1588 | 1587 | |
| 1589 | 1588 | // update event |
@@ -1639,13 +1638,13 @@ discard block |
||
| 1639 | 1638 | $event['owner'] = $event_info['master_event']['owner']; |
| 1640 | 1639 | $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method |
| 1641 | 1640 | $this->server2usertime($event_to_store); |
| 1642 | - $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
| 1641 | + $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
| 1643 | 1642 | unset($event_to_store); |
| 1644 | 1643 | } |
| 1645 | 1644 | |
| 1646 | 1645 | $event_to_store = $event; // prevent $event from being changed by update method |
| 1647 | 1646 | $this->server2usertime($event_to_store); |
| 1648 | - $updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification); |
|
| 1647 | + $updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification); |
|
| 1649 | 1648 | unset($event_to_store); |
| 1650 | 1649 | } |
| 1651 | 1650 | break; |
@@ -1654,7 +1653,7 @@ discard block |
||
| 1654 | 1653 | if ($this->log) |
| 1655 | 1654 | { |
| 1656 | 1655 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1657 | - "(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile); |
|
| 1656 | + "(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile); |
|
| 1658 | 1657 | } |
| 1659 | 1658 | //Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION', |
| 1660 | 1659 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -1675,7 +1674,7 @@ discard block |
||
| 1675 | 1674 | // save the series master with the adjusted exceptions |
| 1676 | 1675 | $event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method |
| 1677 | 1676 | $this->server2usertime($event_to_store); |
| 1678 | - $updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification); |
|
| 1677 | + $updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification); |
|
| 1679 | 1678 | unset($event_to_store); |
| 1680 | 1679 | } |
| 1681 | 1680 | |
@@ -1702,13 +1701,13 @@ discard block |
||
| 1702 | 1701 | if ($event_info['acl_edit']) |
| 1703 | 1702 | { |
| 1704 | 1703 | // update all participants if we have the right to do that |
| 1705 | - $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
|
| 1704 | + $this->update_status($event, $event_info['stored_event'], 0, $skip_notification); |
|
| 1706 | 1705 | } |
| 1707 | 1706 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
| 1708 | 1707 | { |
| 1709 | 1708 | // update the users status only |
| 1710 | 1709 | $this->set_status($event_info['stored_event']['id'], $this->user, |
| 1711 | - ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification); |
|
| 1710 | + ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification); |
|
| 1712 | 1711 | } |
| 1713 | 1712 | } |
| 1714 | 1713 | break; |
@@ -1720,13 +1719,13 @@ discard block |
||
| 1720 | 1719 | if ($event_info['acl_edit']) |
| 1721 | 1720 | { |
| 1722 | 1721 | // update all participants if we have the right to do that |
| 1723 | - $this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification); |
|
| 1722 | + $this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification); |
|
| 1724 | 1723 | } |
| 1725 | 1724 | elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user])) |
| 1726 | 1725 | { |
| 1727 | 1726 | // update the users status only |
| 1728 | 1727 | $this->set_status($event_info['master_event']['id'], $this->user, |
| 1729 | - ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification); |
|
| 1728 | + ($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification); |
|
| 1730 | 1729 | } |
| 1731 | 1730 | } |
| 1732 | 1731 | break; |
@@ -1743,7 +1742,7 @@ discard block |
||
| 1743 | 1742 | break; |
| 1744 | 1743 | |
| 1745 | 1744 | case 'SERIES-PSEUDO-EXCEPTION': |
| 1746 | - $return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false; |
|
| 1745 | + $return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false; |
|
| 1747 | 1746 | break; |
| 1748 | 1747 | |
| 1749 | 1748 | case 'SERIES-EXCEPTION-PROPAGATE': |
@@ -1756,7 +1755,7 @@ discard block |
||
| 1756 | 1755 | { |
| 1757 | 1756 | // we did not have sufficient rights to propagate the status only exception to a real one |
| 1758 | 1757 | // we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched |
| 1759 | - $return_id = $event_info['master_event']['id'] . ':' . $event['recurrence']; |
|
| 1758 | + $return_id = $event_info['master_event']['id'].':'.$event['recurrence']; |
|
| 1760 | 1759 | } |
| 1761 | 1760 | break; |
| 1762 | 1761 | } |
@@ -1770,8 +1769,8 @@ discard block |
||
| 1770 | 1769 | if ($this->log) |
| 1771 | 1770 | { |
| 1772 | 1771 | $event_info['stored_event'] = $this->read($event_info['stored_event']['id']); |
| 1773 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" . |
|
| 1774 | - array2string($event_info['stored_event'])."\n",3,$this->logfile); |
|
| 1772 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n". |
|
| 1773 | + array2string($event_info['stored_event'])."\n", 3, $this->logfile); |
|
| 1775 | 1774 | } |
| 1776 | 1775 | } |
| 1777 | 1776 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
@@ -1793,19 +1792,19 @@ discard block |
||
| 1793 | 1792 | * @return mixed on success: int $cal_id > 0, on error or conflicts false. |
| 1794 | 1793 | * Conflicts are passed to $this->conflict_callback |
| 1795 | 1794 | */ |
| 1796 | - public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
| 1795 | + public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
| 1797 | 1796 | { |
| 1798 | - if($this->conflict_callback !== null) |
|
| 1797 | + if ($this->conflict_callback !== null) |
|
| 1799 | 1798 | { |
| 1800 | 1799 | // calendar_ical overrides search(), which breaks conflict checking |
| 1801 | 1800 | // so we make sure to use the original from parent |
| 1802 | 1801 | static $bo = null; |
| 1803 | - if(!$bo) |
|
| 1802 | + if (!$bo) |
|
| 1804 | 1803 | { |
| 1805 | 1804 | $bo = new calendar_boupdate(); |
| 1806 | 1805 | } |
| 1807 | 1806 | $conflicts = $bo->conflicts($event); |
| 1808 | - if(is_array($conflicts) && count($conflicts) > 0) |
|
| 1807 | + if (is_array($conflicts) && count($conflicts) > 0) |
|
| 1809 | 1808 | { |
| 1810 | 1809 | call_user_func_array($this->conflict_callback, array(&$event, &$conflicts)); |
| 1811 | 1810 | return false; |
@@ -1826,11 +1825,11 @@ discard block |
||
| 1826 | 1825 | { |
| 1827 | 1826 | if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
| 1828 | 1827 | $modified = 0; |
| 1829 | - foreach($event['alarm'] as &$alarm) |
|
| 1828 | + foreach ($event['alarm'] as &$alarm) |
|
| 1830 | 1829 | { |
| 1831 | 1830 | // check if alarm is already stored or from other users |
| 1832 | 1831 | $found = false; |
| 1833 | - foreach($old_alarms as $id => $old_alarm) |
|
| 1832 | + foreach ($old_alarms as $id => $old_alarm) |
|
| 1834 | 1833 | { |
| 1835 | 1834 | // not current users alarm --> ignore |
| 1836 | 1835 | if (!$old_alarm['all'] && $old_alarm['owner'] != $user) |
@@ -1846,7 +1845,7 @@ discard block |
||
| 1846 | 1845 | break; |
| 1847 | 1846 | } |
| 1848 | 1847 | } |
| 1849 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
| 1848 | + if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found ? 'existing' : 'new')." alarm ".array2string($alarm)); |
|
| 1850 | 1849 | if (!empty($alarm['attrs']['X-LIC-ERROR'])) |
| 1851 | 1850 | { |
| 1852 | 1851 | if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
@@ -1874,7 +1873,7 @@ discard block |
||
| 1874 | 1873 | } |
| 1875 | 1874 | } |
| 1876 | 1875 | // remove all old alarms left from current user |
| 1877 | - foreach($old_alarms as $id => $old_alarm) |
|
| 1876 | + foreach ($old_alarms as $id => $old_alarm) |
|
| 1878 | 1877 | { |
| 1879 | 1878 | // not current users alarm --> ignore |
| 1880 | 1879 | if (!$old_alarm['all'] && $old_alarm['owner'] != $user) |
@@ -1897,7 +1896,7 @@ discard block |
||
| 1897 | 1896 | * @param string $what ='value' |
| 1898 | 1897 | * @return mixed |
| 1899 | 1898 | */ |
| 1900 | - static function _get_attribute($components,$name,$what='value') |
|
| 1899 | + static function _get_attribute($components, $name, $what = 'value') |
|
| 1901 | 1900 | { |
| 1902 | 1901 | foreach ($components as $attribute) |
| 1903 | 1902 | { |
@@ -1932,7 +1931,7 @@ discard block |
||
| 1932 | 1931 | case 'DURATION': |
| 1933 | 1932 | if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END') |
| 1934 | 1933 | { |
| 1935 | - $alarm['offset'] = $duration -$vattr['value']; |
|
| 1934 | + $alarm['offset'] = $duration - $vattr['value']; |
|
| 1936 | 1935 | } |
| 1937 | 1936 | elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START') |
| 1938 | 1937 | { |
@@ -1948,7 +1947,7 @@ discard block |
||
| 1948 | 1947 | $alarm['time'] = $vattr['value']; |
| 1949 | 1948 | break; |
| 1950 | 1949 | default: |
| 1951 | - error_log('VALARM/TRIGGER: unsupported value type:' . $vtype); |
|
| 1950 | + error_log('VALARM/TRIGGER: unsupported value type:'.$vtype); |
|
| 1952 | 1951 | } |
| 1953 | 1952 | break; |
| 1954 | 1953 | |
@@ -1973,9 +1972,9 @@ discard block |
||
| 1973 | 1972 | return 0; |
| 1974 | 1973 | } |
| 1975 | 1974 | |
| 1976 | - function setSupportedFields($_productManufacturer='', $_productName='') |
|
| 1975 | + function setSupportedFields($_productManufacturer = '', $_productName = '') |
|
| 1977 | 1976 | { |
| 1978 | - $state =& $_SESSION['SyncML.state']; |
|
| 1977 | + $state = & $_SESSION['SyncML.state']; |
|
| 1979 | 1978 | if (isset($state)) |
| 1980 | 1979 | { |
| 1981 | 1980 | $deviceInfo = $state->getClientDeviceInfo(); |
@@ -2272,10 +2271,10 @@ discard block |
||
| 2272 | 2271 | if ($this->log) |
| 2273 | 2272 | { |
| 2274 | 2273 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2275 | - '(' . $this->productManufacturer . |
|
| 2276 | - ', '. $this->productName .', ' . |
|
| 2277 | - ($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) . |
|
| 2278 | - ', ' . $this->calendarOwner . ")\n" , 3, $this->logfile); |
|
| 2274 | + '('.$this->productManufacturer. |
|
| 2275 | + ', '.$this->productName.', '. |
|
| 2276 | + ($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()). |
|
| 2277 | + ', '.$this->calendarOwner.")\n", 3, $this->logfile); |
|
| 2279 | 2278 | } |
| 2280 | 2279 | |
| 2281 | 2280 | //Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', ' |
@@ -2293,12 +2292,12 @@ discard block |
||
| 2293 | 2292 | * utf-8 for new format, iso-8859-1 for old format. |
| 2294 | 2293 | * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure |
| 2295 | 2294 | */ |
| 2296 | - function icaltoegw($_vcalData, $principalURL='', $charset=null) |
|
| 2295 | + function icaltoegw($_vcalData, $principalURL = '', $charset = null) |
|
| 2297 | 2296 | { |
| 2298 | 2297 | if ($this->log) |
| 2299 | 2298 | { |
| 2300 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" . |
|
| 2301 | - array2string($_vcalData)."\n",3,$this->logfile); |
|
| 2299 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n". |
|
| 2300 | + array2string($_vcalData)."\n", 3, $this->logfile); |
|
| 2302 | 2301 | } |
| 2303 | 2302 | |
| 2304 | 2303 | if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
@@ -2333,14 +2332,14 @@ discard block |
||
| 2333 | 2332 | if ($this->log) |
| 2334 | 2333 | { |
| 2335 | 2334 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2336 | - "(): No vCalendar Container found!\n",3,$this->logfile); |
|
| 2335 | + "(): No vCalendar Container found!\n", 3, $this->logfile); |
|
| 2337 | 2336 | } |
| 2338 | 2337 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
| 2339 | 2338 | return false; |
| 2340 | 2339 | } |
| 2341 | 2340 | foreach ($vcal->getComponents() as $component) |
| 2342 | 2341 | { |
| 2343 | - if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal))) |
|
| 2342 | + if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal))) |
|
| 2344 | 2343 | { |
| 2345 | 2344 | $events[] = $event; |
| 2346 | 2345 | } |
@@ -2385,13 +2384,13 @@ discard block |
||
| 2385 | 2384 | * @param Horde_Icalendar $container =null container to access attributes on container |
| 2386 | 2385 | * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent |
| 2387 | 2386 | */ |
| 2388 | - function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null) |
|
| 2387 | + function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null) |
|
| 2389 | 2388 | { |
| 2390 | 2389 | //unset($component->_container); _debug_array($component); |
| 2391 | 2390 | |
| 2392 | 2391 | if ($this->log) |
| 2393 | 2392 | { |
| 2394 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile); |
|
| 2393 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile); |
|
| 2395 | 2394 | } |
| 2396 | 2395 | |
| 2397 | 2396 | // eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component |
@@ -2451,16 +2450,16 @@ discard block |
||
| 2451 | 2450 | * @param Horde_Icalendar $container =null container to access attributes on container |
| 2452 | 2451 | * @return array|boolean event on success, false on failure |
| 2453 | 2452 | */ |
| 2454 | - function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null) |
|
| 2453 | + function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null) |
|
| 2455 | 2454 | { |
| 2456 | - unset($principalURL); // not longer used, but required in function signature |
|
| 2455 | + unset($principalURL); // not longer used, but required in function signature |
|
| 2457 | 2456 | |
| 2458 | 2457 | if ($check_component && !is_a($component, $check_component)) |
| 2459 | 2458 | { |
| 2460 | 2459 | if ($this->log) |
| 2461 | 2460 | { |
| 2462 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' . |
|
| 2463 | - get_class($component)." found\n",3,$this->logfile); |
|
| 2461 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'. |
|
| 2462 | + get_class($component)." found\n", 3, $this->logfile); |
|
| 2464 | 2463 | } |
| 2465 | 2464 | return false; |
| 2466 | 2465 | } |
@@ -2476,11 +2475,11 @@ discard block |
||
| 2476 | 2475 | |
| 2477 | 2476 | $isDate = false; |
| 2478 | 2477 | $event = array(); |
| 2479 | - $alarms = array(); |
|
| 2480 | - $vcardData = array( |
|
| 2478 | + $alarms = array(); |
|
| 2479 | + $vcardData = array( |
|
| 2481 | 2480 | 'recur_type' => MCAL_RECUR_NONE, |
| 2482 | 2481 | 'recur_exception' => array(), |
| 2483 | - 'priority' => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal |
|
| 2482 | + 'priority' => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal |
|
| 2484 | 2483 | ); |
| 2485 | 2484 | // we need to parse DTSTART, DTEND or DURATION (in that order!) first |
| 2486 | 2485 | foreach (array_merge( |
@@ -2497,7 +2496,7 @@ discard block |
||
| 2497 | 2496 | $isDate = true; |
| 2498 | 2497 | } |
| 2499 | 2498 | $dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']); |
| 2500 | - $vcardData['start'] = $dtstart_ts; |
|
| 2499 | + $vcardData['start'] = $dtstart_ts; |
|
| 2501 | 2500 | |
| 2502 | 2501 | // set event timezone from dtstart, if specified there |
| 2503 | 2502 | if (!empty($attributes['params']['TZID'])) |
@@ -2515,18 +2514,18 @@ discard block |
||
| 2515 | 2514 | } |
| 2516 | 2515 | else |
| 2517 | 2516 | { |
| 2518 | - error_log(__METHOD__ . '() unknown TZID=' |
|
| 2519 | - . $attributes['params']['TZID'] . ', defaulting to timezone "' |
|
| 2520 | - . date_default_timezone_get() . '".'.array2string($tz)); |
|
| 2521 | - $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
| 2517 | + error_log(__METHOD__.'() unknown TZID=' |
|
| 2518 | + . $attributes['params']['TZID'].', defaulting to timezone "' |
|
| 2519 | + . date_default_timezone_get().'".'.array2string($tz)); |
|
| 2520 | + $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
| 2522 | 2521 | } |
| 2523 | 2522 | } |
| 2524 | - catch(Exception $e) |
|
| 2523 | + catch (Exception $e) |
|
| 2525 | 2524 | { |
| 2526 | - error_log(__METHOD__ . '() unknown TZID=' |
|
| 2527 | - . $attributes['params']['TZID'] . ', defaulting to timezone "' |
|
| 2528 | - . date_default_timezone_get() . '".'.$e->getMessage()); |
|
| 2529 | - $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
| 2525 | + error_log(__METHOD__.'() unknown TZID=' |
|
| 2526 | + . $attributes['params']['TZID'].', defaulting to timezone "' |
|
| 2527 | + . date_default_timezone_get().'".'.$e->getMessage()); |
|
| 2528 | + $event['tzid'] = date_default_timezone_get(); // default to current timezone |
|
| 2530 | 2529 | } |
| 2531 | 2530 | } |
| 2532 | 2531 | // if no timezone given and one is specified in class (never the case for CalDAV) |
@@ -2550,11 +2549,11 @@ discard block |
||
| 2550 | 2549 | |
| 2551 | 2550 | case 'DTEND': |
| 2552 | 2551 | $dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']); |
| 2553 | - if (date('H:i:s',$dtend_ts) == '00:00:00') |
|
| 2552 | + if (date('H:i:s', $dtend_ts) == '00:00:00') |
|
| 2554 | 2553 | { |
| 2555 | 2554 | $dtend_ts -= 1; |
| 2556 | 2555 | } |
| 2557 | - $vcardData['end'] = $dtend_ts; |
|
| 2556 | + $vcardData['end'] = $dtend_ts; |
|
| 2558 | 2557 | break; |
| 2559 | 2558 | |
| 2560 | 2559 | case 'DURATION': // clients can use DTSTART+DURATION, instead of DTSTART+DTEND |
@@ -2574,7 +2573,7 @@ discard block |
||
| 2574 | 2573 | if ($this->log) |
| 2575 | 2574 | { |
| 2576 | 2575 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 2577 | - . "() DTSTART missing!\n",3,$this->logfile); |
|
| 2576 | + . "() DTSTART missing!\n", 3, $this->logfile); |
|
| 2578 | 2577 | } |
| 2579 | 2578 | return false; // not a valid entry |
| 2580 | 2579 | } |
@@ -2593,7 +2592,7 @@ discard block |
||
| 2593 | 2592 | case 'X-MICROSOFT-CDO-ALLDAYEVENT': |
| 2594 | 2593 | if (isset($supportedFields['whole_day'])) |
| 2595 | 2594 | { |
| 2596 | - $event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true); |
|
| 2595 | + $event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true); |
|
| 2597 | 2596 | } |
| 2598 | 2597 | break; |
| 2599 | 2598 | case 'AALARM': |
@@ -2623,18 +2622,18 @@ discard block |
||
| 2623 | 2622 | $vcardData['recurrence'] = $attributes['value']; |
| 2624 | 2623 | break; |
| 2625 | 2624 | case 'LOCATION': |
| 2626 | - $vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']); |
|
| 2625 | + $vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']); |
|
| 2627 | 2626 | break; |
| 2628 | 2627 | case 'RRULE': |
| 2629 | 2628 | $recurence = $attributes['value']; |
| 2630 | 2629 | $vcardData['recur_interval'] = 1; |
| 2631 | - $type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0]; |
|
| 2630 | + $type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0]; |
|
| 2632 | 2631 | // vCard 2.0 values for all types |
| 2633 | - if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches)) |
|
| 2632 | + if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches)) |
|
| 2634 | 2633 | { |
| 2635 | 2634 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]); |
| 2636 | 2635 | // If it couldn't be parsed, treat it as not set |
| 2637 | - if(is_string($vcardData['recur_enddate'])) |
|
| 2636 | + if (is_string($vcardData['recur_enddate'])) |
|
| 2638 | 2637 | { |
| 2639 | 2638 | unset($vcardData['recur_enddate']); |
| 2640 | 2639 | } |
@@ -2644,16 +2643,16 @@ discard block |
||
| 2644 | 2643 | self::check_fix_endate($vcardData); |
| 2645 | 2644 | } |
| 2646 | 2645 | } |
| 2647 | - elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches)) |
|
| 2646 | + elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches)) |
|
| 2648 | 2647 | { |
| 2649 | 2648 | $vcardData['recur_count'] = (int)$matches[1]; |
| 2650 | 2649 | } |
| 2651 | - if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches)) |
|
| 2650 | + if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches)) |
|
| 2652 | 2651 | { |
| 2653 | - $vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1; |
|
| 2652 | + $vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1; |
|
| 2654 | 2653 | } |
| 2655 | 2654 | $vcardData['recur_data'] = 0; |
| 2656 | - switch($type) |
|
| 2655 | + switch ($type) |
|
| 2657 | 2656 | { |
| 2658 | 2657 | case 'D': // 1.0 |
| 2659 | 2658 | $recurenceMatches = null; |
@@ -2677,20 +2676,20 @@ discard block |
||
| 2677 | 2676 | case 'W': |
| 2678 | 2677 | case 'WEEKLY': |
| 2679 | 2678 | $days = array(); |
| 2680 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
| 2679 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches)) // 1.0 |
|
| 2681 | 2680 | { |
| 2682 | 2681 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2683 | 2682 | if (empty($recurenceMatches[2])) |
| 2684 | 2683 | { |
| 2685 | - $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
|
| 2684 | + $days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2)); |
|
| 2686 | 2685 | } |
| 2687 | 2686 | else |
| 2688 | 2687 | { |
| 2689 | - $days = explode(' ',trim($recurenceMatches[2])); |
|
| 2688 | + $days = explode(' ', trim($recurenceMatches[2])); |
|
| 2690 | 2689 | } |
| 2691 | 2690 | |
| 2692 | 2691 | $repeatMatches = null; |
| 2693 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
|
| 2692 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches)) |
|
| 2694 | 2693 | { |
| 2695 | 2694 | if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
| 2696 | 2695 | } |
@@ -2701,21 +2700,21 @@ discard block |
||
| 2701 | 2700 | |
| 2702 | 2701 | $recur_days = $this->recur_days_1_0; |
| 2703 | 2702 | } |
| 2704 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
| 2703 | + elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches)) // 2.0 |
|
| 2705 | 2704 | { |
| 2706 | - $days = explode(',',$recurenceMatches[1]); |
|
| 2705 | + $days = explode(',', $recurenceMatches[1]); |
|
| 2707 | 2706 | $recur_days = $this->recur_days; |
| 2708 | 2707 | } |
| 2709 | 2708 | else // no day given, use the day of dtstart |
| 2710 | 2709 | { |
| 2711 | - $vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']); |
|
| 2710 | + $vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']); |
|
| 2712 | 2711 | $vcardData['recur_type'] = MCAL_RECUR_WEEKLY; |
| 2713 | 2712 | } |
| 2714 | 2713 | if ($days) |
| 2715 | 2714 | { |
| 2716 | 2715 | foreach ($recur_days as $id => $day) |
| 2717 | 2716 | { |
| 2718 | - if (in_array(strtoupper(substr($day,0,2)),$days)) |
|
| 2717 | + if (in_array(strtoupper(substr($day, 0, 2)), $days)) |
|
| 2719 | 2718 | { |
| 2720 | 2719 | $vcardData['recur_data'] |= $id; |
| 2721 | 2720 | } |
@@ -2731,17 +2730,17 @@ discard block |
||
| 2731 | 2730 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2732 | 2731 | $vcardData['recur_count'] = $recurenceMatches[2]; |
| 2733 | 2732 | } |
| 2734 | - elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
| 2733 | + elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
| 2735 | 2734 | { |
| 2736 | 2735 | $vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY; |
| 2737 | 2736 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2738 | 2737 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
| 2739 | 2738 | } |
| 2740 | - elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches)) |
|
| 2739 | + elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches)) |
|
| 2741 | 2740 | { |
| 2742 | 2741 | $vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY; |
| 2743 | 2742 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2744 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches)) |
|
| 2743 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches)) |
|
| 2745 | 2744 | { |
| 2746 | 2745 | $vcardData['recur_count'] = $recurenceMatches[1]; |
| 2747 | 2746 | } |
@@ -2758,7 +2757,7 @@ discard block |
||
| 2758 | 2757 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2759 | 2758 | $vcardData['recur_count'] = $recurenceMatches[2]; |
| 2760 | 2759 | } |
| 2761 | - elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
| 2760 | + elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
| 2762 | 2761 | { |
| 2763 | 2762 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2764 | 2763 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
@@ -2772,11 +2771,11 @@ discard block |
||
| 2772 | 2771 | } |
| 2773 | 2772 | // handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL |
| 2774 | 2773 | $vcardData['recur_interval'] = $vcardData['recur_interval'] ? |
| 2775 | - 12*$vcardData['recur_interval'] : 12; |
|
| 2774 | + 12 * $vcardData['recur_interval'] : 12; |
|
| 2776 | 2775 | // fall-through |
| 2777 | 2776 | case 'MONTHLY': |
| 2778 | 2777 | // does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART |
| 2779 | - $vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ? |
|
| 2778 | + $vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ? |
|
| 2780 | 2779 | MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY; |
| 2781 | 2780 | break; |
| 2782 | 2781 | } |
@@ -2832,11 +2831,11 @@ discard block |
||
| 2832 | 2831 | (strpos($this->productName, 'outlook') !== false |
| 2833 | 2832 | || strpos($this->productName, 'pocket pc') !== false)) |
| 2834 | 2833 | { |
| 2835 | - $vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']]; |
|
| 2834 | + $vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']]; |
|
| 2836 | 2835 | } |
| 2837 | 2836 | else |
| 2838 | 2837 | { |
| 2839 | - $vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']]; |
|
| 2838 | + $vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']]; |
|
| 2840 | 2839 | } |
| 2841 | 2840 | break; |
| 2842 | 2841 | case 'CATEGORIES': |
@@ -2850,10 +2849,10 @@ discard block |
||
| 2850 | 2849 | } |
| 2851 | 2850 | break; |
| 2852 | 2851 | case 'ORGANIZER': |
| 2853 | - $event['organizer'] = $attributes['value']; // no egw field, but needed in AS |
|
| 2854 | - if (strtolower(substr($event['organizer'],0,7)) == 'mailto:') |
|
| 2852 | + $event['organizer'] = $attributes['value']; // no egw field, but needed in AS |
|
| 2853 | + if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:') |
|
| 2855 | 2854 | { |
| 2856 | - $event['organizer'] = substr($event['organizer'],7); |
|
| 2855 | + $event['organizer'] = substr($event['organizer'], 7); |
|
| 2857 | 2856 | } |
| 2858 | 2857 | if (!empty($attributes['params']['CN'])) |
| 2859 | 2858 | { |
@@ -2890,19 +2889,19 @@ discard block |
||
| 2890 | 2889 | } |
| 2891 | 2890 | // try parsing email and cn from attendee |
| 2892 | 2891 | elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i', |
| 2893 | - $attributes['value'],$matches)) |
|
| 2892 | + $attributes['value'], $matches)) |
|
| 2894 | 2893 | { |
| 2895 | 2894 | $email = $matches[1] ? $matches[1] : $matches[3]; |
| 2896 | - $cn = isset($matches[2]) ? $matches[2]: ''; |
|
| 2895 | + $cn = isset($matches[2]) ? $matches[2] : ''; |
|
| 2897 | 2896 | } |
| 2898 | 2897 | elseif (!empty($attributes['value']) && |
| 2899 | 2898 | preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i', |
| 2900 | - $attributes['value'],$matches)) |
|
| 2899 | + $attributes['value'], $matches)) |
|
| 2901 | 2900 | { |
| 2902 | 2901 | $cn = $matches[1]; |
| 2903 | 2902 | $email = $matches[2]; |
| 2904 | 2903 | } |
| 2905 | - elseif (strpos($attributes['value'],'@') !== false) |
|
| 2904 | + elseif (strpos($attributes['value'], '@') !== false) |
|
| 2906 | 2905 | { |
| 2907 | 2906 | $email = $attributes['value']; |
| 2908 | 2907 | } |
@@ -2919,7 +2918,7 @@ discard block |
||
| 2919 | 2918 | if ($this->log) |
| 2920 | 2919 | { |
| 2921 | 2920 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 2922 | - . "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile); |
|
| 2921 | + . "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile); |
|
| 2923 | 2922 | } |
| 2924 | 2923 | } |
| 2925 | 2924 | elseif ($attributes['value'] == 'Unknown') |
@@ -2937,7 +2936,7 @@ discard block |
||
| 2937 | 2936 | if ($this->log) |
| 2938 | 2937 | { |
| 2939 | 2938 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 2940 | - . "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
| 2939 | + . "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
| 2941 | 2940 | } |
| 2942 | 2941 | } |
| 2943 | 2942 | if (!$uid) |
@@ -2954,9 +2953,9 @@ discard block |
||
| 2954 | 2953 | $cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'), |
| 2955 | 2954 | array(',', ';', ':', '\\'), |
| 2956 | 2955 | $attributes['params']['CN']); |
| 2957 | - if ($cn[0] == '"' && substr($cn,-1) == '"') |
|
| 2956 | + if ($cn[0] == '"' && substr($cn, -1) == '"') |
|
| 2958 | 2957 | { |
| 2959 | - $cn = substr($cn,1,-1); |
|
| 2958 | + $cn = substr($cn, 1, -1); |
|
| 2960 | 2959 | } |
| 2961 | 2960 | // not searching for $cn, as match can be not unique or without an email address |
| 2962 | 2961 | // --> notification will fail, better store just as email |
@@ -2965,19 +2964,19 @@ discard block |
||
| 2965 | 2964 | if ($this->log) |
| 2966 | 2965 | { |
| 2967 | 2966 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 2968 | - . "() Search participant: '$cn', '$email'\n",3,$this->logfile); |
|
| 2967 | + . "() Search participant: '$cn', '$email'\n", 3, $this->logfile); |
|
| 2969 | 2968 | } |
| 2970 | 2969 | |
| 2971 | 2970 | //elseif (//$attributes['params']['CUTYPE'] == 'GROUP' |
| 2972 | - if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches)) |
|
| 2971 | + if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches)) |
|
| 2973 | 2972 | { |
| 2974 | 2973 | // we found a group |
| 2975 | 2974 | if ($this->log) |
| 2976 | 2975 | { |
| 2977 | 2976 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 2978 | - . "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile); |
|
| 2977 | + . "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile); |
|
| 2979 | 2978 | } |
| 2980 | - if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g'))) |
|
| 2979 | + if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g'))) |
|
| 2981 | 2980 | { |
| 2982 | 2981 | //Horde::logMessage("vevent2egw: group participant $uid", |
| 2983 | 2982 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -2991,7 +2990,7 @@ discard block |
||
| 2991 | 2990 | //Horde::logMessage("vevent2egw: set status to " . $status, |
| 2992 | 2991 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
| 2993 | 2992 | $vcardData['participants'][$this->user] = |
| 2994 | - calendar_so::combine_status($status,$quantity,$role); |
|
| 2993 | + calendar_so::combine_status($status, $quantity, $role); |
|
| 2995 | 2994 | } |
| 2996 | 2995 | } |
| 2997 | 2996 | $status = 'U'; // keep the group |
@@ -3000,36 +2999,36 @@ discard block |
||
| 3000 | 2999 | } |
| 3001 | 3000 | elseif (empty($searcharray)) |
| 3002 | 3001 | { |
| 3003 | - continue; // participants without email AND CN --> ignore it |
|
| 3002 | + continue; // participants without email AND CN --> ignore it |
|
| 3004 | 3003 | } |
| 3005 | 3004 | elseif ((list($data) = $this->addressbook->search($searcharray, |
| 3006 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
| 3005 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
| 3007 | 3006 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
| 3008 | - '','',false,'OR'))) |
|
| 3007 | + '', '', false, 'OR'))) |
|
| 3009 | 3008 | { |
| 3010 | 3009 | // found an addressbook entry |
| 3011 | 3010 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
| 3012 | 3011 | if ($this->log) |
| 3013 | 3012 | { |
| 3014 | 3013 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 3015 | - . "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
| 3014 | + . "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
| 3016 | 3015 | } |
| 3017 | 3016 | } |
| 3018 | 3017 | else |
| 3019 | 3018 | { |
| 3020 | 3019 | if (!$email) |
| 3021 | 3020 | { |
| 3022 | - $email = '[email protected]'; // set dummy email to store the CN |
|
| 3021 | + $email = '[email protected]'; // set dummy email to store the CN |
|
| 3023 | 3022 | } |
| 3024 | - $uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email); |
|
| 3023 | + $uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email); |
|
| 3025 | 3024 | if ($this->log) |
| 3026 | 3025 | { |
| 3027 | 3026 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
| 3028 | - . "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile); |
|
| 3027 | + . "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile); |
|
| 3029 | 3028 | } |
| 3030 | 3029 | } |
| 3031 | 3030 | } |
| 3032 | - switch($attributes['name']) |
|
| 3031 | + switch ($attributes['name']) |
|
| 3033 | 3032 | { |
| 3034 | 3033 | case 'ATTENDEE': |
| 3035 | 3034 | if (!isset($attributes['params']['ROLE']) && |
@@ -3043,7 +3042,7 @@ discard block |
||
| 3043 | 3042 | // keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role |
| 3044 | 3043 | // as this is currently the only way to store an external organizer and send him iMip responses |
| 3045 | 3044 | $q = $r = null; |
| 3046 | - if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) && |
|
| 3045 | + if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) && |
|
| 3047 | 3046 | calendar_so::split_status($s, $q, $r) && $r == 'CHAIR') |
| 3048 | 3047 | { |
| 3049 | 3048 | $role = 'CHAIR'; |
@@ -3057,7 +3056,7 @@ discard block |
||
| 3057 | 3056 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
| 3058 | 3057 | $component->getAttribute('ORGANIZER'); |
| 3059 | 3058 | } |
| 3060 | - catch(Horde_Icalendar_Exception $e) |
|
| 3059 | + catch (Horde_Icalendar_Exception $e) |
|
| 3061 | 3060 | { |
| 3062 | 3061 | // we can store the ORGANIZER as event owner |
| 3063 | 3062 | $event['owner'] = $uid; |
@@ -3113,7 +3112,7 @@ discard block |
||
| 3113 | 3112 | break; |
| 3114 | 3113 | |
| 3115 | 3114 | case 'ATTACH': |
| 3116 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
| 3115 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
| 3117 | 3116 | // fall throught to store external attachment url |
| 3118 | 3117 | default: // X- attribute or other by EGroupware unsupported property |
| 3119 | 3118 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3171,7 +3170,7 @@ discard block |
||
| 3171 | 3170 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 3172 | 3171 | { |
| 3173 | 3172 | $event['reference'] = 0; |
| 3174 | - foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r) |
|
| 3173 | + foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r) |
|
| 3175 | 3174 | { |
| 3176 | 3175 | if (isset($vcardData[$r])) |
| 3177 | 3176 | { |
@@ -3194,12 +3193,12 @@ discard block |
||
| 3194 | 3193 | // reset recure_enddate to 00:00:00 on the last day |
| 3195 | 3194 | $rriter = calendar_rrule::event2rrule($event, false); |
| 3196 | 3195 | $last = $rriter->normalize_enddate(); |
| 3197 | - if(!is_object($last)) |
|
| 3196 | + if (!is_object($last)) |
|
| 3198 | 3197 | { |
| 3199 | - if($this->log) |
|
| 3198 | + if ($this->log) |
|
| 3200 | 3199 | { |
| 3201 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
| 3202 | - " Unable to determine recurrence end date. \n".array2string($event),3, $this->logfile); |
|
| 3200 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
| 3201 | + " Unable to determine recurrence end date. \n".array2string($event), 3, $this->logfile); |
|
| 3203 | 3202 | } |
| 3204 | 3203 | return false; |
| 3205 | 3204 | } |
@@ -3208,16 +3207,16 @@ discard block |
||
| 3208 | 3207 | $event['recur_enddate'] = Api\DateTime::to($last, 'server'); |
| 3209 | 3208 | } |
| 3210 | 3209 | // translate COUNT into an enddate, as we only store enddates |
| 3211 | - elseif($event['recur_count']) |
|
| 3210 | + elseif ($event['recur_count']) |
|
| 3212 | 3211 | { |
| 3213 | 3212 | $rriter = calendar_rrule::event2rrule($event, false); |
| 3214 | 3213 | $last = $rriter->count2date($event['recur_count']); |
| 3215 | - if(!is_object($last)) |
|
| 3214 | + if (!is_object($last)) |
|
| 3216 | 3215 | { |
| 3217 | - if($this->log) |
|
| 3216 | + if ($this->log) |
|
| 3218 | 3217 | { |
| 3219 | 3218 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__, |
| 3220 | - " Unable to determine recurrence end date. \n".array2string($event),3, $this->logfile); |
|
| 3219 | + " Unable to determine recurrence end date. \n".array2string($event), 3, $this->logfile); |
|
| 3221 | 3220 | } |
| 3222 | 3221 | return false; |
| 3223 | 3222 | } |
@@ -3231,7 +3230,7 @@ discard block |
||
| 3231 | 3230 | if ($this->productManufacturer == 'groupdav' && $container && |
| 3232 | 3231 | ($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS'))) |
| 3233 | 3232 | { |
| 3234 | - $event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC'); |
|
| 3233 | + $event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC'); |
|
| 3235 | 3234 | } |
| 3236 | 3235 | //error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public'])); |
| 3237 | 3236 | } |
@@ -3252,15 +3251,15 @@ discard block |
||
| 3252 | 3251 | |
| 3253 | 3252 | if ($this->log) |
| 3254 | 3253 | { |
| 3255 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
| 3256 | - array2string($event)."\n",3,$this->logfile); |
|
| 3254 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
| 3255 | + array2string($event)."\n", 3, $this->logfile); |
|
| 3257 | 3256 | } |
| 3258 | 3257 | //Horde::logMessage("vevent2egw:\n" . print_r($event, true), |
| 3259 | 3258 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
| 3260 | 3259 | return $event; |
| 3261 | 3260 | } |
| 3262 | 3261 | |
| 3263 | - function search($_vcalData, $contentID=null, $relax=false, $charset=null) |
|
| 3262 | + function search($_vcalData, $contentID = null, $relax = false, $charset = null) |
|
| 3264 | 3263 | { |
| 3265 | 3264 | if (($events = $this->icaltoegw($_vcalData, $charset))) |
| 3266 | 3265 | { |
@@ -3281,8 +3280,8 @@ discard block |
||
| 3281 | 3280 | } |
| 3282 | 3281 | if ($this->log) |
| 3283 | 3282 | { |
| 3284 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" . |
|
| 3285 | - array2string($events)."\n",3,$this->logfile); |
|
| 3283 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n". |
|
| 3284 | + array2string($events)."\n", 3, $this->logfile); |
|
| 3286 | 3285 | } |
| 3287 | 3286 | } |
| 3288 | 3287 | return array(); |
@@ -3321,23 +3320,23 @@ discard block |
||
| 3321 | 3320 | * @param array $extra =null extra attributes to add |
| 3322 | 3321 | * X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy |
| 3323 | 3322 | */ |
| 3324 | - function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
|
| 3323 | + function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null) |
|
| 3325 | 3324 | { |
| 3326 | - if (!$start) $start = time(); // default now |
|
| 3327 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
| 3325 | + if (!$start) $start = time(); // default now |
|
| 3326 | + if (!$end) $end = time() + 100 * DAY_s; // default next 100 days |
|
| 3328 | 3327 | |
| 3329 | 3328 | $vcal = new Horde_Icalendar; |
| 3330 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 3329 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 3331 | 3330 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 3332 | - $vcal->setAttribute('VERSION','2.0'); |
|
| 3333 | - $vcal->setAttribute('METHOD',$method); |
|
| 3331 | + $vcal->setAttribute('VERSION', '2.0'); |
|
| 3332 | + $vcal->setAttribute('METHOD', $method); |
|
| 3334 | 3333 | |
| 3335 | - $vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal); |
|
| 3334 | + $vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal); |
|
| 3336 | 3335 | |
| 3337 | 3336 | $attributes = array( |
| 3338 | 3337 | 'DTSTAMP' => time(), |
| 3339 | - 'DTSTART' => $this->date2ts($start,true), // true = server-time |
|
| 3340 | - 'DTEND' => $this->date2ts($end,true), // true = server-time |
|
| 3338 | + 'DTSTART' => $this->date2ts($start, true), // true = server-time |
|
| 3339 | + 'DTEND' => $this->date2ts($end, true), // true = server-time |
|
| 3341 | 3340 | ); |
| 3342 | 3341 | if (!$utc) |
| 3343 | 3342 | { |
@@ -3348,9 +3347,9 @@ discard block |
||
| 3348 | 3347 | } |
| 3349 | 3348 | if (is_null($extra)) $extra = array( |
| 3350 | 3349 | 'URL' => $this->freebusy_url($user), |
| 3351 | - 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
|
| 3350 | + 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'), |
|
| 3352 | 3351 | ); |
| 3353 | - foreach($attributes+$extra as $attr => $value) |
|
| 3352 | + foreach ($attributes + $extra as $attr => $value) |
|
| 3354 | 3353 | { |
| 3355 | 3354 | $vfreebusy->setAttribute($attr, $value); |
| 3356 | 3355 | } |
@@ -3373,16 +3372,16 @@ discard block |
||
| 3373 | 3372 | |
| 3374 | 3373 | if ($utc) |
| 3375 | 3374 | { |
| 3376 | - $vfreebusy->setAttribute('FREEBUSY',array(array( |
|
| 3375 | + $vfreebusy->setAttribute('FREEBUSY', array(array( |
|
| 3377 | 3376 | 'start' => $event['start'], |
| 3378 | 3377 | 'end' => $event['end'], |
| 3379 | 3378 | )), array('FBTYPE' => $fbtype)); |
| 3380 | 3379 | } |
| 3381 | 3380 | else |
| 3382 | 3381 | { |
| 3383 | - $vfreebusy->setAttribute('FREEBUSY',array(array( |
|
| 3384 | - 'start' => date('Ymd\THis',$event['start']), |
|
| 3385 | - 'end' => date('Ymd\THis',$event['end']), |
|
| 3382 | + $vfreebusy->setAttribute('FREEBUSY', array(array( |
|
| 3383 | + 'start' => date('Ymd\THis', $event['start']), |
|
| 3384 | + 'end' => date('Ymd\THis', $event['end']), |
|
| 3386 | 3385 | )), array('FBTYPE' => $fbtype)); |
| 3387 | 3386 | } |
| 3388 | 3387 | } |
@@ -183,7 +183,10 @@ discard block |
||
| 183 | 183 | function __construct(&$_clientProperties = array()) |
| 184 | 184 | { |
| 185 | 185 | parent::__construct(); |
| 186 | - if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 186 | + if ($this->log) |
|
| 187 | + { |
|
| 188 | + $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
| 189 | + } |
|
| 187 | 190 | $this->clientProperties = $_clientProperties; |
| 188 | 191 | $this->vCalendar = new Horde_Icalendar; |
| 189 | 192 | $this->addressbook = new Api\Contacts; |
@@ -232,10 +235,14 @@ discard block |
||
| 232 | 235 | 'ATTACH' => 'attachments', |
| 233 | 236 | ); |
| 234 | 237 | |
| 235 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 238 | + if (!is_array($this->supportedFields)) |
|
| 239 | + { |
|
| 240 | + $this->setSupportedFields(); |
|
| 241 | + } |
|
| 236 | 242 | |
| 237 | 243 | if ($this->productManufacturer == '' ) |
| 238 | - { // syncevolution is broken |
|
| 244 | + { |
|
| 245 | +// syncevolution is broken |
|
| 239 | 246 | $version = '2.0'; |
| 240 | 247 | } |
| 241 | 248 | |
@@ -243,10 +250,16 @@ discard block |
||
| 243 | 250 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
| 244 | 251 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 245 | 252 | $vcal->setAttribute('VERSION', $version); |
| 246 | - if ($method) $vcal->setAttribute('METHOD', $method); |
|
| 253 | + if ($method) |
|
| 254 | + { |
|
| 255 | + $vcal->setAttribute('METHOD', $method); |
|
| 256 | + } |
|
| 247 | 257 | $events_exported = false; |
| 248 | 258 | |
| 249 | - if (!is_array($events)) $events = array($events); |
|
| 259 | + if (!is_array($events)) |
|
| 260 | + { |
|
| 261 | + $events = array($events); |
|
| 262 | + } |
|
| 250 | 263 | |
| 251 | 264 | $vtimezones_added = array(); |
| 252 | 265 | foreach ($events as $event) |
@@ -312,7 +325,10 @@ discard block |
||
| 312 | 325 | self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']); |
| 313 | 326 | } |
| 314 | 327 | |
| 315 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 328 | + if ($this->so->isWholeDay($event)) |
|
| 329 | + { |
|
| 330 | + $event['whole_day'] = true; |
|
| 331 | + } |
|
| 316 | 332 | |
| 317 | 333 | if ($this->log) |
| 318 | 334 | { |
@@ -323,7 +339,10 @@ discard block |
||
| 323 | 339 | |
| 324 | 340 | if ($recurrence) |
| 325 | 341 | { |
| 326 | - if (!($master = $this->read($event['id'], 0, true, 'server'))) continue; |
|
| 342 | + if (!($master = $this->read($event['id'], 0, true, 'server'))) |
|
| 343 | + { |
|
| 344 | + continue; |
|
| 345 | + } |
|
| 327 | 346 | |
| 328 | 347 | if (!isset($this->supportedFields['participants'])) |
| 329 | 348 | { |
@@ -380,7 +399,8 @@ discard block |
||
| 380 | 399 | if ($this->productManufacturer != 'file' && $this->uidExtension) |
| 381 | 400 | { |
| 382 | 401 | // Append UID to DESCRIPTION |
| 383 | - if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
|
| 402 | + if (!preg_match('/\[UID:.+\]/m', $event['description'])) |
|
| 403 | + { |
|
| 384 | 404 | $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
| 385 | 405 | } |
| 386 | 406 | } |
@@ -440,11 +460,21 @@ discard block |
||
| 440 | 460 | $quantity = $role = null; |
| 441 | 461 | calendar_so::split_status($status, $quantity, $role); |
| 442 | 462 | // do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant |
| 443 | - if (count($event['participants']) == 1 && $event['owner'] == $uid) continue; |
|
| 463 | + if (count($event['participants']) == 1 && $event['owner'] == $uid) |
|
| 464 | + { |
|
| 465 | + continue; |
|
| 466 | + } |
|
| 444 | 467 | |
| 445 | - if (!($info = $this->resource_info($uid))) continue; |
|
| 468 | + if (!($info = $this->resource_info($uid))) |
|
| 469 | + { |
|
| 470 | + continue; |
|
| 471 | + } |
|
| 446 | 472 | |
| 447 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
| 473 | + if (in_array($status, array('X','E'))) |
|
| 474 | + { |
|
| 475 | + continue; |
|
| 476 | + } |
|
| 477 | + // dont include deleted participants |
|
| 448 | 478 | |
| 449 | 479 | if ($this->log) |
| 450 | 480 | { |
@@ -523,24 +553,49 @@ discard block |
||
| 523 | 553 | } |
| 524 | 554 | // ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*} |
| 525 | 555 | $options = array(); |
| 526 | - if (!empty($participantCN)) $options['CN'] = $participantCN; |
|
| 527 | - if (!empty($role)) $options['ROLE'] = $role; |
|
| 528 | - if (!empty($status)) $options['PARTSTAT'] = $status; |
|
| 529 | - if (!empty($cutype)) $options['CUTYPE'] = $cutype; |
|
| 530 | - if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
|
| 556 | + if (!empty($participantCN)) |
|
| 557 | + { |
|
| 558 | + $options['CN'] = $participantCN; |
|
| 559 | + } |
|
| 560 | + if (!empty($role)) |
|
| 561 | + { |
|
| 562 | + $options['ROLE'] = $role; |
|
| 563 | + } |
|
| 564 | + if (!empty($status)) |
|
| 565 | + { |
|
| 566 | + $options['PARTSTAT'] = $status; |
|
| 567 | + } |
|
| 568 | + if (!empty($cutype)) |
|
| 569 | + { |
|
| 570 | + $options['CUTYPE'] = $cutype; |
|
| 571 | + } |
|
| 572 | + if (!empty($rsvp)) |
|
| 573 | + { |
|
| 574 | + $options['RSVP'] = $rsvp; |
|
| 575 | + } |
|
| 531 | 576 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
| 532 | 577 | { |
| 533 | 578 | $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
| 534 | 579 | } |
| 535 | - if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 536 | - if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 580 | + if ($info['type'] != 'e') |
|
| 581 | + { |
|
| 582 | + $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
| 583 | + } |
|
| 584 | + if ($quantity > 1) |
|
| 585 | + { |
|
| 586 | + $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
|
| 587 | + } |
|
| 537 | 588 | $attributes['ATTENDEE'][] = $participantURL; |
| 538 | 589 | $parameters['ATTENDEE'][] = $options; |
| 539 | 590 | } |
| 540 | 591 | break; |
| 541 | 592 | |
| 542 | 593 | case 'CLASS': |
| 543 | - if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default |
|
| 594 | + if ($event['public']) |
|
| 595 | + { |
|
| 596 | + continue; |
|
| 597 | + } |
|
| 598 | + // public is default, no need to export, fails CalDAVTester if added as default |
|
| 544 | 599 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
| 545 | 600 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
| 546 | 601 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -572,9 +627,18 @@ discard block |
||
| 572 | 627 | 'CUTYPE' => 'INDIVIDUAL', |
| 573 | 628 | //'RSVP' => 'FALSE', |
| 574 | 629 | ); |
| 575 | - if (!empty($organizerCN)) $options['CN'] = $organizerCN; |
|
| 576 | - if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail; |
|
| 577 | - if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 630 | + if (!empty($organizerCN)) |
|
| 631 | + { |
|
| 632 | + $options['CN'] = $organizerCN; |
|
| 633 | + } |
|
| 634 | + if (!empty($organizerEMail)) |
|
| 635 | + { |
|
| 636 | + $options['EMAIL'] = $organizerEMail; |
|
| 637 | + } |
|
| 638 | + if (!empty($event['owner'])) |
|
| 639 | + { |
|
| 640 | + $options['X-EGROUPWARE-UID'] = $event['owner']; |
|
| 641 | + } |
|
| 578 | 642 | $attributes['ATTENDEE'][] = $organizerURL; |
| 579 | 643 | $parameters['ATTENDEE'][] = $options; |
| 580 | 644 | } |
@@ -603,9 +667,12 @@ discard block |
||
| 603 | 667 | { |
| 604 | 668 | // Hack for CalDAVTester to export duration instead of endtime |
| 605 | 669 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
| 606 | - $attributes['duration'] = $event['end'] - $event['start']; |
|
| 607 | - else |
|
| 608 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 670 | + { |
|
| 671 | + $attributes['duration'] = $event['end'] - $event['start']; |
|
| 672 | + } |
|
| 673 | + else { |
|
| 674 | + $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
| 675 | + } |
|
| 609 | 676 | } |
| 610 | 677 | else |
| 611 | 678 | { |
@@ -625,7 +692,11 @@ discard block |
||
| 625 | 692 | break; |
| 626 | 693 | |
| 627 | 694 | case 'RRULE': |
| 628 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
| 695 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 696 | + { |
|
| 697 | + break; |
|
| 698 | + } |
|
| 699 | + // no recuring event |
|
| 629 | 700 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
| 630 | 701 | $rrule = $rriter->generate_rrule($version); |
| 631 | 702 | if ($event['recur_enddate']) |
@@ -667,7 +738,10 @@ discard block |
||
| 667 | 738 | break; |
| 668 | 739 | |
| 669 | 740 | case 'EXDATE': |
| 670 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; |
|
| 741 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
| 742 | + { |
|
| 743 | + break; |
|
| 744 | + } |
|
| 671 | 745 | if (!empty($event['recur_exception'])) |
| 672 | 746 | { |
| 673 | 747 | if (empty($event['whole_day'])) |
@@ -694,14 +768,21 @@ discard block |
||
| 694 | 768 | ); |
| 695 | 769 | } |
| 696 | 770 | $event['recur_exception'] = $days; |
| 697 | - if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 771 | + if ($version != '1.0') |
|
| 772 | + { |
|
| 773 | + $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
| 774 | + } |
|
| 698 | 775 | } |
| 699 | 776 | $vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']); |
| 700 | 777 | } |
| 701 | 778 | break; |
| 702 | 779 | |
| 703 | 780 | case 'PRIORITY': |
| 704 | - if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 781 | + if (!$event['priority']) |
|
| 782 | + { |
|
| 783 | + continue; |
|
| 784 | + } |
|
| 785 | + // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
| 705 | 786 | if ($this->productManufacturer == 'funambol' && |
| 706 | 787 | (strpos($this->productName, 'outlook') !== false |
| 707 | 788 | || strpos($this->productName, 'pocket pc') !== false)) |
@@ -715,7 +796,11 @@ discard block |
||
| 715 | 796 | break; |
| 716 | 797 | |
| 717 | 798 | case 'TRANSP': |
| 718 | - if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 799 | + if (!$event['non_blocking']) |
|
| 800 | + { |
|
| 801 | + continue; |
|
| 802 | + } |
|
| 803 | + // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
| 719 | 804 | if ($version == '1.0') |
| 720 | 805 | { |
| 721 | 806 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -772,7 +857,11 @@ discard block |
||
| 772 | 857 | elseif ($event['recurrence'] && $event['reference']) |
| 773 | 858 | { |
| 774 | 859 | // $event['reference'] is a calendar_id, not a timestamp |
| 775 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
| 860 | + if (!($revent = $this->read($event['reference']))) |
|
| 861 | + { |
|
| 862 | + break; |
|
| 863 | + } |
|
| 864 | + // referenced event does not exist |
|
| 776 | 865 | |
| 777 | 866 | if (empty($revent['whole_day'])) |
| 778 | 867 | { |
@@ -898,7 +987,10 @@ discard block |
||
| 898 | 987 | foreach ((array)$event['alarm'] as $alarmData) |
| 899 | 988 | { |
| 900 | 989 | // skip over alarms that don't have the minimum required info |
| 901 | - if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue; |
|
| 990 | + if (!isset($alarmData['offset']) && !isset($alarmData['time'])) |
|
| 991 | + { |
|
| 992 | + continue; |
|
| 993 | + } |
|
| 902 | 994 | |
| 903 | 995 | // skip alarms not being set for all users and alarms owned by other users |
| 904 | 996 | if ($alarmData['all'] != true && $alarmData['owner'] != $this->user) |
@@ -915,7 +1007,10 @@ discard block |
||
| 915 | 1007 | |
| 916 | 1008 | if ($version == '1.0') |
| 917 | 1009 | { |
| 918 | - if ($event['title']) $description = $event['title']; |
|
| 1010 | + if ($event['title']) |
|
| 1011 | + { |
|
| 1012 | + $description = $event['title']; |
|
| 1013 | + } |
|
| 919 | 1014 | if ($description) |
| 920 | 1015 | { |
| 921 | 1016 | $values['DALARM']['snooze_time'] = ''; |
@@ -935,7 +1030,10 @@ discard block |
||
| 935 | 1030 | // VCalendar 2.0 / RFC 2445 |
| 936 | 1031 | |
| 937 | 1032 | // RFC requires DESCRIPTION for DISPLAY |
| 938 | - if (!$event['title'] && !$description) $description = 'Alarm'; |
|
| 1033 | + if (!$event['title'] && !$description) |
|
| 1034 | + { |
|
| 1035 | + $description = 'Alarm'; |
|
| 1036 | + } |
|
| 939 | 1037 | |
| 940 | 1038 | /* Disabling for now |
| 941 | 1039 | // Lightning infinitly pops up alarms for recuring events, if the only use an offset |
@@ -1126,13 +1224,20 @@ discard block |
||
| 1126 | 1224 | $this->events_imported = 0; |
| 1127 | 1225 | $replace = $delete_exceptions= false; |
| 1128 | 1226 | |
| 1129 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 1227 | + if (!is_array($this->supportedFields)) |
|
| 1228 | + { |
|
| 1229 | + $this->setSupportedFields(); |
|
| 1230 | + } |
|
| 1130 | 1231 | |
| 1131 | 1232 | if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset))) |
| 1132 | 1233 | { |
| 1133 | 1234 | return false; |
| 1134 | 1235 | } |
| 1135 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1236 | + if (!is_array($events)) |
|
| 1237 | + { |
|
| 1238 | + $cal_id = -1; |
|
| 1239 | + } |
|
| 1240 | + // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
| 1136 | 1241 | |
| 1137 | 1242 | if ($cal_id > 0) |
| 1138 | 1243 | { |
@@ -1140,8 +1245,14 @@ discard block |
||
| 1140 | 1245 | { |
| 1141 | 1246 | $replace = $recur_date == 0; |
| 1142 | 1247 | $events[0]['id'] = $cal_id; |
| 1143 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
| 1144 | - if ($recur_date) $events[0]['recurrence'] = $recur_date; |
|
| 1248 | + if (!is_null($etag)) |
|
| 1249 | + { |
|
| 1250 | + $events[0]['etag'] = (int) $etag; |
|
| 1251 | + } |
|
| 1252 | + if ($recur_date) |
|
| 1253 | + { |
|
| 1254 | + $events[0]['recurrence'] = $recur_date; |
|
| 1255 | + } |
|
| 1145 | 1256 | } |
| 1146 | 1257 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
| 1147 | 1258 | ($eventId = array_shift($foundEvent)) && |
@@ -1149,7 +1260,10 @@ discard block |
||
| 1149 | 1260 | { |
| 1150 | 1261 | foreach ($events as $k => $event) |
| 1151 | 1262 | { |
| 1152 | - if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1263 | + if (!isset($event['uid'])) |
|
| 1264 | + { |
|
| 1265 | + $events[$k]['uid'] = $egwEvent['uid']; |
|
| 1266 | + } |
|
| 1153 | 1267 | } |
| 1154 | 1268 | } |
| 1155 | 1269 | } |
@@ -1179,10 +1293,17 @@ discard block |
||
| 1179 | 1293 | $msg = null; |
| 1180 | 1294 | foreach ($events as $event) |
| 1181 | 1295 | { |
| 1182 | - if (!is_array($event)) continue; // the iterator may return false |
|
| 1296 | + if (!is_array($event)) |
|
| 1297 | + { |
|
| 1298 | + continue; |
|
| 1299 | + } |
|
| 1300 | + // the iterator may return false |
|
| 1183 | 1301 | ++$this->events_imported; |
| 1184 | 1302 | |
| 1185 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 1303 | + if ($this->so->isWholeDay($event)) |
|
| 1304 | + { |
|
| 1305 | + $event['whole_day'] = true; |
|
| 1306 | + } |
|
| 1186 | 1307 | if (is_array($event['category'])) |
| 1187 | 1308 | { |
| 1188 | 1309 | $event['category'] = $this->find_or_add_categories($event['category'], |
@@ -1219,7 +1340,10 @@ discard block |
||
| 1219 | 1340 | } |
| 1220 | 1341 | else |
| 1221 | 1342 | { |
| 1222 | - if (!($exception = $this->read($id))) continue; |
|
| 1343 | + if (!($exception = $this->read($id))) |
|
| 1344 | + { |
|
| 1345 | + continue; |
|
| 1346 | + } |
|
| 1223 | 1347 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1224 | 1348 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1225 | 1349 | $this->update($exception, true,true,false,true,$msg,$skip_notification); |
@@ -1308,7 +1432,10 @@ discard block |
||
| 1308 | 1432 | break; |
| 1309 | 1433 | |
| 1310 | 1434 | default: |
| 1311 | - if (!empty($value)) $event[$key] = $value; |
|
| 1435 | + if (!empty($value)) |
|
| 1436 | + { |
|
| 1437 | + $event[$key] = $value; |
|
| 1438 | + } |
|
| 1312 | 1439 | } |
| 1313 | 1440 | } |
| 1314 | 1441 | } |
@@ -1406,7 +1533,10 @@ discard block |
||
| 1406 | 1533 | else // common adjustments for new events |
| 1407 | 1534 | { |
| 1408 | 1535 | unset($event['id']); |
| 1409 | - if ($caldav_name) $event['caldav_name'] = $caldav_name; |
|
| 1536 | + if ($caldav_name) |
|
| 1537 | + { |
|
| 1538 | + $event['caldav_name'] = $caldav_name; |
|
| 1539 | + } |
|
| 1410 | 1540 | // set non blocking all day depending on the user setting |
| 1411 | 1541 | if (!empty($event['whole_day']) && $this->nonBlockingAllday) |
| 1412 | 1542 | { |
@@ -1454,7 +1584,10 @@ discard block |
||
| 1454 | 1584 | || !isset($event['participants'][$event['owner']])) |
| 1455 | 1585 | { |
| 1456 | 1586 | $status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR'); |
| 1457 | - if (!is_array($event['participants'])) $event['participants'] = array(); |
|
| 1587 | + if (!is_array($event['participants'])) |
|
| 1588 | + { |
|
| 1589 | + $event['participants'] = array(); |
|
| 1590 | + } |
|
| 1458 | 1591 | $event['participants'][$event['owner']] = $status; |
| 1459 | 1592 | } |
| 1460 | 1593 | else |
@@ -1607,7 +1740,10 @@ discard block |
||
| 1607 | 1740 | $occurence = $exception = false; |
| 1608 | 1741 | foreach ($event_info['master_event']['recur_exception'] as $exception) |
| 1609 | 1742 | { |
| 1610 | - if ($exception > $event['start']) break; |
|
| 1743 | + if ($exception > $event['start']) |
|
| 1744 | + { |
|
| 1745 | + break; |
|
| 1746 | + } |
|
| 1611 | 1747 | $occurence = $exception; |
| 1612 | 1748 | } |
| 1613 | 1749 | if (!$occurence) |
@@ -1697,12 +1833,15 @@ discard block |
||
| 1697 | 1833 | case 'SERIES-MASTER': |
| 1698 | 1834 | case 'SERIES-EXCEPTION': |
| 1699 | 1835 | case 'SERIES-EXCEPTION-PROPAGATE': |
| 1700 | - if (is_array($event_info['stored_event'])) // status update requires a stored event |
|
| 1836 | + if (is_array($event_info['stored_event'])) |
|
| 1837 | + { |
|
| 1838 | + // status update requires a stored event |
|
| 1701 | 1839 | { |
| 1702 | 1840 | if ($event_info['acl_edit']) |
| 1703 | 1841 | { |
| 1704 | 1842 | // update all participants if we have the right to do that |
| 1705 | 1843 | $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
| 1844 | + } |
|
| 1706 | 1845 | } |
| 1707 | 1846 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
| 1708 | 1847 | { |
@@ -1714,9 +1853,12 @@ discard block |
||
| 1714 | 1853 | break; |
| 1715 | 1854 | |
| 1716 | 1855 | case 'SERIES-PSEUDO-EXCEPTION': |
| 1717 | - if (is_array($event_info['master_event'])) // status update requires a stored master event |
|
| 1856 | + if (is_array($event_info['master_event'])) |
|
| 1857 | + { |
|
| 1858 | + // status update requires a stored master event |
|
| 1718 | 1859 | { |
| 1719 | 1860 | $recurrence = $this->date2usertime($event['recurrence']); |
| 1861 | + } |
|
| 1720 | 1862 | if ($event_info['acl_edit']) |
| 1721 | 1863 | { |
| 1722 | 1864 | // update all participants if we have the right to do that |
@@ -1824,7 +1966,10 @@ discard block |
||
| 1824 | 1966 | */ |
| 1825 | 1967 | public function sync_alarms(array &$event, array $old_alarms, $user) |
| 1826 | 1968 | { |
| 1827 | - if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1969 | + if ($this->debug) |
|
| 1970 | + { |
|
| 1971 | + error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
| 1972 | + } |
|
| 1828 | 1973 | $modified = 0; |
| 1829 | 1974 | foreach($event['alarm'] as &$alarm) |
| 1830 | 1975 | { |
@@ -1846,29 +1991,56 @@ discard block |
||
| 1846 | 1991 | break; |
| 1847 | 1992 | } |
| 1848 | 1993 | } |
| 1849 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
| 1994 | + if ($this->debug) |
|
| 1995 | + { |
|
| 1996 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
| 1997 | + } |
|
| 1850 | 1998 | if (!empty($alarm['attrs']['X-LIC-ERROR'])) |
| 1851 | 1999 | { |
| 1852 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
| 2000 | + if ($this->debug) |
|
| 2001 | + { |
|
| 2002 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
| 2003 | + } |
|
| 1853 | 2004 | unset($alarm['attrs']['X-LIC-ERROR']); |
| 1854 | 2005 | } |
| 1855 | 2006 | // alarm not found --> add it |
| 1856 | 2007 | if (!$found) |
| 1857 | 2008 | { |
| 1858 | 2009 | $alarm['owner'] = $user; |
| 1859 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1860 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1861 | - if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 1862 | - if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 2010 | + if (!isset($alarm['time'])) |
|
| 2011 | + { |
|
| 2012 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 2013 | + } |
|
| 2014 | + if ($alarm['time'] < time()) |
|
| 2015 | + { |
|
| 2016 | + calendar_so::shift_alarm($event, $alarm); |
|
| 2017 | + } |
|
| 2018 | + if ($this->debug) |
|
| 2019 | + { |
|
| 2020 | + error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
| 2021 | + } |
|
| 2022 | + if ($event['id']) |
|
| 2023 | + { |
|
| 2024 | + $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
| 2025 | + } |
|
| 1863 | 2026 | ++$modified; |
| 1864 | 2027 | } |
| 1865 | 2028 | // existing alarm --> update it |
| 1866 | 2029 | else |
| 1867 | 2030 | { |
| 1868 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 1869 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 2031 | + if (!isset($alarm['time'])) |
|
| 2032 | + { |
|
| 2033 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 2034 | + } |
|
| 2035 | + if ($alarm['time'] < time()) |
|
| 2036 | + { |
|
| 2037 | + calendar_so::shift_alarm($event, $alarm); |
|
| 2038 | + } |
|
| 1870 | 2039 | $alarm = array_merge($old_alarm, $alarm); |
| 1871 | - if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 2040 | + if ($this->debug) |
|
| 2041 | + { |
|
| 2042 | + error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
| 2043 | + } |
|
| 1872 | 2044 | $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
| 1873 | 2045 | ++$modified; |
| 1874 | 2046 | } |
@@ -1882,7 +2054,10 @@ discard block |
||
| 1882 | 2054 | unset($old_alarm[$id]); |
| 1883 | 2055 | continue; |
| 1884 | 2056 | } |
| 1885 | - if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 2057 | + if ($this->debug) |
|
| 2058 | + { |
|
| 2059 | + error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
| 2060 | + } |
|
| 1886 | 2061 | $this->delete_alarm($id); |
| 1887 | 2062 | ++$modified; |
| 1888 | 2063 | } |
@@ -2301,7 +2476,10 @@ discard block |
||
| 2301 | 2476 | array2string($_vcalData)."\n",3,$this->logfile); |
| 2302 | 2477 | } |
| 2303 | 2478 | |
| 2304 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
| 2479 | + if (!is_array($this->supportedFields)) |
|
| 2480 | + { |
|
| 2481 | + $this->setSupportedFields(); |
|
| 2482 | + } |
|
| 2305 | 2483 | |
| 2306 | 2484 | // we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0]) |
| 2307 | 2485 | if (is_resource($_vcalData)) |
@@ -2667,19 +2845,27 @@ discard block |
||
| 2667 | 2845 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2668 | 2846 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2])); |
| 2669 | 2847 | } |
| 2670 | - else break; |
|
| 2848 | + else { |
|
| 2849 | + break; |
|
| 2850 | + } |
|
| 2671 | 2851 | // fall-through |
| 2672 | 2852 | case 'DAILY': // 2.0 |
| 2673 | 2853 | $vcardData['recur_type'] = MCAL_RECUR_DAILY; |
| 2674 | - if (stripos($recurence, 'BYDAY') === false) break; |
|
| 2854 | + if (stripos($recurence, 'BYDAY') === false) |
|
| 2855 | + { |
|
| 2856 | + break; |
|
| 2857 | + } |
|
| 2675 | 2858 | // hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval |
| 2676 | 2859 | // fall-through |
| 2677 | 2860 | case 'W': |
| 2678 | 2861 | case 'WEEKLY': |
| 2679 | 2862 | $days = array(); |
| 2680 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
| 2863 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) |
|
| 2864 | + { |
|
| 2865 | + // 1.0 |
|
| 2681 | 2866 | { |
| 2682 | 2867 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2868 | + } |
|
| 2683 | 2869 | if (empty($recurenceMatches[2])) |
| 2684 | 2870 | { |
| 2685 | 2871 | $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
@@ -2692,7 +2878,10 @@ discard block |
||
| 2692 | 2878 | $repeatMatches = null; |
| 2693 | 2879 | if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
| 2694 | 2880 | { |
| 2695 | - if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2881 | + if ($repeatMatches[1]) |
|
| 2882 | + { |
|
| 2883 | + $vcardData['recur_count'] = $repeatMatches[1]; |
|
| 2884 | + } |
|
| 2696 | 2885 | } |
| 2697 | 2886 | else |
| 2698 | 2887 | { |
@@ -2701,9 +2890,12 @@ discard block |
||
| 2701 | 2890 | |
| 2702 | 2891 | $recur_days = $this->recur_days_1_0; |
| 2703 | 2892 | } |
| 2704 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
| 2893 | + elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) |
|
| 2894 | + { |
|
| 2895 | + // 2.0 |
|
| 2705 | 2896 | { |
| 2706 | 2897 | $days = explode(',',$recurenceMatches[1]); |
| 2898 | + } |
|
| 2707 | 2899 | $recur_days = $this->recur_days; |
| 2708 | 2900 | } |
| 2709 | 2901 | else // no day given, use the day of dtstart |
@@ -2762,7 +2954,10 @@ discard block |
||
| 2762 | 2954 | { |
| 2763 | 2955 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
| 2764 | 2956 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
| 2765 | - } else break; |
|
| 2957 | + } |
|
| 2958 | + else { |
|
| 2959 | + break; |
|
| 2960 | + } |
|
| 2766 | 2961 | // fall-through |
| 2767 | 2962 | case 'YEARLY': // 2.0 |
| 2768 | 2963 | if (strpos($recurence, 'BYDAY') === false) |
@@ -2782,7 +2977,10 @@ discard block |
||
| 2782 | 2977 | } |
| 2783 | 2978 | break; |
| 2784 | 2979 | case 'EXDATE': |
| 2785 | - if (!$attributes['value']) break; |
|
| 2980 | + if (!$attributes['value']) |
|
| 2981 | + { |
|
| 2982 | + break; |
|
| 2983 | + } |
|
| 2786 | 2984 | if ((isset($attributes['params']['VALUE']) |
| 2787 | 2985 | && $attributes['params']['VALUE'] == 'DATE') || |
| 2788 | 2986 | (!isset($attributes['params']['VALUE']) && $isDate)) |
@@ -2862,13 +3060,16 @@ discard block |
||
| 2862 | 3060 | // fall throught |
| 2863 | 3061 | case 'ATTENDEE': |
| 2864 | 3062 | if (isset($attributes['params']['PARTSTAT'])) |
| 2865 | - { |
|
| 3063 | + { |
|
| 2866 | 3064 | $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
| 2867 | 3065 | } |
| 2868 | 3066 | if (isset($attributes['params']['STATUS'])) |
| 2869 | - { |
|
| 3067 | + { |
|
| 2870 | 3068 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
| 2871 | - if (empty($status)) $status = 'X'; |
|
| 3069 | + if (empty($status)) |
|
| 3070 | + { |
|
| 3071 | + $status = 'X'; |
|
| 3072 | + } |
|
| 2872 | 3073 | } |
| 2873 | 3074 | else |
| 2874 | 3075 | { |
@@ -2928,7 +3129,10 @@ discard block |
||
| 2928 | 3129 | $uid = $this->user; |
| 2929 | 3130 | } |
| 2930 | 3131 | // check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY |
| 2931 | - if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3132 | + if (!$uid) |
|
| 3133 | + { |
|
| 3134 | + $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
| 3135 | + } |
|
| 2932 | 3136 | |
| 2933 | 3137 | // try to find an email address |
| 2934 | 3138 | if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email'))) |
@@ -2996,7 +3200,10 @@ discard block |
||
| 2996 | 3200 | } |
| 2997 | 3201 | $status = 'U'; // keep the group |
| 2998 | 3202 | } |
| 2999 | - else continue; // can't find this group |
|
| 3203 | + else { |
|
| 3204 | + continue; |
|
| 3205 | + } |
|
| 3206 | + // can't find this group |
|
| 3000 | 3207 | } |
| 3001 | 3208 | elseif (empty($searcharray)) |
| 3002 | 3209 | { |
@@ -3055,7 +3262,9 @@ discard block |
||
| 3055 | 3262 | |
| 3056 | 3263 | try { |
| 3057 | 3264 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
| 3058 | - $component->getAttribute('ORGANIZER'); |
|
| 3265 | + { |
|
| 3266 | + $component->getAttribute('ORGANIZER'); |
|
| 3267 | + } |
|
| 3059 | 3268 | } |
| 3060 | 3269 | catch(Horde_Icalendar_Exception $e) |
| 3061 | 3270 | { |
@@ -3092,7 +3301,10 @@ discard block |
||
| 3092 | 3301 | } |
| 3093 | 3302 | break; |
| 3094 | 3303 | case 'CREATED': // will be written direct to the event |
| 3095 | - if ($event['modified']) break; |
|
| 3304 | + if ($event['modified']) |
|
| 3305 | + { |
|
| 3306 | + break; |
|
| 3307 | + } |
|
| 3096 | 3308 | // fall through |
| 3097 | 3309 | case 'LAST-MODIFIED': // will be written direct to the event |
| 3098 | 3310 | $event['modified'] = $attributes['value']; |
@@ -3113,7 +3325,11 @@ discard block |
||
| 3113 | 3325 | break; |
| 3114 | 3326 | |
| 3115 | 3327 | case 'ATTACH': |
| 3116 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
| 3328 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) |
|
| 3329 | + { |
|
| 3330 | + break; |
|
| 3331 | + } |
|
| 3332 | + // handeled by managed attachment code |
|
| 3117 | 3333 | // fall throught to store external attachment url |
| 3118 | 3334 | default: // X- attribute or other by EGroupware unsupported property |
| 3119 | 3335 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3244,7 +3460,10 @@ discard block |
||
| 3244 | 3460 | $event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength']; |
| 3245 | 3461 | } |
| 3246 | 3462 | |
| 3247 | - if ($this->calendarOwner) $event['owner'] = $this->calendarOwner; |
|
| 3463 | + if ($this->calendarOwner) |
|
| 3464 | + { |
|
| 3465 | + $event['owner'] = $this->calendarOwner; |
|
| 3466 | + } |
|
| 3248 | 3467 | |
| 3249 | 3468 | // parsing ATTACH attributes for managed attachments |
| 3250 | 3469 | $event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE'; |
@@ -3270,7 +3489,10 @@ discard block |
||
| 3270 | 3489 | $filter = $relax ? 'relax' : 'check'; |
| 3271 | 3490 | $event = array_shift($events); |
| 3272 | 3491 | $eventId = -1; |
| 3273 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
| 3492 | + if ($this->so->isWholeDay($event)) |
|
| 3493 | + { |
|
| 3494 | + $event['whole_day'] = true; |
|
| 3495 | + } |
|
| 3274 | 3496 | if ($contentID) |
| 3275 | 3497 | { |
| 3276 | 3498 | $parts = preg_split('/:/', $contentID); |
@@ -3323,8 +3545,16 @@ discard block |
||
| 3323 | 3545 | */ |
| 3324 | 3546 | function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
| 3325 | 3547 | { |
| 3326 | - if (!$start) $start = time(); // default now |
|
| 3327 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
| 3548 | + if (!$start) |
|
| 3549 | + { |
|
| 3550 | + $start = time(); |
|
| 3551 | + } |
|
| 3552 | + // default now |
|
| 3553 | + if (!$end) |
|
| 3554 | + { |
|
| 3555 | + $end = time() + 100*DAY_s; |
|
| 3556 | + } |
|
| 3557 | + // default next 100 days |
|
| 3328 | 3558 | |
| 3329 | 3559 | $vcal = new Horde_Icalendar; |
| 3330 | 3560 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
@@ -3346,10 +3576,13 @@ discard block |
||
| 3346 | 3576 | $attributes[$attr] = date('Ymd\THis', $value); |
| 3347 | 3577 | } |
| 3348 | 3578 | } |
| 3349 | - if (is_null($extra)) $extra = array( |
|
| 3579 | + if (is_null($extra)) |
|
| 3580 | + { |
|
| 3581 | + $extra = array( |
|
| 3350 | 3582 | 'URL' => $this->freebusy_url($user), |
| 3351 | 3583 | 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
| 3352 | 3584 | ); |
| 3585 | + } |
|
| 3353 | 3586 | foreach($attributes+$extra as $attr => $value) |
| 3354 | 3587 | { |
| 3355 | 3588 | $vfreebusy->setAttribute($attr, $value); |
@@ -3365,9 +3598,18 @@ discard block |
||
| 3365 | 3598 | { |
| 3366 | 3599 | foreach ($fbdata as $event) |
| 3367 | 3600 | { |
| 3368 | - if ($event['non_blocking']) continue; |
|
| 3369 | - if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue; |
|
| 3370 | - if ($event['participants'][$user] == 'R') continue; |
|
| 3601 | + if ($event['non_blocking']) |
|
| 3602 | + { |
|
| 3603 | + continue; |
|
| 3604 | + } |
|
| 3605 | + if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) |
|
| 3606 | + { |
|
| 3607 | + continue; |
|
| 3608 | + } |
|
| 3609 | + if ($event['participants'][$user] == 'R') |
|
| 3610 | + { |
|
| 3611 | + continue; |
|
| 3612 | + } |
|
| 3371 | 3613 | |
| 3372 | 3614 | $fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY'; |
| 3373 | 3615 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param importepport_iface_egw_record record The egw_record object being imported |
| 75 | 75 | * @param importexport_iface_import_record import_csv Import object contains current state |
| 76 | 76 | * |
| 77 | - * @return boolean success |
|
| 77 | + * @return null|boolean success |
|
| 78 | 78 | */ |
| 79 | 79 | public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
| 80 | 80 | { |
@@ -254,7 +254,6 @@ discard block |
||
| 254 | 254 | * perform the required action |
| 255 | 255 | * |
| 256 | 256 | * @param int $_action one of $this->actions |
| 257 | - * @param array $_data record data for the action |
|
| 258 | 257 | * @return bool success or not |
| 259 | 258 | */ |
| 260 | 259 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
@@ -343,7 +342,7 @@ discard block |
||
| 343 | 342 | /** |
| 344 | 343 | * Alter a row for preview to show multiple participants instead of Array |
| 345 | 344 | * |
| 346 | - * @param egw_record $row_entry |
|
| 345 | + * @param importexport_iface_egw_record $row_entry |
|
| 347 | 346 | */ |
| 348 | 347 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
| 349 | 348 | { |
@@ -32,8 +32,8 @@ |
||
| 32 | 32 | protected static $conditions = array('exists'); |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * For figuring out if an entry has changed |
|
| 36 | - */ |
|
| 35 | + * For figuring out if an entry has changed |
|
| 36 | + */ |
|
| 37 | 37 | protected $tracking; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->role_map = array_flip($this->bo->roles); |
| 58 | 58 | |
| 59 | 59 | $this->lookups = array( |
| 60 | - 'priority' => Array( |
|
| 60 | + 'priority' => array( |
|
| 61 | 61 | 0 => lang('None'), |
| 62 | 62 | 1 => lang('Low'), |
| 63 | 63 | 2 => lang('Normal'), |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return boolean |
| 239 | 239 | */ |
| 240 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
| 240 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$records = array()) |
|
| 241 | 241 | { |
| 242 | 242 | if($record->__get($condition['string']) && $condition['string'] == 'id') { |
| 243 | 243 | $event = $this->bo->read($record->__get($condition['string'])); |
@@ -17,7 +17,8 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for calendar |
| 19 | 19 | */ |
| 20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
| 20 | +class calendar_import_csv extends importexport_basic_import_csv |
|
| 21 | +{ |
|
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * actions wich could be done to data entries |
@@ -83,8 +84,10 @@ discard block |
||
| 83 | 84 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
| 84 | 85 | |
| 85 | 86 | // Set owner, unless it's supposed to come from CSV file |
| 86 | - if($options['owner_from_csv']) { |
|
| 87 | - if(!is_numeric($record['owner'])) { |
|
| 87 | + if($options['owner_from_csv']) |
|
| 88 | + { |
|
| 89 | + if(!is_numeric($record['owner'])) |
|
| 90 | + { |
|
| 88 | 91 | $this->errors[$import_csv->get_current_position()] = lang( |
| 89 | 92 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
| 90 | 93 | $record->owner, |
@@ -106,14 +109,16 @@ discard block |
||
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | // Parse particpants |
| 109 | - if ($record->participants && !is_array($record->participants)) { |
|
| 112 | + if ($record->participants && !is_array($record->participants)) |
|
| 113 | + { |
|
| 110 | 114 | // Importing participants in human friendly format: |
| 111 | 115 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
| 112 | 116 | preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
| 113 | 117 | $p_participants = array(); |
| 114 | 118 | $missing = array(); |
| 115 | 119 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
| 116 | - foreach($names as $key => $name) { |
|
| 120 | + foreach($names as $key => $name) |
|
| 121 | + { |
|
| 117 | 122 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
| 118 | 123 | |
| 119 | 124 | // Search for direct account name, then user in accounts first |
@@ -121,9 +126,13 @@ discard block |
||
| 121 | 126 | $id = importexport_helper_functions::account_name2id($name); |
| 122 | 127 | |
| 123 | 128 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
| 124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 129 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
| 130 | + { |
|
| 125 | 131 | $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
| 126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 132 | + if($contacts) |
|
| 133 | + { |
|
| 134 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | if(!$id) |
| 129 | 138 | { |
@@ -131,7 +140,10 @@ discard block |
||
| 131 | 140 | foreach($this->bo->resources as $resource) |
| 132 | 141 | { |
| 133 | 142 | // Can't search for email |
| 134 | - if($resource['app'] == 'email') continue; |
|
| 143 | + if($resource['app'] == 'email') |
|
| 144 | + { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 135 | 147 | // Special resource search, since it does special stuff in link_query |
| 136 | 148 | if($resource['app'] == 'resources') |
| 137 | 149 | { |
@@ -140,7 +152,8 @@ discard block |
||
| 140 | 152 | $this->resource_so = new resources_so(); |
| 141 | 153 | } |
| 142 | 154 | $result = $this->resource_so->search($search,'res_id'); |
| 143 | - if(count($result) >= 1) { |
|
| 155 | + if(count($result) >= 1) |
|
| 156 | + { |
|
| 144 | 157 | $id = $resource['type'].$result[0]['res_id']; |
| 145 | 158 | break; |
| 146 | 159 | } |
@@ -159,7 +172,8 @@ discard block |
||
| 159 | 172 | } |
| 160 | 173 | } |
| 161 | 174 | } |
| 162 | - if($id) { |
|
| 175 | + if($id) |
|
| 176 | + { |
|
| 163 | 177 | $p_participants[$id] = calendar_so::combine_status( |
| 164 | 178 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
| 165 | 179 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -188,27 +202,38 @@ discard block |
||
| 188 | 202 | } |
| 189 | 203 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
| 190 | 204 | |
| 191 | - if ( $options['conditions'] ) { |
|
| 192 | - foreach ( $options['conditions'] as $condition ) { |
|
| 205 | + if ( $options['conditions'] ) |
|
| 206 | + { |
|
| 207 | + foreach ( $options['conditions'] as $condition ) |
|
| 208 | + { |
|
| 193 | 209 | $records = array(); |
| 194 | - switch ( $condition['type'] ) { |
|
| 210 | + switch ( $condition['type'] ) |
|
| 211 | + { |
|
| 195 | 212 | // exists |
| 196 | 213 | case 'exists' : |
| 197 | 214 | // Check for that record |
| 198 | 215 | $result = $this->exists($record, $condition, $records); |
| 199 | 216 | |
| 200 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 217 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 218 | + { |
|
| 201 | 219 | // apply action to all records matching this exists condition |
| 202 | 220 | $action = $condition['true']; |
| 203 | - foreach ( (array)$records as $event ) { |
|
| 221 | + foreach ( (array)$records as $event ) |
|
| 222 | + { |
|
| 204 | 223 | $record->id = $event['id']; |
| 205 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 206 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
| 224 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
| 225 | + { |
|
| 226 | + if ( !is_array( $record->category ) ) |
|
| 227 | + { |
|
| 228 | + $record->category = explode( ',', $record->category ); |
|
| 229 | + } |
|
| 207 | 230 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
| 208 | 231 | } |
| 209 | 232 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 210 | 233 | } |
| 211 | - } else { |
|
| 234 | + } |
|
| 235 | + else |
|
| 236 | + { |
|
| 212 | 237 | $action = $condition['false']; |
| 213 | 238 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 214 | 239 | } |
@@ -219,9 +244,14 @@ discard block |
||
| 219 | 244 | die('condition / action not supported!!!'); |
| 220 | 245 | break; |
| 221 | 246 | } |
| 222 | - if ($action['last']) break; |
|
| 247 | + if ($action['last']) |
|
| 248 | + { |
|
| 249 | + break; |
|
| 250 | + } |
|
| 223 | 251 | } |
| 224 | - } else { |
|
| 252 | + } |
|
| 253 | + else |
|
| 254 | + { |
|
| 225 | 255 | // unconditional insert |
| 226 | 256 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 227 | 257 | } |
@@ -240,12 +270,14 @@ discard block |
||
| 240 | 270 | */ |
| 241 | 271 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
| 242 | 272 | { |
| 243 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 273 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
| 274 | + { |
|
| 244 | 275 | $event = $this->bo->read($record->__get($condition['string'])); |
| 245 | 276 | $records = array($event); |
| 246 | 277 | } |
| 247 | 278 | |
| 248 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 279 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
| 280 | + { |
|
| 249 | 281 | return true; |
| 250 | 282 | } |
| 251 | 283 | return false; |
@@ -261,7 +293,8 @@ discard block |
||
| 261 | 293 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
| 262 | 294 | { |
| 263 | 295 | $_data = $record->get_record_array(); |
| 264 | - switch ($_action) { |
|
| 296 | + switch ($_action) |
|
| 297 | + { |
|
| 265 | 298 | case 'none' : |
| 266 | 299 | return true; |
| 267 | 300 | case 'update' : |
@@ -269,7 +302,8 @@ discard block |
||
| 269 | 302 | $old = $this->bo->read($_data['id']); |
| 270 | 303 | |
| 271 | 304 | // Don't change a user account into a record |
| 272 | - if(!$this->definition->plugin_options['change_owner']) { |
|
| 305 | + if(!$this->definition->plugin_options['change_owner']) |
|
| 306 | + { |
|
| 273 | 307 | // Don't change owner of an existing record |
| 274 | 308 | unset($_data['owner']); |
| 275 | 309 | } |
@@ -277,23 +311,27 @@ discard block |
||
| 277 | 311 | // Merge to deal with fields not in import record |
| 278 | 312 | $_data = array_merge($old, $_data); |
| 279 | 313 | $changed = $this->tracking->changed_fields($_data, $old); |
| 280 | - if(count($changed) == 0) { |
|
| 314 | + if(count($changed) == 0) |
|
| 315 | + { |
|
| 281 | 316 | return true; |
| 282 | 317 | } |
| 283 | 318 | // Fall through |
| 284 | 319 | case 'insert' : |
| 285 | - if($_action == 'insert') { |
|
| 320 | + if($_action == 'insert') |
|
| 321 | + { |
|
| 286 | 322 | // Backend doesn't like inserting with ID specified, can overwrite existing |
| 287 | 323 | unset($_data['id']); |
| 288 | 324 | } |
| 289 | 325 | // Make sure participants are set |
| 290 | - if(!$_data['participants']) { |
|
| 326 | + if(!$_data['participants']) |
|
| 327 | + { |
|
| 291 | 328 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
| 292 | 329 | $_data['participants'] = array( |
| 293 | 330 | $user => 'U' |
| 294 | 331 | ); |
| 295 | 332 | } |
| 296 | - if ( $this->dry_run ) { |
|
| 333 | + if ( $this->dry_run ) |
|
| 334 | + { |
|
| 297 | 335 | //print_r($_data); |
| 298 | 336 | // User is interested in conflict checks, do so for dry run |
| 299 | 337 | // Otherwise, conflicts are just ignored and imported anyway |
@@ -309,7 +347,9 @@ discard block |
||
| 309 | 347 | } |
| 310 | 348 | $this->results[$_action]++; |
| 311 | 349 | return true; |
| 312 | - } else { |
|
| 350 | + } |
|
| 351 | + else |
|
| 352 | + { |
|
| 313 | 353 | $messages = null; |
| 314 | 354 | $result = $this->bo->update( $_data, |
| 315 | 355 | !$this->definition->plugin_options['skip_conflicts'], |
@@ -360,7 +400,8 @@ discard block |
||
| 360 | 400 | * |
| 361 | 401 | * @return string name |
| 362 | 402 | */ |
| 363 | - public static function get_name() { |
|
| 403 | + public static function get_name() |
|
| 404 | + { |
|
| 364 | 405 | return lang('Calendar CSV import'); |
| 365 | 406 | } |
| 366 | 407 | |
@@ -369,7 +410,8 @@ discard block |
||
| 369 | 410 | * |
| 370 | 411 | * @return string descriprion |
| 371 | 412 | */ |
| 372 | - public static function get_description() { |
|
| 413 | + public static function get_description() |
|
| 414 | + { |
|
| 373 | 415 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
| 374 | 416 | } |
| 375 | 417 | |
@@ -378,7 +420,8 @@ discard block |
||
| 378 | 420 | * |
| 379 | 421 | * @return string suffix (comma seperated) |
| 380 | 422 | */ |
| 381 | - public static function get_filesuffix() { |
|
| 423 | + public static function get_filesuffix() |
|
| 424 | + { |
|
| 382 | 425 | return 'csv'; |
| 383 | 426 | } |
| 384 | 427 | |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * class import_csv for calendar |
| 19 | 19 | */ |
| 20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
| 20 | +class calendar_import_csv extends importexport_basic_import_csv { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * actions wich could be done to data entries |
| 24 | 24 | */ |
| 25 | - protected static $actions = array( 'none', 'update', 'insert' ); |
|
| 25 | + protected static $actions = array('none', 'update', 'insert'); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * conditions for actions |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * Set up tracker |
| 46 | 46 | */ |
| 47 | - protected function init(importexport_definition &$definition) |
|
| 47 | + protected function init(importexport_definition&$definition) |
|
| 48 | 48 | { |
| 49 | 49 | // fetch the addressbook bo |
| 50 | - $this->bo= new calendar_boupdate(); |
|
| 50 | + $this->bo = new calendar_boupdate(); |
|
| 51 | 51 | |
| 52 | 52 | // Get the tracker for changes |
| 53 | 53 | $this->tracking = new calendar_tracking(); |
| 54 | 54 | |
| 55 | 55 | // Used for participants |
| 56 | - $this->status_map = array_flip(array_map('lang',$this->bo->verbose_status)); |
|
| 56 | + $this->status_map = array_flip(array_map('lang', $this->bo->verbose_status)); |
|
| 57 | 57 | $this->role_map = array_flip($this->bo->roles); |
| 58 | 58 | |
| 59 | 59 | $this->lookups = array( |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return boolean success |
| 78 | 78 | */ |
| 79 | - public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
|
| 79 | + public function import_record(\importexport_iface_egw_record&$record, &$import_csv) |
|
| 80 | 80 | { |
| 81 | 81 | // set eventOwner |
| 82 | - $options =& $this->definition->plugin_options; |
|
| 82 | + $options = & $this->definition->plugin_options; |
|
| 83 | 83 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
| 84 | 84 | |
| 85 | 85 | // Set owner, unless it's supposed to come from CSV file |
| 86 | - if($options['owner_from_csv']) { |
|
| 87 | - if(!is_numeric($record['owner'])) { |
|
| 86 | + if ($options['owner_from_csv']) { |
|
| 87 | + if (!is_numeric($record['owner'])) { |
|
| 88 | 88 | $this->errors[$import_csv->get_current_position()] = lang( |
| 89 | 89 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
| 90 | 90 | $record->owner, |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Handle errors in length or start/end date |
| 102 | - if($record->start > $record->end) |
|
| 102 | + if ($record->start > $record->end) |
|
| 103 | 103 | { |
| 104 | 104 | $record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60; |
| 105 | 105 | $this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!'); |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | if ($record->participants && !is_array($record->participants)) { |
| 110 | 110 | // Importing participants in human friendly format: |
| 111 | 111 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
| 112 | - preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
|
| 112 | + preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants); |
|
| 113 | 113 | $p_participants = array(); |
| 114 | 114 | $missing = array(); |
| 115 | 115 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
| 116 | - foreach($names as $key => $name) { |
|
| 116 | + foreach ($names as $key => $name) { |
|
| 117 | 117 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
| 118 | 118 | |
| 119 | 119 | // Search for direct account name, then user in accounts first |
@@ -121,26 +121,26 @@ discard block |
||
| 121 | 121 | $id = importexport_helper_functions::account_name2id($name); |
| 122 | 122 | |
| 123 | 123 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
| 124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 125 | - $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
|
| 126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 124 | + if (!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
| 125 | + $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1)); |
|
| 126 | + if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
| 127 | 127 | } |
| 128 | - if(!$id) |
|
| 128 | + if (!$id) |
|
| 129 | 129 | { |
| 130 | 130 | // Use calendar's registered resources to find participant |
| 131 | - foreach($this->bo->resources as $resource) |
|
| 131 | + foreach ($this->bo->resources as $resource) |
|
| 132 | 132 | { |
| 133 | 133 | // Can't search for email |
| 134 | - if($resource['app'] == 'email') continue; |
|
| 134 | + if ($resource['app'] == 'email') continue; |
|
| 135 | 135 | // Special resource search, since it does special stuff in link_query |
| 136 | - if($resource['app'] == 'resources') |
|
| 136 | + if ($resource['app'] == 'resources') |
|
| 137 | 137 | { |
| 138 | - if(!$this->resource_so) |
|
| 138 | + if (!$this->resource_so) |
|
| 139 | 139 | { |
| 140 | 140 | $this->resource_so = new resources_so(); |
| 141 | 141 | } |
| 142 | - $result = $this->resource_so->search($search,'res_id'); |
|
| 143 | - if(count($result) >= 1) { |
|
| 142 | + $result = $this->resource_so->search($search, 'res_id'); |
|
| 143 | + if (count($result) >= 1) { |
|
| 144 | 144 | $id = $resource['type'].$result[0]['res_id']; |
| 145 | 145 | break; |
| 146 | 146 | } |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | $link_options = array(); |
| 152 | 152 | $result = Link::query($resource['app'], $search, $link_options); |
| 153 | 153 | |
| 154 | - if($result) |
|
| 154 | + if ($result) |
|
| 155 | 155 | { |
| 156 | - $id = $resource['type'] . key($result); |
|
| 156 | + $id = $resource['type'].key($result); |
|
| 157 | 157 | break; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | - if($id) { |
|
| 162 | + if ($id) { |
|
| 163 | 163 | $p_participants[$id] = calendar_so::combine_status( |
| 164 | 164 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
| 165 | 165 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -170,16 +170,16 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $missing[] = $name; |
| 172 | 172 | } |
| 173 | - if(count($missing) > 0) |
|
| 173 | + if (count($missing) > 0) |
|
| 174 | 174 | { |
| 175 | - $this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' . |
|
| 176 | - lang('Contact not found!') . '<br />'.implode(", ",$missing); |
|
| 175 | + $this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '. |
|
| 176 | + lang('Contact not found!').'<br />'.implode(", ", $missing); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | $record->participants = $p_participants; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if($record->recurrence) |
|
| 182 | + if ($record->recurrence) |
|
| 183 | 183 | { |
| 184 | 184 | $start = new Api\DateTime($record->start); |
| 185 | 185 | try |
@@ -194,37 +194,37 @@ discard block |
||
| 194 | 194 | catch (Exception $e) |
| 195 | 195 | { |
| 196 | 196 | // Try old way from export using just recur_type / interval |
| 197 | - list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2); |
|
| 197 | + list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2); |
|
| 198 | 198 | $record->recur_interval = trim($record->recur_interval); |
| 199 | - $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence'])); |
|
| 199 | + $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence'])); |
|
| 200 | 200 | } |
| 201 | 201 | unset($record->recurrence); |
| 202 | 202 | } |
| 203 | 203 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
| 204 | 204 | |
| 205 | - if ( $options['conditions'] ) { |
|
| 206 | - foreach ( $options['conditions'] as $condition ) { |
|
| 205 | + if ($options['conditions']) { |
|
| 206 | + foreach ($options['conditions'] as $condition) { |
|
| 207 | 207 | $records = array(); |
| 208 | - switch ( $condition['type'] ) { |
|
| 208 | + switch ($condition['type']) { |
|
| 209 | 209 | // exists |
| 210 | 210 | case 'exists' : |
| 211 | 211 | // Check for that record |
| 212 | 212 | $result = $this->exists($record, $condition, $records); |
| 213 | 213 | |
| 214 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 214 | + if (is_array($records) && count($records) >= 1) { |
|
| 215 | 215 | // apply action to all records matching this exists condition |
| 216 | 216 | $action = $condition['true']; |
| 217 | - foreach ( (array)$records as $event ) { |
|
| 217 | + foreach ((array)$records as $event) { |
|
| 218 | 218 | $record->id = $event['id']; |
| 219 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 220 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
| 221 | - $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
|
| 219 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
| 220 | + if (!is_array($record->category)) $record->category = explode(',', $record->category); |
|
| 221 | + $record->category = implode(',', array_unique(array_merge($record->category, $event['category']))); |
|
| 222 | 222 | } |
| 223 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
| 223 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
| 224 | 224 | } |
| 225 | 225 | } else { |
| 226 | 226 | $action = $condition['false']; |
| 227 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 227 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 228 | 228 | } |
| 229 | 229 | break; |
| 230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | } else { |
| 239 | 239 | // unconditional insert |
| 240 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
| 240 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | return $success; |
@@ -252,14 +252,14 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return boolean |
| 254 | 254 | */ |
| 255 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
| 255 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array()) |
|
| 256 | 256 | { |
| 257 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 257 | + if ($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
| 258 | 258 | $event = $this->bo->read($record->__get($condition['string'])); |
| 259 | 259 | $records = array($event); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
| 262 | + if (is_array($records) && count($records) >= 1) { |
|
| 263 | 263 | return true; |
| 264 | 264 | } |
| 265 | 265 | return false; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param array $_data record data for the action |
| 273 | 273 | * @return bool success or not |
| 274 | 274 | */ |
| 275 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
| 275 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) |
|
| 276 | 276 | { |
| 277 | 277 | $_data = $record->get_record_array(); |
| 278 | 278 | switch ($_action) { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $old = $this->bo->read($_data['id']); |
| 284 | 284 | |
| 285 | 285 | // Don't change a user account into a record |
| 286 | - if(!$this->definition->plugin_options['change_owner']) { |
|
| 286 | + if (!$this->definition->plugin_options['change_owner']) { |
|
| 287 | 287 | // Don't change owner of an existing record |
| 288 | 288 | unset($_data['owner']); |
| 289 | 289 | } |
@@ -291,30 +291,30 @@ discard block |
||
| 291 | 291 | // Merge to deal with fields not in import record |
| 292 | 292 | $_data = array_merge($old, $_data); |
| 293 | 293 | $changed = $this->tracking->changed_fields($_data, $old); |
| 294 | - if(count($changed) == 0) { |
|
| 294 | + if (count($changed) == 0) { |
|
| 295 | 295 | return true; |
| 296 | 296 | } |
| 297 | 297 | // Fall through |
| 298 | 298 | case 'insert' : |
| 299 | - if($_action == 'insert') { |
|
| 299 | + if ($_action == 'insert') { |
|
| 300 | 300 | // Backend doesn't like inserting with ID specified, can overwrite existing |
| 301 | 301 | unset($_data['id']); |
| 302 | 302 | } |
| 303 | 303 | // Make sure participants are set |
| 304 | - if(!$_data['participants']) { |
|
| 304 | + if (!$_data['participants']) { |
|
| 305 | 305 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
| 306 | 306 | $_data['participants'] = array( |
| 307 | 307 | $user => 'U' |
| 308 | 308 | ); |
| 309 | 309 | } |
| 310 | - if ( $this->dry_run ) { |
|
| 310 | + if ($this->dry_run) { |
|
| 311 | 311 | //print_r($_data); |
| 312 | 312 | // User is interested in conflict checks, do so for dry run |
| 313 | 313 | // Otherwise, conflicts are just ignored and imported anyway |
| 314 | - if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
| 314 | + if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking']) |
|
| 315 | 315 | { |
| 316 | 316 | $conflicts = $this->bo->conflicts($_data); |
| 317 | - if($conflicts) |
|
| 317 | + if ($conflicts) |
|
| 318 | 318 | { |
| 319 | 319 | $this->conflict_warning($record_num, $conflicts); |
| 320 | 320 | $this->results['skipped']++; |
@@ -325,15 +325,15 @@ discard block |
||
| 325 | 325 | return true; |
| 326 | 326 | } else { |
| 327 | 327 | $messages = null; |
| 328 | - $result = $this->bo->update( $_data, |
|
| 328 | + $result = $this->bo->update($_data, |
|
| 329 | 329 | !$this->definition->plugin_options['skip_conflicts'], |
| 330 | 330 | true, $this->is_admin, true, $messages, |
| 331 | 331 | $this->definition->plugin_options['no_notification'] |
| 332 | 332 | ); |
| 333 | - if(!$result) |
|
| 333 | + if (!$result) |
|
| 334 | 334 | { |
| 335 | - $this->errors[$record_num] = lang('Unable to save') . "\n" . |
|
| 336 | - implode("\n",$messages); |
|
| 335 | + $this->errors[$record_num] = lang('Unable to save')."\n". |
|
| 336 | + implode("\n", $messages); |
|
| 337 | 337 | } |
| 338 | 338 | else if (is_array($result)) |
| 339 | 339 | { |
@@ -363,10 +363,10 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | protected function conflict_warning($record_num, &$conflicts) |
| 365 | 365 | { |
| 366 | - $this->warnings[$record_num] = lang('Conflicts') . ':'; |
|
| 367 | - foreach($conflicts as $conflict) |
|
| 366 | + $this->warnings[$record_num] = lang('Conflicts').':'; |
|
| 367 | + foreach ($conflicts as $conflict) |
|
| 368 | 368 | { |
| 369 | - $this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title']; |
|
| 369 | + $this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title']; |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | * |
| 403 | 403 | * @param egw_record $row_entry |
| 404 | 404 | */ |
| 405 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
| 405 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
| 406 | 406 | { |
| 407 | - $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true)); |
|
| 407 | + $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true)); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | } |
| 411 | 411 | \ No newline at end of file |