@@ -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 Separated 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 | * |
@@ -1878,12 +1878,12 @@ discard block |
||
| 1878 | 1878 | */ |
| 1879 | 1879 | function event2array($event) |
| 1880 | 1880 | { |
| 1881 | - $var['title'] = Array( |
|
| 1881 | + $var['title'] = array( |
|
| 1882 | 1882 | 'field' => lang('Title'), |
| 1883 | 1883 | 'data' => $event['title'] |
| 1884 | 1884 | ); |
| 1885 | 1885 | |
| 1886 | - $var['description'] = Array( |
|
| 1886 | + $var['description'] = array( |
|
| 1887 | 1887 | 'field' => lang('Description'), |
| 1888 | 1888 | 'data' => $event['description'] |
| 1889 | 1889 | ); |
@@ -1892,48 +1892,48 @@ discard block |
||
| 1892 | 1892 | { |
| 1893 | 1893 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1894 | 1894 | } |
| 1895 | - $var['category'] = Array( |
|
| 1895 | + $var['category'] = array( |
|
| 1896 | 1896 | 'field' => lang('Category'), |
| 1897 | 1897 | 'data' => implode(', ',$cat_string) |
| 1898 | 1898 | ); |
| 1899 | 1899 | |
| 1900 | - $var['location'] = Array( |
|
| 1900 | + $var['location'] = array( |
|
| 1901 | 1901 | 'field' => lang('Location'), |
| 1902 | 1902 | 'data' => $event['location'] |
| 1903 | 1903 | ); |
| 1904 | 1904 | |
| 1905 | - $var['startdate'] = Array( |
|
| 1905 | + $var['startdate'] = array( |
|
| 1906 | 1906 | 'field' => lang('Start Date/Time'), |
| 1907 | 1907 | 'data' => $this->format_date($event['start']), |
| 1908 | 1908 | ); |
| 1909 | 1909 | |
| 1910 | - $var['enddate'] = Array( |
|
| 1910 | + $var['enddate'] = array( |
|
| 1911 | 1911 | 'field' => lang('End Date/Time'), |
| 1912 | 1912 | 'data' => $this->format_date($event['end']), |
| 1913 | 1913 | ); |
| 1914 | 1914 | |
| 1915 | - $pri = Array( |
|
| 1915 | + $pri = array( |
|
| 1916 | 1916 | 0 => lang('None'), |
| 1917 | 1917 | 1 => lang('Low'), |
| 1918 | 1918 | 2 => lang('Normal'), |
| 1919 | 1919 | 3 => lang('High') |
| 1920 | 1920 | ); |
| 1921 | - $var['priority'] = Array( |
|
| 1921 | + $var['priority'] = array( |
|
| 1922 | 1922 | 'field' => lang('Priority'), |
| 1923 | 1923 | 'data' => $pri[$event['priority']] |
| 1924 | 1924 | ); |
| 1925 | 1925 | |
| 1926 | - $var['owner'] = Array( |
|
| 1926 | + $var['owner'] = array( |
|
| 1927 | 1927 | 'field' => lang('Owner'), |
| 1928 | 1928 | 'data' => Api\Accounts::username($event['owner']) |
| 1929 | 1929 | ); |
| 1930 | 1930 | |
| 1931 | - $var['updated'] = Array( |
|
| 1931 | + $var['updated'] = array( |
|
| 1932 | 1932 | 'field' => lang('Updated'), |
| 1933 | 1933 | 'data' => $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier']) |
| 1934 | 1934 | ); |
| 1935 | 1935 | |
| 1936 | - $var['access'] = Array( |
|
| 1936 | + $var['access'] = array( |
|
| 1937 | 1937 | 'field' => lang('Access'), |
| 1938 | 1938 | 'data' => $event['public'] ? lang('Public') : lang('Private') |
| 1939 | 1939 | ); |
@@ -1956,13 +1956,13 @@ discard block |
||
| 1956 | 1956 | } |
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | - $var['participants'] = Array( |
|
| 1959 | + $var['participants'] = array( |
|
| 1960 | 1960 | 'field' => lang('Participants'), |
| 1961 | 1961 | 'data' => $participants |
| 1962 | 1962 | ); |
| 1963 | 1963 | |
| 1964 | 1964 | // Repeated Events |
| 1965 | - $var['recur_type'] = Array( |
|
| 1965 | + $var['recur_type'] = array( |
|
| 1966 | 1966 | 'field' => lang('Repetition'), |
| 1967 | 1967 | 'data' => ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '', |
| 1968 | 1968 | ); |
@@ -2012,7 +2012,7 @@ discard block |
||
| 2012 | 2012 | * @param Api\DateTime|int|null $instance_date For recurring events, this is the date we |
| 2013 | 2013 | * are dealing with |
| 2014 | 2014 | */ |
| 2015 | - function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
|
| 2015 | + function check_move_alarms(array &$event, array $old_event = null, $instance_date = null) |
|
| 2016 | 2016 | { |
| 2017 | 2017 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 2018 | 2018 | |
@@ -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,16 +116,16 @@ 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 | - unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
| 121 | + unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
| 122 | 122 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 123 | 123 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
| 124 | 124 | |
| 125 | 125 | if ($this->debug > 1 || $this->debug == 'update') |
| 126 | 126 | { |
| 127 | 127 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
| 128 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
| 128 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
| 129 | 129 | } |
| 130 | 130 | // check some minimum requirements: |
| 131 | 131 | // - new events need start, end and title |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // check if user has the permission to update / create the event |
| 156 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 157 | - $new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) && |
|
| 158 | - !$this->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 156 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 157 | + $new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) && |
|
| 158 | + !$this->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 159 | 159 | { |
| 160 | - $messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner'])); |
|
| 160 | + $messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner'])); |
|
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | if ($new_event) |
@@ -166,24 +166,24 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | else |
| 168 | 168 | { |
| 169 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
| 169 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // do we need to check, if user is allowed to invite the invited participants |
| 173 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
| 173 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
| 174 | 174 | { |
| 175 | 175 | // report removed participants back to user |
| 176 | - foreach($removed as $key => $account_id) |
|
| 176 | + foreach ($removed as $key => $account_id) |
|
| 177 | 177 | { |
| 178 | 178 | $removed[$key] = $this->participant_name($account_id); |
| 179 | 179 | } |
| 180 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
| 181 | - ': '.implode(', ',$removed); |
|
| 180 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
| 181 | + ': '.implode(', ', $removed); |
|
| 182 | 182 | } |
| 183 | 183 | // check category based ACL |
| 184 | 184 | if ($event['category']) |
| 185 | 185 | { |
| 186 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 186 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
| 187 | 187 | if (!$old_event || !isset($old_event['category'])) |
| 188 | 188 | { |
| 189 | 189 | $old_event['category'] = array(); |
@@ -192,38 +192,38 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $old_event['category'] = explode(',', $old_event['category']); |
| 194 | 194 | } |
| 195 | - foreach($event['category'] as $key => $cat_id) |
|
| 195 | + foreach ($event['category'] as $key => $cat_id) |
|
| 196 | 196 | { |
| 197 | 197 | // check if user is allowed to update event categories |
| 198 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
| 199 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
| 198 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
| 199 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
| 200 | 200 | { |
| 201 | 201 | unset($event['category'][$key]); |
| 202 | 202 | // report removed category to user |
| 203 | 203 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
| 204 | - continue; // no further check, as cat was removed |
|
| 204 | + continue; // no further check, as cat was removed |
|
| 205 | 205 | } |
| 206 | 206 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
| 207 | 207 | if (!$status_reset_to_unknown && |
| 208 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
| 208 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
| 209 | 209 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
| 210 | 210 | { |
| 211 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 211 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 212 | 212 | { |
| 213 | 213 | $q = $r = null; |
| 214 | - calendar_so::split_status($status,$q,$r); |
|
| 214 | + calendar_so::split_status($status, $q, $r); |
|
| 215 | 215 | if ($status != 'U') |
| 216 | 216 | { |
| 217 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 217 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 218 | 218 | // todo: report reset status to user |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - $status_reset_to_unknown = true; // once is enough |
|
| 221 | + $status_reset_to_unknown = true; // once is enough |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | if ($removed_cats) |
| 225 | 225 | { |
| 226 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
| 226 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
| 227 | 227 | } |
| 228 | 228 | if ($status_reset_to_unknown) |
| 229 | 229 | { |
@@ -259,30 +259,30 @@ discard block |
||
| 259 | 259 | $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); |
| 260 | 260 | //error_log("new $cal_id=". array2string($event)); |
| 261 | 261 | |
| 262 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
| 262 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
| 263 | 263 | { |
| 264 | 264 | // Restored, bring back links |
| 265 | 265 | Link::restore('calendar', $cal_id); |
| 266 | 266 | } |
| 267 | 267 | if ($this->log_file) |
| 268 | 268 | { |
| 269 | - $this->log2file($event2save,$event,$old_event); |
|
| 269 | + $this->log2file($event2save, $event, $old_event); |
|
| 270 | 270 | } |
| 271 | 271 | // send notifications |
| 272 | - if(!$skip_notification) |
|
| 272 | + if (!$skip_notification) |
|
| 273 | 273 | { |
| 274 | 274 | if ($new_event) |
| 275 | 275 | { |
| 276 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
| 276 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
| 277 | 277 | } |
| 278 | 278 | else // update existing event |
| 279 | 279 | { |
| 280 | - $this->check4update($event,$old_event); |
|
| 280 | + $this->check4update($event, $old_event); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | // notify the link-class about the update, as other apps may be subscribt to it |
| 285 | - Link::notify_update('calendar',$cal_id,$event); |
|
| 285 | + Link::notify_update('calendar', $cal_id, $event); |
|
| 286 | 286 | |
| 287 | 287 | return $cal_id; |
| 288 | 288 | } |
@@ -300,27 +300,27 @@ discard block |
||
| 300 | 300 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
| 301 | 301 | * @return array or events |
| 302 | 302 | */ |
| 303 | - function conflicts(array $event, &$checked_excluding=null) |
|
| 303 | + function conflicts(array $event, &$checked_excluding = null) |
|
| 304 | 304 | { |
| 305 | 305 | $types_with_quantity = array(); |
| 306 | - foreach($this->resources as $type => $data) |
|
| 306 | + foreach ($this->resources as $type => $data) |
|
| 307 | 307 | { |
| 308 | 308 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
| 309 | 309 | } |
| 310 | 310 | // get all NOT rejected participants and evtl. their quantity |
| 311 | 311 | $quantity = $users = array(); |
| 312 | - foreach($event['participants'] as $uid => $status) |
|
| 312 | + foreach ($event['participants'] as $uid => $status) |
|
| 313 | 313 | { |
| 314 | 314 | $q = $role = null; |
| 315 | 315 | calendar_so::split_status($status, $q, $role); |
| 316 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 316 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 317 | 317 | |
| 318 | 318 | if ($uid < 0) // group, check it's members too |
| 319 | 319 | { |
| 320 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
| 320 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
| 321 | 321 | } |
| 322 | 322 | $users[] = $uid; |
| 323 | - if (in_array($uid[0],$types_with_quantity)) |
|
| 323 | + if (in_array($uid[0], $types_with_quantity)) |
|
| 324 | 324 | { |
| 325 | 325 | $quantity[$uid] = $q; |
| 326 | 326 | } |
@@ -343,58 +343,58 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | $checked = 0; |
| 345 | 345 | $start = microtime(true); |
| 346 | - $duration = $event['end']-$event['start']; |
|
| 347 | - foreach($recurences as $date) |
|
| 346 | + $duration = $event['end'] - $event['start']; |
|
| 347 | + foreach ($recurences as $date) |
|
| 348 | 348 | { |
| 349 | 349 | $startts = $date->format('ts'); |
| 350 | 350 | |
| 351 | 351 | // skip past events or recurrences |
| 352 | - if ($startts+$duration < $this->now_su) continue; |
|
| 352 | + if ($startts + $duration < $this->now_su) continue; |
|
| 353 | 353 | |
| 354 | 354 | // abort check if configured limits are exceeded |
| 355 | 355 | if ($event['recur_type'] && |
| 356 | 356 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 357 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
| 357 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
| 358 | 358 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
| 359 | 359 | { |
| 360 | 360 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 361 | 361 | { |
| 362 | 362 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 363 | - $checked, microtime(true)-$start, $date); |
|
| 363 | + $checked, microtime(true) - $start, $date); |
|
| 364 | 364 | } |
| 365 | 365 | $checked_excluding = $date; |
| 366 | 366 | break; |
| 367 | 367 | } |
| 368 | - $overlapping_events =& $this->search(array( |
|
| 368 | + $overlapping_events = & $this->search(array( |
|
| 369 | 369 | 'start' => $startts, |
| 370 | - 'end' => $startts+$duration, |
|
| 370 | + 'end' => $startts + $duration, |
|
| 371 | 371 | 'users' => $users, |
| 372 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 373 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
| 372 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 373 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
| 374 | 374 | 'query' => array( |
| 375 | 375 | 'cal_non_blocking' => 0, |
| 376 | 376 | ), |
| 377 | - 'no_integration' => true, // do NOT use integration of other apps |
|
| 377 | + 'no_integration' => true, // do NOT use integration of other apps |
|
| 378 | 378 | )); |
| 379 | 379 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 380 | 380 | { |
| 381 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
| 381 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
| 382 | 382 | } |
| 383 | - foreach((array) $overlapping_events as $k => $overlap) |
|
| 383 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
| 384 | 384 | { |
| 385 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 386 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 385 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 386 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 387 | 387 | $overlap['non_blocking']) // that's a non_blocking event |
| 388 | 388 | { |
| 389 | 389 | continue; |
| 390 | 390 | } |
| 391 | 391 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 392 | 392 | { |
| 393 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
| 393 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
| 394 | 394 | } |
| 395 | 395 | // check if the overlap is with a rejected participant or within the allowed quantity |
| 396 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
| 397 | - foreach($common_parts as $n => $uid) |
|
| 396 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
| 397 | + foreach ($common_parts as $n => $uid) |
|
| 398 | 398 | { |
| 399 | 399 | $status = $overlap['participants'][$uid]; |
| 400 | 400 | calendar_so::split_status($status, $q, $role); |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | unset($common_parts[$n]); |
| 404 | 404 | continue; |
| 405 | 405 | } |
| 406 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
| 406 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
| 407 | 407 | { |
| 408 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 408 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 409 | 409 | } |
| 410 | 410 | if (!isset($max_quantity[$uid])) |
| 411 | 411 | { |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $quantity[$uid] += $q; |
| 416 | 416 | if ($quantity[$uid] <= $max_quantity[$uid]) |
| 417 | 417 | { |
| 418 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
| 418 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
| 419 | 419 | unset($common_parts[$n]); |
| 420 | 420 | continue; |
| 421 | 421 | } |
@@ -425,22 +425,22 @@ discard block |
||
| 425 | 425 | { |
| 426 | 426 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 427 | 427 | { |
| 428 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
| 428 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
| 429 | 429 | } |
| 430 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
| 430 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
| 435 | 435 | // check if we are withing the allowed quantity and if not add all events using that resource |
| 436 | 436 | // seems this function is doing very strange things, it gives empty conflicts |
| 437 | - foreach($max_quantity as $uid => $max) |
|
| 437 | + foreach ($max_quantity as $uid => $max) |
|
| 438 | 438 | { |
| 439 | 439 | if ($quantity[$uid] > $max) |
| 440 | 440 | { |
| 441 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 441 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 442 | 442 | { |
| 443 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
| 443 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
| 444 | 444 | } |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | if (count($conflicts)) |
| 450 | 450 | { |
| 451 | - foreach($conflicts as $key => $conflict) |
|
| 451 | + foreach ($conflicts as $key => $conflict) |
|
| 452 | 452 | { |
| 453 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 454 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
| 453 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 454 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
| 455 | 455 | { |
| 456 | 456 | $conflicts[$key] = array( |
| 457 | 457 | 'id' => $conflict['id'], |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | } |
| 465 | 465 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 466 | 466 | { |
| 467 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
| 467 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | return $conflicts; |
@@ -476,22 +476,22 @@ discard block |
||
| 476 | 476 | * @param array $old_event =null old event with already invited participants |
| 477 | 477 | * @return array removed participants because of missing invite grants |
| 478 | 478 | */ |
| 479 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
| 479 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
| 480 | 480 | { |
| 481 | 481 | if (!$this->require_acl_invite) |
| 482 | 482 | { |
| 483 | - return array(); // nothing to check, everyone can invite everyone else |
|
| 483 | + return array(); // nothing to check, everyone can invite everyone else |
|
| 484 | 484 | } |
| 485 | 485 | if ($event['id'] && is_null($old_event)) |
| 486 | 486 | { |
| 487 | 487 | $old_event = $this->read($event['id']); |
| 488 | 488 | } |
| 489 | 489 | $removed = array(); |
| 490 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
| 490 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
| 491 | 491 | { |
| 492 | 492 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
| 493 | 493 | { |
| 494 | - unset($event['participants'][$uid]); // remove participant |
|
| 494 | + unset($event['participants'][$uid]); // remove participant |
|
| 495 | 495 | $removed[] = $uid; |
| 496 | 496 | } |
| 497 | 497 | } |
@@ -514,15 +514,15 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | elseif (!$this->require_acl_invite) |
| 516 | 516 | { |
| 517 | - $ret = true; // no grant required |
|
| 517 | + $ret = true; // no grant required |
|
| 518 | 518 | } |
| 519 | 519 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
| 520 | 520 | { |
| 521 | - $ret = true; // grant only required for groups |
|
| 521 | + $ret = true; // grant only required for groups |
|
| 522 | 522 | } |
| 523 | 523 | else |
| 524 | 524 | { |
| 525 | - $ret = $this->check_perms(self::ACL_INVITE,0,$uid); |
|
| 525 | + $ret = $this->check_perms(self::ACL_INVITE, 0, $uid); |
|
| 526 | 526 | } |
| 527 | 527 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
| 528 | 528 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | * @param array $old_event the event before the update |
| 537 | 537 | * @todo check if there is a real change, not assume every save is a change |
| 538 | 538 | */ |
| 539 | - function check4update($new_event,$old_event) |
|
| 539 | + function check4update($new_event, $old_event) |
|
| 540 | 540 | { |
| 541 | 541 | //error_log(__METHOD__."($new_event[title])"); |
| 542 | 542 | $modified = $added = $deleted = array(); |
@@ -544,9 +544,9 @@ discard block |
||
| 544 | 544 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
| 545 | 545 | |
| 546 | 546 | // Find modified and deleted participants ... |
| 547 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
| 547 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
| 548 | 548 | { |
| 549 | - if(isset($new_event['participants'][$old_userid])) |
|
| 549 | + if (isset($new_event['participants'][$old_userid])) |
|
| 550 | 550 | { |
| 551 | 551 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
| 552 | 552 | } |
@@ -556,27 +556,27 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | // Find new participants ... |
| 559 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
| 559 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
| 560 | 560 | { |
| 561 | - if(!isset($old_event['participants'][$new_userid])) |
|
| 561 | + if (!isset($old_event['participants'][$new_userid])) |
|
| 562 | 562 | { |
| 563 | 563 | $added[$new_userid] = 'U'; |
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
| 567 | - if(count($added) || count($modified) || count($deleted)) |
|
| 567 | + if (count($added) || count($modified) || count($deleted)) |
|
| 568 | 568 | { |
| 569 | - if(count($added)) |
|
| 569 | + if (count($added)) |
|
| 570 | 570 | { |
| 571 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
| 571 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
| 572 | 572 | } |
| 573 | - if(count($modified)) |
|
| 573 | + if (count($modified)) |
|
| 574 | 574 | { |
| 575 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
| 575 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
| 576 | 576 | } |
| 577 | - if(count($deleted)) |
|
| 577 | + if (count($deleted)) |
|
| 578 | 578 | { |
| 579 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
| 579 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -593,11 +593,11 @@ discard block |
||
| 593 | 593 | * @param string $status of current user |
| 594 | 594 | * @return boolean true = update requested, false otherwise |
| 595 | 595 | */ |
| 596 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
| 596 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
| 597 | 597 | { |
| 598 | 598 | if ($msg_type == MSG_ALARM) |
| 599 | 599 | { |
| 600 | - return True; // always True for now |
|
| 600 | + return True; // always True for now |
|
| 601 | 601 | } |
| 602 | 602 | $want_update = 0; |
| 603 | 603 | |
@@ -610,13 +610,13 @@ discard block |
||
| 610 | 610 | if (!is_numeric($userid) && $role == 'CHAIR' && |
| 611 | 611 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
| 612 | 612 | { |
| 613 | - switch($msg_type) |
|
| 613 | + switch ($msg_type) |
|
| 614 | 614 | { |
| 615 | 615 | case MSG_DELETED: // treat deleting event as rejection to organizer |
| 616 | 616 | $msg_type = MSG_REJECTED; |
| 617 | 617 | break; |
| 618 | 618 | case MSG_ADDED: // new events use added, but organizer needs status |
| 619 | - switch($status[0]) |
|
| 619 | + switch ($status[0]) |
|
| 620 | 620 | { |
| 621 | 621 | case 'A': $msg_type = MSG_ACCEPTED; break; |
| 622 | 622 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | } |
| 630 | 630 | else |
| 631 | 631 | { |
| 632 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
| 632 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
| 633 | 633 | { |
| 634 | 634 | case 'responses': |
| 635 | 635 | ++$want_update; |
@@ -643,8 +643,8 @@ discard block |
||
| 643 | 643 | default: |
| 644 | 644 | if (is_array($new_event) && is_array($old_event)) |
| 645 | 645 | { |
| 646 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
| 647 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
| 646 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
| 647 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
| 648 | 648 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
| 649 | 649 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
| 650 | 650 | { |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * @param string $role ='REQ-PARTICIPANT' |
| 675 | 675 | * @return boolean true if user requested to be notified, false if not |
| 676 | 676 | */ |
| 677 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
| 677 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
| 678 | 678 | { |
| 679 | 679 | // check if email is from a user |
| 680 | 680 | if (is_numeric($user_or_email)) |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | ) |
| 699 | 699 | ); |
| 700 | 700 | } |
| 701 | - switch($ical_method) |
|
| 701 | + switch ($ical_method) |
|
| 702 | 702 | { |
| 703 | 703 | default: |
| 704 | 704 | case 'REQUEST': |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | * @param string& $action=null on return verbose name |
| 724 | 724 | * @param string& $msg=null on return notification message |
| 725 | 725 | */ |
| 726 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
| 726 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
| 727 | 727 | { |
| 728 | - switch($msg_type) |
|
| 728 | + switch ($msg_type) |
|
| 729 | 729 | { |
| 730 | 730 | case MSG_DELETED: |
| 731 | 731 | $action = 'Canceled'; |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | $msg = $this->cal_prefs['notify'.$pref]; |
| 778 | 778 | if (empty($msg)) |
| 779 | 779 | { |
| 780 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 780 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 781 | 781 | } |
| 782 | 782 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
| 783 | 783 | return $method; |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | * @param int $user =0 User who started the notify, default current user |
| 794 | 794 | * @return bool true/false |
| 795 | 795 | */ |
| 796 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
| 796 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
| 797 | 797 | { |
| 798 | 798 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
| 799 | 799 | if (!is_array($to_notify)) |
@@ -805,11 +805,11 @@ discard block |
||
| 805 | 805 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
| 806 | 806 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
| 807 | 807 | { |
| 808 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 808 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
| 812 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 812 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 813 | 813 | { |
| 814 | 814 | return False; |
| 815 | 815 | } |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | $restore_tz = $tz; |
| 820 | 820 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
| 821 | 821 | } |
| 822 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 822 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 823 | 823 | |
| 824 | 824 | if (!$user) |
| 825 | 825 | { |
@@ -835,16 +835,16 @@ discard block |
||
| 835 | 835 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
| 836 | 836 | |
| 837 | 837 | // add all group-members to the notification, unless they are already participants |
| 838 | - foreach($to_notify as $userid => $statusid) |
|
| 838 | + foreach ($to_notify as $userid => $statusid) |
|
| 839 | 839 | { |
| 840 | 840 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
| 841 | 841 | ($members = $GLOBALS['egw']->accounts->members($userid, true))) |
| 842 | 842 | { |
| 843 | - foreach($members as $member) |
|
| 843 | + foreach ($members as $member) |
|
| 844 | 844 | { |
| 845 | 845 | if (!isset($to_notify[$member])) |
| 846 | 846 | { |
| 847 | - $to_notify[$member] = 'G'; // Group-invitation |
|
| 847 | + $to_notify[$member] = 'G'; // Group-invitation |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | } |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | { |
| 856 | 856 | // check if we have *only* an external chair |
| 857 | 857 | $chair = null; |
| 858 | - foreach($to_notify as $userid => $statusid) |
|
| 858 | + foreach ($to_notify as $userid => $statusid) |
|
| 859 | 859 | { |
| 860 | 860 | $res_info = $quantity = $role = null; |
| 861 | 861 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -867,7 +867,7 @@ discard block |
||
| 867 | 867 | // *only* an external chair --> do not notify anyone, but the external chair and the current user |
| 868 | 868 | if (!empty($chair) && !is_numeric($chair)) |
| 869 | 869 | { |
| 870 | - $to_notify = array($chair => $to_notify[$chair])+ |
|
| 870 | + $to_notify = array($chair => $to_notify[$chair]) + |
|
| 871 | 871 | (isset($to_notify[$user]) ? array($user => $to_notify[$user]) : array()); |
| 872 | 872 | } |
| 873 | 873 | } |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
| 879 | 879 | //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() : '')); |
| 880 | 880 | $owner_prefs = $ics = null; |
| 881 | - foreach($to_notify as $userid => $statusid) |
|
| 881 | + foreach ($to_notify as $userid => $statusid) |
|
| 882 | 882 | { |
| 883 | 883 | $res_info = $quantity = $role = null; |
| 884 | 884 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -901,14 +901,14 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | if (!isset($userid)) |
| 903 | 903 | { |
| 904 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 904 | + if (empty($res_info['email'])) continue; // no way to notify |
|
| 905 | 905 | // check if event-owner wants non-EGroupware users notified |
| 906 | 906 | if (is_null($owner_prefs)) |
| 907 | 907 | { |
| 908 | 908 | $preferences = new Api\Preferences($owner); |
| 909 | 909 | $owner_prefs = $preferences->read_repository(); |
| 910 | 910 | } |
| 911 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 911 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 912 | 912 | (empty($owner_prefs['calendar']['notify_externals']) || |
| 913 | 913 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
| 914 | 914 | { |
@@ -920,12 +920,12 @@ discard block |
||
| 920 | 920 | |
| 921 | 921 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
| 922 | 922 | { |
| 923 | - continue; // dont notify rejected participants or groups |
|
| 923 | + continue; // dont notify rejected participants or groups |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 926 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 927 | 927 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
| 928 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
| 928 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
| 929 | 929 | $msg_type == MSG_ALARM) |
| 930 | 930 | { |
| 931 | 931 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -934,8 +934,8 @@ discard block |
||
| 934 | 934 | $preferences = new Api\Preferences($userid); |
| 935 | 935 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
| 936 | 936 | $fullname = Api\Accounts::username($userid); |
| 937 | - $tfn = Api\Accounts::id2name($userid,'account_firstname'); |
|
| 938 | - $tln = Api\Accounts::id2name($userid,'account_lastname'); |
|
| 937 | + $tfn = Api\Accounts::id2name($userid, 'account_firstname'); |
|
| 938 | + $tln = Api\Accounts::id2name($userid, 'account_lastname'); |
|
| 939 | 939 | } |
| 940 | 940 | else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
| 941 | 941 | { |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | } |
| 947 | 947 | $part_prefs = $owner_prefs; |
| 948 | 948 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
| 949 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 949 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 950 | 950 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
| 951 | 951 | } |
| 952 | 952 | $m_type = $msg_type; |
@@ -971,14 +971,14 @@ discard block |
||
| 971 | 971 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 972 | 972 | $action, $event_arr, $disinvited); |
| 973 | 973 | $details['to-fullname'] = $fullname; |
| 974 | - $details['to-firstname'] = isset($tfn)? $tfn: ''; |
|
| 975 | - $details['to-lastname'] = isset($tln)? $tln: ''; |
|
| 974 | + $details['to-firstname'] = isset($tfn) ? $tfn : ''; |
|
| 975 | + $details['to-lastname'] = isset($tln) ? $tln : ''; |
|
| 976 | 976 | |
| 977 | 977 | // 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 |
| 978 | 978 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
| 979 | 979 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 980 | 980 | $timeformat = $part_prefs['common']['timeformat']; |
| 981 | - switch($timeformat) |
|
| 981 | + switch ($timeformat) |
|
| 982 | 982 | { |
| 983 | 983 | case '24': |
| 984 | 984 | $timeformat = 'H:i'; |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | $timeformat = 'h:i a'; |
| 988 | 988 | break; |
| 989 | 989 | } |
| 990 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
| 990 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
| 991 | 991 | |
| 992 | 992 | $startdate->setTimezone($timezone); |
| 993 | 993 | $details['startdate'] = $startdate->format($timeformat); |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | $details['enddate'] = $enddate->format($timeformat); |
| 997 | 997 | |
| 998 | 998 | $modified->setTimezone($timezone); |
| 999 | - $details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']); |
|
| 999 | + $details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']); |
|
| 1000 | 1000 | |
| 1001 | 1001 | if ($old_event != False) |
| 1002 | 1002 | { |
@@ -1005,15 +1005,14 @@ discard block |
||
| 1005 | 1005 | } |
| 1006 | 1006 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
| 1007 | 1007 | |
| 1008 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 1008 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 1009 | 1009 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
| 1010 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 1010 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 1011 | 1011 | { |
| 1012 | - case 'ical': |
|
| 1013 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1012 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1014 | 1013 | { |
| 1015 | 1014 | $calendar_ical = new calendar_ical(); |
| 1016 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 1015 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 1017 | 1016 | // we need to pass $event[id] so iCal class reads event again, |
| 1018 | 1017 | // as event is in user TZ, but iCal class expects server TZ! |
| 1019 | 1018 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1034,11 +1033,11 @@ discard block |
||
| 1034 | 1033 | case 'extended': |
| 1035 | 1034 | |
| 1036 | 1035 | $details_body = lang('Event Details follow').":\n"; |
| 1037 | - foreach($event_arr as $key => $val) |
|
| 1036 | + foreach ($event_arr as $key => $val) |
|
| 1038 | 1037 | { |
| 1039 | - if(!empty($details[$key])) |
|
| 1038 | + if (!empty($details[$key])) |
|
| 1040 | 1039 | { |
| 1041 | - switch($key) |
|
| 1040 | + switch ($key) |
|
| 1042 | 1041 | { |
| 1043 | 1042 | case 'access': |
| 1044 | 1043 | case 'priority': |
@@ -1047,7 +1046,7 @@ discard block |
||
| 1047 | 1046 | case 'title': |
| 1048 | 1047 | break; |
| 1049 | 1048 | default: |
| 1050 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
| 1049 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
| 1051 | 1050 | break; |
| 1052 | 1051 | } |
| 1053 | 1052 | } |
@@ -1055,7 +1054,7 @@ discard block |
||
| 1055 | 1054 | break; |
| 1056 | 1055 | } |
| 1057 | 1056 | // send via notification_app |
| 1058 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1057 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1059 | 1058 | { |
| 1060 | 1059 | try { |
| 1061 | 1060 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1077,7 +1076,7 @@ discard block |
||
| 1077 | 1076 | // popup notifiactions: set subject, different message (without separator) and (always) links |
| 1078 | 1077 | $notification->set_popupsubject($subject); |
| 1079 | 1078 | |
| 1080 | - if ($method =='REQUEST') |
|
| 1079 | + if ($method == 'REQUEST') |
|
| 1081 | 1080 | { |
| 1082 | 1081 | // Add ACCEPT|REHECT|TENTATIVE actions |
| 1083 | 1082 | $notification->set_popupdata('calendar', array( |
@@ -1090,11 +1089,11 @@ discard block |
||
| 1090 | 1089 | } |
| 1091 | 1090 | if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
| 1092 | 1091 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
| 1093 | - $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
|
| 1092 | + $notification->set_popuplinks(array($details['link_arr'] + array('app'=>'calendar'))); |
|
| 1094 | 1093 | |
| 1095 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1094 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1096 | 1095 | $notification->send(); |
| 1097 | - foreach(notifications::errors(true) as $error) |
|
| 1096 | + foreach (notifications::errors(true) as $error) |
|
| 1098 | 1097 | { |
| 1099 | 1098 | error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error"); |
| 1100 | 1099 | } |
@@ -1133,14 +1132,14 @@ discard block |
||
| 1133 | 1132 | return true; |
| 1134 | 1133 | } |
| 1135 | 1134 | |
| 1136 | - function get_update_message($event,$added) |
|
| 1135 | + function get_update_message($event, $added) |
|
| 1137 | 1136 | { |
| 1138 | 1137 | $nul = null; |
| 1139 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
| 1138 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
| 1140 | 1139 | |
| 1141 | 1140 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
| 1142 | 1141 | |
| 1143 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 1142 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 1144 | 1143 | } |
| 1145 | 1144 | |
| 1146 | 1145 | /** |
@@ -1154,37 +1153,37 @@ discard block |
||
| 1154 | 1153 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
| 1155 | 1154 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
| 1156 | 1155 | |
| 1157 | - $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1158 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
| 1156 | + $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1157 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
| 1159 | 1158 | { |
| 1160 | - return False; // event not found |
|
| 1159 | + return False; // event not found |
|
| 1161 | 1160 | } |
| 1162 | 1161 | if ($alarm['all']) |
| 1163 | 1162 | { |
| 1164 | 1163 | $to_notify = $event['participants']; |
| 1165 | 1164 | } |
| 1166 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1165 | + elseif ($this->check_perms(Acl::READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1167 | 1166 | { |
| 1168 | 1167 | $to_notify[$alarm['owner']] = 'A'; |
| 1169 | 1168 | } |
| 1170 | 1169 | else |
| 1171 | 1170 | { |
| 1172 | - return False; // no rights |
|
| 1171 | + return False; // no rights |
|
| 1173 | 1172 | } |
| 1174 | 1173 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
| 1175 | 1174 | Api\Translation::add_app('calendar'); |
| 1176 | 1175 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
| 1177 | 1176 | |
| 1178 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
| 1177 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
| 1179 | 1178 | |
| 1180 | 1179 | // create a new alarm for recuring events for the next event, if one exists |
| 1181 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
| 1180 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
| 1182 | 1181 | { |
| 1183 | 1182 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
| 1184 | 1183 | unset($alarm['times']); |
| 1185 | 1184 | unset($alarm['next']); |
| 1186 | 1185 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
| 1187 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1186 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1188 | 1187 | } |
| 1189 | 1188 | return $ret; |
| 1190 | 1189 | } |
@@ -1200,14 +1199,14 @@ discard block |
||
| 1200 | 1199 | * Please note: you should ALLWAYS update timestamps, as they are required for sync! |
| 1201 | 1200 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
| 1202 | 1201 | */ |
| 1203 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
| 1202 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
| 1204 | 1203 | { |
| 1205 | 1204 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
| 1206 | 1205 | |
| 1207 | 1206 | // check if user has the permission to update / create the event |
| 1208 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 1209 | - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && |
|
| 1210 | - !$this->check_perms(Acl::ADD,0,$event['owner']))) |
|
| 1207 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 1208 | + !$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) && |
|
| 1209 | + !$this->check_perms(Acl::ADD, 0, $event['owner']))) |
|
| 1211 | 1210 | { |
| 1212 | 1211 | return false; |
| 1213 | 1212 | } |
@@ -1228,7 +1227,7 @@ discard block |
||
| 1228 | 1227 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
| 1229 | 1228 | { |
| 1230 | 1229 | $event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
| 1231 | - $event['recur_enddate']->setTime(23,59,59); |
|
| 1230 | + $event['recur_enddate']->setTime(23, 59, 59); |
|
| 1232 | 1231 | $rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName()); |
| 1233 | 1232 | $rrule->rewind(); |
| 1234 | 1233 | $enddate = $rrule->current(); |
@@ -1287,19 +1286,19 @@ discard block |
||
| 1287 | 1286 | |
| 1288 | 1287 | $event['recur_enddate'] = $save_event['recur_enddate'] = $time; |
| 1289 | 1288 | } |
| 1290 | - $timestamps = array('modified','created'); |
|
| 1289 | + $timestamps = array('modified', 'created'); |
|
| 1291 | 1290 | // all-day events are handled in server time |
| 1292 | 1291 | // $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName(); |
| 1293 | 1292 | } |
| 1294 | 1293 | else |
| 1295 | 1294 | { |
| 1296 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
| 1295 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
| 1297 | 1296 | } |
| 1298 | 1297 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
| 1299 | - foreach($timestamps as $ts) |
|
| 1298 | + foreach ($timestamps as $ts) |
|
| 1300 | 1299 | { |
| 1301 | 1300 | // we convert here from user-time to timestamps in server-time! |
| 1302 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1301 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
| 1303 | 1302 | } |
| 1304 | 1303 | // convert tzid name to integer tz_id, of set user default |
| 1305 | 1304 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1309,7 +1308,7 @@ discard block |
||
| 1309 | 1308 | // same with the recur exceptions |
| 1310 | 1309 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 1311 | 1310 | { |
| 1312 | - foreach($event['recur_exception'] as &$date) |
|
| 1311 | + foreach ($event['recur_exception'] as &$date) |
|
| 1313 | 1312 | { |
| 1314 | 1313 | if ($event['whole_day']) |
| 1315 | 1314 | { |
@@ -1318,7 +1317,7 @@ discard block |
||
| 1318 | 1317 | } |
| 1319 | 1318 | else |
| 1320 | 1319 | { |
| 1321 | - $date = $this->date2ts($date,true); |
|
| 1320 | + $date = $this->date2ts($date, true); |
|
| 1322 | 1321 | } |
| 1323 | 1322 | } |
| 1324 | 1323 | unset($date); |
@@ -1329,13 +1328,13 @@ discard block |
||
| 1329 | 1328 | // Expand group invitations so we don't lose individual alarms |
| 1330 | 1329 | $expanded = $event; |
| 1331 | 1330 | $this->enum_groups($expanded); |
| 1332 | - foreach($event['alarm'] as $id => &$alarm) |
|
| 1331 | + foreach ($event['alarm'] as $id => &$alarm) |
|
| 1333 | 1332 | { |
| 1334 | 1333 | // remove alarms belonging to not longer existing or rejected participants |
| 1335 | 1334 | if ($alarm['owner'] && isset($expanded['participants'])) |
| 1336 | 1335 | { |
| 1337 | 1336 | // Don't auto-delete alarm if for all users |
| 1338 | - if($alarm['all']) continue; |
|
| 1337 | + if ($alarm['all']) continue; |
|
| 1339 | 1338 | |
| 1340 | 1339 | $status = $expanded['participants'][$alarm['owner']]; |
| 1341 | 1340 | if (!isset($status) || calendar_so::split_status($status) === 'R') |
@@ -1345,21 +1344,20 @@ discard block |
||
| 1345 | 1344 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1346 | 1345 | } |
| 1347 | 1346 | } |
| 1348 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
| 1347 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
| 1349 | 1348 | } |
| 1350 | 1349 | } |
| 1351 | 1350 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
| 1352 | 1351 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
| 1353 | 1352 | { |
| 1354 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
| 1353 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
| 1355 | 1354 | { |
| 1356 | 1355 | if (!isset($event['alarm'][$id])) |
| 1357 | 1356 | { |
| 1358 | 1357 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1359 | 1358 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
| 1360 | 1359 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1361 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
| 1362 | - $old_event['participants'][$alarm['owner']]; |
|
| 1360 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
| 1363 | 1361 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
| 1364 | 1362 | { |
| 1365 | 1363 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1388,7 +1386,7 @@ discard block |
||
| 1388 | 1386 | } |
| 1389 | 1387 | $set_recurrences = $old_event ? abs($event['recur_enddate'] - $old_event['recur_enddate']) > 1 : false; |
| 1390 | 1388 | $set_recurrences_start = 0; |
| 1391 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1389 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1392 | 1390 | { |
| 1393 | 1391 | $save_event['id'] = $cal_id; |
| 1394 | 1392 | // unset participants to enforce the default stati for all added recurrences |
@@ -1399,7 +1397,7 @@ discard block |
||
| 1399 | 1397 | // create links for new participants from addressbook, if configured |
| 1400 | 1398 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
| 1401 | 1399 | { |
| 1402 | - foreach($event['participants'] as $uid => $status) |
|
| 1400 | + foreach ($event['participants'] as $uid => $status) |
|
| 1403 | 1401 | { |
| 1404 | 1402 | $user_type = $user_id = null; |
| 1405 | 1403 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1412,7 +1410,7 @@ discard block |
||
| 1412 | 1410 | |
| 1413 | 1411 | // Update history |
| 1414 | 1412 | $tracking = new calendar_tracking($this); |
| 1415 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1413 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
| 1416 | 1414 | $tracking->track($save_event, $old_event); |
| 1417 | 1415 | |
| 1418 | 1416 | return $cal_id; |
@@ -1427,16 +1425,16 @@ discard block |
||
| 1427 | 1425 | * @param array|int $event event array or id of the event |
| 1428 | 1426 | * @return boolean |
| 1429 | 1427 | */ |
| 1430 | - function check_status_perms($uid,$event) |
|
| 1428 | + function check_status_perms($uid, $event) |
|
| 1431 | 1429 | { |
| 1432 | 1430 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
| 1433 | 1431 | { |
| 1434 | 1432 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1435 | 1433 | |
| 1436 | - return $this->check_perms(Acl::EDIT,0,$event['owner']); |
|
| 1434 | + return $this->check_perms(Acl::EDIT, 0, $event['owner']); |
|
| 1437 | 1435 | } |
| 1438 | 1436 | // check if we have a category Acl for the event or not (null) |
| 1439 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
| 1437 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
| 1440 | 1438 | if (!is_null($access)) |
| 1441 | 1439 | { |
| 1442 | 1440 | return $access; |
@@ -1453,10 +1451,10 @@ discard block |
||
| 1453 | 1451 | // regular user and groups (need to check memberships too) |
| 1454 | 1452 | if (!isset($event['participants'][$uid])) |
| 1455 | 1453 | { |
| 1456 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
| 1454 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
| 1457 | 1455 | } |
| 1458 | 1456 | $memberships[] = $uid; |
| 1459 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid); |
|
| 1457 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid); |
|
| 1460 | 1458 | } |
| 1461 | 1459 | |
| 1462 | 1460 | /** |
@@ -1470,16 +1468,16 @@ discard block |
||
| 1470 | 1468 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1471 | 1469 | * null = cat has no acl |
| 1472 | 1470 | */ |
| 1473 | - function check_cat_acl($right,$event) |
|
| 1471 | + function check_cat_acl($right, $event) |
|
| 1474 | 1472 | { |
| 1475 | 1473 | if (!is_array($event)) $event = $this->read($event); |
| 1476 | 1474 | |
| 1477 | 1475 | $ret = null; |
| 1478 | 1476 | if ($event['category']) |
| 1479 | 1477 | { |
| 1480 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
| 1478 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
| 1481 | 1479 | { |
| 1482 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
| 1480 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
| 1483 | 1481 | if ($access === true) |
| 1484 | 1482 | { |
| 1485 | 1483 | $ret = true; |
@@ -1487,7 +1485,7 @@ discard block |
||
| 1487 | 1485 | } |
| 1488 | 1486 | if ($access === false) |
| 1489 | 1487 | { |
| 1490 | - $ret = false; // cat denies access --> check further cats |
|
| 1488 | + $ret = false; // cat denies access --> check further cats |
|
| 1491 | 1489 | } |
| 1492 | 1490 | } |
| 1493 | 1491 | } |
@@ -1508,12 +1506,12 @@ discard block |
||
| 1508 | 1506 | * @param int $cat_id =null null to return array with all cats |
| 1509 | 1507 | * @return array with account_id => right pairs |
| 1510 | 1508 | */ |
| 1511 | - public static function get_cat_rights($cat_id=null) |
|
| 1509 | + public static function get_cat_rights($cat_id = null) |
|
| 1512 | 1510 | { |
| 1513 | 1511 | if (!isset(self::$cat_rights_cache)) |
| 1514 | 1512 | { |
| 1515 | - self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights', |
|
| 1516 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
| 1513 | + self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights', |
|
| 1514 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
| 1517 | 1515 | } |
| 1518 | 1516 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
| 1519 | 1517 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1526,7 +1524,7 @@ discard block |
||
| 1526 | 1524 | * @param int $user |
| 1527 | 1525 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
| 1528 | 1526 | */ |
| 1529 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
| 1527 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
| 1530 | 1528 | { |
| 1531 | 1529 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1532 | 1530 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1536,15 +1534,15 @@ discard block |
||
| 1536 | 1534 | if ($rights) |
| 1537 | 1535 | { |
| 1538 | 1536 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
| 1539 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
| 1537 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
| 1540 | 1538 | } |
| 1541 | 1539 | else |
| 1542 | 1540 | { |
| 1543 | 1541 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1544 | 1542 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
| 1545 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
| 1543 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
| 1546 | 1544 | } |
| 1547 | - Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
| 1545 | + Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
| 1548 | 1546 | } |
| 1549 | 1547 | } |
| 1550 | 1548 | |
@@ -1555,9 +1553,9 @@ discard block |
||
| 1555 | 1553 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1556 | 1554 | * null = cat has no acl |
| 1557 | 1555 | */ |
| 1558 | - public static function has_cat_right($right,$cat_id,$user) |
|
| 1556 | + public static function has_cat_right($right, $cat_id, $user) |
|
| 1559 | 1557 | { |
| 1560 | - static $cache=null; |
|
| 1558 | + static $cache = null; |
|
| 1561 | 1559 | |
| 1562 | 1560 | if (!isset($cache[$cat_id])) |
| 1563 | 1561 | { |
@@ -1565,21 +1563,21 @@ discard block |
||
| 1565 | 1563 | $cat_rights = self::get_cat_rights($cat_id); |
| 1566 | 1564 | if (!is_null($cat_rights)) |
| 1567 | 1565 | { |
| 1568 | - static $memberships=null; |
|
| 1566 | + static $memberships = null; |
|
| 1569 | 1567 | if (is_null($memberships)) |
| 1570 | 1568 | { |
| 1571 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
| 1569 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 1572 | 1570 | $memberships[] = $user; |
| 1573 | 1571 | } |
| 1574 | - foreach($cat_rights as $uid => $value) |
|
| 1572 | + foreach ($cat_rights as $uid => $value) |
|
| 1575 | 1573 | { |
| 1576 | 1574 | $all |= $value; |
| 1577 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1575 | + if (in_array($uid, $memberships)) $own |= $value; |
|
| 1578 | 1576 | } |
| 1579 | 1577 | } |
| 1580 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
| 1578 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
| 1581 | 1579 | { |
| 1582 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
| 1580 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
| 1583 | 1581 | } |
| 1584 | 1582 | } |
| 1585 | 1583 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1599,13 +1597,13 @@ discard block |
||
| 1599 | 1597 | * @param boolean $skip_notification =false true: do not send notification messages |
| 1600 | 1598 | * @return int number of changed recurrences |
| 1601 | 1599 | */ |
| 1602 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
| 1600 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
| 1603 | 1601 | { |
| 1604 | 1602 | unset($updateTS); |
| 1605 | 1603 | |
| 1606 | 1604 | $cal_id = is_array($event) ? $event['id'] : $event; |
| 1607 | 1605 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
| 1608 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
| 1606 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
| 1609 | 1607 | { |
| 1610 | 1608 | return false; |
| 1611 | 1609 | } |
@@ -1614,16 +1612,16 @@ discard block |
||
| 1614 | 1612 | if ($this->log) |
| 1615 | 1613 | { |
| 1616 | 1614 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1617 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
| 1615 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
| 1618 | 1616 | } |
| 1619 | 1617 | $old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server'); |
| 1620 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
| 1621 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
| 1622 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
| 1618 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
| 1619 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
| 1620 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
| 1623 | 1621 | { |
| 1624 | 1622 | if ($status == 'R') // remove alarms belonging to rejected participants |
| 1625 | 1623 | { |
| 1626 | - foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1624 | + foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1627 | 1625 | { |
| 1628 | 1626 | if ((string)$alarm['owner'] === (string)$uid) |
| 1629 | 1627 | { |
@@ -1645,8 +1643,8 @@ discard block |
||
| 1645 | 1643 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1646 | 1644 | { |
| 1647 | 1645 | if (!is_array($event)) $event = $this->read($cal_id); |
| 1648 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1649 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
| 1646 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
| 1647 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
| 1650 | 1648 | } |
| 1651 | 1649 | |
| 1652 | 1650 | // Update history |
@@ -1666,14 +1664,14 @@ discard block |
||
| 1666 | 1664 | * @param int $recur_date =0 date to change, or 0 = all since now |
| 1667 | 1665 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
| 1668 | 1666 | */ |
| 1669 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
| 1667 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
| 1670 | 1668 | { |
| 1671 | 1669 | if (!isset($new_event['participants'])) return; |
| 1672 | 1670 | |
| 1673 | 1671 | // check the old list against the new list |
| 1674 | 1672 | foreach ($old_event['participants'] as $userid => $status) |
| 1675 | 1673 | { |
| 1676 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1674 | + if (!isset($new_event['participants'][$userid])) { |
|
| 1677 | 1675 | // Attendee will be deleted this way |
| 1678 | 1676 | $new_event['participants'][$userid] = 'G'; |
| 1679 | 1677 | } |
@@ -1686,7 +1684,7 @@ discard block |
||
| 1686 | 1684 | // write the changes |
| 1687 | 1685 | foreach ($new_event['participants'] as $userid => $status) |
| 1688 | 1686 | { |
| 1689 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
| 1687 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
| 1690 | 1688 | } |
| 1691 | 1689 | } |
| 1692 | 1690 | |
@@ -1701,43 +1699,43 @@ discard block |
||
| 1701 | 1699 | * @param int &$exceptions_kept=null on return number of kept exceptions |
| 1702 | 1700 | * @return boolean true on success, false on error (usually permission denied) |
| 1703 | 1701 | */ |
| 1704 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
| 1705 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
| 1702 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
| 1703 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
| 1706 | 1704 | { |
| 1707 | 1705 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
| 1708 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
| 1709 | - !$ignore_acl && !$this->check_perms(Acl::DELETE,$event)) |
|
| 1706 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
| 1707 | + !$ignore_acl && !$this->check_perms(Acl::DELETE, $event)) |
|
| 1710 | 1708 | { |
| 1711 | 1709 | return false; |
| 1712 | 1710 | } |
| 1713 | 1711 | |
| 1714 | 1712 | // Don't send notification if the event has already been deleted |
| 1715 | - if(!$event['deleted'] && !$skip_notification) |
|
| 1713 | + if (!$event['deleted'] && !$skip_notification) |
|
| 1716 | 1714 | { |
| 1717 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
| 1715 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
| 1718 | 1716 | } |
| 1719 | 1717 | |
| 1720 | 1718 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
| 1721 | 1719 | { |
| 1722 | 1720 | $config = Api\Config::read('phpgwapi'); |
| 1723 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1721 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1724 | 1722 | { |
| 1725 | 1723 | $this->so->delete($cal_id); |
| 1726 | 1724 | |
| 1727 | 1725 | // delete all links to the event |
| 1728 | - Link::unlink(0,'calendar',$cal_id); |
|
| 1726 | + Link::unlink(0, 'calendar', $cal_id); |
|
| 1729 | 1727 | } |
| 1730 | 1728 | elseif ($config['calendar_delete_history']) |
| 1731 | 1729 | { |
| 1732 | 1730 | // mark all links to the event as deleted, but keep them |
| 1733 | - Link::unlink(0,'calendar',$cal_id,'','','',true); |
|
| 1731 | + Link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
| 1734 | 1732 | |
| 1735 | 1733 | $event['deleted'] = $this->now; |
| 1736 | 1734 | $this->save($event, $ignore_acl); |
| 1737 | 1735 | // Actually delete alarms |
| 1738 | 1736 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1739 | 1737 | { |
| 1740 | - foreach($event['alarm'] as $id => $alarm) |
|
| 1738 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 1741 | 1739 | { |
| 1742 | 1740 | $this->delete_alarm($id); |
| 1743 | 1741 | } |
@@ -1759,7 +1757,7 @@ discard block |
||
| 1759 | 1757 | if (!($exception = $this->read($id))) continue; |
| 1760 | 1758 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1761 | 1759 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1762 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
| 1760 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
| 1763 | 1761 | ++$exceptions_kept; |
| 1764 | 1762 | } |
| 1765 | 1763 | } |
@@ -1771,9 +1769,9 @@ discard block |
||
| 1771 | 1769 | if ($event['alarm']) |
| 1772 | 1770 | { |
| 1773 | 1771 | $next_recurrance = null; |
| 1774 | - foreach($event['alarm'] as &$alarm) |
|
| 1772 | + foreach ($event['alarm'] as &$alarm) |
|
| 1775 | 1773 | { |
| 1776 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
| 1774 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
| 1777 | 1775 | { |
| 1778 | 1776 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
| 1779 | 1777 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1781,12 +1779,12 @@ discard block |
||
| 1781 | 1779 | { |
| 1782 | 1780 | $checkdate = $recur_date; |
| 1783 | 1781 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
| 1784 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
| 1782 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
| 1785 | 1783 | { |
| 1786 | 1784 | $next_recurrance = $this->date2ts($e['start']); |
| 1787 | 1785 | } |
| 1788 | 1786 | } |
| 1789 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1787 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1790 | 1788 | $alarm['cal_id'] = $cal_id; |
| 1791 | 1789 | unset($alarm['times']); |
| 1792 | 1790 | unset($alarm['next']); |
@@ -1800,7 +1798,7 @@ discard block |
||
| 1800 | 1798 | $event = $this->read($cal_id); |
| 1801 | 1799 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
| 1802 | 1800 | $event['recur_exception'][] = $recur_date; |
| 1803 | - $this->save($event);// updates the content-history |
|
| 1801 | + $this->save($event); // updates the content-history |
|
| 1804 | 1802 | } |
| 1805 | 1803 | if ($event['reference']) |
| 1806 | 1804 | { |
@@ -1818,19 +1816,19 @@ discard block |
||
| 1818 | 1816 | * @param array $disinvited |
| 1819 | 1817 | * @return array |
| 1820 | 1818 | */ |
| 1821 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
| 1819 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
| 1822 | 1820 | { |
| 1823 | 1821 | $details = array( // event-details for the notify-msg |
| 1824 | 1822 | 'id' => $event['id'], |
| 1825 | 1823 | 'action' => lang($action), |
| 1826 | 1824 | ); |
| 1827 | 1825 | $event_arr = $this->event2array($event); |
| 1828 | - foreach($event_arr as $key => $val) |
|
| 1826 | + foreach ($event_arr as $key => $val) |
|
| 1829 | 1827 | { |
| 1830 | 1828 | if ($key == 'recur_type') $key = 'repetition'; |
| 1831 | 1829 | $details[$key] = $val['data']; |
| 1832 | 1830 | } |
| 1833 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
| 1831 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
| 1834 | 1832 | |
| 1835 | 1833 | $event_arr['link']['field'] = lang('URL'); |
| 1836 | 1834 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1846,7 +1844,7 @@ discard block |
||
| 1846 | 1844 | */ |
| 1847 | 1845 | $link_arr = array(); |
| 1848 | 1846 | $link_arr['text'] = $event['title']; |
| 1849 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1847 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1850 | 1848 | 'cal_id' => $event['id'], |
| 1851 | 1849 | 'date' => $eventStart_arr['full'], |
| 1852 | 1850 | 'ajax' => true |
@@ -1855,11 +1853,11 @@ discard block |
||
| 1855 | 1853 | $details['link_arr'] = $link_arr; |
| 1856 | 1854 | |
| 1857 | 1855 | $dis = array(); |
| 1858 | - foreach($disinvited as $uid) |
|
| 1856 | + foreach ($disinvited as $uid) |
|
| 1859 | 1857 | { |
| 1860 | 1858 | $dis[] = $this->participant_name($uid); |
| 1861 | 1859 | } |
| 1862 | - $details['disinvited'] = implode(', ',$dis); |
|
| 1860 | + $details['disinvited'] = implode(', ', $dis); |
|
| 1863 | 1861 | return $details; |
| 1864 | 1862 | } |
| 1865 | 1863 | |
@@ -1883,13 +1881,13 @@ discard block |
||
| 1883 | 1881 | 'data' => $event['description'] |
| 1884 | 1882 | ); |
| 1885 | 1883 | |
| 1886 | - foreach(explode(',',$event['category']) as $cat_id) |
|
| 1884 | + foreach (explode(',', $event['category']) as $cat_id) |
|
| 1887 | 1885 | { |
| 1888 | 1886 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1889 | 1887 | } |
| 1890 | 1888 | $var['category'] = Array( |
| 1891 | 1889 | 'field' => lang('Category'), |
| 1892 | - 'data' => implode(', ',$cat_string) |
|
| 1890 | + 'data' => implode(', ', $cat_string) |
|
| 1893 | 1891 | ); |
| 1894 | 1892 | |
| 1895 | 1893 | $var['location'] = Array( |
@@ -1935,10 +1933,10 @@ discard block |
||
| 1935 | 1933 | |
| 1936 | 1934 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
| 1937 | 1935 | { |
| 1938 | - $participants = $this->participants($event,true); |
|
| 1936 | + $participants = $this->participants($event, true); |
|
| 1939 | 1937 | |
| 1940 | 1938 | // fix external organiser to not be included as participant and shown as organiser |
| 1941 | - foreach($event['participants'] as $uid => $status) |
|
| 1939 | + foreach ($event['participants'] as $uid => $status) |
|
| 1942 | 1940 | { |
| 1943 | 1941 | $role = $quantity = null; |
| 1944 | 1942 | calendar_so::split_status($status, $quantity, $role); |
@@ -1972,26 +1970,26 @@ discard block |
||
| 1972 | 1970 | * @param array $old_event =null event-data in the DB before calling save |
| 1973 | 1971 | * @param string $type ='update' |
| 1974 | 1972 | */ |
| 1975 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
| 1973 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
| 1976 | 1974 | { |
| 1977 | - if (!($f = fopen($this->log_file,'a'))) |
|
| 1975 | + if (!($f = fopen($this->log_file, 'a'))) |
|
| 1978 | 1976 | { |
| 1979 | 1977 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
| 1980 | 1978 | return false; |
| 1981 | 1979 | } |
| 1982 | - fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1983 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
| 1984 | - foreach(array('start','end') as $name) |
|
| 1980 | + fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1981 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
| 1982 | + foreach (array('start', 'end') as $name) |
|
| 1985 | 1983 | { |
| 1986 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1987 | - $this->format_date($event_saved[$name]) .' / '. |
|
| 1984 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1985 | + $this->format_date($event_saved[$name]).' / '. |
|
| 1988 | 1986 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
| 1989 | 1987 | } |
| 1990 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
| 1988 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
| 1991 | 1989 | { |
| 1992 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
| 1990 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
| 1993 | 1991 | } |
| 1994 | - fwrite($f,"\n"); |
|
| 1992 | + fwrite($f, "\n"); |
|
| 1995 | 1993 | fclose($f); |
| 1996 | 1994 | |
| 1997 | 1995 | return true; |
@@ -2012,7 +2010,7 @@ discard block |
||
| 2012 | 2010 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 2013 | 2011 | |
| 2014 | 2012 | $time = new Api\DateTime($event['start']); |
| 2015 | - if(!is_array($event['alarm'])) |
|
| 2013 | + if (!is_array($event['alarm'])) |
|
| 2016 | 2014 | { |
| 2017 | 2015 | $event['alarm'] = $this->so->read_alarms($event['id']); |
| 2018 | 2016 | } |
@@ -2026,9 +2024,9 @@ discard block |
||
| 2026 | 2024 | $instance_date = $instance_date->format('ts'); |
| 2027 | 2025 | } |
| 2028 | 2026 | |
| 2029 | - foreach($event['alarm'] as &$alarm) |
|
| 2027 | + foreach ($event['alarm'] as &$alarm) |
|
| 2030 | 2028 | { |
| 2031 | - if($event['recur_type'] != MCAL_RECUR_NONE && $instance_date) |
|
| 2029 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $instance_date) |
|
| 2032 | 2030 | { |
| 2033 | 2031 | calendar_so::shift_alarm($event, $alarm, $instance_date); |
| 2034 | 2032 | } |
@@ -2048,14 +2046,14 @@ discard block |
||
| 2048 | 2046 | * @param boolean $update_modified =true call update modified, default true |
| 2049 | 2047 | * @return string id of the alarm, or false on error (eg. no perms) |
| 2050 | 2048 | */ |
| 2051 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 2049 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 2052 | 2050 | { |
| 2053 | - if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2051 | + if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2054 | 2052 | { |
| 2055 | 2053 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
| 2056 | - return false; // no rights to add the alarm |
|
| 2054 | + return false; // no rights to add the alarm |
|
| 2057 | 2055 | } |
| 2058 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
| 2056 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
| 2059 | 2057 | |
| 2060 | 2058 | return $this->so->save_alarm($cal_id, $alarm, $update_modified); |
| 2061 | 2059 | } |
@@ -2068,11 +2066,11 @@ discard block |
||
| 2068 | 2066 | */ |
| 2069 | 2067 | function delete_alarm($id) |
| 2070 | 2068 | { |
| 2071 | - list(,$cal_id) = explode(':',$id); |
|
| 2069 | + list(,$cal_id) = explode(':', $id); |
|
| 2072 | 2070 | |
| 2073 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2071 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2074 | 2072 | { |
| 2075 | - return false; // no rights to delete the alarm |
|
| 2073 | + return false; // no rights to delete the alarm |
|
| 2076 | 2074 | } |
| 2077 | 2075 | |
| 2078 | 2076 | return $this->so->delete_alarm($id); |
@@ -2087,13 +2085,13 @@ discard block |
||
| 2087 | 2085 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
| 2088 | 2086 | * @return array category ids (found, added and preserved categories) |
| 2089 | 2087 | */ |
| 2090 | - function find_or_add_categories($catname_list, $old_event=null) |
|
| 2088 | + function find_or_add_categories($catname_list, $old_event = null) |
|
| 2091 | 2089 | { |
| 2092 | 2090 | if (is_array($old_event) || $old_event > 0) |
| 2093 | 2091 | { |
| 2094 | 2092 | // preserve categories without users read access |
| 2095 | 2093 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
| 2096 | - $old_categories = explode(',',$old_event['category']); |
|
| 2094 | + $old_categories = explode(',', $old_event['category']); |
|
| 2097 | 2095 | $old_cats_preserve = array(); |
| 2098 | 2096 | if (is_array($old_categories) && count($old_categories) > 0) |
| 2099 | 2097 | { |
@@ -2147,7 +2145,7 @@ discard block |
||
| 2147 | 2145 | { |
| 2148 | 2146 | if (!is_array($cat_id_list)) |
| 2149 | 2147 | { |
| 2150 | - $cat_id_list = explode(',',$cat_id_list); |
|
| 2148 | + $cat_id_list = explode(',', $cat_id_list); |
|
| 2151 | 2149 | } |
| 2152 | 2150 | $cat_list = array(); |
| 2153 | 2151 | foreach ($cat_id_list as $cat_id) |
@@ -2172,7 +2170,7 @@ discard block |
||
| 2172 | 2170 | * master -> try to find a releated series master |
| 2173 | 2171 | * @return array calendar_ids of matching entries |
| 2174 | 2172 | */ |
| 2175 | - function find_event($event, $filter='exact') |
|
| 2173 | + function find_event($event, $filter = 'exact') |
|
| 2176 | 2174 | { |
| 2177 | 2175 | $matchingEvents = array(); |
| 2178 | 2176 | $query = array(); |
@@ -2180,14 +2178,14 @@ discard block |
||
| 2180 | 2178 | if ($this->log) |
| 2181 | 2179 | { |
| 2182 | 2180 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2183 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
| 2181 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
| 2184 | 2182 | } |
| 2185 | 2183 | |
| 2186 | 2184 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
| 2187 | 2185 | |
| 2188 | 2186 | if ($filter == 'master') |
| 2189 | 2187 | { |
| 2190 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
| 2188 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
| 2191 | 2189 | $query['cal_recurrence'] = 0; |
| 2192 | 2190 | } |
| 2193 | 2191 | elseif ($filter == 'exact') |
@@ -2208,14 +2206,14 @@ discard block |
||
| 2208 | 2206 | if ($this->log) |
| 2209 | 2207 | { |
| 2210 | 2208 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2211 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
| 2209 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
| 2212 | 2210 | } |
| 2213 | 2211 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
| 2214 | 2212 | { |
| 2215 | 2213 | if ($this->log) |
| 2216 | 2214 | { |
| 2217 | 2215 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2218 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2216 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2219 | 2217 | } |
| 2220 | 2218 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
| 2221 | 2219 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2234,7 +2232,7 @@ discard block |
||
| 2234 | 2232 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
| 2235 | 2233 | if (in_array($event['recurrence'], $exceptions)) |
| 2236 | 2234 | { |
| 2237 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
| 2235 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
| 2238 | 2236 | } |
| 2239 | 2237 | } |
| 2240 | 2238 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2253,19 +2251,19 @@ discard block |
||
| 2253 | 2251 | |
| 2254 | 2252 | // only query calendars of users, we have READ-grants from |
| 2255 | 2253 | $users = array(); |
| 2256 | - foreach(array_keys($this->grants) as $user) |
|
| 2254 | + foreach (array_keys($this->grants) as $user) |
|
| 2257 | 2255 | { |
| 2258 | 2256 | $user = trim($user); |
| 2259 | - if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
|
| 2257 | + if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user)) |
|
| 2260 | 2258 | { |
| 2261 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2259 | + if ($user && !in_array($user, $users)) // already added? |
|
| 2262 | 2260 | { |
| 2263 | 2261 | $users[] = $user; |
| 2264 | 2262 | } |
| 2265 | 2263 | } |
| 2266 | 2264 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2267 | 2265 | { |
| 2268 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2266 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2269 | 2267 | } |
| 2270 | 2268 | // the further code is only for real users |
| 2271 | 2269 | if (!is_numeric($user)) continue; |
@@ -2276,7 +2274,7 @@ discard block |
||
| 2276 | 2274 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 2277 | 2275 | if (is_array($members)) |
| 2278 | 2276 | { |
| 2279 | - foreach($members as $member) |
|
| 2277 | + foreach ($members as $member) |
|
| 2280 | 2278 | { |
| 2281 | 2279 | // use only members which gave the user a read-grant |
| 2282 | 2280 | if (!in_array($member, $users) && |
@@ -2292,7 +2290,7 @@ discard block |
||
| 2292 | 2290 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 2293 | 2291 | if (is_array($memberships)) |
| 2294 | 2292 | { |
| 2295 | - foreach($memberships as $group) |
|
| 2293 | + foreach ($memberships as $group) |
|
| 2296 | 2294 | { |
| 2297 | 2295 | if (!in_array($group, $users)) |
| 2298 | 2296 | { |
@@ -2318,24 +2316,24 @@ discard block |
||
| 2318 | 2316 | |
| 2319 | 2317 | // check length with some tolerance |
| 2320 | 2318 | $length = $event['end'] - $event['start'] - $delta; |
| 2321 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
| 2319 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
| 2322 | 2320 | $length += 2 * $delta; |
| 2323 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
| 2324 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
| 2325 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
| 2321 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
| 2322 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
| 2323 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
| 2326 | 2324 | } |
| 2327 | 2325 | elseif (isset($event['start'])) |
| 2328 | 2326 | { |
| 2329 | 2327 | if ($filter == 'relax') |
| 2330 | 2328 | { |
| 2331 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
| 2332 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
| 2329 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
| 2330 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
| 2333 | 2331 | } |
| 2334 | 2332 | else |
| 2335 | 2333 | { |
| 2336 | 2334 | // we accept a tiny tolerance |
| 2337 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
| 2338 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
| 2335 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
| 2336 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
| 2339 | 2337 | } |
| 2340 | 2338 | } |
| 2341 | 2339 | if ($filter == 'relax') |
@@ -2358,14 +2356,14 @@ discard block |
||
| 2358 | 2356 | if ($this->log) |
| 2359 | 2357 | { |
| 2360 | 2358 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2361 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
| 2359 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
| 2362 | 2360 | } |
| 2363 | 2361 | } |
| 2364 | 2362 | |
| 2365 | 2363 | if ($this->log) |
| 2366 | 2364 | { |
| 2367 | 2365 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2368 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
| 2366 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
| 2369 | 2367 | } |
| 2370 | 2368 | if (!count($users) || !($foundEvents = |
| 2371 | 2369 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2373,19 +2371,19 @@ discard block |
||
| 2373 | 2371 | if ($this->log) |
| 2374 | 2372 | { |
| 2375 | 2373 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2376 | - "[NO MATCH]\n",3,$this->logfile); |
|
| 2374 | + "[NO MATCH]\n", 3, $this->logfile); |
|
| 2377 | 2375 | } |
| 2378 | 2376 | return $matchingEvents; |
| 2379 | 2377 | } |
| 2380 | 2378 | |
| 2381 | 2379 | $pseudos = array(); |
| 2382 | 2380 | |
| 2383 | - foreach($foundEvents as $egwEvent) |
|
| 2381 | + foreach ($foundEvents as $egwEvent) |
|
| 2384 | 2382 | { |
| 2385 | 2383 | if ($this->log) |
| 2386 | 2384 | { |
| 2387 | 2385 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2388 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2386 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2389 | 2387 | } |
| 2390 | 2388 | |
| 2391 | 2389 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2459,7 +2457,7 @@ discard block |
||
| 2459 | 2457 | if (in_array($event['recurrence'], $exceptions)) |
| 2460 | 2458 | { |
| 2461 | 2459 | // We found a pseudo exception |
| 2462 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
| 2460 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
| 2463 | 2461 | break; |
| 2464 | 2462 | } |
| 2465 | 2463 | } |
@@ -2477,7 +2475,7 @@ discard block |
||
| 2477 | 2475 | if ($this->log) |
| 2478 | 2476 | { |
| 2479 | 2477 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2480 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
| 2478 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
| 2481 | 2479 | } |
| 2482 | 2480 | continue; |
| 2483 | 2481 | } |
@@ -2489,7 +2487,7 @@ discard block |
||
| 2489 | 2487 | if ($this->log) |
| 2490 | 2488 | { |
| 2491 | 2489 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2492 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
| 2490 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
| 2493 | 2491 | } |
| 2494 | 2492 | continue; |
| 2495 | 2493 | } |
@@ -2510,8 +2508,8 @@ discard block |
||
| 2510 | 2508 | if ($this->log) |
| 2511 | 2509 | { |
| 2512 | 2510 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2513 | - "() event[$key] differ: '" . $event[$key] . |
|
| 2514 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
| 2511 | + "() event[$key] differ: '".$event[$key]. |
|
| 2512 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
| 2515 | 2513 | } |
| 2516 | 2514 | continue 2; // next foundEvent |
| 2517 | 2515 | } |
@@ -2529,7 +2527,7 @@ discard block |
||
| 2529 | 2527 | if ($this->log) |
| 2530 | 2528 | { |
| 2531 | 2529 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2532 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
| 2530 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
| 2533 | 2531 | } |
| 2534 | 2532 | continue 2; |
| 2535 | 2533 | } |
@@ -2541,7 +2539,7 @@ discard block |
||
| 2541 | 2539 | { |
| 2542 | 2540 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2543 | 2541 | '() event has additional categories:' |
| 2544 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
| 2542 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
| 2545 | 2543 | } |
| 2546 | 2544 | continue; |
| 2547 | 2545 | } |
@@ -2561,7 +2559,7 @@ discard block |
||
| 2561 | 2559 | if ($this->log) |
| 2562 | 2560 | { |
| 2563 | 2561 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2564 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
| 2562 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
| 2565 | 2563 | } |
| 2566 | 2564 | continue 2; |
| 2567 | 2565 | } |
@@ -2584,8 +2582,8 @@ discard block |
||
| 2584 | 2582 | if ($this->log) |
| 2585 | 2583 | { |
| 2586 | 2584 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2587 | - '() missing event[participants]: ' . |
|
| 2588 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
| 2585 | + '() missing event[participants]: '. |
|
| 2586 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
| 2589 | 2587 | } |
| 2590 | 2588 | continue; |
| 2591 | 2589 | } |
@@ -2597,7 +2595,7 @@ discard block |
||
| 2597 | 2595 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
| 2598 | 2596 | { |
| 2599 | 2597 | // We found a pseudo Exception |
| 2600 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
| 2598 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
| 2601 | 2599 | continue; |
| 2602 | 2600 | } |
| 2603 | 2601 | } |
@@ -2619,7 +2617,7 @@ discard block |
||
| 2619 | 2617 | if ($this->log) |
| 2620 | 2618 | { |
| 2621 | 2619 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2622 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
| 2620 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
| 2623 | 2621 | } |
| 2624 | 2622 | continue 2; |
| 2625 | 2623 | } |
@@ -2629,8 +2627,8 @@ discard block |
||
| 2629 | 2627 | if ($this->log) |
| 2630 | 2628 | { |
| 2631 | 2629 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2632 | - '() missing event[recur_exception]: ' . |
|
| 2633 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
| 2630 | + '() missing event[recur_exception]: '. |
|
| 2631 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
| 2634 | 2632 | } |
| 2635 | 2633 | continue; |
| 2636 | 2634 | } |
@@ -2645,8 +2643,8 @@ discard block |
||
| 2645 | 2643 | if ($this->log) |
| 2646 | 2644 | { |
| 2647 | 2645 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2648 | - "() events[$key] differ: " . $event[$key] . |
|
| 2649 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
| 2646 | + "() events[$key] differ: ".$event[$key]. |
|
| 2647 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
| 2650 | 2648 | } |
| 2651 | 2649 | continue 2; |
| 2652 | 2650 | } |
@@ -2662,7 +2660,7 @@ discard block |
||
| 2662 | 2660 | if ($this->log) |
| 2663 | 2661 | { |
| 2664 | 2662 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2665 | - "() new exception for series found.\n",3,$this->logfile); |
|
| 2663 | + "() new exception for series found.\n", 3, $this->logfile); |
|
| 2666 | 2664 | } |
| 2667 | 2665 | $matchingEvents = array(); |
| 2668 | 2666 | } |
@@ -2673,7 +2671,7 @@ discard block |
||
| 2673 | 2671 | if ($this->log) |
| 2674 | 2672 | { |
| 2675 | 2673 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2676 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
| 2674 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
| 2677 | 2675 | } |
| 2678 | 2676 | return $matches; |
| 2679 | 2677 | } |
@@ -2746,7 +2744,7 @@ discard block |
||
| 2746 | 2744 | if ($this->log) |
| 2747 | 2745 | { |
| 2748 | 2746 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2749 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
| 2747 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
| 2750 | 2748 | } |
| 2751 | 2749 | $type = 'SERIES-EXCEPTION'; |
| 2752 | 2750 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2767,7 +2765,7 @@ discard block |
||
| 2767 | 2765 | } |
| 2768 | 2766 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
| 2769 | 2767 | { |
| 2770 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2768 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2771 | 2769 | $recurrence_event = $master_event; |
| 2772 | 2770 | $recurrence_event['start'] = $event['start']; |
| 2773 | 2771 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2784,8 +2782,8 @@ discard block |
||
| 2784 | 2782 | if ($this->log) |
| 2785 | 2783 | { |
| 2786 | 2784 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2787 | - '() try occurrence ' . $egw_rrule->current() |
|
| 2788 | - . " ($occurrence)\n",3,$this->logfile); |
|
| 2785 | + '() try occurrence '.$egw_rrule->current() |
|
| 2786 | + . " ($occurrence)\n", 3, $this->logfile); |
|
| 2789 | 2787 | } |
| 2790 | 2788 | if ($event['start'] == $occurrence) |
| 2791 | 2789 | { |
@@ -2818,8 +2816,8 @@ discard block |
||
| 2818 | 2816 | // default if we cannot find a proof for a fundamental change |
| 2819 | 2817 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
| 2820 | 2818 | // check for changed data |
| 2821 | - foreach (array('start','end','uid','title','location','description', |
|
| 2822 | - 'priority','public','special','non_blocking') as $key) |
|
| 2819 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
| 2820 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
| 2823 | 2821 | { |
| 2824 | 2822 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
| 2825 | 2823 | { |
@@ -2877,10 +2875,10 @@ discard block |
||
| 2877 | 2875 | * @param &$event the event we are working on |
| 2878 | 2876 | * |
| 2879 | 2877 | */ |
| 2880 | - function server2usertime (&$event) |
|
| 2878 | + function server2usertime(&$event) |
|
| 2881 | 2879 | { |
| 2882 | 2880 | // we run all dates through date2usertime, to adjust to user-time |
| 2883 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
| 2881 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
| 2884 | 2882 | { |
| 2885 | 2883 | // we convert here from server-time to timestamps in user-time! |
| 2886 | 2884 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2888,7 +2886,7 @@ discard block |
||
| 2888 | 2886 | // same with the recur exceptions |
| 2889 | 2887 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 2890 | 2888 | { |
| 2891 | - foreach($event['recur_exception'] as $n => $date) |
|
| 2889 | + foreach ($event['recur_exception'] as $n => $date) |
|
| 2892 | 2890 | { |
| 2893 | 2891 | $event['recur_exception'][$n] = $this->date2usertime($date); |
| 2894 | 2892 | } |
@@ -2896,7 +2894,7 @@ discard block |
||
| 2896 | 2894 | // same with the alarms |
| 2897 | 2895 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 2898 | 2896 | { |
| 2899 | - foreach($event['alarm'] as $id => $alarm) |
|
| 2897 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 2900 | 2898 | { |
| 2901 | 2899 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2902 | 2900 | } |
@@ -2913,7 +2911,7 @@ discard block |
||
| 2913 | 2911 | { |
| 2914 | 2912 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
| 2915 | 2913 | { |
| 2916 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
| 2914 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
| 2917 | 2915 | } |
| 2918 | 2916 | } |
| 2919 | 2917 | } |
@@ -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 | /** |
@@ -120,7 +126,10 @@ discard block |
||
| 120 | 126 | { |
| 121 | 127 | unset($updateTS); // ignored, as updating timestamps is required for sync! |
| 122 | 128 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 123 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
| 129 | + if (!is_array($messages)) |
|
| 130 | + { |
|
| 131 | + $messages = $messages ? (array)$messages : array(); |
|
| 132 | + } |
|
| 124 | 133 | |
| 125 | 134 | if ($this->debug > 1 || $this->debug == 'update') |
| 126 | 135 | { |
@@ -140,10 +149,13 @@ discard block |
||
| 140 | 149 | |
| 141 | 150 | $status_reset_to_unknown = false; |
| 142 | 151 | |
| 143 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
| 152 | + if (($new_event = !$event['id'])) |
|
| 153 | + { |
|
| 154 | + // some defaults for new entries |
|
| 144 | 155 | { |
| 145 | 156 | // if no owner given, set user to owner |
| 146 | 157 | if (!$event['owner']) $event['owner'] = $this->user; |
| 158 | + } |
|
| 147 | 159 | // set owner as participant if none is given |
| 148 | 160 | if (!is_array($event['participants']) || !count($event['participants'])) |
| 149 | 161 | { |
@@ -183,7 +195,10 @@ discard block |
||
| 183 | 195 | // check category based ACL |
| 184 | 196 | if ($event['category']) |
| 185 | 197 | { |
| 186 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 198 | + if (!is_array($event['category'])) |
|
| 199 | + { |
|
| 200 | + $event['category'] = explode(',',$event['category']); |
|
| 201 | + } |
|
| 187 | 202 | if (!$old_event || !isset($old_event['category'])) |
| 188 | 203 | { |
| 189 | 204 | $old_event['category'] = array(); |
@@ -235,13 +250,16 @@ discard block |
||
| 235 | 250 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) && |
| 236 | 251 | (($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding)) |
| 237 | 252 | { |
| 238 | - if ($checked_excluding) // warn user if not all recurrences have been checked |
|
| 253 | + if ($checked_excluding) |
|
| 254 | + { |
|
| 255 | + // warn user if not all recurrences have been checked |
|
| 239 | 256 | { |
| 240 | 257 | $conflicts['warning'] = array( |
| 241 | 258 | 'start' => $checked_excluding, |
| 242 | 259 | 'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)), |
| 243 | 260 | ); |
| 244 | 261 | } |
| 262 | + } |
|
| 245 | 263 | return $conflicts; |
| 246 | 264 | } |
| 247 | 265 | |
@@ -305,7 +323,10 @@ discard block |
||
| 305 | 323 | $types_with_quantity = array(); |
| 306 | 324 | foreach($this->resources as $type => $data) |
| 307 | 325 | { |
| 308 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 326 | + if ($data['max_quantity']) |
|
| 327 | + { |
|
| 328 | + $types_with_quantity[] = $type; |
|
| 329 | + } |
|
| 309 | 330 | } |
| 310 | 331 | // get all NOT rejected participants and evtl. their quantity |
| 311 | 332 | $quantity = $users = array(); |
@@ -313,12 +334,19 @@ discard block |
||
| 313 | 334 | { |
| 314 | 335 | $q = $role = null; |
| 315 | 336 | calendar_so::split_status($status, $q, $role); |
| 316 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
| 337 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 338 | + { |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 341 | + // ignore rejected or non-participants |
|
| 317 | 342 | |
| 318 | - if ($uid < 0) // group, check it's members too |
|
| 343 | + if ($uid < 0) |
|
| 344 | + { |
|
| 345 | + // group, check it's members too |
|
| 319 | 346 | { |
| 320 | 347 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
| 321 | 348 | } |
| 349 | + } |
|
| 322 | 350 | $users[] = $uid; |
| 323 | 351 | if (in_array($uid[0],$types_with_quantity)) |
| 324 | 352 | { |
@@ -349,18 +377,24 @@ discard block |
||
| 349 | 377 | $startts = $date->format('ts'); |
| 350 | 378 | |
| 351 | 379 | // skip past events or recurrences |
| 352 | - if ($startts+$duration < $this->now_su) continue; |
|
| 380 | + if ($startts+$duration < $this->now_su) |
|
| 381 | + { |
|
| 382 | + continue; |
|
| 383 | + } |
|
| 353 | 384 | |
| 354 | 385 | // abort check if configured limits are exceeded |
| 355 | 386 | if ($event['recur_type'] && |
| 356 | 387 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 357 | 388 | microtime(true) > $start+$max_check_time || // max check time exceeded |
| 358 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
| 389 | + $startts > $this->config['horizont'])) |
|
| 390 | + { |
|
| 391 | + // we are behind horizon for which recurrences are rendered |
|
| 359 | 392 | { |
| 360 | 393 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 361 | 394 | { |
| 362 | 395 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 363 | 396 | $checked, microtime(true)-$start, $date); |
| 397 | + } |
|
| 364 | 398 | } |
| 365 | 399 | $checked_excluding = $date; |
| 366 | 400 | break; |
@@ -384,10 +418,13 @@ discard block |
||
| 384 | 418 | { |
| 385 | 419 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 386 | 420 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 387 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 421 | + $overlap['non_blocking']) |
|
| 422 | + { |
|
| 423 | + // that's a non_blocking event |
|
| 388 | 424 | { |
| 389 | 425 | continue; |
| 390 | 426 | } |
| 427 | + } |
|
| 391 | 428 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 392 | 429 | { |
| 393 | 430 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -875,14 +912,20 @@ discard block |
||
| 875 | 912 | $startdate = new Api\DateTime($event['start']); |
| 876 | 913 | $enddate = new Api\DateTime($event['end']); |
| 877 | 914 | $modified = new Api\DateTime($event['modified']); |
| 878 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
| 915 | + if ($old_event) |
|
| 916 | + { |
|
| 917 | + $olddate = new Api\DateTime($old_event['start']); |
|
| 918 | + } |
|
| 879 | 919 | //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() : '')); |
| 880 | 920 | $owner_prefs = $ics = null; |
| 881 | 921 | foreach($to_notify as $userid => $statusid) |
| 882 | 922 | { |
| 883 | 923 | $res_info = $quantity = $role = null; |
| 884 | 924 | calendar_so::split_status($statusid, $quantity, $role); |
| 885 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 925 | + if ($this->debug > 0) |
|
| 926 | + { |
|
| 927 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 928 | + } |
|
| 886 | 929 | |
| 887 | 930 | if (!is_numeric($userid)) |
| 888 | 931 | { |
@@ -901,7 +944,11 @@ discard block |
||
| 901 | 944 | |
| 902 | 945 | if (!isset($userid)) |
| 903 | 946 | { |
| 904 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 947 | + if (empty($res_info['email'])) |
|
| 948 | + { |
|
| 949 | + continue; |
|
| 950 | + } |
|
| 951 | + // no way to notify |
|
| 905 | 952 | // check if event-owner wants non-EGroupware users notified |
| 906 | 953 | if (is_null($owner_prefs)) |
| 907 | 954 | { |
@@ -975,7 +1022,10 @@ discard block |
||
| 975 | 1022 | $details['to-lastname'] = isset($tln)? $tln: ''; |
| 976 | 1023 | |
| 977 | 1024 | // 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 |
| 978 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1025 | + if (!isset($part_prefs['common']['tz'])) |
|
| 1026 | + { |
|
| 1027 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 1028 | + } |
|
| 979 | 1029 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 980 | 1030 | $timeformat = $part_prefs['common']['timeformat']; |
| 981 | 1031 | switch($timeformat) |
@@ -1010,9 +1060,12 @@ discard block |
||
| 1010 | 1060 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 1011 | 1061 | { |
| 1012 | 1062 | case 'ical': |
| 1013 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 1063 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 1064 | + { |
|
| 1065 | + // need different ical for organizer notification |
|
| 1014 | 1066 | { |
| 1015 | 1067 | $calendar_ical = new calendar_ical(); |
| 1068 | + } |
|
| 1016 | 1069 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 1017 | 1070 | // we need to pass $event[id] so iCal class reads event again, |
| 1018 | 1071 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1028,7 +1081,10 @@ discard block |
||
| 1028 | 1081 | 'encoding' => '8bit', |
| 1029 | 1082 | 'type' => 'text/calendar; method='.$method, |
| 1030 | 1083 | ); |
| 1031 | - if ($m_type != $msg_type) unset($ics); |
|
| 1084 | + if ($m_type != $msg_type) |
|
| 1085 | + { |
|
| 1086 | + unset($ics); |
|
| 1087 | + } |
|
| 1032 | 1088 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 1033 | 1089 | // fall through |
| 1034 | 1090 | case 'extended': |
@@ -1088,11 +1144,16 @@ discard block |
||
| 1088 | 1144 | 'app' => 'calendar' |
| 1089 | 1145 | )); |
| 1090 | 1146 | } |
| 1091 | - if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1147 | + if ($m_type === MSG_ALARM) |
|
| 1148 | + { |
|
| 1149 | + $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
| 1150 | + } |
|
| 1092 | 1151 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
| 1093 | 1152 | $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
| 1094 | 1153 | |
| 1095 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1154 | + if(is_array($attachment)) |
|
| 1155 | + { |
|
| 1156 | +$notification->set_attachments(array($attachment)); } |
|
| 1096 | 1157 | $notification->send(); |
| 1097 | 1158 | foreach(notifications::errors(true) as $error) |
| 1098 | 1159 | { |
@@ -1128,7 +1189,10 @@ discard block |
||
| 1128 | 1189 | Api\Translation::init(); |
| 1129 | 1190 | } |
| 1130 | 1191 | // restore timezone, in case we had to reset it to server-timezone |
| 1131 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1192 | + if ($restore_tz) |
|
| 1193 | + { |
|
| 1194 | + date_default_timezone_set($restore_tz); |
|
| 1195 | + } |
|
| 1132 | 1196 | |
| 1133 | 1197 | return true; |
| 1134 | 1198 | } |
@@ -1163,10 +1227,13 @@ discard block |
||
| 1163 | 1227 | { |
| 1164 | 1228 | $to_notify = $event['participants']; |
| 1165 | 1229 | } |
| 1166 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1230 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
| 1231 | + { |
|
| 1232 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1167 | 1233 | { |
| 1168 | 1234 | $to_notify[$alarm['owner']] = 'A'; |
| 1169 | 1235 | } |
| 1236 | + } |
|
| 1170 | 1237 | else |
| 1171 | 1238 | { |
| 1172 | 1239 | return False; // no rights |
@@ -1215,14 +1282,20 @@ discard block |
||
| 1215 | 1282 | if ($event['id']) |
| 1216 | 1283 | { |
| 1217 | 1284 | // invalidate the read-cache if it contains the event we store now |
| 1218 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1285 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1286 | + { |
|
| 1287 | + self::$cached_event = array(); |
|
| 1288 | + } |
|
| 1219 | 1289 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
| 1220 | 1290 | } |
| 1221 | 1291 | else |
| 1222 | 1292 | { |
| 1223 | 1293 | $old_event = null; |
| 1224 | 1294 | } |
| 1225 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1295 | + if (!isset($event['whole_day'])) |
|
| 1296 | + { |
|
| 1297 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1298 | + } |
|
| 1226 | 1299 | |
| 1227 | 1300 | // set recur-enddate/range-end to real end-date of last recurrence |
| 1228 | 1301 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
@@ -1299,7 +1372,10 @@ discard block |
||
| 1299 | 1372 | foreach($timestamps as $ts) |
| 1300 | 1373 | { |
| 1301 | 1374 | // we convert here from user-time to timestamps in server-time! |
| 1302 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1375 | + if (isset($event[$ts])) |
|
| 1376 | + { |
|
| 1377 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1378 | + } |
|
| 1303 | 1379 | } |
| 1304 | 1380 | // convert tzid name to integer tz_id, of set user default |
| 1305 | 1381 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1335,7 +1411,10 @@ discard block |
||
| 1335 | 1411 | if ($alarm['owner'] && isset($expanded['participants'])) |
| 1336 | 1412 | { |
| 1337 | 1413 | // Don't auto-delete alarm if for all users |
| 1338 | - if($alarm['all']) continue; |
|
| 1414 | + if($alarm['all']) |
|
| 1415 | + { |
|
| 1416 | + continue; |
|
| 1417 | + } |
|
| 1339 | 1418 | |
| 1340 | 1419 | $status = $expanded['participants'][$alarm['owner']]; |
| 1341 | 1420 | if (!isset($status) || calendar_so::split_status($status) === 'R') |
@@ -1356,7 +1435,10 @@ discard block |
||
| 1356 | 1435 | if (!isset($event['alarm'][$id])) |
| 1357 | 1436 | { |
| 1358 | 1437 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1359 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1438 | + if ($alarm['time'] < time()) |
|
| 1439 | + { |
|
| 1440 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1441 | + } |
|
| 1360 | 1442 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1361 | 1443 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1362 | 1444 | $old_event['participants'][$alarm['owner']]; |
@@ -1412,7 +1494,10 @@ discard block |
||
| 1412 | 1494 | |
| 1413 | 1495 | // Update history |
| 1414 | 1496 | $tracking = new calendar_tracking($this); |
| 1415 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1497 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1498 | + { |
|
| 1499 | + $event['id']=$cal_id; |
|
| 1500 | + } |
|
| 1416 | 1501 | $tracking->track($save_event, $old_event); |
| 1417 | 1502 | |
| 1418 | 1503 | return $cal_id; |
@@ -1429,9 +1514,12 @@ discard block |
||
| 1429 | 1514 | */ |
| 1430 | 1515 | function check_status_perms($uid,$event) |
| 1431 | 1516 | { |
| 1432 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1517 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1518 | + { |
|
| 1519 | + // for contact we use the owner of the event |
|
| 1433 | 1520 | { |
| 1434 | 1521 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1522 | + } |
|
| 1435 | 1523 | |
| 1436 | 1524 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
| 1437 | 1525 | } |
@@ -1442,13 +1530,19 @@ discard block |
||
| 1442 | 1530 | return $access; |
| 1443 | 1531 | } |
| 1444 | 1532 | // no access or denied access because of category acl --> regular check |
| 1445 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1533 | + if (!is_numeric($uid)) |
|
| 1534 | + { |
|
| 1535 | + // this is eg. for resources (r123) |
|
| 1446 | 1536 | { |
| 1447 | 1537 | $resource = $this->resource_info($uid); |
| 1538 | + } |
|
| 1448 | 1539 | |
| 1449 | 1540 | return Acl::EDIT & $resource['rights']; |
| 1450 | 1541 | } |
| 1451 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1542 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1543 | + { |
|
| 1544 | + return false; |
|
| 1545 | + } |
|
| 1452 | 1546 | |
| 1453 | 1547 | // regular user and groups (need to check memberships too) |
| 1454 | 1548 | if (!isset($event['participants'][$uid])) |
@@ -1472,7 +1566,10 @@ discard block |
||
| 1472 | 1566 | */ |
| 1473 | 1567 | function check_cat_acl($right,$event) |
| 1474 | 1568 | { |
| 1475 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1569 | + if (!is_array($event)) |
|
| 1570 | + { |
|
| 1571 | + $event = $this->read($event); |
|
| 1572 | + } |
|
| 1476 | 1573 | |
| 1477 | 1574 | $ret = null; |
| 1478 | 1575 | if ($event['category']) |
@@ -1529,7 +1626,10 @@ discard block |
||
| 1529 | 1626 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1530 | 1627 | { |
| 1531 | 1628 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1532 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1629 | + if (!isset(self::$cat_rights_cache)) |
|
| 1630 | + { |
|
| 1631 | + self::get_cat_rights($cat_id); |
|
| 1632 | + } |
|
| 1533 | 1633 | |
| 1534 | 1634 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1535 | 1635 | { |
@@ -1541,7 +1641,10 @@ discard block |
||
| 1541 | 1641 | else |
| 1542 | 1642 | { |
| 1543 | 1643 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1544 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1644 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1645 | + { |
|
| 1646 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1647 | + } |
|
| 1545 | 1648 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1546 | 1649 | } |
| 1547 | 1650 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1574,7 +1677,10 @@ discard block |
||
| 1574 | 1677 | foreach($cat_rights as $uid => $value) |
| 1575 | 1678 | { |
| 1576 | 1679 | $all |= $value; |
| 1577 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1680 | + if (in_array($uid,$memberships)) |
|
| 1681 | + { |
|
| 1682 | + $own |= $value; |
|
| 1683 | + } |
|
| 1578 | 1684 | } |
| 1579 | 1685 | } |
| 1580 | 1686 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1621,13 +1727,16 @@ discard block |
||
| 1621 | 1727 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1622 | 1728 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1623 | 1729 | { |
| 1624 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1730 | + if ($status == 'R') |
|
| 1731 | + { |
|
| 1732 | + // remove alarms belonging to rejected participants |
|
| 1625 | 1733 | { |
| 1626 | 1734 | foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1627 | 1735 | { |
| 1628 | 1736 | if ((string)$alarm['owner'] === (string)$uid) |
| 1629 | 1737 | { |
| 1630 | 1738 | $this->so->delete_alarm($id); |
| 1739 | + } |
|
| 1631 | 1740 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1632 | 1741 | } |
| 1633 | 1742 | } |
@@ -1644,8 +1753,15 @@ discard block |
||
| 1644 | 1753 | |
| 1645 | 1754 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1646 | 1755 | { |
| 1647 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1648 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1756 | + if (!is_array($event)) |
|
| 1757 | + { |
|
| 1758 | + $event = $this->read($cal_id); |
|
| 1759 | + } |
|
| 1760 | + if (isset($recur_date)) |
|
| 1761 | + { |
|
| 1762 | + $event = $this->read($event['id'],$recur_date); |
|
| 1763 | + } |
|
| 1764 | + //re-read the actually edited recurring event |
|
| 1649 | 1765 | $this->send_update($status2msg[$status],$event['participants'],$event); |
| 1650 | 1766 | } |
| 1651 | 1767 | |
@@ -1668,12 +1784,16 @@ discard block |
||
| 1668 | 1784 | */ |
| 1669 | 1785 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1670 | 1786 | { |
| 1671 | - if (!isset($new_event['participants'])) return; |
|
| 1787 | + if (!isset($new_event['participants'])) |
|
| 1788 | + { |
|
| 1789 | + return; |
|
| 1790 | + } |
|
| 1672 | 1791 | |
| 1673 | 1792 | // check the old list against the new list |
| 1674 | 1793 | foreach ($old_event['participants'] as $userid => $status) |
| 1675 | - { |
|
| 1676 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1794 | + { |
|
| 1795 | + if (!isset($new_event['participants'][$userid])) |
|
| 1796 | + { |
|
| 1677 | 1797 | // Attendee will be deleted this way |
| 1678 | 1798 | $new_event['participants'][$userid] = 'G'; |
| 1679 | 1799 | } |
@@ -1756,7 +1876,10 @@ discard block |
||
| 1756 | 1876 | } |
| 1757 | 1877 | else |
| 1758 | 1878 | { |
| 1759 | - if (!($exception = $this->read($id))) continue; |
|
| 1879 | + if (!($exception = $this->read($id))) |
|
| 1880 | + { |
|
| 1881 | + continue; |
|
| 1882 | + } |
|
| 1760 | 1883 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1761 | 1884 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1762 | 1885 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1827,7 +1950,10 @@ discard block |
||
| 1827 | 1950 | $event_arr = $this->event2array($event); |
| 1828 | 1951 | foreach($event_arr as $key => $val) |
| 1829 | 1952 | { |
| 1830 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1953 | + if ($key == 'recur_type') |
|
| 1954 | + { |
|
| 1955 | + $key = 'repetition'; |
|
| 1956 | + } |
|
| 1831 | 1957 | $details[$key] = $val['data']; |
| 1832 | 1958 | } |
| 1833 | 1959 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1836,7 +1962,10 @@ discard block |
||
| 1836 | 1962 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
| 1837 | 1963 | $link = $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit&cal_id='.$event['id'].'&date='.$eventStart_arr['full'].'&no_popup=1&ajax=true'; |
| 1838 | 1964 | // if url is only a path, try guessing the rest ;-) |
| 1839 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
| 1965 | + if ($link[0] == '/') |
|
| 1966 | + { |
|
| 1967 | + $link = Api\Framework::getUrl($link); |
|
| 1968 | + } |
|
| 1840 | 1969 | $event_arr['link']['data'] = $details['link'] = $link; |
| 1841 | 1970 | |
| 1842 | 1971 | /* this is needed for notification-app |
@@ -2009,7 +2138,10 @@ discard block |
||
| 2009 | 2138 | */ |
| 2010 | 2139 | function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
| 2011 | 2140 | { |
| 2012 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 2141 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 2142 | + { |
|
| 2143 | + return; |
|
| 2144 | + } |
|
| 2013 | 2145 | |
| 2014 | 2146 | $time = new Api\DateTime($event['start']); |
| 2015 | 2147 | if(!is_array($event['alarm'])) |
@@ -2092,7 +2224,10 @@ discard block |
||
| 2092 | 2224 | if (is_array($old_event) || $old_event > 0) |
| 2093 | 2225 | { |
| 2094 | 2226 | // preserve categories without users read access |
| 2095 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2227 | + if (!is_array($old_event)) |
|
| 2228 | + { |
|
| 2229 | + $old_event = $this->read($old_event); |
|
| 2230 | + } |
|
| 2096 | 2231 | $old_categories = explode(',',$old_event['category']); |
| 2097 | 2232 | $old_cats_preserve = array(); |
| 2098 | 2233 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2183,7 +2318,10 @@ discard block |
||
| 2183 | 2318 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 2184 | 2319 | } |
| 2185 | 2320 | |
| 2186 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2321 | + if (!isset($event['recurrence'])) |
|
| 2322 | + { |
|
| 2323 | + $event['recurrence'] = 0; |
|
| 2324 | + } |
|
| 2187 | 2325 | |
| 2188 | 2326 | if ($filter == 'master') |
| 2189 | 2327 | { |
@@ -2237,19 +2375,26 @@ discard block |
||
| 2237 | 2375 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2238 | 2376 | } |
| 2239 | 2377 | } |
| 2240 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2378 | + } |
|
| 2379 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2241 | 2380 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2242 | 2381 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2243 | 2382 | { |
| 2244 | 2383 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2245 | 2384 | } |
| 2246 | 2385 | } |
| 2247 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2386 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2387 | + { |
|
| 2388 | + return $matchingEvents; |
|
| 2389 | + } |
|
| 2248 | 2390 | } |
| 2249 | 2391 | unset($event['id']); |
| 2250 | 2392 | |
| 2251 | 2393 | // No chance to find a master without [U]ID |
| 2252 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2394 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2395 | + { |
|
| 2396 | + return $matchingEvents; |
|
| 2397 | + } |
|
| 2253 | 2398 | |
| 2254 | 2399 | // only query calendars of users, we have READ-grants from |
| 2255 | 2400 | $users = array(); |
@@ -2258,17 +2403,23 @@ discard block |
||
| 2258 | 2403 | $user = trim($user); |
| 2259 | 2404 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
| 2260 | 2405 | { |
| 2261 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2406 | + if ($user && !in_array($user,$users)) |
|
| 2407 | + { |
|
| 2408 | + // already added? |
|
| 2262 | 2409 | { |
| 2263 | 2410 | $users[] = $user; |
| 2264 | 2411 | } |
| 2412 | + } |
|
| 2265 | 2413 | } |
| 2266 | 2414 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2267 | 2415 | { |
| 2268 | 2416 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2269 | 2417 | } |
| 2270 | 2418 | // the further code is only for real users |
| 2271 | - if (!is_numeric($user)) continue; |
|
| 2419 | + if (!is_numeric($user)) |
|
| 2420 | + { |
|
| 2421 | + continue; |
|
| 2422 | + } |
|
| 2272 | 2423 | |
| 2273 | 2424 | // for groups we have to include the members |
| 2274 | 2425 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2348,7 +2499,10 @@ discard block |
||
| 2348 | 2499 | } |
| 2349 | 2500 | foreach ($matchFields as $key) |
| 2350 | 2501 | { |
| 2351 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2502 | + if (isset($event[$key])) |
|
| 2503 | + { |
|
| 2504 | + $query['cal_'.$key] = $event[$key]; |
|
| 2505 | + } |
|
| 2352 | 2506 | } |
| 2353 | 2507 | } |
| 2354 | 2508 | |
@@ -2388,7 +2542,10 @@ discard block |
||
| 2388 | 2542 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2389 | 2543 | } |
| 2390 | 2544 | |
| 2391 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2545 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2546 | + { |
|
| 2547 | + continue; |
|
| 2548 | + } |
|
| 2392 | 2549 | |
| 2393 | 2550 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2394 | 2551 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2555,13 +2712,16 @@ discard block |
||
| 2555 | 2712 | foreach ($event['participants'] as $attendee => $status) |
| 2556 | 2713 | { |
| 2557 | 2714 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2558 | - $attendee != $egwEvent['owner']) // || |
|
| 2715 | + $attendee != $egwEvent['owner']) |
|
| 2716 | + { |
|
| 2717 | + // || |
|
| 2559 | 2718 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2560 | 2719 | { |
| 2561 | 2720 | if ($this->log) |
| 2562 | 2721 | { |
| 2563 | 2722 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2564 | 2723 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2724 | + } |
|
| 2565 | 2725 | } |
| 2566 | 2726 | continue 2; |
| 2567 | 2727 | } |
@@ -2883,7 +3043,10 @@ discard block |
||
| 2883 | 3043 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2884 | 3044 | { |
| 2885 | 3045 | // we convert here from server-time to timestamps in user-time! |
| 2886 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3046 | + if (isset($event[$ts])) |
|
| 3047 | + { |
|
| 3048 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 3049 | + } |
|
| 2887 | 3050 | } |
| 2888 | 3051 | // same with the recur exceptions |
| 2889 | 3052 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2911,9 +3074,12 @@ discard block |
||
| 2911 | 3074 | */ |
| 2912 | 3075 | function purge($age) |
| 2913 | 3076 | { |
| 2914 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 3077 | + if (is_numeric($age) && $age > 0) |
|
| 3078 | + { |
|
| 3079 | + // just make sure bogus values dont delete everything |
|
| 2915 | 3080 | { |
| 2916 | 3081 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2917 | 3082 | } |
| 3083 | + } |
|
| 2918 | 3084 | } |
| 2919 | 3085 | } |
@@ -135,6 +135,9 @@ |
||
| 135 | 135 | return $until_year ? $years : $years[$year]; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + /** |
|
| 139 | + * @param string $url |
|
| 140 | + */ |
|
| 138 | 141 | protected static function is_url($url) |
| 139 | 142 | { |
| 140 | 143 | return $url[0] == '/' || strpos($url, '://') !== false; |
@@ -41,7 +41,10 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function read($country, $year=null) |
| 43 | 43 | { |
| 44 | - if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
|
| 44 | + if (!$year) |
|
| 45 | + { |
|
| 46 | + $year = (int)Api\DateTime::to('now', 'Y'); |
|
| 47 | + } |
|
| 45 | 48 | $level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE; |
| 46 | 49 | |
| 47 | 50 | $holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year); |
@@ -68,7 +71,10 @@ discard block |
||
| 68 | 71 | */ |
| 69 | 72 | public static function render($country, $year=null, $until_year=null) |
| 70 | 73 | { |
| 71 | - if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
|
| 74 | + if (!$year) |
|
| 75 | + { |
|
| 76 | + $year = (int)Api\DateTime::to('now', 'Y'); |
|
| 77 | + } |
|
| 72 | 78 | $end_year = $until_year && $year < $until_year ? $until_year : $year; |
| 73 | 79 | |
| 74 | 80 | $starttime = microtime(true); |
@@ -81,22 +87,40 @@ discard block |
||
| 81 | 87 | { |
| 82 | 88 | $start = new Api\DateTime($event['start']); |
| 83 | 89 | $end = new Api\DateTime($event['end']); |
| 84 | - if ($start->format('Y') > $end_year) continue; |
|
| 85 | - if ($end->format('Y') < $year && !$event['recur_type']) continue; |
|
| 90 | + if ($start->format('Y') > $end_year) |
|
| 91 | + { |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 94 | + if ($end->format('Y') < $year && !$event['recur_type']) |
|
| 95 | + { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 86 | 98 | |
| 87 | 99 | // recuring events |
| 88 | 100 | if ($event['recur_type']) |
| 89 | 101 | { |
| 90 | 102 | // calendar_rrule limits no enddate, to 5 years |
| 91 | - if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101'; |
|
| 103 | + if (!$event['recur_enddate']) |
|
| 104 | + { |
|
| 105 | + $event['recur_enddate'] = (1+$end_year).'0101'; |
|
| 106 | + } |
|
| 92 | 107 | |
| 93 | 108 | $rrule = calendar_rrule::event2rrule($event); |
| 94 | - if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue; |
|
| 109 | + if ($rrule->enddate && $rrule->enddate->format('Y') < $year) |
|
| 110 | + { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 95 | 113 | |
| 96 | 114 | foreach($rrule as $rtime) |
| 97 | 115 | { |
| 98 | - if (($y = (int)$rtime->format('Y')) < $year) continue; |
|
| 99 | - if ($y > $end_year) break; |
|
| 116 | + if (($y = (int)$rtime->format('Y')) < $year) |
|
| 117 | + { |
|
| 118 | + continue; |
|
| 119 | + } |
|
| 120 | + if ($y > $end_year) |
|
| 121 | + { |
|
| 122 | + break; |
|
| 123 | + } |
|
| 100 | 124 | |
| 101 | 125 | $ymd = (int)$rtime->format('Ymd'); |
| 102 | 126 | $years[$y][(string)$ymd][] = array( |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param int $year =null default current year |
| 45 | 45 | * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title' |
| 46 | 46 | */ |
| 47 | - public static function read($country, $year=null) |
|
| 47 | + public static function read($country, $year = null) |
|
| 48 | 48 | { |
| 49 | 49 | if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
| 50 | 50 | $level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE; |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | $holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year); |
| 53 | 53 | |
| 54 | 54 | // if we dont find holidays in cache, we render from previous year until next 5 years |
| 55 | - if (!isset($holidays) && ($years = self::render($country, $year-1, $year+5))) |
|
| 55 | + if (!isset($holidays) && ($years = self::render($country, $year - 1, $year + 5))) |
|
| 56 | 56 | { |
| 57 | - foreach($years as $y => $data) |
|
| 57 | + foreach ($years as $y => $data) |
|
| 58 | 58 | { |
| 59 | 59 | Api\Cache::setCache($level, __CLASS__, $country.':'.$y, $data, self::HOLIDAY_CACHE_TIME); |
| 60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param int $until_year =null default, fetch only one year, if given result is indexed additional by year |
| 72 | 72 | * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title' |
| 73 | 73 | */ |
| 74 | - public static function render($country, $year=null, $until_year=null) |
|
| 74 | + public static function render($country, $year = null, $until_year = null) |
|
| 75 | 75 | { |
| 76 | 76 | if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
| 77 | 77 | $end_year = $until_year && $year < $until_year ? $until_year : $year; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | return array(); |
| 83 | 83 | } |
| 84 | 84 | $years = array(); |
| 85 | - foreach($holidays as $event) |
|
| 85 | + foreach ($holidays as $event) |
|
| 86 | 86 | { |
| 87 | 87 | $start = new Api\DateTime($event['start']); |
| 88 | 88 | $end = new Api\DateTime($event['end']); |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | if ($event['recur_type']) |
| 94 | 94 | { |
| 95 | 95 | // calendar_rrule limits no enddate, to 5 years |
| 96 | - if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101'; |
|
| 96 | + if (!$event['recur_enddate']) $event['recur_enddate'] = (1 + $end_year).'0101'; |
|
| 97 | 97 | |
| 98 | 98 | $rrule = calendar_rrule::event2rrule($event); |
| 99 | 99 | if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue; |
| 100 | 100 | |
| 101 | - foreach($rrule as $rtime) |
|
| 101 | + foreach ($rrule as $rtime) |
|
| 102 | 102 | { |
| 103 | 103 | if (($y = (int)$rtime->format('Y')) < $year) continue; |
| 104 | 104 | if ($y > $end_year) break; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | 118 | $end_ymd = (int)$end->format('Ymd'); |
| 119 | - while(($ymd = (int)$start->format('Ymd')) <= $end_ymd) |
|
| 119 | + while (($ymd = (int)$start->format('Ymd')) <= $end_ymd) |
|
| 120 | 120 | { |
| 121 | 121 | $y = (int)$start->format('Y'); |
| 122 | 122 | $years[$y][(string)$ymd][] = array( |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | - foreach($years as $y => &$data) |
|
| 133 | + foreach ($years as $y => &$data) |
|
| 134 | 134 | { |
| 135 | 135 | ksort($data); |
| 136 | 136 | } |
| 137 | - error_log(__METHOD__."('$country', $year, $end_year) took ". number_format(microtime(true)-$starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events'); |
|
| 137 | + error_log(__METHOD__."('$country', $year, $end_year) took ".number_format(microtime(true) - $starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events'); |
|
| 138 | 138 | unset($starttime); |
| 139 | 139 | |
| 140 | 140 | return $until_year ? $years : $years[$year]; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | // php does not automatic gzip decode, but it does not accept that in request headers |
| 167 | 167 | // iCloud eg. always gzip compresses: https://p16-calendars.icloud.com/holidays/au_en-au.ics |
| 168 | - foreach($http_response_header as $h) |
|
| 168 | + foreach ($http_response_header as $h) |
|
| 169 | 169 | { |
| 170 | 170 | if (preg_match('/^content-encoding:.*gzip/i', $h)) |
| 171 | 171 | { |
@@ -204,6 +204,7 @@ |
||
| 204 | 204 | * |
| 205 | 205 | * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date |
| 206 | 206 | * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT |
| 207 | + * @param boolean $updated |
|
| 207 | 208 | * @return string message about update |
| 208 | 209 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
| 209 | 210 | * @throws Api\Exception\WrongUserinput if no PDO sqlite support |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public static function DateTimeZone($tzid) |
| 73 | 73 | { |
| 74 | - if (($id = self::tz2id($tzid,'alias'))) |
|
| 74 | + if (($id = self::tz2id($tzid, 'alias'))) |
|
| 75 | 75 | { |
| 76 | 76 | $tzid = self::id2tz($id); |
| 77 | 77 | } |
@@ -89,34 +89,34 @@ discard block |
||
| 89 | 89 | * @param string $what ='id' what to return, default id, null for whole array |
| 90 | 90 | * @return int tz_id or null if not found |
| 91 | 91 | */ |
| 92 | - public static function tz2id($tzid,$what='id') |
|
| 92 | + public static function tz2id($tzid, $what = 'id') |
|
| 93 | 93 | { |
| 94 | - $id =& self::$tz2id[$tzid]; |
|
| 94 | + $id = & self::$tz2id[$tzid]; |
|
| 95 | 95 | |
| 96 | 96 | if (!isset($id)) |
| 97 | 97 | { |
| 98 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 98 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 99 | 99 | 'tz_tzid' => $tzid, |
| 100 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 100 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 101 | 101 | { |
| 102 | 102 | $id = $data['tz_id']; |
| 103 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
| 103 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | // check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires' |
| 107 | 107 | if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2) |
| 108 | 108 | { |
| 109 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 109 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 110 | 110 | 'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]), |
| 111 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 111 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 112 | 112 | { |
| 113 | 113 | $id = $data['tz_id']; |
| 114 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
| 114 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | if (isset($id) && $what != 'id') |
| 118 | 118 | { |
| 119 | - return self::id2tz($id,$what); |
|
| 119 | + return self::id2tz($id, $what); |
|
| 120 | 120 | } |
| 121 | 121 | return $id; |
| 122 | 122 | } |
@@ -134,24 +134,24 @@ discard block |
||
| 134 | 134 | * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude' |
| 135 | 135 | * @return mixed false: if not found |
| 136 | 136 | */ |
| 137 | - public static function id2tz($id,$what='tzid') |
|
| 137 | + public static function id2tz($id, $what = 'tzid') |
|
| 138 | 138 | { |
| 139 | - $data =& self::$tz_cache[$id]; |
|
| 139 | + $data = & self::$tz_cache[$id]; |
|
| 140 | 140 | |
| 141 | 141 | if (!isset($data)) |
| 142 | 142 | { |
| 143 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
| 143 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
| 144 | 144 | 'tz_id' => $id, |
| 145 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
| 145 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
| 146 | 146 | { |
| 147 | - $data = Api\Db::strip_array_keys($data,'tz_'); |
|
| 147 | + $data = Api\Db::strip_array_keys($data, 'tz_'); |
|
| 148 | 148 | self::$tz2id[$data['tzid']] = $id; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | // if not tzid queried, resolve aliases automatically |
| 152 | 152 | if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') |
| 153 | 153 | { |
| 154 | - $data = self::id2tz($data['alias'],null); |
|
| 154 | + $data = self::id2tz($data['alias'], null); |
|
| 155 | 155 | } |
| 156 | 156 | return !$data ? $data : ($what ? $data[$what] : $data); |
| 157 | 157 | } |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public static function init_static() |
| 172 | 172 | { |
| 173 | - self::$tz_cache =& Api\Cache::getSession(__CLASS__,'tz_cache'); |
|
| 174 | - self::$tz2id =& Api\Cache::getSession(__CLASS__,'tz2id'); |
|
| 173 | + self::$tz_cache = & Api\Cache::getSession(__CLASS__, 'tz_cache'); |
|
| 174 | + self::$tz2id = & Api\Cache::getSession(__CLASS__, 'tz2id'); |
|
| 175 | 175 | |
| 176 | 176 | // init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar |
| 177 | 177 | if (!is_array(self::$tz2id)) |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $updated = false; |
| 190 | 190 | $msg = self::import_zones($updated); |
| 191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
| 191 | + if ($updated) error_log($msg); // log that timezones have been updated |
|
| 192 | 192 | |
| 193 | 193 | $alias_msg = self::import_tz_aliases($updated); |
| 194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 194 | + if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 195 | 195 | |
| 196 | 196 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
| 197 | 197 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @throws Api\Exception\WrongUserinput for broken sqlite extension |
| 211 | 211 | * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json |
| 212 | 212 | */ |
| 213 | - public static function import_zones(&$updated=null, $file='calendar/setup/zones.json') |
|
| 213 | + public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json') |
|
| 214 | 214 | { |
| 215 | 215 | $path = EGW_SERVER_ROOT.'/'.$file; |
| 216 | 216 | |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | { |
| 233 | 233 | $updated = false; |
| 234 | 234 | fclose($fp); |
| 235 | - return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right |
|
| 235 | + return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right |
|
| 236 | 236 | } |
| 237 | - $json .= fread($fp, 1024*1024); |
|
| 237 | + $json .= fread($fp, 1024 * 1024); |
|
| 238 | 238 | fclose($fp); |
| 239 | 239 | if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones'])) |
| 240 | 240 | { |
@@ -242,38 +242,38 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | // import zones first and then aliases |
| 244 | 244 | $tz2id = array(); |
| 245 | - foreach(array('zones', 'aliases') as $type) |
|
| 245 | + foreach (array('zones', 'aliases') as $type) |
|
| 246 | 246 | { |
| 247 | - foreach($zones[$type] as $tzid => $data) |
|
| 247 | + foreach ($zones[$type] as $tzid => $data) |
|
| 248 | 248 | { |
| 249 | 249 | if ($type == 'aliases') |
| 250 | 250 | { |
| 251 | 251 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
| 252 | - if (!$data['alias']) continue; // there's no such tzid |
|
| 252 | + if (!$data['alias']) continue; // there's no such tzid |
|
| 253 | 253 | } |
| 254 | 254 | // check if already in database |
| 255 | - $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
|
| 255 | + $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array( |
|
| 256 | 256 | 'tz_tzid' => $tzid, |
| 257 | - ),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 257 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 258 | 258 | |
| 259 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
| 259 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
| 260 | 260 | 'tz_alias' => $data['alias'], |
| 261 | 261 | 'tz_latitude' => $data['latitude'], |
| 262 | 262 | 'tz_longitude' => $data['longitude'], |
| 263 | 263 | 'tz_component' => $data['ics'], |
| 264 | - ),array( |
|
| 264 | + ), array( |
|
| 265 | 265 | 'tz_tzid' => $tzid, |
| 266 | - ),__LINE__,__FILE__,'calendar'); |
|
| 266 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 267 | 267 | |
| 268 | 268 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
| 269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 269 | + if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id'); |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
| 273 | 273 | |
| 274 | 274 | //_debug_array($tz2id); |
| 275 | 275 | $updated = true; |
| 276 | - return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id)); |
|
| 276 | + return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id)); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @return string message about update |
| 285 | 285 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
| 286 | 286 | */ |
| 287 | - public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php') |
|
| 287 | + public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php') |
|
| 288 | 288 | { |
| 289 | 289 | $path = EGW_SERVER_ROOT.'/'.$file; |
| 290 | 290 | |
@@ -297,27 +297,27 @@ discard block |
||
| 297 | 297 | if ($tz_aliases_mtime === $config['tz_aliases_mtime']) |
| 298 | 298 | { |
| 299 | 299 | $updated = false; |
| 300 | - return lang('Nothing to update, version is already %1.',$tz_aliases_mtime); |
|
| 300 | + return lang('Nothing to update, version is already %1.', $tz_aliases_mtime); |
|
| 301 | 301 | } |
| 302 | 302 | $tz_aliases = array(); |
| 303 | - include($path); // sets $tz_aliases |
|
| 303 | + include($path); // sets $tz_aliases |
|
| 304 | 304 | |
| 305 | 305 | $updates = 0; |
| 306 | - foreach($tz_aliases as $alias => $tzid) |
|
| 306 | + foreach ($tz_aliases as $alias => $tzid) |
|
| 307 | 307 | { |
| 308 | - if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
| 308 | + if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
| 309 | 309 | ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
| 310 | 310 | { |
| 311 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
| 311 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
| 312 | 312 | 'tz_alias' => $tz_id, |
| 313 | - ),array( |
|
| 313 | + ), array( |
|
| 314 | 314 | 'tz_tzid' => $alias, |
| 315 | - ),__LINE__,__FILE__,'calendar'); |
|
| 315 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 316 | 316 | ++$updates; |
| 317 | 317 | } |
| 318 | 318 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
| 319 | 319 | } |
| 320 | - Api\Config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi'); |
|
| 320 | + Api\Config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi'); |
|
| 321 | 321 | |
| 322 | 322 | //_debug_array($tz2id); |
| 323 | 323 | $updated = true; |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | // $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly |
| 360 | 360 | // --> we have to parse it and let Horde_Icalendar add it again |
| 361 | - $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false); |
|
| 362 | - $horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE'); |
|
| 361 | + $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false); |
|
| 362 | + $horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE'); |
|
| 363 | 363 | // DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing |
| 364 | 364 | $standard = $horde_vtimezone->findComponent('STANDARD'); |
| 365 | 365 | if (is_a($standard, 'Horde_Icalendar')) |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component |
| 391 | 391 | * @return string |
| 392 | 392 | */ |
| 393 | - public static function user_timezone($user=null, $type='vcalendar') |
|
| 393 | + public static function user_timezone($user = null, $type = 'vcalendar') |
|
| 394 | 394 | { |
| 395 | 395 | if (!$user || $user == $GLOBALS['egw_info']['user']['account_id']) |
| 396 | 396 | { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | case 'vcalendar': |
| 410 | 410 | // checking type of $val, now we included the object definition (no need to always include it!) |
| 411 | 411 | $vcal = new Horde_Icalendar; |
| 412 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 412 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
| 413 | 413 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
| 414 | 414 | self::add_vtimezone($vcal, $tzid); |
| 415 | 415 | $tzid = $vcal->exportvCalendar('utf-8'); |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | case 'tzid': |
| 418 | 418 | break; |
| 419 | 419 | default: |
| 420 | - $tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type); |
|
| 420 | + $tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type); |
|
| 421 | 421 | break; |
| 422 | 422 | } |
| 423 | 423 | return $tzid; |
@@ -188,10 +188,18 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $updated = false; |
| 190 | 190 | $msg = self::import_zones($updated); |
| 191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
| 191 | + if ($updated) |
|
| 192 | + { |
|
| 193 | + error_log($msg); |
|
| 194 | + } |
|
| 195 | + // log that timezones have been updated |
|
| 192 | 196 | |
| 193 | 197 | $alias_msg = self::import_tz_aliases($updated); |
| 194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
| 198 | + if ($updated) |
|
| 199 | + { |
|
| 200 | + error_log($alias_msg); |
|
| 201 | + } |
|
| 202 | + // log that timezone aliases have been updated |
|
| 195 | 203 | |
| 196 | 204 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
| 197 | 205 | |
@@ -249,7 +257,11 @@ discard block |
||
| 249 | 257 | if ($type == 'aliases') |
| 250 | 258 | { |
| 251 | 259 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
| 252 | - if (!$data['alias']) continue; // there's no such tzid |
|
| 260 | + if (!$data['alias']) |
|
| 261 | + { |
|
| 262 | + continue; |
|
| 263 | + } |
|
| 264 | + // there's no such tzid |
|
| 253 | 265 | } |
| 254 | 266 | // check if already in database |
| 255 | 267 | $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
@@ -266,7 +278,10 @@ discard block |
||
| 266 | 278 | ),__LINE__,__FILE__,'calendar'); |
| 267 | 279 | |
| 268 | 280 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
| 269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 281 | + if (!$tz2id[$tzid]) |
|
| 282 | + { |
|
| 283 | + $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | } |
| 272 | 287 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
@@ -306,13 +321,16 @@ discard block |
||
| 306 | 321 | foreach($tz_aliases as $alias => $tzid) |
| 307 | 322 | { |
| 308 | 323 | if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
| 309 | - ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
|
| 324 | + ($tz_id = self::tz2id($tzid))) |
|
| 325 | + { |
|
| 326 | + // given tzid for alias exists in DB |
|
| 310 | 327 | { |
| 311 | 328 | $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
| 312 | 329 | 'tz_alias' => $tz_id, |
| 313 | 330 | ),array( |
| 314 | 331 | 'tz_tzid' => $alias, |
| 315 | 332 | ),__LINE__,__FILE__,'calendar'); |
| 333 | + } |
|
| 316 | 334 | ++$updates; |
| 317 | 335 | } |
| 318 | 336 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
@@ -402,7 +420,10 @@ discard block |
||
| 402 | 420 | $prefs = $prefs_obj->read(); |
| 403 | 421 | $tzid = $prefs['common']['tz']; |
| 404 | 422 | } |
| 405 | - if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName(); |
|
| 423 | + if (!$tzid) |
|
| 424 | + { |
|
| 425 | + $tzid = Api\DateTime::$server_timezone->getName(); |
|
| 426 | + } |
|
| 406 | 427 | |
| 407 | 428 | switch ($type) |
| 408 | 429 | { |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | * date instead of today |
| 1078 | 1078 | * @param boolean $no_notifications Toggle notifications to participants |
| 1079 | 1079 | * |
| 1080 | - * @return false or error message |
|
| 1080 | + * @return string|false or error message |
|
| 1081 | 1081 | */ |
| 1082 | 1082 | function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true) |
| 1083 | 1083 | { |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | * Freetime search |
| 2174 | 2174 | * |
| 2175 | 2175 | * As the function is called in a popup via javascript, parametes get initialy transfered via the url |
| 2176 | - * @param array $content=null array with parameters or false (default) to use the get-params |
|
| 2176 | + * @param array $content array with parameters or false (default) to use the get-params |
|
| 2177 | 2177 | * @param string start[str] start-date |
| 2178 | 2178 | * @param string start[hour] start-hour |
| 2179 | 2179 | * @param string start[min] start-minutes |
@@ -2417,7 +2417,7 @@ discard block |
||
| 2417 | 2417 | /** |
| 2418 | 2418 | * Export events as vCalendar version 2.0 files (iCal) |
| 2419 | 2419 | * |
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2420 | + * @param integer $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | 2421 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2422 | 2422 | * @return string error-msg if $return_error |
| 2423 | 2423 | */ |
@@ -2415,14 +2415,14 @@ discard block |
||
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | /** |
| 2418 | - * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | - * |
|
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | - * @return string error-msg if $return_error |
|
| 2423 | - */ |
|
| 2424 | - function export($content=0,$return_error=false) |
|
| 2425 | - { |
|
| 2418 | + * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | + * |
|
| 2420 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | + * @return string error-msg if $return_error |
|
| 2423 | + */ |
|
| 2424 | + function export($content=0,$return_error=false) |
|
| 2425 | + { |
|
| 2426 | 2426 | $boical = new calendar_ical(); |
| 2427 | 2427 | #error_log(__METHOD__.print_r($content,true)); |
| 2428 | 2428 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
| 2477 | 2477 | $etpl = new etemplate_new('calendar.export'); |
| 2478 | 2478 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
| 2479 | - } |
|
| 2479 | + } |
|
| 2480 | 2480 | |
| 2481 | 2481 | /** |
| 2482 | 2482 | * Edit category ACL (admin only) |
@@ -2548,8 +2548,8 @@ discard block |
||
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
| 2551 | - * Set up the required fields to get the history tab |
|
| 2552 | - */ |
|
| 2551 | + * Set up the required fields to get the history tab |
|
| 2552 | + */ |
|
| 2553 | 2553 | public function setup_history(&$content, &$sel_options) |
| 2554 | 2554 | { |
| 2555 | 2555 | $status = 'history_status'; |
@@ -2890,11 +2890,11 @@ |
||
| 2890 | 2890 | { |
| 2891 | 2891 | $msg = lang('Event deleted'); |
| 2892 | 2892 | } |
| 2893 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 2893 | + $response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete')); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | else |
| 2896 | 2896 | { |
| 2897 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 2897 | + $response->apply('egw.message', array(lang('Error')),'error'); |
|
| 2898 | 2898 | } |
| 2899 | 2899 | } |
| 2900 | 2900 | |
@@ -598,220 +598,220 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | switch((string)$button) |
| 600 | 600 | { |
| 601 | - case 'exception': // create an exception in a recuring event |
|
| 602 | - $msg = $this->_create_exception($event,$preserv); |
|
| 603 | - break; |
|
| 601 | + case 'exception': // create an exception in a recuring event |
|
| 602 | + $msg = $this->_create_exception($event,$preserv); |
|
| 603 | + break; |
|
| 604 | 604 | |
| 605 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 606 | - unset($event['id']); |
|
| 607 | - unset($event['uid']); |
|
| 608 | - unset($event['reference']); |
|
| 609 | - unset($preserv['reference']); |
|
| 610 | - unset($event['recurrence']); |
|
| 611 | - unset($preserv['recurrence']); |
|
| 612 | - unset($event['recur_exception']); |
|
| 613 | - unset($event['edit_single']); // in case it has been set |
|
| 614 | - unset($event['modified']); |
|
| 615 | - unset($event['modifier']); |
|
| 616 | - unset($event['caldav_name']); |
|
| 617 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 605 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 606 | + unset($event['id']); |
|
| 607 | + unset($event['uid']); |
|
| 608 | + unset($event['reference']); |
|
| 609 | + unset($preserv['reference']); |
|
| 610 | + unset($event['recurrence']); |
|
| 611 | + unset($preserv['recurrence']); |
|
| 612 | + unset($event['recur_exception']); |
|
| 613 | + unset($event['edit_single']); // in case it has been set |
|
| 614 | + unset($event['modified']); |
|
| 615 | + unset($event['modifier']); |
|
| 616 | + unset($event['caldav_name']); |
|
| 617 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 618 | + |
|
| 619 | + // Clear participant stati |
|
| 620 | + foreach($event['participant_types'] as $type => &$participants) |
|
| 621 | + { |
|
| 622 | + foreach($participants as $id => &$p_response) |
|
| 623 | + { |
|
| 624 | + if($type == 'u' && $id == $event['owner']) continue; |
|
| 625 | + calendar_so::split_status($p_response, $quantity, $role); |
|
| 626 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 627 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 628 | + $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 629 | + } |
|
| 630 | + } |
|
| 618 | 631 | |
| 619 | - // Clear participant stati |
|
| 620 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 621 | - { |
|
| 622 | - foreach($participants as $id => &$p_response) |
|
| 632 | + // Copy alarms |
|
| 633 | + if (is_array($event['alarm'])) |
|
| 623 | 634 | { |
| 624 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 625 | - calendar_so::split_status($p_response, $quantity, $role); |
|
| 626 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 627 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 628 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 635 | + foreach($event['alarm'] as $n => &$alarm) |
|
| 636 | + { |
|
| 637 | + unset($alarm['id']); |
|
| 638 | + unset($alarm['cal_id']); |
|
| 639 | + } |
|
| 629 | 640 | } |
| 630 | - } |
|
| 631 | 641 | |
| 632 | - // Copy alarms |
|
| 633 | - if (is_array($event['alarm'])) |
|
| 634 | - { |
|
| 635 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 642 | + // Get links to be copied |
|
| 643 | + // With no ID, $content['link_to']['to_id'] is used |
|
| 644 | + $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 645 | + foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 636 | 646 | { |
| 637 | - unset($alarm['id']); |
|
| 638 | - unset($alarm['cal_id']); |
|
| 647 | + if ($link['app'] != Link::VFS_APPNAME) |
|
| 648 | + { |
|
| 649 | + Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 650 | + } |
|
| 651 | + elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 652 | + { |
|
| 653 | + Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 654 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 655 | + 'name' => $link['id'], |
|
| 656 | + ), $link['remark']); |
|
| 657 | + } |
|
| 639 | 658 | } |
| 640 | - } |
|
| 659 | + unset($link); |
|
| 660 | + $preserv['view'] = $preserv['edit_single'] = false; |
|
| 661 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 662 | + $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 663 | + break; |
|
| 641 | 664 | |
| 642 | - // Get links to be copied |
|
| 643 | - // With no ID, $content['link_to']['to_id'] is used |
|
| 644 | - $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 645 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 646 | - { |
|
| 647 | - if ($link['app'] != Link::VFS_APPNAME) |
|
| 665 | + case 'mail': |
|
| 666 | + case 'sendrequest': |
|
| 667 | + case 'save': |
|
| 668 | + case 'print': |
|
| 669 | + case 'apply': |
|
| 670 | + case 'infolog': |
|
| 671 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 648 | 672 | { |
| 649 | - Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 673 | + $msg = lang('Permission denied'); |
|
| 674 | + $button = ''; |
|
| 675 | + break; |
|
| 650 | 676 | } |
| 651 | - elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 677 | + if ($event['start'] > $event['end']) |
|
| 652 | 678 | { |
| 653 | - Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 654 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 655 | - 'name' => $link['id'], |
|
| 656 | - ), $link['remark']); |
|
| 679 | + $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 680 | + $button = ''; |
|
| 681 | + break; |
|
| 657 | 682 | } |
| 658 | - } |
|
| 659 | - unset($link); |
|
| 660 | - $preserv['view'] = $preserv['edit_single'] = false; |
|
| 661 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 662 | - $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 663 | - break; |
|
| 664 | - |
|
| 665 | - case 'mail': |
|
| 666 | - case 'sendrequest': |
|
| 667 | - case 'save': |
|
| 668 | - case 'print': |
|
| 669 | - case 'apply': |
|
| 670 | - case 'infolog': |
|
| 671 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 672 | - { |
|
| 673 | - $msg = lang('Permission denied'); |
|
| 674 | - $button = ''; |
|
| 675 | - break; |
|
| 676 | - } |
|
| 677 | - if ($event['start'] > $event['end']) |
|
| 678 | - { |
|
| 679 | - $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 680 | - $button = ''; |
|
| 681 | - break; |
|
| 682 | - } |
|
| 683 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 684 | - { |
|
| 685 | - $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 686 | - $button = ''; |
|
| 687 | - break; |
|
| 688 | - } |
|
| 689 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 690 | - { |
|
| 691 | - $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 692 | - $button = ''; |
|
| 693 | - break; |
|
| 694 | - } |
|
| 695 | - if (!$event['participants']) |
|
| 696 | - { |
|
| 697 | - $msg = lang('Error: no participants selected !!!'); |
|
| 698 | - $button = ''; |
|
| 699 | - break; |
|
| 700 | - } |
|
| 701 | - // if private event with ressource reservation is forbidden |
|
| 702 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 703 | - { |
|
| 704 | - foreach (array_keys($event['participants']) as $uid) |
|
| 683 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 684 | + { |
|
| 685 | + $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 686 | + $button = ''; |
|
| 687 | + break; |
|
| 688 | + } |
|
| 689 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 690 | + { |
|
| 691 | + $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 692 | + $button = ''; |
|
| 693 | + break; |
|
| 694 | + } |
|
| 695 | + if (!$event['participants']) |
|
| 705 | 696 | { |
| 706 | - if ($uid[0] == 'r') //ressource detection |
|
| 697 | + $msg = lang('Error: no participants selected !!!'); |
|
| 698 | + $button = ''; |
|
| 699 | + break; |
|
| 700 | + } |
|
| 701 | + // if private event with ressource reservation is forbidden |
|
| 702 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 703 | + { |
|
| 704 | + foreach (array_keys($event['participants']) as $uid) |
|
| 707 | 705 | { |
| 708 | - $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 709 | - $button = ''; |
|
| 710 | - break 2; //break foreach and case |
|
| 706 | + if ($uid[0] == 'r') //ressource detection |
|
| 707 | + { |
|
| 708 | + $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 709 | + $button = ''; |
|
| 710 | + break 2; //break foreach and case |
|
| 711 | + } |
|
| 711 | 712 | } |
| 712 | 713 | } |
| 713 | - } |
|
| 714 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 715 | - { |
|
| 716 | - $event['reference'] = $event['id']; |
|
| 717 | - $event['recurrence'] = $content['edit_single']; |
|
| 718 | - unset($event['id']); |
|
| 719 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 720 | - if (!is_array($conflicts) && $conflicts) |
|
| 714 | + if ($content['edit_single']) // we edited a single event from a series |
|
| 721 | 715 | { |
| 722 | - // now we need to add the original start as recur-execption to the series |
|
| 723 | - $recur_event = $this->bo->read($event['reference']); |
|
| 724 | - $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 725 | - // check if we need to move the alarms, because they are next on that exception |
|
| 726 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 716 | + $event['reference'] = $event['id']; |
|
| 717 | + $event['recurrence'] = $content['edit_single']; |
|
| 718 | + unset($event['id']); |
|
| 719 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 720 | + if (!is_array($conflicts) && $conflicts) |
|
| 727 | 721 | { |
| 728 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 722 | + // now we need to add the original start as recur-execption to the series |
|
| 723 | + $recur_event = $this->bo->read($event['reference']); |
|
| 724 | + $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 725 | + // check if we need to move the alarms, because they are next on that exception |
|
| 726 | + foreach($recur_event['alarm'] as $id => $alarm) |
|
| 729 | 727 | { |
| 730 | - $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 731 | - foreach ($rrule as $time) |
|
| 728 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 732 | 729 | { |
| 733 | - if ($content['edit_single'] < $time->format('ts')) |
|
| 730 | + $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 731 | + foreach ($rrule as $time) |
|
| 734 | 732 | { |
| 735 | - $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 736 | - $this->bo->save_alarm($event['reference'], $alarm); |
|
| 737 | - break; |
|
| 733 | + if ($content['edit_single'] < $time->format('ts')) |
|
| 734 | + { |
|
| 735 | + $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 736 | + $this->bo->save_alarm($event['reference'], $alarm); |
|
| 737 | + break; |
|
| 738 | + } |
|
| 738 | 739 | } |
| 739 | 740 | } |
| 740 | 741 | } |
| 741 | - } |
|
| 742 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 743 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 744 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 742 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 743 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 744 | + $this->bo->update($recur_event,true); // no conflict check here |
|
| 745 | 745 | |
| 746 | - // Save links |
|
| 747 | - if($content['links']) |
|
| 748 | - { |
|
| 749 | - Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
| 750 | - } |
|
| 746 | + // Save links |
|
| 747 | + if($content['links']) |
|
| 748 | + { |
|
| 749 | + Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | - if(Api\Json\Response::isJSONResponse()) |
|
| 752 | + if(Api\Json\Response::isJSONResponse()) |
|
| 753 | + { |
|
| 754 | + // Sending null will trigger a removal of the original |
|
| 755 | + // for that date |
|
| 756 | + Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + unset($recur_event); |
|
| 760 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 761 | + unset($preserv['edit_single']); |
|
| 762 | + } |
|
| 763 | + else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 753 | 764 | { |
| 754 | - // Sending null will trigger a removal of the original |
|
| 755 | - // for that date |
|
| 756 | - Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 765 | + $event['id'] = $event['reference']; |
|
| 766 | + $event['reference'] = $event['recurrence'] = 0; |
|
| 767 | + $event['uid'] = $content['uid']; |
|
| 757 | 768 | } |
| 758 | - |
|
| 759 | - unset($recur_event); |
|
| 760 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 761 | - unset($preserv['edit_single']); |
|
| 769 | + $update_type = 'edit'; |
|
| 762 | 770 | } |
| 763 | - else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 771 | + else // we edited a non-reccuring event or the whole series |
|
| 764 | 772 | { |
| 765 | - $event['id'] = $event['reference']; |
|
| 766 | - $event['reference'] = $event['recurrence'] = 0; |
|
| 767 | - $event['uid'] = $content['uid']; |
|
| 768 | - } |
|
| 769 | - $update_type = 'edit'; |
|
| 770 | - } |
|
| 771 | - else // we edited a non-reccuring event or the whole series |
|
| 772 | - { |
|
| 773 | - if (($old_event = $this->bo->read($event['id']))) |
|
| 774 | - { |
|
| 775 | - if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 773 | + if (($old_event = $this->bo->read($event['id']))) |
|
| 776 | 774 | { |
| 777 | - $update_type = 'edit'; |
|
| 778 | - |
|
| 779 | - // we edit a existing series event |
|
| 780 | - if ($event['start'] != $old_event['start'] || |
|
| 781 | - $event['whole_day'] != $old_event['whole_day'] || |
|
| 782 | - $event['end'] != $old_event['end']) |
|
| 775 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 783 | 776 | { |
| 784 | - // calculate offset against old series start or clicked recurrance, |
|
| 785 | - // depending on which is smaller |
|
| 786 | - $offset = $event['start'] - $old_event['start']; |
|
| 787 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 788 | - { |
|
| 789 | - $offset = $off2; |
|
| 790 | - } |
|
| 791 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 792 | - if($msg) |
|
| 777 | + $update_type = 'edit'; |
|
| 778 | + |
|
| 779 | + // we edit a existing series event |
|
| 780 | + if ($event['start'] != $old_event['start'] || |
|
| 781 | + $event['whole_day'] != $old_event['whole_day'] || |
|
| 782 | + $event['end'] != $old_event['end']) |
|
| 793 | 783 | { |
| 794 | - $noerror = false; |
|
| 784 | + // calculate offset against old series start or clicked recurrance, |
|
| 785 | + // depending on which is smaller |
|
| 786 | + $offset = $event['start'] - $old_event['start']; |
|
| 787 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 788 | + { |
|
| 789 | + $offset = $off2; |
|
| 790 | + } |
|
| 791 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 792 | + if($msg) |
|
| 793 | + { |
|
| 794 | + $noerror = false; |
|
| 795 | + } |
|
| 795 | 796 | } |
| 796 | 797 | } |
| 797 | - } |
|
| 798 | - else |
|
| 799 | - { |
|
| 800 | - if ($old_event['start'] != $event['start'] || |
|
| 801 | - $old_event['end'] != $event['end'] || |
|
| 802 | - $event['whole_day'] != $old_event['whole_day']) |
|
| 798 | + else |
|
| 803 | 799 | { |
| 804 | - $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 805 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 800 | + if ($old_event['start'] != $event['start'] || |
|
| 801 | + $old_event['end'] != $event['end'] || |
|
| 802 | + $event['whole_day'] != $old_event['whole_day']) |
|
| 806 | 803 | { |
| 807 | - $q = $r = null; |
|
| 808 | - calendar_so::split_status($status,$q,$r); |
|
| 809 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 804 | + $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 805 | + foreach((array)$event['participants'] as $uid => $status) |
|
| 810 | 806 | { |
| 811 | - $preferences = new Api\Preferences($uid); |
|
| 812 | - $part_prefs = $preferences->read_repository(); |
|
| 813 | - switch ($part_prefs['calendar']['reset_stati']) |
|
| 807 | + $q = $r = null; |
|
| 808 | + calendar_so::split_status($status,$q,$r); |
|
| 809 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 814 | 810 | { |
| 811 | + $preferences = new Api\Preferences($uid); |
|
| 812 | + $part_prefs = $preferences->read_repository(); |
|
| 813 | + switch ($part_prefs['calendar']['reset_stati']) |
|
| 814 | + { |
|
| 815 | 815 | case 'no': |
| 816 | 816 | break; |
| 817 | 817 | case 'startday': |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | $status_reset_to_unknown = true; |
| 821 | 821 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
| 822 | 822 | // todo: report reset status to user |
| 823 | - } |
|
| 823 | + } |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | // check if we need to move the alarms, because they are relative |
@@ -962,83 +962,83 @@ discard block |
||
| 962 | 962 | } |
| 963 | 963 | break; |
| 964 | 964 | |
| 965 | - case 'cancel': |
|
| 966 | - if($content['cancel_needs_refresh']) |
|
| 967 | - { |
|
| 968 | - Framework::refresh_opener($msg, 'calendar'); |
|
| 969 | - } |
|
| 970 | - break; |
|
| 971 | - |
|
| 972 | - case 'delete': // delete of event (regular or series) |
|
| 973 | - $exceptions_kept = null; |
|
| 974 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 975 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 976 | - { |
|
| 977 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 965 | + case 'cancel': |
|
| 966 | + if($content['cancel_needs_refresh']) |
|
| 978 | 967 | { |
| 979 | - $msg = lang('Series deleted'); |
|
| 980 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 968 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 981 | 969 | } |
| 982 | - else |
|
| 970 | + break; |
|
| 971 | + |
|
| 972 | + case 'delete': // delete of event (regular or series) |
|
| 973 | + $exceptions_kept = null; |
|
| 974 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 975 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 983 | 976 | { |
| 984 | - $msg = lang('Event deleted'); |
|
| 985 | - } |
|
| 977 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 978 | + { |
|
| 979 | + $msg = lang('Series deleted'); |
|
| 980 | + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 981 | + } |
|
| 982 | + else |
|
| 983 | + { |
|
| 984 | + $msg = lang('Event deleted'); |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | - } |
|
| 988 | - break; |
|
| 987 | + } |
|
| 988 | + break; |
|
| 989 | 989 | |
| 990 | - case 'freetime': |
|
| 991 | - // the "click" has to be in onload, to make sure the button is already created |
|
| 992 | - $event['button_was'] = $button; |
|
| 993 | - break; |
|
| 990 | + case 'freetime': |
|
| 991 | + // the "click" has to be in onload, to make sure the button is already created |
|
| 992 | + $event['button_was'] = $button; |
|
| 993 | + break; |
|
| 994 | 994 | |
| 995 | - case 'add_alarm': |
|
| 996 | - $time = $content['start']; |
|
| 997 | - $offset = $time - $content['new_alarm']['date']; |
|
| 998 | - if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 999 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 1000 | - $time < $next_occurrence['start']) |
|
| 1001 | - { |
|
| 1002 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 1003 | - } |
|
| 1004 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1005 | - { |
|
| 1006 | - $alarm = array( |
|
| 1007 | - 'offset' => $offset, |
|
| 1008 | - 'time' => $content['new_alarm']['date'], |
|
| 1009 | - 'all' => !$content['new_alarm']['owner'], |
|
| 1010 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 1011 | - ); |
|
| 1012 | - if ($alarm['time'] < $this->bo->now_su) |
|
| 995 | + case 'add_alarm': |
|
| 996 | + $time = $content['start']; |
|
| 997 | + $offset = $time - $content['new_alarm']['date']; |
|
| 998 | + if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 999 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 1000 | + $time < $next_occurrence['start']) |
|
| 1013 | 1001 | { |
| 1014 | - $msg = lang("Can't add alarms in the past !!!"); |
|
| 1002 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 1015 | 1003 | } |
| 1016 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1004 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1017 | 1005 | { |
| 1018 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1006 | + $alarm = array( |
|
| 1007 | + 'offset' => $offset, |
|
| 1008 | + 'time' => $content['new_alarm']['date'], |
|
| 1009 | + 'all' => !$content['new_alarm']['owner'], |
|
| 1010 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 1011 | + ); |
|
| 1012 | + if ($alarm['time'] < $this->bo->now_su) |
|
| 1013 | + { |
|
| 1014 | + $msg = lang("Can't add alarms in the past !!!"); |
|
| 1015 | + } |
|
| 1016 | + elseif ($event['id']) // save the alarm immediatly |
|
| 1019 | 1017 | { |
| 1020 | - $alarm['id'] = $alarm_id; |
|
| 1021 | - $event['alarm'][$alarm_id] = $alarm; |
|
| 1018 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1019 | + { |
|
| 1020 | + $alarm['id'] = $alarm_id; |
|
| 1021 | + $event['alarm'][$alarm_id] = $alarm; |
|
| 1022 | 1022 | |
| 1023 | - $msg = lang('Alarm added'); |
|
| 1024 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1023 | + $msg = lang('Alarm added'); |
|
| 1024 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1025 | + } |
|
| 1026 | + else |
|
| 1027 | + { |
|
| 1028 | + $msg = lang('Error adding the alarm'); |
|
| 1029 | + } |
|
| 1025 | 1030 | } |
| 1026 | 1031 | else |
| 1027 | 1032 | { |
| 1028 | - $msg = lang('Error adding the alarm'); |
|
| 1033 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | + $event['alarm'][$alarm['id']] = $alarm; |
|
| 1029 | 1035 | } |
| 1030 | 1036 | } |
| 1031 | 1037 | else |
| 1032 | 1038 | { |
| 1033 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | - $event['alarm'][$alarm['id']] = $alarm; |
|
| 1039 | + $msg = lang('Permission denied'); |
|
| 1035 | 1040 | } |
| 1036 | - } |
|
| 1037 | - else |
|
| 1038 | - { |
|
| 1039 | - $msg = lang('Permission denied'); |
|
| 1040 | - } |
|
| 1041 | - break; |
|
| 1041 | + break; |
|
| 1042 | 1042 | } |
| 1043 | 1043 | // add notification-errors, if we have some |
| 1044 | 1044 | if (($notification_errors = notifications::errors(true))) |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @var locktime in seconds |
| 56 | 56 | */ |
| 57 | - var $locktime_default=1; |
|
| 57 | + var $locktime_default = 1; |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Constructor |
| 61 | 61 | */ |
| 62 | 62 | function __construct() |
| 63 | 63 | { |
| 64 | - parent::__construct(true); // call the parent's constructor |
|
| 64 | + parent::__construct(true); // call the parent's constructor |
|
| 65 | 65 | |
| 66 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 66 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 67 | 67 | { |
| 68 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
| 68 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -77,11 +77,10 @@ discard block |
||
| 77 | 77 | function &default_add_event() |
| 78 | 78 | { |
| 79 | 79 | $extra_participants = $_GET['participants'] ? |
| 80 | - (!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) : |
|
| 81 | - array(); |
|
| 80 | + (!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array(); |
|
| 82 | 81 | |
| 83 | 82 | // if participant is a contact, add its link title as title |
| 84 | - foreach($extra_participants as $uid) |
|
| 83 | + foreach ($extra_participants as $uid) |
|
| 85 | 84 | { |
| 86 | 85 | if ($uid[0] == 'c') |
| 87 | 86 | { |
@@ -93,14 +92,14 @@ discard block |
||
| 93 | 92 | if (isset($_GET['owner'])) |
| 94 | 93 | { |
| 95 | 94 | $owner = $_GET['owner']; |
| 96 | - if(!is_array($owner) && strpos($owner, ',')) |
|
| 95 | + if (!is_array($owner) && strpos($owner, ',')) |
|
| 97 | 96 | { |
| 98 | - $owner = explode(',',$owner); |
|
| 97 | + $owner = explode(',', $owner); |
|
| 99 | 98 | } |
| 100 | - if(is_array($owner)) |
|
| 99 | + if (is_array($owner)) |
|
| 101 | 100 | { |
| 102 | 101 | // old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0' |
| 103 | - if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
| 102 | + if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
| 104 | 103 | { |
| 105 | 104 | $extra_participants += $owner; |
| 106 | 105 | } |
@@ -118,18 +117,18 @@ discard block |
||
| 118 | 117 | } |
| 119 | 118 | |
| 120 | 119 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 121 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
| 120 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
| 122 | 121 | { |
| 123 | 122 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
| 124 | 123 | { |
| 125 | - if(!is_array($owner)) |
|
| 124 | + if (!is_array($owner)) |
|
| 126 | 125 | { |
| 127 | - $owner = explode(',',$owner); |
|
| 126 | + $owner = explode(',', $owner); |
|
| 128 | 127 | } |
| 129 | 128 | // if we come from ressources we don't need any users selected in calendar |
| 130 | 129 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
| 131 | 130 | { |
| 132 | - foreach($owner as $uid) |
|
| 131 | + foreach ($owner as $uid) |
|
| 133 | 132 | { |
| 134 | 133 | $extra_participants[] = $uid; |
| 135 | 134 | } |
@@ -139,77 +138,77 @@ discard block |
||
| 139 | 138 | } |
| 140 | 139 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
| 141 | 140 | |
| 142 | - if(isset($_GET['start'])) |
|
| 141 | + if (isset($_GET['start'])) |
|
| 143 | 142 | { |
| 144 | 143 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
| 145 | 144 | } |
| 146 | 145 | else |
| 147 | 146 | { |
| 148 | 147 | $start = $this->bo->date2ts(array( |
| 149 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
| 150 | - 'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 151 | - 'minute' => (int) $_GET['minute'], |
|
| 148 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
| 149 | + 'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 150 | + 'minute' => (int)$_GET['minute'], |
|
| 152 | 151 | )); |
| 153 | 152 | } |
| 154 | 153 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
| 155 | 154 | |
| 156 | 155 | $participant_types['u'] = $participant_types = $participants = array(); |
| 157 | - foreach($extra_participants as $uid) |
|
| 156 | + foreach ($extra_participants as $uid) |
|
| 158 | 157 | { |
| 159 | - if (isset($participants[$uid])) continue; // already included |
|
| 158 | + if (isset($participants[$uid])) continue; // already included |
|
| 160 | 159 | |
| 161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 160 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 162 | 161 | |
| 163 | 162 | if (is_numeric($uid)) |
| 164 | 163 | { |
| 165 | 164 | $participants[$uid] = $participant_types['u'][$uid] = |
| 166 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 167 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 165 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 166 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 168 | 167 | } |
| 169 | 168 | elseif (is_array($this->bo->resources[$uid[0]])) |
| 170 | 169 | { |
| 171 | 170 | // Expand mailing lists |
| 172 | - if($uid[0] == 'l') |
|
| 171 | + if ($uid[0] == 'l') |
|
| 173 | 172 | { |
| 174 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
| 173 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
| 175 | 174 | { |
| 176 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
| 177 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
| 175 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
| 176 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
| 178 | 177 | } |
| 179 | 178 | continue; |
| 180 | 179 | } |
| 181 | 180 | // if contact is a user, use the user instead (as the GUI) |
| 182 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
| 181 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
| 183 | 182 | { |
| 184 | 183 | $uid = $account_id; |
| 185 | 184 | $participants[$uid] = $participant_types['u'][$uid] = |
| 186 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 187 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 185 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 186 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 188 | 187 | continue; |
| 189 | 188 | } |
| 190 | 189 | $res_data = $this->bo->resources[$uid[0]]; |
| 191 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
| 192 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
| 190 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
| 191 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
| 193 | 192 | { |
| 194 | 193 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
| 195 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
| 194 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
| 196 | 195 | } |
| 197 | 196 | } |
| 198 | 197 | } |
| 199 | 198 | if (!$participants) // if all participants got removed, include current user |
| 200 | 199 | { |
| 201 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
| 200 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
| 202 | 201 | } |
| 203 | - if(isset($_GET['cat_id'])) |
|
| 202 | + if (isset($_GET['cat_id'])) |
|
| 204 | 203 | { |
| 205 | - $cat_id = explode(',',$_GET['cat_id']); |
|
| 206 | - foreach($cat_id as &$cat) |
|
| 204 | + $cat_id = explode(',', $_GET['cat_id']); |
|
| 205 | + foreach ($cat_id as &$cat) |
|
| 207 | 206 | { |
| 208 | 207 | $cat = (int)$cat; |
| 209 | 208 | } |
| 210 | 209 | } |
| 211 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
| 212 | - if(isset($_GET['end'])) |
|
| 210 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
| 211 | + if (isset($_GET['end'])) |
|
| 213 | 212 | { |
| 214 | 213 | $end = Api\DateTime::to($_GET['end'], 'ts'); |
| 215 | 214 | $duration = $end - $start; |
@@ -227,9 +226,9 @@ discard block |
||
| 227 | 226 | if ((string)$this->cal_prefs[$alarm_pref] !== '') |
| 228 | 227 | { |
| 229 | 228 | $offset = 60 * $this->cal_prefs[$alarm_pref]; |
| 230 | - $alarms[1] = array( |
|
| 229 | + $alarms[1] = array( |
|
| 231 | 230 | 'default' => 1, |
| 232 | - 'offset' => $offset , |
|
| 231 | + 'offset' => $offset, |
|
| 233 | 232 | 'time' => $start - $offset, |
| 234 | 233 | 'all' => false, |
| 235 | 234 | 'owner' => $owner, |
@@ -244,7 +243,7 @@ discard block |
||
| 244 | 243 | 'start' => $start, |
| 245 | 244 | 'end' => $end, |
| 246 | 245 | 'tzid' => $this->bo->common_prefs['tz'], |
| 247 | - 'priority' => 2, // normal |
|
| 246 | + 'priority' => 2, // normal |
|
| 248 | 247 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
| 249 | 248 | 'alarm' => $alarms, |
| 250 | 249 | 'recur_exception' => array(), |
@@ -263,7 +262,7 @@ discard block |
||
| 263 | 262 | { |
| 264 | 263 | if (!is_array($content)) // redirect from etemplate, if POST empty |
| 265 | 264 | { |
| 266 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
| 265 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
| 267 | 266 | } |
| 268 | 267 | // clear notification errors |
| 269 | 268 | notifications::errors(true); |
@@ -277,22 +276,22 @@ discard block |
||
| 277 | 276 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 278 | 277 | |
| 279 | 278 | list($button) = @each($content['button']); |
| 280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 279 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 281 | 280 | unset($content['button']); unset($content['action']); |
| 282 | 281 | |
| 283 | 282 | $view = $content['view']; |
| 284 | 283 | if ($button == 'ical') |
| 285 | 284 | { |
| 286 | - $msg = $this->export($content['id'],true); |
|
| 285 | + $msg = $this->export($content['id'], true); |
|
| 287 | 286 | } |
| 288 | 287 | // delete a recur-exception |
| 289 | 288 | if ($content['recur_exception']['delete_exception']) |
| 290 | 289 | { |
| 291 | 290 | list($date) = each($content['recur_exception']['delete_exception']); |
| 292 | 291 | // eT2 converts time to |
| 293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 292 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
| 294 | 293 | unset($content['recur_exception']['delete_exception']); |
| 295 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
| 294 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
| 296 | 295 | { |
| 297 | 296 | // propagate the exception to a single event |
| 298 | 297 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -302,7 +301,7 @@ discard block |
||
| 302 | 301 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
| 303 | 302 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 304 | 303 | $exception['reference'] = $exception['recurrence'] = 0; |
| 305 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
| 304 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
| 306 | 305 | break; |
| 307 | 306 | } |
| 308 | 307 | unset($content['recur_exception'][$key]); |
@@ -343,7 +342,7 @@ discard block |
||
| 343 | 342 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
| 344 | 343 | if ((string)$def_alarm === '') |
| 345 | 344 | { |
| 346 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 345 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 347 | 346 | } |
| 348 | 347 | else |
| 349 | 348 | { |
@@ -365,7 +364,7 @@ discard block |
||
| 365 | 364 | $offset = 60 * $def_alarm; |
| 366 | 365 | array_unshift($content['alarm'], array( |
| 367 | 366 | 'default' => 1, |
| 368 | - 'offset' => $offset , |
|
| 367 | + 'offset' => $offset, |
|
| 369 | 368 | 'time' => $content['start'] - $offset, |
| 370 | 369 | 'all' => false, |
| 371 | 370 | 'owner' => 0, |
@@ -378,7 +377,7 @@ discard block |
||
| 378 | 377 | unset($event['alarm']['delete_alarm']); |
| 379 | 378 | unset($event['duration']); |
| 380 | 379 | |
| 381 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
| 380 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
| 382 | 381 | { |
| 383 | 382 | // no conversation necessary, event is already in the right format |
| 384 | 383 | } |
@@ -398,7 +397,7 @@ discard block |
||
| 398 | 397 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
| 399 | 398 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 400 | 399 | { |
| 401 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
| 400 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
| 402 | 401 | } |
| 403 | 402 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
| 404 | 403 | { |
@@ -410,9 +409,9 @@ discard block |
||
| 410 | 409 | |
| 411 | 410 | $event['participants'] = $event['participant_types'] = array(); |
| 412 | 411 | |
| 413 | - foreach($content['participants'] as $key => $data) |
|
| 412 | + foreach ($content['participants'] as $key => $data) |
|
| 414 | 413 | { |
| 415 | - switch($key) |
|
| 414 | + switch ($key) |
|
| 416 | 415 | { |
| 417 | 416 | case 'delete': // handled in default |
| 418 | 417 | case 'quantity': // handled in new_resource |
@@ -421,7 +420,7 @@ discard block |
||
| 421 | 420 | case 'status_date': |
| 422 | 421 | break; |
| 423 | 422 | case 'participant': |
| 424 | - foreach($data as $participant) |
|
| 423 | + foreach ($data as $participant) |
|
| 425 | 424 | { |
| 426 | 425 | if (is_null($participant)) |
| 427 | 426 | { |
@@ -430,17 +429,17 @@ discard block |
||
| 430 | 429 | |
| 431 | 430 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
| 432 | 431 | $email = array(); |
| 433 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
| 432 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
| 434 | 433 | { |
| 435 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
| 436 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 434 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
| 435 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 437 | 436 | { |
| 438 | 437 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
| 439 | 438 | } |
| 440 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
| 439 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
| 441 | 440 | 'email' => $email[2], |
| 442 | 441 | 'email_home' => $email[2], |
| 443 | - ),true,'','','',false,'OR'))) |
|
| 442 | + ), true, '', '', '', false, 'OR'))) |
|
| 444 | 443 | { |
| 445 | 444 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
| 446 | 445 | } |
@@ -451,7 +450,7 @@ discard block |
||
| 451 | 450 | } |
| 452 | 451 | else |
| 453 | 452 | { |
| 454 | - if(is_numeric($participant)) |
|
| 453 | + if (is_numeric($participant)) |
|
| 455 | 454 | { |
| 456 | 455 | $uid = $participant; |
| 457 | 456 | $id = $participant; |
@@ -460,12 +459,12 @@ discard block |
||
| 460 | 459 | else |
| 461 | 460 | { |
| 462 | 461 | $uid = $participant; |
| 463 | - $id = substr($participant,1); |
|
| 462 | + $id = substr($participant, 1); |
|
| 464 | 463 | $resource = $this->bo->resources[$participant[0]]; |
| 465 | 464 | } |
| 466 | - if(!$this->bo->check_acl_invite($uid)) |
|
| 465 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 467 | 466 | { |
| 468 | - if(!$msg_permission_denied_added) |
|
| 467 | + if (!$msg_permission_denied_added) |
|
| 469 | 468 | { |
| 470 | 469 | $msg .= lang('Permission denied!'); |
| 471 | 470 | $msg_permission_denied_added = true; |
@@ -475,20 +474,19 @@ discard block |
||
| 475 | 474 | |
| 476 | 475 | $type = $resource['type']; |
| 477 | 476 | $status = isset($this->bo->resources[$type]['new_status']) ? |
| 478 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
| 479 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 477 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 480 | 478 | |
| 481 | 479 | // Expand mailing lists |
| 482 | - if($type == 'l') |
|
| 480 | + if ($type == 'l') |
|
| 483 | 481 | { |
| 484 | 482 | // Ignore ACL here, allow inviting anyone in the list |
| 485 | - foreach($this->bo->enum_mailing_list($participant, true) as $contact) |
|
| 483 | + foreach ($this->bo->enum_mailing_list($participant, true) as $contact) |
|
| 486 | 484 | { |
| 487 | 485 | // Mailing lists can contain users, so allow for that possibility |
| 488 | 486 | $_type = is_numeric($contact) ? '' : $contact[0]; |
| 489 | - $_uid = is_numeric($contact) ? $contact : substr($contact,1); |
|
| 487 | + $_uid = is_numeric($contact) ? $contact : substr($contact, 1); |
|
| 490 | 488 | $event['participants'][$contact] = $event['participant_types'][$_type][$_uid] = |
| 491 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 489 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 492 | 490 | } |
| 493 | 491 | continue; |
| 494 | 492 | } |
@@ -498,8 +496,8 @@ discard block |
||
| 498 | 496 | // todo check real availability = maximum - already booked quantity |
| 499 | 497 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
| 500 | 498 | { |
| 501 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
| 502 | - foreach(array('quantity','resource','role') as $n) |
|
| 499 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
| 500 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 503 | 501 | { |
| 504 | 502 | $event['participants'][$n] = $content['participants'][$n]; |
| 505 | 503 | } |
@@ -508,7 +506,7 @@ discard block |
||
| 508 | 506 | else |
| 509 | 507 | { |
| 510 | 508 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 511 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 509 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 512 | 510 | } |
| 513 | 511 | } |
| 514 | 512 | } |
@@ -522,15 +520,15 @@ discard block |
||
| 522 | 520 | break; |
| 523 | 521 | |
| 524 | 522 | default: // existing participant row |
| 525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 523 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 526 | 524 | $quantity = $status = $role = null; |
| 527 | - foreach(array('uid','status','quantity','role') as $name) |
|
| 525 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
| 528 | 526 | { |
| 529 | 527 | $$name = $data[$name]; |
| 530 | 528 | } |
| 531 | 529 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
| 532 | 530 | { |
| 533 | - $uid = false; // entry has been deleted |
|
| 531 | + $uid = false; // entry has been deleted |
|
| 534 | 532 | } |
| 535 | 533 | elseif ($uid) |
| 536 | 534 | { |
@@ -541,27 +539,27 @@ discard block |
||
| 541 | 539 | } |
| 542 | 540 | else |
| 543 | 541 | { |
| 544 | - $id = substr($uid,1); |
|
| 542 | + $id = substr($uid, 1); |
|
| 545 | 543 | $type = $uid[0]; |
| 546 | 544 | } |
| 547 | 545 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
| 548 | 546 | { |
| 549 | 547 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 550 | 548 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 551 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 549 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 552 | 550 | { |
| 553 | 551 | // Update main window |
| 554 | 552 | $d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone); |
| 555 | 553 | $client_updated = $this->update_client($event['id'], $d); |
| 556 | 554 | |
| 557 | 555 | // refreshing the calendar-view with the changed participant-status |
| 558 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 556 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 559 | 557 | { |
| 560 | 558 | $msg = lang('Status for all future scheduled days changed'); |
| 561 | 559 | } |
| 562 | 560 | else |
| 563 | 561 | { |
| 564 | - if(isset($content['edit_single'])) |
|
| 562 | + if (isset($content['edit_single'])) |
|
| 565 | 563 | { |
| 566 | 564 | $msg = lang('Status for this particular day changed'); |
| 567 | 565 | // prevent accidentally creating a real exception afterwards |
@@ -582,7 +580,7 @@ discard block |
||
| 582 | 580 | if ($status == 'R' && $event['alarm']) |
| 583 | 581 | { |
| 584 | 582 | // remove from bo->set_status deleted alarms of rejected users from UI too |
| 585 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
| 583 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
| 586 | 584 | { |
| 587 | 585 | if ((string)$alarm['owner'] === (string)$uid) |
| 588 | 586 | { |
@@ -595,7 +593,7 @@ discard block |
||
| 595 | 593 | if ($uid && $status != 'G') |
| 596 | 594 | { |
| 597 | 595 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 598 | - calendar_so::combine_status($status,$quantity,$role); |
|
| 596 | + calendar_so::combine_status($status, $quantity, $role); |
|
| 599 | 597 | } |
| 600 | 598 | } |
| 601 | 599 | break; |
@@ -614,26 +612,26 @@ discard block |
||
| 614 | 612 | 'tabs' => $content['tabs'], |
| 615 | 613 | 'template' => $content['template'], |
| 616 | 614 | ); |
| 617 | - $noerror=true; |
|
| 615 | + $noerror = true; |
|
| 618 | 616 | |
| 619 | 617 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
| 620 | 618 | |
| 621 | 619 | $ignore_conflicts = $status_reset_to_unknown = false; |
| 622 | 620 | |
| 623 | - switch((string)$button) |
|
| 621 | + switch ((string)$button) |
|
| 624 | 622 | { |
| 625 | 623 | case 'ignore': |
| 626 | 624 | $ignore_conflicts = true; |
| 627 | - $button = $event['button_was']; // save or apply |
|
| 625 | + $button = $event['button_was']; // save or apply |
|
| 628 | 626 | unset($event['button_was']); |
| 629 | 627 | break; |
| 630 | 628 | |
| 631 | 629 | } |
| 632 | 630 | |
| 633 | - switch((string)$button) |
|
| 631 | + switch ((string)$button) |
|
| 634 | 632 | { |
| 635 | 633 | case 'exception': // create an exception in a recuring event |
| 636 | - $msg = $this->_create_exception($event,$preserv); |
|
| 634 | + $msg = $this->_create_exception($event, $preserv); |
|
| 637 | 635 | break; |
| 638 | 636 | |
| 639 | 637 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -644,29 +642,29 @@ discard block |
||
| 644 | 642 | unset($event['recurrence']); |
| 645 | 643 | unset($preserv['recurrence']); |
| 646 | 644 | unset($event['recur_exception']); |
| 647 | - unset($event['edit_single']); // in case it has been set |
|
| 645 | + unset($event['edit_single']); // in case it has been set |
|
| 648 | 646 | unset($event['modified']); |
| 649 | 647 | unset($event['modifier']); |
| 650 | 648 | unset($event['caldav_name']); |
| 651 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 649 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner']; |
|
| 652 | 650 | |
| 653 | 651 | // Clear participant stati |
| 654 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 652 | + foreach ($event['participant_types'] as $type => &$participants) |
|
| 655 | 653 | { |
| 656 | - foreach($participants as $id => &$p_response) |
|
| 654 | + foreach ($participants as $id => &$p_response) |
|
| 657 | 655 | { |
| 658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 656 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
| 659 | 657 | calendar_so::split_status($p_response, $quantity, $role); |
| 660 | 658 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 661 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 662 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 659 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
| 660 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
| 663 | 661 | } |
| 664 | 662 | } |
| 665 | 663 | |
| 666 | 664 | // Copy alarms |
| 667 | 665 | if (is_array($event['alarm'])) |
| 668 | 666 | { |
| 669 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 667 | + foreach ($event['alarm'] as $n => &$alarm) |
|
| 670 | 668 | { |
| 671 | 669 | unset($alarm['id']); |
| 672 | 670 | unset($alarm['cal_id']); |
@@ -676,7 +674,7 @@ discard block |
||
| 676 | 674 | // Get links to be copied |
| 677 | 675 | // With no ID, $content['link_to']['to_id'] is used |
| 678 | 676 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
| 679 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 677 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
| 680 | 678 | { |
| 681 | 679 | if ($link['app'] != Link::VFS_APPNAME) |
| 682 | 680 | { |
@@ -692,7 +690,7 @@ discard block |
||
| 692 | 690 | } |
| 693 | 691 | unset($link); |
| 694 | 692 | $preserv['view'] = $preserv['edit_single'] = false; |
| 695 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 693 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry'))); |
|
| 696 | 694 | $event['title'] = lang('Copy of:').' '.$event['title']; |
| 697 | 695 | break; |
| 698 | 696 | |
@@ -702,7 +700,7 @@ discard block |
||
| 702 | 700 | case 'print': |
| 703 | 701 | case 'apply': |
| 704 | 702 | case 'infolog': |
| 705 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 703 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 706 | 704 | { |
| 707 | 705 | $msg = lang('Permission denied'); |
| 708 | 706 | $button = ''; |
@@ -720,7 +718,7 @@ discard block |
||
| 720 | 718 | $button = ''; |
| 721 | 719 | break; |
| 722 | 720 | } |
| 723 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 721 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 724 | 722 | { |
| 725 | 723 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
| 726 | 724 | $button = ''; |
@@ -750,14 +748,14 @@ discard block |
||
| 750 | 748 | $event['reference'] = $event['id']; |
| 751 | 749 | $event['recurrence'] = $content['edit_single']; |
| 752 | 750 | unset($event['id']); |
| 753 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 751 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 754 | 752 | if (!is_array($conflicts) && $conflicts) |
| 755 | 753 | { |
| 756 | 754 | // now we need to add the original start as recur-execption to the series |
| 757 | 755 | $recur_event = $this->bo->read($event['reference']); |
| 758 | 756 | $recur_event['recur_exception'][] = $content['edit_single']; |
| 759 | 757 | // check if we need to move the alarms, because they are next on that exception |
| 760 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 758 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
| 761 | 759 | { |
| 762 | 760 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
| 763 | 761 | { |
@@ -773,17 +771,17 @@ discard block |
||
| 773 | 771 | } |
| 774 | 772 | } |
| 775 | 773 | } |
| 776 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 777 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 778 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 774 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 775 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 776 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 779 | 777 | |
| 780 | 778 | // Save links |
| 781 | - if($content['links']) |
|
| 779 | + if ($content['links']) |
|
| 782 | 780 | { |
| 783 | 781 | Link::link('calendar', $event['id'], $content['links']['to_id']); |
| 784 | 782 | } |
| 785 | 783 | |
| 786 | - if(Api\Json\Response::isJSONResponse()) |
|
| 784 | + if (Api\Json\Response::isJSONResponse()) |
|
| 787 | 785 | { |
| 788 | 786 | // Sending null will trigger a removal of the original |
| 789 | 787 | // for that date |
@@ -791,7 +789,7 @@ discard block |
||
| 791 | 789 | } |
| 792 | 790 | |
| 793 | 791 | unset($recur_event); |
| 794 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 792 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 795 | 793 | unset($preserv['edit_single']); |
| 796 | 794 | } |
| 797 | 795 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -822,8 +820,8 @@ discard block |
||
| 822 | 820 | { |
| 823 | 821 | $offset = $off2; |
| 824 | 822 | } |
| 825 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 826 | - if($msg) |
|
| 823 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
| 824 | + if ($msg) |
|
| 827 | 825 | { |
| 828 | 826 | $noerror = false; |
| 829 | 827 | } |
@@ -836,10 +834,10 @@ discard block |
||
| 836 | 834 | $event['whole_day'] != $old_event['whole_day']) |
| 837 | 835 | { |
| 838 | 836 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 839 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 837 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 840 | 838 | { |
| 841 | 839 | $q = $r = null; |
| 842 | - calendar_so::split_status($status,$q,$r); |
|
| 840 | + calendar_so::split_status($status, $q, $r); |
|
| 843 | 841 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 844 | 842 | { |
| 845 | 843 | $preferences = new Api\Preferences($uid); |
@@ -852,7 +850,7 @@ discard block |
||
| 852 | 850 | if ($sameday) break; |
| 853 | 851 | default: |
| 854 | 852 | $status_reset_to_unknown = true; |
| 855 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 853 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 856 | 854 | // todo: report reset status to user |
| 857 | 855 | } |
| 858 | 856 | } |
@@ -870,43 +868,43 @@ discard block |
||
| 870 | 868 | } |
| 871 | 869 | // Adding participants needs to be done as an edit, in case we |
| 872 | 870 | // have participants visible in seperate calendars |
| 873 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 871 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 874 | 872 | { |
| 875 | 873 | $update_type = 'edit'; |
| 876 | 874 | } |
| 877 | 875 | // Changing category may affect event filtering |
| 878 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 876 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 879 | 877 | { |
| 880 | 878 | $update_type = 'edit'; |
| 881 | 879 | } |
| 882 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 880 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 883 | 881 | unset($event['ignore']); |
| 884 | 882 | } |
| 885 | 883 | if (is_array($conflicts)) |
| 886 | 884 | { |
| 887 | - $event['button_was'] = $button; // remember for ignore |
|
| 888 | - return $this->conflicts($event,$conflicts,$preserv); |
|
| 885 | + $event['button_was'] = $button; // remember for ignore |
|
| 886 | + return $this->conflicts($event, $conflicts, $preserv); |
|
| 889 | 887 | } |
| 890 | 888 | |
| 891 | 889 | // Event spans multiple days, need an edit to make sure they all get updated |
| 892 | 890 | // We could check old date, as removing from days could still be an update |
| 893 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 891 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 894 | 892 | { |
| 895 | 893 | $update_type = 'edit'; |
| 896 | 894 | } |
| 897 | 895 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
| 898 | 896 | if ($messages) |
| 899 | 897 | { |
| 900 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
| 898 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
| 901 | 899 | } |
| 902 | 900 | if ($conflicts === 0) |
| 903 | 901 | { |
| 904 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 905 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 906 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 902 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 903 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 904 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 907 | 905 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 908 | 906 | 'cal_id' => $content['id'], |
| 909 | - ))).'">','</a>'); |
|
| 907 | + ))).'">', '</a>'); |
|
| 910 | 908 | $noerror = false; |
| 911 | 909 | } |
| 912 | 910 | elseif ($conflicts > 0) |
@@ -928,19 +926,19 @@ discard block |
||
| 928 | 926 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
| 929 | 927 | if ($alarm['time'] < $this->bo->now_su) |
| 930 | 928 | { |
| 931 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
| 929 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
| 932 | 930 | { |
| 933 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 931 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 934 | 932 | } |
| 935 | 933 | else |
| 936 | 934 | { |
| 937 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 935 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 938 | 936 | } |
| 939 | 937 | } |
| 940 | 938 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
| 941 | 939 | elseif ($event_time < $event['start']) |
| 942 | 940 | { |
| 943 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 941 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 944 | 942 | } |
| 945 | 943 | if ($alarm) |
| 946 | 944 | { |
@@ -949,9 +947,9 @@ discard block |
||
| 949 | 947 | } |
| 950 | 948 | } |
| 951 | 949 | // attach all future exceptions to the new series |
| 952 | - $events =& $this->bo->search(array( |
|
| 950 | + $events = & $this->bo->search(array( |
|
| 953 | 951 | 'query' => array('cal_uid' => $old_event['uid']), |
| 954 | - 'filter' => 'owner', // return all possible entries |
|
| 952 | + 'filter' => 'owner', // return all possible entries |
|
| 955 | 953 | 'daywise' => false, |
| 956 | 954 | 'date_format' => 'ts', |
| 957 | 955 | )); |
@@ -962,7 +960,7 @@ discard block |
||
| 962 | 960 | $exception['recurrence'] += $offset; |
| 963 | 961 | $exception['reference'] = $event['id']; |
| 964 | 962 | $exception['uid'] = $event['uid']; |
| 965 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
| 963 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
| 966 | 964 | } |
| 967 | 965 | } |
| 968 | 966 | } |
@@ -970,12 +968,12 @@ discard block |
||
| 970 | 968 | $message = lang('Event saved'); |
| 971 | 969 | if ($status_reset_to_unknown) |
| 972 | 970 | { |
| 973 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 971 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 974 | 972 | { |
| 975 | 973 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 976 | 974 | { |
| 977 | - calendar_so::split_status($status,$q,$r); |
|
| 978 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 975 | + calendar_so::split_status($status, $q, $r); |
|
| 976 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 979 | 977 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 980 | 978 | } |
| 981 | 979 | } |
@@ -983,17 +981,17 @@ discard block |
||
| 983 | 981 | } |
| 984 | 982 | |
| 985 | 983 | $response = Api\Json\Response::get(); |
| 986 | - if($response && $update_type != 'delete') |
|
| 984 | + if ($response && $update_type != 'delete') |
|
| 987 | 985 | { |
| 988 | 986 | $client_updated = $this->update_client($event['id']); |
| 989 | 987 | } |
| 990 | 988 | |
| 991 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
| 989 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
| 992 | 990 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
| 993 | 991 | // writing links for new entry, existing ones are handled by the widget itself |
| 994 | 992 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
| 995 | 993 | { |
| 996 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
| 994 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
| 997 | 995 | } |
| 998 | 996 | } |
| 999 | 997 | else |
@@ -1003,7 +1001,7 @@ discard block |
||
| 1003 | 1001 | break; |
| 1004 | 1002 | |
| 1005 | 1003 | case 'cancel': |
| 1006 | - if($content['cancel_needs_refresh']) |
|
| 1004 | + if ($content['cancel_needs_refresh']) |
|
| 1007 | 1005 | { |
| 1008 | 1006 | Framework::refresh_opener($msg, 'calendar'); |
| 1009 | 1007 | } |
@@ -1041,7 +1039,7 @@ discard block |
||
| 1041 | 1039 | { |
| 1042 | 1040 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
| 1043 | 1041 | } |
| 1044 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1042 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
| 1045 | 1043 | { |
| 1046 | 1044 | $alarm = array( |
| 1047 | 1045 | 'offset' => $offset, |
@@ -1055,13 +1053,13 @@ discard block |
||
| 1055 | 1053 | } |
| 1056 | 1054 | elseif ($event['id']) // save the alarm immediatly |
| 1057 | 1055 | { |
| 1058 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1056 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
| 1059 | 1057 | { |
| 1060 | 1058 | $alarm['id'] = $alarm_id; |
| 1061 | 1059 | $event['alarm'][$alarm_id] = $alarm; |
| 1062 | 1060 | |
| 1063 | 1061 | $msg = lang('Alarm added'); |
| 1064 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1062 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
| 1065 | 1063 | } |
| 1066 | 1064 | else |
| 1067 | 1065 | { |
@@ -1070,7 +1068,7 @@ discard block |
||
| 1070 | 1068 | } |
| 1071 | 1069 | else |
| 1072 | 1070 | { |
| 1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1071 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1074 | 1072 | $event['alarm'][$alarm['id']] = $alarm; |
| 1075 | 1073 | } |
| 1076 | 1074 | } |
@@ -1087,32 +1085,32 @@ discard block |
||
| 1087 | 1085 | } |
| 1088 | 1086 | // New event, send data before updating so it's there |
| 1089 | 1087 | $response = Api\Json\Response::get(); |
| 1090 | - if($response && !$content['id'] && $event['id']) |
|
| 1088 | + if ($response && !$content['id'] && $event['id']) |
|
| 1091 | 1089 | { |
| 1092 | 1090 | $client_updated = $this->update_client($event['id']); |
| 1093 | 1091 | } |
| 1094 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
| 1092 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
| 1095 | 1093 | { |
| 1096 | 1094 | if ($content['lock_token']) // remove an existing lock |
| 1097 | 1095 | { |
| 1098 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
| 1096 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
| 1099 | 1097 | } |
| 1100 | 1098 | if ($content['no_popup']) |
| 1101 | 1099 | { |
| 1102 | - Egw::redirect_link('/index.php',array( |
|
| 1100 | + Egw::redirect_link('/index.php', array( |
|
| 1103 | 1101 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 1104 | 1102 | 'msg' => $msg, |
| 1105 | 1103 | 'ajax' => 'true' |
| 1106 | 1104 | )); |
| 1107 | 1105 | } |
| 1108 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1106 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1109 | 1107 | { |
| 1110 | - Framework::refresh_opener($msg,'calendar'); |
|
| 1108 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 1111 | 1109 | } |
| 1112 | 1110 | else |
| 1113 | 1111 | { |
| 1114 | 1112 | Framework::refresh_opener($msg, 'calendar', |
| 1115 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
| 1113 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
| 1116 | 1114 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
| 1117 | 1115 | ); |
| 1118 | 1116 | } |
@@ -1120,7 +1118,7 @@ discard block |
||
| 1120 | 1118 | exit(); |
| 1121 | 1119 | } |
| 1122 | 1120 | unset($event['no_notifications']); |
| 1123 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1121 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1124 | 1122 | } |
| 1125 | 1123 | |
| 1126 | 1124 | /** |
@@ -1132,7 +1130,7 @@ discard block |
||
| 1132 | 1130 | * @param array &$preserv |
| 1133 | 1131 | * @return string message that exception was created |
| 1134 | 1132 | */ |
| 1135 | - function _create_exception(&$event,&$preserv) |
|
| 1133 | + function _create_exception(&$event, &$preserv) |
|
| 1136 | 1134 | { |
| 1137 | 1135 | // In some cases where the user makes the first day an exception, actual_date may be missing |
| 1138 | 1136 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1142,25 +1140,25 @@ discard block |
||
| 1142 | 1140 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
| 1143 | 1141 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
| 1144 | 1142 | $event['recur_type'] = MCAL_RECUR_NONE; |
| 1145 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
| 1143 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
| 1146 | 1144 | { |
| 1147 | 1145 | unset($event[$name]); |
| 1148 | 1146 | } |
| 1149 | 1147 | // add all alarms as new alarms to execption |
| 1150 | 1148 | $event['alarm'] = array_values((array)$event['alarm']); |
| 1151 | - foreach($event['alarm'] as &$alarm) |
|
| 1149 | + foreach ($event['alarm'] as &$alarm) |
|
| 1152 | 1150 | { |
| 1153 | 1151 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
| 1154 | 1152 | } |
| 1155 | 1153 | |
| 1156 | 1154 | // Copy links |
| 1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1155 | + if (!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1158 | 1156 | $event['link_to']['to_app'] = 'calendar'; |
| 1159 | 1157 | $event['link_to']['to_id'] = 0; |
| 1160 | 1158 | |
| 1161 | - foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
| 1159 | + foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
| 1162 | 1160 | { |
| 1163 | - if(!$link['id']) continue; |
|
| 1161 | + if (!$link['id']) continue; |
|
| 1164 | 1162 | if ($link['app'] != Link::VFS_APPNAME) |
| 1165 | 1163 | { |
| 1166 | 1164 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1176,7 +1174,7 @@ discard block |
||
| 1176 | 1174 | |
| 1177 | 1175 | $event['links'] = $event['link_to']; |
| 1178 | 1176 | |
| 1179 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1177 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1180 | 1178 | { |
| 1181 | 1179 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
| 1182 | 1180 | } |
@@ -1203,14 +1201,14 @@ discard block |
||
| 1203 | 1201 | { |
| 1204 | 1202 | $msg = false; |
| 1205 | 1203 | |
| 1206 | - if(!$as_of_date ) |
|
| 1204 | + if (!$as_of_date) |
|
| 1207 | 1205 | { |
| 1208 | 1206 | $as_of_date = time(); |
| 1209 | 1207 | } |
| 1210 | 1208 | |
| 1211 | 1209 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
| 1212 | 1210 | |
| 1213 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1211 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1214 | 1212 | { |
| 1215 | 1213 | $msg = lang("Error: You can't shift a series from the past!"); |
| 1216 | 1214 | return $msg; |
@@ -1223,11 +1221,11 @@ discard block |
||
| 1223 | 1221 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
| 1224 | 1222 | |
| 1225 | 1223 | // base start-date of new series on actual / clicked date |
| 1226 | - $event['start'] = $as_of_date ; |
|
| 1224 | + $event['start'] = $as_of_date; |
|
| 1227 | 1225 | |
| 1228 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
| 1226 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
| 1229 | 1227 | // Adjust for requested date in the past |
| 1230 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
| 1228 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
| 1231 | 1229 | ) |
| 1232 | 1230 | { |
| 1233 | 1231 | |
@@ -1247,17 +1245,17 @@ discard block |
||
| 1247 | 1245 | $rriter->next_no_exception(); |
| 1248 | 1246 | $occurrence = $rriter->current(); |
| 1249 | 1247 | } |
| 1250 | - while ($rriter->valid() && ( |
|
| 1248 | + while ($rriter->valid() && ( |
|
| 1251 | 1249 | Api\DateTime::to($occurrence, 'ts') <= time() || |
| 1252 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
| 1250 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
| 1253 | 1251 | ) && ($last = $occurrence)); |
| 1254 | 1252 | |
| 1255 | 1253 | |
| 1256 | 1254 | // Make sure as_of_date is still valid, may have to move forward |
| 1257 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
| 1255 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
| 1258 | 1256 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
| 1259 | 1257 | { |
| 1260 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
| 1258 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
| 1261 | 1259 | } |
| 1262 | 1260 | |
| 1263 | 1261 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1265,7 +1263,7 @@ discard block |
||
| 1265 | 1263 | { |
| 1266 | 1264 | $event['end'] = $event['start'] + $duration; |
| 1267 | 1265 | } |
| 1268 | - elseif($event['end'] < $event['start']) |
|
| 1266 | + elseif ($event['end'] < $event['start']) |
|
| 1269 | 1267 | { |
| 1270 | 1268 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
| 1271 | 1269 | } |
@@ -1274,7 +1272,7 @@ discard block |
||
| 1274 | 1272 | $event['participants'] = $old_event['participants']; |
| 1275 | 1273 | foreach ($old_event['recur_exception'] as $key => $exdate) |
| 1276 | 1274 | { |
| 1277 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
| 1275 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
| 1278 | 1276 | { |
| 1279 | 1277 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
| 1280 | 1278 | unset($old_event['recur_exception'][$key]); |
@@ -1288,18 +1286,18 @@ discard block |
||
| 1288 | 1286 | } |
| 1289 | 1287 | $last->setTime(0, 0, 0); |
| 1290 | 1288 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
| 1291 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
| 1289 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
| 1292 | 1290 | { |
| 1293 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1294 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 1295 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 1291 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1292 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 1293 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 1296 | 1294 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 1297 | 1295 | 'cal_id' => $event['id'], |
| 1298 | - ))).'">','</a>'); |
|
| 1296 | + ))).'">', '</a>'); |
|
| 1299 | 1297 | $event = $orig_event; |
| 1300 | 1298 | } |
| 1301 | 1299 | } |
| 1302 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 1300 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
| 1303 | 1301 | return $msg; |
| 1304 | 1302 | } |
| 1305 | 1303 | |
@@ -1310,18 +1308,18 @@ discard block |
||
| 1310 | 1308 | * @param boolean $added |
| 1311 | 1309 | * @return string javascript window.open command |
| 1312 | 1310 | */ |
| 1313 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
| 1311 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
| 1314 | 1312 | { |
| 1315 | 1313 | $to = array(); |
| 1316 | 1314 | |
| 1317 | - foreach($event['participants'] as $uid => $status) |
|
| 1315 | + foreach ($event['participants'] as $uid => $status) |
|
| 1318 | 1316 | { |
| 1319 | 1317 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1320 | 1318 | if (empty($status)) continue; |
| 1321 | - if(!is_array($status)) |
|
| 1319 | + if (!is_array($status)) |
|
| 1322 | 1320 | { |
| 1323 | 1321 | $quantity = $role = null; |
| 1324 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1322 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1325 | 1323 | $status = array( |
| 1326 | 1324 | 'status' => $status, |
| 1327 | 1325 | 'uid' => $uid, |
@@ -1332,32 +1330,32 @@ discard block |
||
| 1332 | 1330 | |
| 1333 | 1331 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1334 | 1332 | { |
| 1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1333 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
| 1336 | 1334 | |
| 1337 | 1335 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1338 | 1336 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1339 | 1337 | |
| 1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1338 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
| 1341 | 1339 | } |
| 1342 | 1340 | elseif ($uid < 0) |
| 1343 | 1341 | { |
| 1344 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
| 1342 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
| 1345 | 1343 | { |
| 1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1344 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
| 1347 | 1345 | |
| 1348 | 1346 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1349 | 1347 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1350 | 1348 | |
| 1351 | 1349 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1350 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1353 | 1351 | } |
| 1354 | 1352 | } |
| 1355 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1353 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1356 | 1354 | { |
| 1357 | 1355 | $to[] = $info['email']; |
| 1358 | 1356 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1359 | 1357 | } |
| 1360 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1358 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1361 | 1359 | { |
| 1362 | 1360 | $to[] = $info['email']; |
| 1363 | 1361 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1366,7 +1364,7 @@ discard block |
||
| 1366 | 1364 | // prefer event description over standard notification text |
| 1367 | 1365 | if (empty($event['description'])) |
| 1368 | 1366 | { |
| 1369 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1367 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1370 | 1368 | } |
| 1371 | 1369 | else |
| 1372 | 1370 | { |
@@ -1381,12 +1379,12 @@ discard block |
||
| 1381 | 1379 | $boical = new calendar_ical(); |
| 1382 | 1380 | // we need to pass $event[id] so iCal class reads event again, |
| 1383 | 1381 | // as event is in user TZ, but iCal class expects server TZ! |
| 1384 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
| 1382 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
| 1385 | 1383 | |
| 1386 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
| 1387 | - if(($f = fopen($ics_file,'w'))) |
|
| 1384 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
| 1385 | + if (($f = fopen($ics_file, 'w'))) |
|
| 1388 | 1386 | { |
| 1389 | - fwrite($f,$ics); |
|
| 1387 | + fwrite($f, $ics); |
|
| 1390 | 1388 | fclose($f); |
| 1391 | 1389 | } |
| 1392 | 1390 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1397,10 +1395,10 @@ discard block |
||
| 1397 | 1395 | 'preset[body]' => $body, |
| 1398 | 1396 | 'preset[name]' => 'event.ics', |
| 1399 | 1397 | 'preset[file]' => $ics_file, |
| 1400 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
| 1398 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
| 1401 | 1399 | 'preset[size]' => filesize($ics_file), |
| 1402 | 1400 | ); |
| 1403 | - $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
|
| 1401 | + $vars[$asrequest ? 'preset[to]' : 'preset[bcc]'] = $to; |
|
| 1404 | 1402 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
| 1405 | 1403 | $response = Api\Json\Response::get(); |
| 1406 | 1404 | $response->call('app.calendar.custom_mail', $vars); |
@@ -1454,7 +1452,7 @@ discard block |
||
| 1454 | 1452 | * @param mixed $link_to_id ='' from or for the link-widget |
| 1455 | 1453 | * @param string $msg_type =null default automatic detect, if it contains "error" |
| 1456 | 1454 | */ |
| 1457 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
| 1455 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
| 1458 | 1456 | { |
| 1459 | 1457 | $sel_options = array( |
| 1460 | 1458 | 'recur_type' => &$this->bo->recur_types, |
@@ -1478,8 +1476,8 @@ discard block |
||
| 1478 | 1476 | 'no_popup' => isset($_GET['no_popup']), |
| 1479 | 1477 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
| 1480 | 1478 | ); |
| 1481 | - $cal_id = (int) $_GET['cal_id']; |
|
| 1482 | - if($_GET['action']) |
|
| 1479 | + $cal_id = (int)$_GET['cal_id']; |
|
| 1480 | + if ($_GET['action']) |
|
| 1483 | 1481 | { |
| 1484 | 1482 | $event = $this->bo->read($cal_id); |
| 1485 | 1483 | $event['action'] = $_GET['action']; |
@@ -1497,14 +1495,14 @@ discard block |
||
| 1497 | 1495 | { |
| 1498 | 1496 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
| 1499 | 1497 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
| 1500 | - $event =& $this->default_add_event(); |
|
| 1498 | + $event = & $this->default_add_event(); |
|
| 1501 | 1499 | } |
| 1502 | 1500 | if (!empty($_GET['ical_data']) && |
| 1503 | 1501 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
| 1504 | 1502 | { |
| 1505 | 1503 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
| 1506 | 1504 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
| 1507 | - $event =& $this->default_add_event(); |
|
| 1505 | + $event = & $this->default_add_event(); |
|
| 1508 | 1506 | } |
| 1509 | 1507 | if (!empty($_GET['ical'])) |
| 1510 | 1508 | { |
@@ -1513,14 +1511,14 @@ discard block |
||
| 1513 | 1511 | { |
| 1514 | 1512 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
| 1515 | 1513 | $msg = lang('Error: importing the iCal'); |
| 1516 | - $event =& $this->default_add_event(); |
|
| 1514 | + $event = & $this->default_add_event(); |
|
| 1517 | 1515 | } |
| 1518 | 1516 | else |
| 1519 | 1517 | { |
| 1520 | 1518 | if (count($events) > 1) |
| 1521 | 1519 | { |
| 1522 | 1520 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
| 1523 | - $msg_type = 'notice'; // no not hide automatic |
|
| 1521 | + $msg_type = 'notice'; // no not hide automatic |
|
| 1524 | 1522 | } |
| 1525 | 1523 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
| 1526 | 1524 | $this->bo->db2data($events, 'ts'); |
@@ -1533,7 +1531,7 @@ discard block |
||
| 1533 | 1531 | else |
| 1534 | 1532 | { |
| 1535 | 1533 | $event['participant_types'] = array(); |
| 1536 | - foreach($event['participants'] as $uid => $status) |
|
| 1534 | + foreach ($event['participants'] as $uid => $status) |
|
| 1537 | 1535 | { |
| 1538 | 1536 | $user_type = $user_id = null; |
| 1539 | 1537 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1554,15 +1552,15 @@ discard block |
||
| 1554 | 1552 | } |
| 1555 | 1553 | else |
| 1556 | 1554 | { |
| 1557 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
| 1555 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
| 1558 | 1556 | exit(); |
| 1559 | 1557 | } |
| 1560 | 1558 | } |
| 1561 | - $event =& $this->default_add_event(); |
|
| 1559 | + $event = & $this->default_add_event(); |
|
| 1562 | 1560 | } |
| 1563 | 1561 | else |
| 1564 | 1562 | { |
| 1565 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1563 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1566 | 1564 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1567 | 1565 | { |
| 1568 | 1566 | if (empty($event['whole_day'])) |
@@ -1575,10 +1573,10 @@ discard block |
||
| 1575 | 1573 | $date->setUser(); |
| 1576 | 1574 | } |
| 1577 | 1575 | $event = $this->bo->read($cal_id, $date, true); |
| 1578 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1576 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1579 | 1577 | if ($_GET['exception']) |
| 1580 | 1578 | { |
| 1581 | - $msg = $this->_create_exception($event,$preserv); |
|
| 1579 | + $msg = $this->_create_exception($event, $preserv); |
|
| 1582 | 1580 | } |
| 1583 | 1581 | else |
| 1584 | 1582 | { |
@@ -1587,9 +1585,9 @@ discard block |
||
| 1587 | 1585 | } |
| 1588 | 1586 | } |
| 1589 | 1587 | // set new start and end if given by $_GET |
| 1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1588 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
| 1589 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
| 1590 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1593 | 1591 | // check if the event is the whole day |
| 1594 | 1592 | $start = $this->bo->date2array($event['start']); |
| 1595 | 1593 | $end = $this->bo->date2array($event['end']); |
@@ -1599,30 +1597,30 @@ discard block |
||
| 1599 | 1597 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
| 1600 | 1598 | { |
| 1601 | 1599 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
| 1602 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1600 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1603 | 1601 | { |
| 1604 | 1602 | $link_id = $link_ids[$n]; |
| 1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1603 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
| 1606 | 1604 | { |
| 1607 | 1605 | continue; |
| 1608 | 1606 | } |
| 1609 | - if(!$n) |
|
| 1607 | + if (!$n) |
|
| 1610 | 1608 | { |
| 1611 | - $event['title'] = Link::title($link_app,$link_id); |
|
| 1609 | + $event['title'] = Link::title($link_app, $link_id); |
|
| 1612 | 1610 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
| 1613 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
| 1611 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
| 1614 | 1612 | { |
| 1615 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
| 1613 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
| 1616 | 1614 | { |
| 1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1615 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
| 1618 | 1616 | } |
| 1619 | 1617 | unset($set['link_app']); |
| 1620 | 1618 | unset($set['link_id']); |
| 1621 | 1619 | |
| 1622 | - $event = array_merge($event,$set); |
|
| 1620 | + $event = array_merge($event, $set); |
|
| 1623 | 1621 | } |
| 1624 | 1622 | } |
| 1625 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
| 1623 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
| 1626 | 1624 | } |
| 1627 | 1625 | } |
| 1628 | 1626 | } |
@@ -1632,45 +1630,45 @@ discard block |
||
| 1632 | 1630 | { |
| 1633 | 1631 | $etpl->read($preserv['template'] = 'calendar.edit'); |
| 1634 | 1632 | } |
| 1635 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
| 1633 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
| 1636 | 1634 | //echo "view=$view, event="; _debug_array($event); |
| 1637 | 1635 | // shared locking of entries to edit |
| 1638 | 1636 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
| 1639 | 1637 | { |
| 1640 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
| 1638 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
| 1641 | 1639 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1642 | 1640 | |
| 1643 | 1641 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
| 1644 | 1642 | { |
| 1645 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
| 1643 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
| 1646 | 1644 | } |
| 1647 | 1645 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1648 | 1646 | { |
| 1649 | 1647 | $msg .= ' '.lang('This entry is currently opened by %1!', |
| 1650 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
| 1648 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
| 1651 | 1649 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
| 1652 | 1650 | } |
| 1653 | - elseif($lock) |
|
| 1651 | + elseif ($lock) |
|
| 1654 | 1652 | { |
| 1655 | 1653 | $preserv['lock_token'] = $lock['token']; |
| 1656 | 1654 | } |
| 1657 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
| 1655 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
| 1658 | 1656 | { |
| 1659 | 1657 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
| 1660 | 1658 | } |
| 1661 | 1659 | else |
| 1662 | 1660 | { |
| 1663 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1661 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1664 | 1662 | $view = true; |
| 1665 | 1663 | } |
| 1666 | 1664 | } |
| 1667 | - $content = array_merge($event,array( |
|
| 1665 | + $content = array_merge($event, array( |
|
| 1668 | 1666 | 'cal_id' => $event['id'], |
| 1669 | 1667 | 'link_to' => array( |
| 1670 | 1668 | 'to_id' => $link_to_id, |
| 1671 | 1669 | 'to_app' => 'calendar', |
| 1672 | 1670 | ), |
| 1673 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1671 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1674 | 1672 | 'tabs' => $preserv['tabs'], |
| 1675 | 1673 | 'view' => $view, |
| 1676 | 1674 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1682,11 +1680,11 @@ discard block |
||
| 1682 | 1680 | $row = 3; |
| 1683 | 1681 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1684 | 1682 | // preserve some ui elements, if set eg. under error-conditions |
| 1685 | - foreach(array('quantity','resource','role') as $n) |
|
| 1683 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 1686 | 1684 | { |
| 1687 | 1685 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
| 1688 | 1686 | } |
| 1689 | - foreach($event['participant_types'] as $type => $participants) |
|
| 1687 | + foreach ($event['participant_types'] as $type => $participants) |
|
| 1690 | 1688 | { |
| 1691 | 1689 | $name = 'accounts'; |
| 1692 | 1690 | if (isset($this->bo->resources[$type])) |
@@ -1695,17 +1693,17 @@ discard block |
||
| 1695 | 1693 | } |
| 1696 | 1694 | // sort participants (in there group/app) by title |
| 1697 | 1695 | uksort($participants, array($this, 'uid_title_cmp')); |
| 1698 | - foreach($participants as $id => $status) |
|
| 1696 | + foreach ($participants as $id => $status) |
|
| 1699 | 1697 | { |
| 1700 | 1698 | $uid = $type == 'u' ? $id : $type.$id; |
| 1701 | 1699 | $quantity = $role = null; |
| 1702 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1700 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1703 | 1701 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1704 | 1702 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
| 1705 | 1703 | 'uid' => $uid, |
| 1706 | 1704 | 'status' => $status, |
| 1707 | 1705 | 'old_status' => $status, |
| 1708 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1706 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1709 | 1707 | 'role' => $role, |
| 1710 | 1708 | ); |
| 1711 | 1709 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1714,33 +1712,33 @@ discard block |
||
| 1714 | 1712 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
| 1715 | 1713 | } |
| 1716 | 1714 | // allow third party apps to use categories for roles |
| 1717 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
| 1715 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
| 1718 | 1716 | { |
| 1719 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
| 1717 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
| 1720 | 1718 | } |
| 1721 | 1719 | else |
| 1722 | 1720 | { |
| 1723 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
| 1721 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
| 1724 | 1722 | } |
| 1725 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
| 1723 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
| 1726 | 1724 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1727 | 1725 | |
| 1728 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
| 1726 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
| 1729 | 1727 | $readonlys['participants'][$row]['status'] = $no_status; |
| 1730 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1728 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1731 | 1729 | $readonlys['participants']['delete'][$uid] = true; |
| 1732 | 1730 | // todo: make the participants available as links with email as title |
| 1733 | 1731 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1734 | 1732 | // enumerate group-invitations, so people can accept/reject them |
| 1735 | 1733 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
| 1736 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
| 1734 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
| 1737 | 1735 | { |
| 1738 | 1736 | $sel_options['status']['G'] = lang('Select one'); |
| 1739 | 1737 | // sort members by title |
| 1740 | 1738 | usort($members, array($this, 'uid_title_cmp')); |
| 1741 | - foreach($members as $member) |
|
| 1739 | + foreach ($members as $member) |
|
| 1742 | 1740 | { |
| 1743 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
| 1741 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
| 1744 | 1742 | { |
| 1745 | 1743 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1746 | 1744 | 'app' => 'Group invitation', |
@@ -1749,7 +1747,7 @@ discard block |
||
| 1749 | 1747 | ); |
| 1750 | 1748 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
| 1751 | 1749 | // read access is enough to invite participants, but you need edit rights to change status |
| 1752 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
| 1750 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
| 1753 | 1751 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
| 1754 | 1752 | } |
| 1755 | 1753 | } |
@@ -1757,37 +1755,37 @@ discard block |
||
| 1757 | 1755 | } |
| 1758 | 1756 | // resouces / apps we shedule, atm. resources and addressbook |
| 1759 | 1757 | $content['participants']['cal_resources'] = ''; |
| 1760 | - foreach($this->bo->resources as $data) |
|
| 1758 | + foreach ($this->bo->resources as $data) |
|
| 1761 | 1759 | { |
| 1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1760 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1763 | 1761 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1764 | 1762 | } |
| 1765 | 1763 | } |
| 1766 | 1764 | $content['participants']['status_date'] = $preserv['actual_date']; |
| 1767 | - $preserved = array_merge($preserv,$content); |
|
| 1765 | + $preserved = array_merge($preserv, $content); |
|
| 1768 | 1766 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
| 1769 | 1767 | if ($event['alarm']) |
| 1770 | 1768 | { |
| 1771 | 1769 | // makes keys of the alarm-array starting with 1 |
| 1772 | 1770 | $content['alarm'] = array(false); |
| 1773 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
| 1771 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
| 1774 | 1772 | { |
| 1775 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
| 1773 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
| 1776 | 1774 | { |
| 1777 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1775 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1778 | 1776 | } |
| 1779 | - $alarm['all'] = (int) $alarm['all']; |
|
| 1777 | + $alarm['all'] = (int)$alarm['all']; |
|
| 1780 | 1778 | // fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise |
| 1781 | 1779 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1782 | 1780 | $after = false; |
| 1783 | - if($alarm['offset'] < 0) |
|
| 1781 | + if ($alarm['offset'] < 0) |
|
| 1784 | 1782 | { |
| 1785 | 1783 | $after = true; |
| 1786 | 1784 | $alarm['offset'] = -1 * $alarm['offset']; |
| 1787 | 1785 | } |
| 1788 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
| 1789 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1790 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
| 1786 | + $days = (int)($alarm['offset'] / DAY_s); |
|
| 1787 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1788 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
| 1791 | 1789 | $label = array(); |
| 1792 | 1790 | if ($days) $label[] = $days.' '.lang('days'); |
| 1793 | 1791 | if ($hours) $label[] = $hours.' '.lang('hours'); |
@@ -1798,11 +1796,11 @@ discard block |
||
| 1798 | 1796 | } |
| 1799 | 1797 | else |
| 1800 | 1798 | { |
| 1801 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
| 1799 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
| 1802 | 1800 | } |
| 1803 | 1801 | $content['alarm'][] = $alarm; |
| 1804 | 1802 | |
| 1805 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
| 1803 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
| 1806 | 1804 | } |
| 1807 | 1805 | if (count($content['alarm']) == 1) |
| 1808 | 1806 | { |
@@ -1817,20 +1815,20 @@ discard block |
||
| 1817 | 1815 | |
| 1818 | 1816 | if ($view) |
| 1819 | 1817 | { |
| 1820 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1818 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1821 | 1819 | $readonlys['button[cancel]'] = $readonlys['action'] = |
| 1822 | 1820 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
| 1823 | 1821 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
| 1824 | 1822 | |
| 1825 | 1823 | $content['participants']['no_add'] = true; |
| 1826 | 1824 | |
| 1827 | - if(!$event['whole_day']) |
|
| 1825 | + if (!$event['whole_day']) |
|
| 1828 | 1826 | { |
| 1829 | 1827 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
| 1830 | 1828 | } |
| 1831 | 1829 | |
| 1832 | 1830 | // respect category permissions |
| 1833 | - if(!empty($event['category'])) |
|
| 1831 | + if (!empty($event['category'])) |
|
| 1834 | 1832 | { |
| 1835 | 1833 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
| 1836 | 1834 | } |
@@ -1841,7 +1839,7 @@ discard block |
||
| 1841 | 1839 | |
| 1842 | 1840 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1843 | 1841 | { |
| 1844 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1842 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1845 | 1843 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
| 1846 | 1844 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
| 1847 | 1845 | } |
@@ -1851,9 +1849,9 @@ discard block |
||
| 1851 | 1849 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
| 1852 | 1850 | } |
| 1853 | 1851 | } |
| 1854 | - if($content['category'] && !is_array($content['category'])) |
|
| 1852 | + if ($content['category'] && !is_array($content['category'])) |
|
| 1855 | 1853 | { |
| 1856 | - $content['category'] = explode(',',$event['category']); |
|
| 1854 | + $content['category'] = explode(',', $event['category']); |
|
| 1857 | 1855 | } |
| 1858 | 1856 | // disabling the custom fields tab, if there are none |
| 1859 | 1857 | $readonlys['tabs'] = array( |
@@ -1870,13 +1868,13 @@ discard block |
||
| 1870 | 1868 | { |
| 1871 | 1869 | $readonlys['action'] = true; |
| 1872 | 1870 | } |
| 1873 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
| 1871 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
| 1874 | 1872 | { |
| 1875 | 1873 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1876 | 1874 | } |
| 1877 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
| 1875 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
| 1878 | 1876 | |
| 1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1877 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1880 | 1878 | { |
| 1881 | 1879 | $sel_options['owner'][0] = lang('All participants'); |
| 1882 | 1880 | } |
@@ -1884,26 +1882,26 @@ discard block |
||
| 1884 | 1882 | { |
| 1885 | 1883 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
| 1886 | 1884 | } |
| 1887 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
| 1885 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
| 1888 | 1886 | { |
| 1889 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
| 1887 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
| 1890 | 1888 | { |
| 1891 | 1889 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
| 1892 | 1890 | } |
| 1893 | 1891 | } |
| 1894 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1892 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1895 | 1893 | if (!$event['id']) |
| 1896 | 1894 | { |
| 1897 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
| 1895 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
| 1898 | 1896 | } |
| 1899 | 1897 | if ($preserved['no_popup']) |
| 1900 | 1898 | { |
| 1901 | 1899 | // If not a popup, load the normal calendar interface on cancel |
| 1902 | - $etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
| 1900 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
| 1903 | 1901 | } |
| 1904 | 1902 | |
| 1905 | 1903 | // Allow admins to restore deleted events |
| 1906 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
| 1904 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
| 1907 | 1905 | { |
| 1908 | 1906 | $content['deleted'] = $preserved['deleted'] = null; |
| 1909 | 1907 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1915,7 +1913,7 @@ discard block |
||
| 1915 | 1913 | // Setup history tab |
| 1916 | 1914 | $this->setup_history($content, $sel_options); |
| 1917 | 1915 | |
| 1918 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
| 1916 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
| 1919 | 1917 | . (!$event['id'] ? lang('Add') |
| 1920 | 1918 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
| 1921 | 1919 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1925,15 +1923,15 @@ discard block |
||
| 1925 | 1923 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
| 1926 | 1924 | |
| 1927 | 1925 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1928 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1926 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1929 | 1927 | { |
| 1930 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1928 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1931 | 1929 | $content['button']['save'] = true; |
| 1932 | - $this->process_edit(array_merge($content,$preserved)); |
|
| 1930 | + $this->process_edit(array_merge($content, $preserved)); |
|
| 1933 | 1931 | } |
| 1934 | 1932 | else |
| 1935 | 1933 | { |
| 1936 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
| 1934 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
| 1937 | 1935 | } |
| 1938 | 1936 | } |
| 1939 | 1937 | |
@@ -1943,14 +1941,14 @@ discard block |
||
| 1943 | 1941 | * @param int $id |
| 1944 | 1942 | * @param string $token |
| 1945 | 1943 | */ |
| 1946 | - function ajax_unlock($id,$token) |
|
| 1944 | + function ajax_unlock($id, $token) |
|
| 1947 | 1945 | { |
| 1948 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
| 1946 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
| 1949 | 1947 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1950 | 1948 | |
| 1951 | 1949 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
| 1952 | 1950 | { |
| 1953 | - Vfs::unlock($lock_path,$token,false); |
|
| 1951 | + Vfs::unlock($lock_path, $token, false); |
|
| 1954 | 1952 | } |
| 1955 | 1953 | } |
| 1956 | 1954 | |
@@ -1962,17 +1960,17 @@ discard block |
||
| 1962 | 1960 | * are called by new mail-app; and we intend to use the stuff passed on by session |
| 1963 | 1961 | * @param string $msg = null |
| 1964 | 1962 | */ |
| 1965 | - function meeting(array $event=null, $msg=null) |
|
| 1963 | + function meeting(array $event = null, $msg = null) |
|
| 1966 | 1964 | { |
| 1967 | 1965 | $user = $GLOBALS['egw_info']['user']['account_id']; |
| 1968 | 1966 | $readonlys['button[apply]'] = true; |
| 1969 | - $_usesession=!is_array($event); |
|
| 1967 | + $_usesession = !is_array($event); |
|
| 1970 | 1968 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
| 1971 | 1969 | //are called by new mail-app; and we intend to use the stuff passed on by session |
| 1972 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
| 1970 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
| 1973 | 1971 | { |
| 1974 | - $event=null; // set to null |
|
| 1975 | - $_usesession=true; // trigger session read |
|
| 1972 | + $event = null; // set to null |
|
| 1973 | + $_usesession = true; // trigger session read |
|
| 1976 | 1974 | } |
| 1977 | 1975 | if (!is_array($event)) |
| 1978 | 1976 | { |
@@ -2002,7 +2000,7 @@ discard block |
||
| 2002 | 2000 | if (($existing_event = $this->bo->read($event['uid'], $event['recurrence'], false, 'ts', null, true)) && // true = read the exception |
| 2003 | 2001 | !$existing_event['deleted']) |
| 2004 | 2002 | { |
| 2005 | - switch(strtolower($ical_method)) |
|
| 2003 | + switch (strtolower($ical_method)) |
|
| 2006 | 2004 | { |
| 2007 | 2005 | case 'reply': |
| 2008 | 2006 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -2056,25 +2054,25 @@ discard block |
||
| 2056 | 2054 | } |
| 2057 | 2055 | else // event not in calendar |
| 2058 | 2056 | { |
| 2059 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 2057 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 2060 | 2058 | } |
| 2061 | 2059 | $event['participant_types'] = array(); |
| 2062 | - foreach($event['participants'] as $uid => $status) |
|
| 2060 | + foreach ($event['participants'] as $uid => $status) |
|
| 2063 | 2061 | { |
| 2064 | 2062 | $user_type = $user_id = null; |
| 2065 | 2063 | calendar_so::split_user($uid, $user_type, $user_id); |
| 2066 | 2064 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
| 2067 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 2065 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 2068 | 2066 | } |
| 2069 | 2067 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
| 2070 | 2068 | $event['recure'] = $this->bo->recure2string($event); |
| 2071 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
| 2069 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 2072 | 2070 | |
| 2073 | 2071 | // EGroupware event has been deleted, dont let user resurect it by accepting again |
| 2074 | 2072 | if ($existing_event && $existing_event['deleted'] && strtolower($ical_method) !== 'cancel') |
| 2075 | 2073 | { |
| 2076 | 2074 | // check if this is an EGroupware event or has an external organizer |
| 2077 | - foreach($existing_event['participants'] as $uid => $status) |
|
| 2075 | + foreach ($existing_event['participants'] as $uid => $status) |
|
| 2078 | 2076 | { |
| 2079 | 2077 | $quantity = $role = null; |
| 2080 | 2078 | calendar_so::split_status($status, $quantity, $role); |
@@ -2105,23 +2103,23 @@ discard block |
||
| 2105 | 2103 | // clear notification errors |
| 2106 | 2104 | notifications::errors(true); |
| 2107 | 2105 | |
| 2108 | - switch($button) |
|
| 2106 | + switch ($button) |
|
| 2109 | 2107 | { |
| 2110 | 2108 | case 'reject': |
| 2111 | 2109 | if (!$event['id']) |
| 2112 | 2110 | { |
| 2113 | 2111 | // send reply to organizer |
| 2114 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
| 2115 | - break; // no need to store rejected event |
|
| 2112 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
| 2113 | + break; // no need to store rejected event |
|
| 2116 | 2114 | } |
| 2117 | 2115 | // fall-through |
| 2118 | 2116 | case 'accept': |
| 2119 | 2117 | case 'tentativ': |
| 2120 | - $status = strtoupper($button[0]); // A, R or T |
|
| 2118 | + $status = strtoupper($button[0]); // A, R or T |
|
| 2121 | 2119 | if (!$event['id']) |
| 2122 | 2120 | { |
| 2123 | 2121 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
| 2124 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 2122 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 2125 | 2123 | { |
| 2126 | 2124 | // --> make organize a participant with role chair and current user the owner |
| 2127 | 2125 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2129,7 +2127,7 @@ discard block |
||
| 2129 | 2127 | $event['owner'] = $this->user; |
| 2130 | 2128 | } |
| 2131 | 2129 | // store event without notifications! |
| 2132 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
| 2130 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
| 2133 | 2131 | { |
| 2134 | 2132 | $msg[] = lang('Event saved'); |
| 2135 | 2133 | } |
@@ -2143,7 +2141,7 @@ discard block |
||
| 2143 | 2141 | elseif (self::event_changed($event, $event['old'])) |
| 2144 | 2142 | { |
| 2145 | 2143 | // check if we are allowed to update the event |
| 2146 | - if($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
| 2144 | + if ($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
| 2147 | 2145 | { |
| 2148 | 2146 | if ($event['recurrence'] && !$event['old']['reference'] && ($recur_event = $this->bo->read($event['id']))) |
| 2149 | 2147 | { |
@@ -2151,9 +2149,9 @@ discard block |
||
| 2151 | 2149 | $recur_event['recur_exception'][] = $event['recurrence']; |
| 2152 | 2150 | // check if we need to move the alarms, because they are next on that exception |
| 2153 | 2151 | $this->bo->check_move_alarms($recur_event, null, $event['recurrence']); |
| 2154 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2155 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2156 | - $this->bo->update($recur_event, $ignore_conflicts=true, true, false, true, $msg, true); |
|
| 2152 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2153 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2154 | + $this->bo->update($recur_event, $ignore_conflicts = true, true, false, true, $msg, true); |
|
| 2157 | 2155 | |
| 2158 | 2156 | // then we need to create the exception as new event |
| 2159 | 2157 | unset($event['id']); |
@@ -2168,7 +2166,7 @@ discard block |
||
| 2168 | 2166 | } |
| 2169 | 2167 | unset($event['old']); |
| 2170 | 2168 | |
| 2171 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
| 2169 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
| 2172 | 2170 | { |
| 2173 | 2171 | $msg[] = lang('Event saved'); |
| 2174 | 2172 | } |
@@ -2218,7 +2216,7 @@ discard block |
||
| 2218 | 2216 | Framework::message(implode("\n", (array)$msg)); |
| 2219 | 2217 | $readonlys['button[edit]'] = !$event['id']; |
| 2220 | 2218 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
| 2221 | - switch(strtolower($ical_method)) |
|
| 2219 | + switch (strtolower($ical_method)) |
|
| 2222 | 2220 | { |
| 2223 | 2221 | case 'reply': |
| 2224 | 2222 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2232,7 +2230,7 @@ discard block |
||
| 2232 | 2230 | break; |
| 2233 | 2231 | } |
| 2234 | 2232 | $tpl = new Etemplate('calendar.meeting'); |
| 2235 | - $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event+array( |
|
| 2233 | + $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event + array( |
|
| 2236 | 2234 | 'old' => $existing_event, |
| 2237 | 2235 | ), 2); |
| 2238 | 2236 | } |
@@ -2264,37 +2262,37 @@ discard block |
||
| 2264 | 2262 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
| 2265 | 2263 | * @param array $preserv data to preserv |
| 2266 | 2264 | */ |
| 2267 | - function conflicts($event,$conflicts,$preserv) |
|
| 2265 | + function conflicts($event, $conflicts, $preserv) |
|
| 2268 | 2266 | { |
| 2269 | 2267 | $etpl = new Etemplate('calendar.conflicts'); |
| 2270 | 2268 | $allConflicts = array(); |
| 2271 | 2269 | |
| 2272 | - foreach($conflicts as $k => $conflict) |
|
| 2270 | + foreach ($conflicts as $k => $conflict) |
|
| 2273 | 2271 | { |
| 2274 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
| 2272 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
| 2275 | 2273 | |
| 2276 | 2274 | $conflicts[$k] += array( |
| 2277 | 2275 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
| 2278 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
| 2279 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
| 2280 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
| 2281 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
| 2282 | - ),true,true)), // show group invitations too |
|
| 2276 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
| 2277 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
| 2278 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
| 2279 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
| 2280 | + ), true, true)), // show group invitations too |
|
| 2283 | 2281 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
| 2284 | 2282 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
| 2285 | 2283 | ); |
| 2286 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 2284 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 2287 | 2285 | } |
| 2288 | 2286 | $content = $event + array( |
| 2289 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2287 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2290 | 2288 | ); |
| 2291 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
| 2289 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
| 2292 | 2290 | $resources_config = Api\Config::read('resources'); |
| 2293 | 2291 | $readonlys = array(); |
| 2294 | 2292 | |
| 2295 | 2293 | foreach (array_keys($allConflicts) as $pId) |
| 2296 | 2294 | { |
| 2297 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2295 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
| 2298 | 2296 | { |
| 2299 | 2297 | |
| 2300 | 2298 | switch ($resources_config['ignoreconflicts']) |
@@ -2314,7 +2312,7 @@ discard block |
||
| 2314 | 2312 | } |
| 2315 | 2313 | } |
| 2316 | 2314 | } |
| 2317 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
| 2315 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
| 2318 | 2316 | } |
| 2319 | 2317 | |
| 2320 | 2318 | /** |
@@ -2332,7 +2330,7 @@ discard block |
||
| 2332 | 2330 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
| 2333 | 2331 | |
| 2334 | 2332 | // convert start/end date-time values to timestamps |
| 2335 | - foreach(array('start', 'end') as $name) |
|
| 2333 | + foreach (array('start', 'end') as $name) |
|
| 2336 | 2334 | { |
| 2337 | 2335 | if (!empty($edit_content[$name])) |
| 2338 | 2336 | { |
@@ -2362,7 +2360,7 @@ discard block |
||
| 2362 | 2360 | 'recur_type' => $edit_content['recur_type'], |
| 2363 | 2361 | 'participants' => array(), |
| 2364 | 2362 | ); |
| 2365 | - foreach($edit_content['participants'] as $key => $data) |
|
| 2363 | + foreach ($edit_content['participants'] as $key => $data) |
|
| 2366 | 2364 | { |
| 2367 | 2365 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
| 2368 | 2366 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2377,21 +2375,21 @@ discard block |
||
| 2377 | 2375 | // default search parameters |
| 2378 | 2376 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
| 2379 | 2377 | $content['end_time'] = $this->cal_prefs['workdayends']; |
| 2380 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
| 2378 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
| 2381 | 2379 | { |
| 2382 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2380 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2383 | 2381 | } |
| 2384 | 2382 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
| 2385 | 2383 | |
| 2386 | 2384 | $content['search_window'] = 7 * DAY_s; |
| 2387 | 2385 | |
| 2388 | 2386 | // store content in session |
| 2389 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
| 2387 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
| 2390 | 2388 | |
| 2391 | 2389 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
| 2392 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
| 2390 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
| 2393 | 2391 | |
| 2394 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
| 2392 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
| 2395 | 2393 | |
| 2396 | 2394 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
| 2397 | 2395 | |
@@ -2414,26 +2412,26 @@ discard block |
||
| 2414 | 2412 | { |
| 2415 | 2413 | $etpl = new Etemplate('calendar.freetimesearch'); |
| 2416 | 2414 | $sel_options['search_window'] = array( |
| 2417 | - 7*DAY_s => lang('one week'), |
|
| 2418 | - 14*DAY_s => lang('two weeks'), |
|
| 2419 | - 31*DAY_s => lang('one month'), |
|
| 2420 | - 92*DAY_s => lang('three month'), |
|
| 2421 | - 365*DAY_s => lang('one year'), |
|
| 2415 | + 7 * DAY_s => lang('one week'), |
|
| 2416 | + 14 * DAY_s => lang('two weeks'), |
|
| 2417 | + 31 * DAY_s => lang('one month'), |
|
| 2418 | + 92 * DAY_s => lang('three month'), |
|
| 2419 | + 365 * DAY_s => lang('one year'), |
|
| 2422 | 2420 | ); |
| 2423 | 2421 | if (!is_array($content)) |
| 2424 | 2422 | { |
| 2425 | 2423 | // get content from session (and delete it immediatly) |
| 2426 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2427 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2424 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2425 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2428 | 2426 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
| 2429 | 2427 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
| 2430 | 2428 | $sTime = $content['start_time']; |
| 2431 | 2429 | $eTime = $content['end_time']; |
| 2432 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
| 2433 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
| 2430 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
| 2431 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
| 2434 | 2432 | |
| 2435 | 2433 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
| 2436 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
| 2434 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
| 2437 | 2435 | { |
| 2438 | 2436 | if ($window > $content['duration']) |
| 2439 | 2437 | { |
@@ -2460,19 +2458,19 @@ discard block |
||
| 2460 | 2458 | { |
| 2461 | 2459 | $content['msg'] .= lang('Only the initial date of that recurring event is checked!'); |
| 2462 | 2460 | } |
| 2463 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
| 2464 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
| 2461 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
| 2462 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
| 2465 | 2463 | |
| 2466 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
| 2464 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
| 2467 | 2465 | |
| 2468 | 2466 | $sel_options['duration'] = $this->durations; |
| 2469 | 2467 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
| 2470 | 2468 | |
| 2471 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
| 2469 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
| 2472 | 2470 | 'participants' => $content['participants'], |
| 2473 | 2471 | 'cal_id' => $content['cal_id'], |
| 2474 | 2472 | 'recur_type' => $content['recur_type'], |
| 2475 | - ),2); |
|
| 2473 | + ), 2); |
|
| 2476 | 2474 | } |
| 2477 | 2475 | |
| 2478 | 2476 | /** |
@@ -2485,15 +2483,15 @@ discard block |
||
| 2485 | 2483 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
| 2486 | 2484 | * @return array of free time-slots: array with start and end values |
| 2487 | 2485 | */ |
| 2488 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
| 2486 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
| 2489 | 2487 | { |
| 2490 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2488 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
| 2491 | 2489 | |
| 2492 | 2490 | $busy = $this->bo->search(array( |
| 2493 | 2491 | 'start' => $start, |
| 2494 | 2492 | 'end' => $end, |
| 2495 | 2493 | 'users' => $participants, |
| 2496 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2494 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2497 | 2495 | )); |
| 2498 | 2496 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
| 2499 | 2497 | 'start' => $end, |
@@ -2502,15 +2500,15 @@ discard block |
||
| 2502 | 2500 | $ft_start = $start; |
| 2503 | 2501 | $freetime = array(); |
| 2504 | 2502 | $n = 0; |
| 2505 | - foreach($busy as $event) |
|
| 2503 | + foreach ($busy as $event) |
|
| 2506 | 2504 | { |
| 2507 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2505 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2508 | 2506 | |
| 2509 | 2507 | if ($event['non_blocking']) continue; // ignore non_blocking events |
| 2510 | 2508 | |
| 2511 | 2509 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2512 | 2510 | $non_rejected_found = false; |
| 2513 | - foreach($participants as $uid) |
|
| 2511 | + foreach ($participants as $uid) |
|
| 2514 | 2512 | { |
| 2515 | 2513 | $status = $event['participants'][$uid]; |
| 2516 | 2514 | $quantity = $role = null; |
@@ -2529,10 +2527,10 @@ discard block |
||
| 2529 | 2527 | |
| 2530 | 2528 | if ($this->debug) |
| 2531 | 2529 | { |
| 2532 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
| 2530 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
| 2533 | 2531 | echo "event[title]=$event[title]<br>\n"; |
| 2534 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
| 2535 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
| 2532 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
| 2533 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
| 2536 | 2534 | } |
| 2537 | 2535 | // $events ends before our actual position ==> ignore it |
| 2538 | 2536 | if ($event['end'] < $ft_start) |
@@ -2556,11 +2554,11 @@ discard block |
||
| 2556 | 2554 | 'start' => $ft_start, |
| 2557 | 2555 | 'end' => $ft_end, |
| 2558 | 2556 | ); |
| 2559 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2557 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
| 2560 | 2558 | } |
| 2561 | 2559 | $ft_start = $event['end']; |
| 2562 | 2560 | } |
| 2563 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2561 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
| 2564 | 2562 | |
| 2565 | 2563 | return $freetime; |
| 2566 | 2564 | } |
@@ -2580,46 +2578,46 @@ discard block |
||
| 2580 | 2578 | */ |
| 2581 | 2579 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2582 | 2580 | { |
| 2583 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2581 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
| 2584 | 2582 | |
| 2585 | 2583 | $freetime_daywise = array(); |
| 2586 | 2584 | if (!is_array($sel_options)) $sel_options = array(); |
| 2587 | 2585 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2588 | 2586 | |
| 2589 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
| 2590 | - $end_time = (int) $_end_time; |
|
| 2587 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
| 2588 | + $end_time = (int)$_end_time; |
|
| 2591 | 2589 | |
| 2592 | 2590 | // ignore the end_time, if duration would never fit |
| 2593 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
| 2591 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
| 2594 | 2592 | { |
| 2595 | 2593 | $end_time = 0; |
| 2596 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2594 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
| 2597 | 2595 | } |
| 2598 | 2596 | $n = 0; |
| 2599 | - foreach($freetime as $ft) |
|
| 2597 | + foreach ($freetime as $ft) |
|
| 2600 | 2598 | { |
| 2601 | 2599 | $adaybegin = $this->bo->date2array($ft['start']); |
| 2602 | 2600 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
| 2603 | 2601 | unset($adaybegin['raw']); |
| 2604 | 2602 | $daybegin = $this->bo->date2ts($adaybegin); |
| 2605 | 2603 | |
| 2606 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
| 2604 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
| 2607 | 2605 | { |
| 2608 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
| 2609 | - $mcal_dow = pow(2,$dow); |
|
| 2610 | - if (!($weekdays & $mcal_dow)) |
|
| 2606 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
| 2607 | + $mcal_dow = pow(2, $dow); |
|
| 2608 | + if (!($weekdays&$mcal_dow)) |
|
| 2611 | 2609 | { |
| 2612 | 2610 | //echo "wrong day of week $dow<br>\n"; |
| 2613 | - continue; // wrong day of week |
|
| 2611 | + continue; // wrong day of week |
|
| 2614 | 2612 | } |
| 2615 | 2613 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2616 | 2614 | |
| 2617 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2615 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
| 2618 | 2616 | { |
| 2619 | - $start = $daybegin + $start_time*HOUR_s; |
|
| 2617 | + $start = $daybegin + $start_time * HOUR_s; |
|
| 2620 | 2618 | } |
| 2621 | 2619 | // if end_time given use it, else the original slot's end |
| 2622 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
| 2620 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
| 2623 | 2621 | if ($end > $ft['end']) $end = $ft['end']; |
| 2624 | 2622 | |
| 2625 | 2623 | // slot to small for duration |
@@ -2633,11 +2631,11 @@ discard block |
||
| 2633 | 2631 | 'end' => $end, |
| 2634 | 2632 | ); |
| 2635 | 2633 | $times = array(); |
| 2636 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
| 2634 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
| 2637 | 2635 | { |
| 2638 | 2636 | $e = $s + $duration; |
| 2639 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
| 2640 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
| 2637 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
| 2638 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
| 2641 | 2639 | } |
| 2642 | 2640 | $sel_options[$n.'start'] = $times; |
| 2643 | 2641 | } |
@@ -2652,13 +2650,13 @@ discard block |
||
| 2652 | 2650 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2653 | 2651 | * @return string error-msg if $return_error |
| 2654 | 2652 | */ |
| 2655 | - function export($content=0,$return_error=false) |
|
| 2653 | + function export($content = 0, $return_error = false) |
|
| 2656 | 2654 | { |
| 2657 | 2655 | $boical = new calendar_ical(); |
| 2658 | 2656 | #error_log(__METHOD__.print_r($content,true)); |
| 2659 | 2657 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
| 2660 | 2658 | { |
| 2661 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
| 2659 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
| 2662 | 2660 | { |
| 2663 | 2661 | $msg = lang('Permission denied'); |
| 2664 | 2662 | |
@@ -2666,20 +2664,20 @@ discard block |
||
| 2666 | 2664 | } |
| 2667 | 2665 | else |
| 2668 | 2666 | { |
| 2669 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
| 2667 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
| 2670 | 2668 | echo $ical; |
| 2671 | 2669 | common::egw_exit(); |
| 2672 | 2670 | } |
| 2673 | 2671 | } |
| 2674 | 2672 | if (is_array($content)) |
| 2675 | 2673 | { |
| 2676 | - $events =& $this->bo->search(array( |
|
| 2674 | + $events = & $this->bo->search(array( |
|
| 2677 | 2675 | 'start' => $content['start'], |
| 2678 | 2676 | 'end' => $content['end'], |
| 2679 | 2677 | 'enum_recuring' => false, |
| 2680 | 2678 | 'daywise' => false, |
| 2681 | 2679 | 'owner' => $this->owner, |
| 2682 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2680 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2683 | 2681 | )); |
| 2684 | 2682 | if (!$events) |
| 2685 | 2683 | { |
@@ -2687,8 +2685,8 @@ discard block |
||
| 2687 | 2685 | } |
| 2688 | 2686 | else |
| 2689 | 2687 | { |
| 2690 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
| 2691 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
| 2688 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
| 2689 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
| 2692 | 2690 | echo $ical; |
| 2693 | 2691 | common::egw_exit(); |
| 2694 | 2692 | } |
@@ -2704,9 +2702,9 @@ discard block |
||
| 2704 | 2702 | } |
| 2705 | 2703 | $content['msg'] = $msg; |
| 2706 | 2704 | |
| 2707 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
| 2705 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
| 2708 | 2706 | $etpl = new etemplate_new('calendar.export'); |
| 2709 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
| 2707 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
| 2710 | 2708 | } |
| 2711 | 2709 | |
| 2712 | 2710 | /** |
@@ -2714,7 +2712,7 @@ discard block |
||
| 2714 | 2712 | * |
| 2715 | 2713 | * @param array $_content |
| 2716 | 2714 | */ |
| 2717 | - function cat_acl(array $_content=null) |
|
| 2715 | + function cat_acl(array $_content = null) |
|
| 2718 | 2716 | { |
| 2719 | 2717 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
| 2720 | 2718 | { |
@@ -2726,15 +2724,15 @@ discard block |
||
| 2726 | 2724 | unset($_content['button']); |
| 2727 | 2725 | if ($button != 'cancel') // store changed Acl |
| 2728 | 2726 | { |
| 2729 | - foreach($_content as $data) |
|
| 2727 | + foreach ($_content as $data) |
|
| 2730 | 2728 | { |
| 2731 | 2729 | if (!($cat_id = $data['cat_id'])) continue; |
| 2732 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
| 2730 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
| 2733 | 2731 | { |
| 2734 | 2732 | $rights = 0; |
| 2735 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2736 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2737 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2733 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2734 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2735 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
| 2738 | 2736 | } |
| 2739 | 2737 | } |
| 2740 | 2738 | } |
@@ -2746,20 +2744,20 @@ discard block |
||
| 2746 | 2744 | ), 'admin'); |
| 2747 | 2745 | } |
| 2748 | 2746 | } |
| 2749 | - $content= $preserv = array(); |
|
| 2747 | + $content = $preserv = array(); |
|
| 2750 | 2748 | $n = 1; |
| 2751 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2749 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2752 | 2750 | { |
| 2753 | - $cat_id = substr($Lcat_id,1); |
|
| 2751 | + $cat_id = substr($Lcat_id, 1); |
|
| 2754 | 2752 | $row = array( |
| 2755 | 2753 | 'cat_id' => $cat_id, |
| 2756 | 2754 | 'add' => array(), |
| 2757 | 2755 | 'status' => array(), |
| 2758 | 2756 | ); |
| 2759 | - foreach($data as $account_id => $rights) |
|
| 2757 | + foreach ($data as $account_id => $rights) |
|
| 2760 | 2758 | { |
| 2761 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2762 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2759 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2760 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2763 | 2761 | } |
| 2764 | 2762 | $content[$n] = $row; |
| 2765 | 2763 | $preserv[$n] = array( |
@@ -2775,7 +2773,7 @@ discard block |
||
| 2775 | 2773 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
| 2776 | 2774 | $tmp = new Etemplate('calendar.cat_acl'); |
| 2777 | 2775 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
| 2778 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
| 2776 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
| 2779 | 2777 | } |
| 2780 | 2778 | |
| 2781 | 2779 | /** |
@@ -2825,18 +2823,18 @@ discard block |
||
| 2825 | 2823 | |
| 2826 | 2824 | |
| 2827 | 2825 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
| 2828 | - if($content['recur_type'] || $content['recurrence']) |
|
| 2826 | + if ($content['recur_type'] || $content['recurrence']) |
|
| 2829 | 2827 | { |
| 2830 | 2828 | $content['history']['filter'] = array( |
| 2831 | 2829 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
| 2832 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
| 2833 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
| 2830 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
| 2831 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
| 2834 | 2832 | ); |
| 2835 | 2833 | } |
| 2836 | 2834 | |
| 2837 | 2835 | // Translate labels |
| 2838 | 2836 | $tracking = new calendar_tracking(); |
| 2839 | - foreach($tracking->field2label as $field => $label) |
|
| 2837 | + foreach ($tracking->field2label as $field => $label) |
|
| 2840 | 2838 | { |
| 2841 | 2839 | $sel_options[$status][$field] = lang($label); |
| 2842 | 2840 | } |
@@ -2855,44 +2853,44 @@ discard block |
||
| 2855 | 2853 | * which particular instance was dragged |
| 2856 | 2854 | * @return string XML response if no error occurs |
| 2857 | 2855 | */ |
| 2858 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
| 2856 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
| 2859 | 2857 | { |
| 2860 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 2858 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 2861 | 2859 | $ignore_conflicts = false; |
| 2862 | 2860 | |
| 2863 | 2861 | // we do not allow dragging into another users calendar ATM |
| 2864 | - if($targetOwner < 0) |
|
| 2862 | + if ($targetOwner < 0) |
|
| 2865 | 2863 | { |
| 2866 | 2864 | $targetOwner = array($targetOwner); |
| 2867 | 2865 | } |
| 2868 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2866 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2869 | 2867 | { |
| 2870 | 2868 | $targetOwner = $calendarOwner; |
| 2871 | 2869 | } |
| 2872 | 2870 | // But you may be viewing multiple users, or a group calendar and |
| 2873 | 2871 | // dragging your event - dragging across calendars does not change owner |
| 2874 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2872 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2875 | 2873 | { |
| 2876 | 2874 | $return = true; |
| 2877 | - foreach($targetOwner as $owner) |
|
| 2875 | + foreach ($targetOwner as $owner) |
|
| 2878 | 2876 | { |
| 2879 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
| 2877 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
| 2880 | 2878 | { |
| 2881 | 2879 | $return = false; |
| 2882 | 2880 | break; |
| 2883 | 2881 | } |
| 2884 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
| 2882 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
| 2885 | 2883 | { |
| 2886 | 2884 | $return = false; |
| 2887 | 2885 | break; |
| 2888 | 2886 | } |
| 2889 | 2887 | } |
| 2890 | - if($return) return; |
|
| 2888 | + if ($return) return; |
|
| 2891 | 2889 | } |
| 2892 | - $old_event=$event=$this->bo->read($eventId); |
|
| 2890 | + $old_event = $event = $this->bo->read($eventId); |
|
| 2893 | 2891 | if (!$durationT) |
| 2894 | 2892 | { |
| 2895 | - $duration=$event['end']-$event['start']; |
|
| 2893 | + $duration = $event['end'] - $event['start']; |
|
| 2896 | 2894 | } |
| 2897 | 2895 | // Drag a normal event to whole day non-blocking |
| 2898 | 2896 | else if ($durationT == 'whole_day') |
@@ -2900,7 +2898,7 @@ discard block |
||
| 2900 | 2898 | $event['whole_day'] = true; |
| 2901 | 2899 | $event['non_blocking'] = true; |
| 2902 | 2900 | // Make duration whole days, less 1 second |
| 2903 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
| 2901 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
| 2904 | 2902 | } |
| 2905 | 2903 | else |
| 2906 | 2904 | { |
@@ -2913,19 +2911,19 @@ discard block |
||
| 2913 | 2911 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2914 | 2912 | if (!empty($event['whole_day'])) |
| 2915 | 2913 | { |
| 2916 | - $d =& $this->bo->so->startOfDay($d); |
|
| 2914 | + $d = & $this->bo->so->startOfDay($d); |
|
| 2917 | 2915 | $d->setUser(); |
| 2918 | 2916 | } |
| 2919 | 2917 | $event = $this->bo->read($eventId, $d, true); |
| 2920 | 2918 | |
| 2921 | 2919 | // For DnD, create an exception if they gave the date |
| 2922 | 2920 | $preserv = null; |
| 2923 | - $this->_create_exception($event,$preserv); |
|
| 2921 | + $this->_create_exception($event, $preserv); |
|
| 2924 | 2922 | unset($event['id']); |
| 2925 | 2923 | $links = $event['link_to']['to_id']; |
| 2926 | 2924 | |
| 2927 | 2925 | $messages = null; |
| 2928 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
| 2926 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
| 2929 | 2927 | if (!is_array($conflicts) && $conflicts) |
| 2930 | 2928 | { |
| 2931 | 2929 | // now we need to add the original start as recur-execption to the series |
@@ -2933,28 +2931,28 @@ discard block |
||
| 2933 | 2931 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 2934 | 2932 | // check if we need to move the alarms, because they are next on that exception |
| 2935 | 2933 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 2936 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2937 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2938 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 2934 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2935 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2936 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 2939 | 2937 | |
| 2940 | 2938 | // Sending null will trigger a removal of the original for that date |
| 2941 | 2939 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 2942 | 2940 | |
| 2943 | 2941 | unset($recur_event); |
| 2944 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2942 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2945 | 2943 | unset($preserv['edit_single']); |
| 2946 | 2944 | } |
| 2947 | 2945 | } |
| 2948 | 2946 | |
| 2949 | 2947 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
| 2950 | 2948 | $event['start'] = $d->format('ts'); |
| 2951 | - $event['end'] = $event['start']+$duration; |
|
| 2949 | + $event['end'] = $event['start'] + $duration; |
|
| 2952 | 2950 | |
| 2953 | 2951 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
| 2954 | 2952 | { |
| 2955 | 2953 | // calculate offset against clicked recurrance, |
| 2956 | 2954 | // depending on which is smaller |
| 2957 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
| 2955 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
| 2958 | 2956 | $event['start'] = $old_event['start'] + $offset; |
| 2959 | 2957 | $event['duration'] = $duration; |
| 2960 | 2958 | |
@@ -2965,31 +2963,31 @@ discard block |
||
| 2965 | 2963 | // Can't handle conflict. Just ignore it. |
| 2966 | 2964 | $ignore_conflicts = true; |
| 2967 | 2965 | } |
| 2968 | - if(!$event['recur_type']) |
|
| 2966 | + if (!$event['recur_type']) |
|
| 2969 | 2967 | { |
| 2970 | 2968 | $this->bo->check_move_alarms($event, $old_event); |
| 2971 | 2969 | } |
| 2972 | 2970 | |
| 2973 | 2971 | // Drag a whole day to a time |
| 2974 | - if($durationT && $durationT != 'whole_day') |
|
| 2972 | + if ($durationT && $durationT != 'whole_day') |
|
| 2975 | 2973 | { |
| 2976 | 2974 | $event['whole_day'] = ($duration == DAY_s); |
| 2977 | 2975 | $event['non_blocking'] = false; |
| 2978 | 2976 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
| 2979 | 2977 | // so save the change now, and then let the conflict check happen. |
| 2980 | 2978 | $message = null; |
| 2981 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
| 2979 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
| 2982 | 2980 | |
| 2983 | 2981 | // Whole day non blocking with DAY_s would add a day |
| 2984 | - if($duration==DAY_s) $duration=0; |
|
| 2982 | + if ($duration == DAY_s) $duration = 0; |
|
| 2985 | 2983 | } |
| 2986 | 2984 | |
| 2987 | 2985 | $status_reset_to_unknown = false; |
| 2988 | 2986 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 2989 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 2987 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 2990 | 2988 | { |
| 2991 | 2989 | $q = $r = null; |
| 2992 | - calendar_so::split_status($status,$q,$r); |
|
| 2990 | + calendar_so::split_status($status, $q, $r); |
|
| 2993 | 2991 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 2994 | 2992 | { |
| 2995 | 2993 | $preferences = new Api\Preferences($uid); |
@@ -3002,29 +3000,29 @@ discard block |
||
| 3002 | 3000 | if ($sameday) break; |
| 3003 | 3001 | default: |
| 3004 | 3002 | $status_reset_to_unknown = true; |
| 3005 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 3003 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 3006 | 3004 | // todo: report reset status to user |
| 3007 | 3005 | } |
| 3008 | 3006 | } |
| 3009 | 3007 | } |
| 3010 | 3008 | |
| 3011 | 3009 | $message = false; |
| 3012 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
| 3010 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
| 3013 | 3011 | |
| 3014 | 3012 | // Save links |
| 3015 | - if($links) |
|
| 3013 | + if ($links) |
|
| 3016 | 3014 | { |
| 3017 | 3015 | Link::link('calendar', $event['id'], $links); |
| 3018 | 3016 | } |
| 3019 | 3017 | |
| 3020 | - $this->update_client($event['id'],$d); |
|
| 3018 | + $this->update_client($event['id'], $d); |
|
| 3021 | 3019 | $response = Api\Json\Response::get(); |
| 3022 | - if(!is_array($conflicts) && $conflicts) |
|
| 3020 | + if (!is_array($conflicts) && $conflicts) |
|
| 3023 | 3021 | { |
| 3024 | - if(is_int($conflicts)) |
|
| 3022 | + if (is_int($conflicts)) |
|
| 3025 | 3023 | { |
| 3026 | 3024 | $event['id'] = $conflicts; |
| 3027 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 3025 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 3028 | 3026 | } |
| 3029 | 3027 | } |
| 3030 | 3028 | else if ($conflicts) |
@@ -3037,21 +3035,21 @@ discard block |
||
| 3037 | 3035 | .'&end='.$event['end'] |
| 3038 | 3036 | .'&non_interactive=true' |
| 3039 | 3037 | .'&cancel_needs_refresh=true', |
| 3040 | - '',750,410); |
|
| 3038 | + '', 750, 410); |
|
| 3041 | 3039 | } |
| 3042 | 3040 | else if ($message) |
| 3043 | 3041 | { |
| 3044 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 3042 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 3045 | 3043 | } |
| 3046 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3044 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
| 3047 | 3045 | if ($status_reset_to_unknown) |
| 3048 | 3046 | { |
| 3049 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 3047 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 3050 | 3048 | { |
| 3051 | 3049 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 3052 | 3050 | { |
| 3053 | - calendar_so::split_status($status,$q,$r); |
|
| 3054 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 3051 | + calendar_so::split_status($status, $q, $r); |
|
| 3052 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 3055 | 3053 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 3056 | 3054 | } |
| 3057 | 3055 | } |
@@ -3068,7 +3066,7 @@ discard block |
||
| 3068 | 3066 | { |
| 3069 | 3067 | list($eventId, $date) = explode(':', $_eventId); |
| 3070 | 3068 | $event = $this->bo->read($eventId); |
| 3071 | - if($date) |
|
| 3069 | + if ($date) |
|
| 3072 | 3070 | { |
| 3073 | 3071 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 3074 | 3072 | } |
@@ -3078,29 +3076,29 @@ discard block |
||
| 3078 | 3076 | { |
| 3079 | 3077 | if (!empty($event['whole_day'])) |
| 3080 | 3078 | { |
| 3081 | - $d =& $this->bo->so->startOfDay($date); |
|
| 3079 | + $d = & $this->bo->so->startOfDay($date); |
|
| 3082 | 3080 | $d->setUser(); |
| 3083 | 3081 | } |
| 3084 | 3082 | $event = $this->bo->read($eventId, $d, true); |
| 3085 | 3083 | $date = $d->format('ts'); |
| 3086 | 3084 | } |
| 3087 | - if($event['participants'][$uid]) |
|
| 3085 | + if ($event['participants'][$uid]) |
|
| 3088 | 3086 | { |
| 3089 | 3087 | $q = $r = null; |
| 3090 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 3091 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 3092 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 3088 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 3089 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 3090 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 3093 | 3091 | } |
| 3094 | 3092 | else |
| 3095 | 3093 | { |
| 3096 | 3094 | // Group membership |
| 3097 | - foreach(array_keys($event['participants']) as $id) |
|
| 3095 | + foreach (array_keys($event['participants']) as $id) |
|
| 3098 | 3096 | { |
| 3099 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
| 3097 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
| 3100 | 3098 | { |
| 3101 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 3102 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 3103 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 3099 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 3100 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 3101 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 3104 | 3102 | break; |
| 3105 | 3103 | } |
| 3106 | 3104 | } |
@@ -3108,7 +3106,7 @@ discard block |
||
| 3108 | 3106 | |
| 3109 | 3107 | // Directly update stored data. If event is still visible, it will |
| 3110 | 3108 | // be notified & update itself. |
| 3111 | - $this->update_client($eventId,$d); |
|
| 3109 | + $this->update_client($eventId, $d); |
|
| 3112 | 3110 | } |
| 3113 | 3111 | |
| 3114 | 3112 | /** |
@@ -3116,8 +3114,8 @@ discard block |
||
| 3116 | 3114 | */ |
| 3117 | 3115 | public function ajax_delete($eventId) |
| 3118 | 3116 | { |
| 3119 | - list($id, $date) = explode(':',$eventId); |
|
| 3120 | - $event=$this->bo->read($id); |
|
| 3117 | + list($id, $date) = explode(':', $eventId); |
|
| 3118 | + $event = $this->bo->read($id); |
|
| 3121 | 3119 | $response = Api\Json\Response::get(); |
| 3122 | 3120 | |
| 3123 | 3121 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -3130,11 +3128,11 @@ discard block |
||
| 3130 | 3128 | { |
| 3131 | 3129 | $msg = lang('Event deleted'); |
| 3132 | 3130 | } |
| 3133 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 3131 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
| 3134 | 3132 | } |
| 3135 | 3133 | else |
| 3136 | 3134 | { |
| 3137 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 3135 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
| 3138 | 3136 | } |
| 3139 | 3137 | } |
| 3140 | 3138 | |
@@ -3147,10 +3145,10 @@ discard block |
||
| 3147 | 3145 | */ |
| 3148 | 3146 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
| 3149 | 3147 | { |
| 3150 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 3148 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 3151 | 3149 | |
| 3152 | 3150 | $event = $this->bo->read($eventId); |
| 3153 | - if($date) |
|
| 3151 | + if ($date) |
|
| 3154 | 3152 | { |
| 3155 | 3153 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 3156 | 3154 | } |
@@ -3160,17 +3158,17 @@ discard block |
||
| 3160 | 3158 | { |
| 3161 | 3159 | if (!empty($event['whole_day'])) |
| 3162 | 3160 | { |
| 3163 | - $d =& $this->bo->so->startOfDay($date); |
|
| 3161 | + $d = & $this->bo->so->startOfDay($date); |
|
| 3164 | 3162 | $d->setUser(); |
| 3165 | 3163 | } |
| 3166 | 3164 | $event = $this->bo->read($eventId, $d, true); |
| 3167 | 3165 | // For DnD, create an exception if they gave the date |
| 3168 | 3166 | $preserv = null; |
| 3169 | - $this->_create_exception($event,$preserv); |
|
| 3167 | + $this->_create_exception($event, $preserv); |
|
| 3170 | 3168 | unset($event['id']); |
| 3171 | 3169 | |
| 3172 | 3170 | $messages = null; |
| 3173 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
| 3171 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
| 3174 | 3172 | if (!is_array($conflicts) && $conflicts) |
| 3175 | 3173 | { |
| 3176 | 3174 | // now we need to add the original start as recur-execption to the series |
@@ -3178,28 +3176,28 @@ discard block |
||
| 3178 | 3176 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 3179 | 3177 | // check if we need to move the alarms, because they are next on that exception |
| 3180 | 3178 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 3181 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 3182 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 3183 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 3179 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 3180 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 3181 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 3184 | 3182 | |
| 3185 | 3183 | // Sending null will trigger a removal of the original for that date |
| 3186 | 3184 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 3187 | 3185 | |
| 3188 | 3186 | unset($recur_event); |
| 3189 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 3187 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 3190 | 3188 | unset($preserv['edit_single']); |
| 3191 | 3189 | } |
| 3192 | 3190 | } |
| 3193 | - foreach($remove as $participant) |
|
| 3191 | + foreach ($remove as $participant) |
|
| 3194 | 3192 | { |
| 3195 | 3193 | unset($event['participants'][$participant]); |
| 3196 | 3194 | } |
| 3197 | - foreach($invite as $participant) |
|
| 3195 | + foreach ($invite as $participant) |
|
| 3198 | 3196 | { |
| 3199 | 3197 | $event['participants'][$participant] = 'U'; |
| 3200 | 3198 | } |
| 3201 | 3199 | $message = null; |
| 3202 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
| 3200 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
| 3203 | 3201 | |
| 3204 | 3202 | $response = Api\Json\Response::get(); |
| 3205 | 3203 | |
@@ -3207,8 +3205,8 @@ discard block |
||
| 3207 | 3205 | { |
| 3208 | 3206 | // Save it anyway, was done with explicit user interaction, |
| 3209 | 3207 | // and if we don't we lose the invite |
| 3210 | - $this->bo->update($event,true); // no conflict check here |
|
| 3211 | - $this->update_client($event['id'],$d); |
|
| 3208 | + $this->bo->update($event, true); // no conflict check here |
|
| 3209 | + $this->update_client($event['id'], $d); |
|
| 3212 | 3210 | $response->call( |
| 3213 | 3211 | 'egw_openWindowCentered2', |
| 3214 | 3212 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3217,22 +3215,22 @@ discard block |
||
| 3217 | 3215 | .'&end='.$event['end'] |
| 3218 | 3216 | .'&non_interactive=true' |
| 3219 | 3217 | .'&cancel_needs_refresh=true', |
| 3220 | - '',750,410); |
|
| 3218 | + '', 750, 410); |
|
| 3221 | 3219 | } |
| 3222 | 3220 | else if ($message) |
| 3223 | 3221 | { |
| 3224 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 3222 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 3225 | 3223 | } |
| 3226 | - if($conflicts) |
|
| 3224 | + if ($conflicts) |
|
| 3227 | 3225 | { |
| 3228 | - $this->update_client($event['id'],$d); |
|
| 3229 | - if(is_int($conflicts)) |
|
| 3226 | + $this->update_client($event['id'], $d); |
|
| 3227 | + if (is_int($conflicts)) |
|
| 3230 | 3228 | { |
| 3231 | 3229 | $event['id'] = $conflicts; |
| 3232 | 3230 | } |
| 3233 | - if($event['id']) |
|
| 3231 | + if ($event['id']) |
|
| 3234 | 3232 | { |
| 3235 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 3233 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 3236 | 3234 | } |
| 3237 | 3235 | } |
| 3238 | 3236 | } |
@@ -3243,13 +3241,13 @@ discard block |
||
| 3243 | 3241 | * @param array $mailContent = null mail content |
| 3244 | 3242 | * @return array |
| 3245 | 3243 | */ |
| 3246 | - function mail_import(array $mailContent=null) |
|
| 3244 | + function mail_import(array $mailContent = null) |
|
| 3247 | 3245 | { |
| 3248 | 3246 | // It would get called from compose as a popup with egw_data |
| 3249 | 3247 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
| 3250 | 3248 | { |
| 3251 | 3249 | // get raw mail data |
| 3252 | - Link::get_data ($_GET['egw_data']); |
|
| 3250 | + Link::get_data($_GET['egw_data']); |
|
| 3253 | 3251 | return false; |
| 3254 | 3252 | } |
| 3255 | 3253 | |
@@ -3259,7 +3257,7 @@ discard block |
||
| 3259 | 3257 | $AB = new Api\Contacts(); |
| 3260 | 3258 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
| 3261 | 3259 | |
| 3262 | - $participants[0] = array ( |
|
| 3260 | + $participants[0] = array( |
|
| 3263 | 3261 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
| 3264 | 3262 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
| 3265 | 3263 | 'status' => 'A', |
@@ -3267,23 +3265,23 @@ discard block |
||
| 3267 | 3265 | 'app' => 'User', |
| 3268 | 3266 | 'role' => 'REQ-PARTICIPANT' |
| 3269 | 3267 | ); |
| 3270 | - foreach($mailContent['addresses'] as $address) |
|
| 3268 | + foreach ($mailContent['addresses'] as $address) |
|
| 3271 | 3269 | { |
| 3272 | 3270 | // Get available contacts from the email |
| 3273 | 3271 | $contacts = $AB->search(array( |
| 3274 | 3272 | 'email' => $address['email'], |
| 3275 | 3273 | 'email_home' => $address['email'] |
| 3276 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
| 3274 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
| 3277 | 3275 | if (is_array($contacts)) |
| 3278 | 3276 | { |
| 3279 | - foreach($contacts as $account) |
|
| 3277 | + foreach ($contacts as $account) |
|
| 3280 | 3278 | { |
| 3281 | 3279 | $accounts[] = $account['account_id']; |
| 3282 | 3280 | } |
| 3283 | 3281 | } |
| 3284 | 3282 | else |
| 3285 | 3283 | { |
| 3286 | - $participants []= array ( |
|
| 3284 | + $participants [] = array( |
|
| 3287 | 3285 | 'app' => 'email', |
| 3288 | 3286 | 'uid' => 'e'.$address['email'], |
| 3289 | 3287 | 'status' => 'U', |
@@ -3291,7 +3289,7 @@ discard block |
||
| 3291 | 3289 | ); |
| 3292 | 3290 | } |
| 3293 | 3291 | } |
| 3294 | - $participants = array_merge($participants , array( |
|
| 3292 | + $participants = array_merge($participants, array( |
|
| 3295 | 3293 | "participant" => $accounts, |
| 3296 | 3294 | "role" => "REQ-PARTICIPANT", |
| 3297 | 3295 | "add" => "pressed" |
@@ -3315,14 +3313,14 @@ discard block |
||
| 3315 | 3313 | { |
| 3316 | 3314 | foreach ($mailContent['attachments'] as $attachment) |
| 3317 | 3315 | { |
| 3318 | - if($attachment['egw_data']) |
|
| 3316 | + if ($attachment['egw_data']) |
|
| 3319 | 3317 | { |
| 3320 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
| 3318 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
| 3321 | 3319 | } |
| 3322 | - else if(is_readable($attachment['tmp_name']) || |
|
| 3320 | + else if (is_readable($attachment['tmp_name']) || |
|
| 3323 | 3321 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
| 3324 | 3322 | { |
| 3325 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
| 3323 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
| 3326 | 3324 | } |
| 3327 | 3325 | } |
| 3328 | 3326 | } |
@@ -120,11 +120,14 @@ discard block |
||
| 120 | 120 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 121 | 121 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 122 | 122 | { |
| 123 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 123 | + if ($owner) |
|
| 124 | + { |
|
| 125 | + // make an owner who is no user or we have no add-rights a participant |
|
| 124 | 126 | { |
| 125 | 127 | if(!is_array($owner)) |
| 126 | 128 | { |
| 127 | 129 | $owner = explode(',',$owner); |
| 130 | + } |
|
| 128 | 131 | } |
| 129 | 132 | // if we come from ressources we don't need any users selected in calendar |
| 130 | 133 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -156,9 +159,17 @@ discard block |
||
| 156 | 159 | $participant_types['u'] = $participant_types = $participants = array(); |
| 157 | 160 | foreach($extra_participants as $uid) |
| 158 | 161 | { |
| 159 | - if (isset($participants[$uid])) continue; // already included |
|
| 162 | + if (isset($participants[$uid])) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 166 | + // already included |
|
| 160 | 167 | |
| 161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 168 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 169 | + { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 172 | + // no right to invite --> ignored |
|
| 162 | 173 | |
| 163 | 174 | if (is_numeric($uid)) |
| 164 | 175 | { |
@@ -196,10 +207,13 @@ discard block |
||
| 196 | 207 | } |
| 197 | 208 | } |
| 198 | 209 | } |
| 199 | - if (!$participants) // if all participants got removed, include current user |
|
| 210 | + if (!$participants) |
|
| 211 | + { |
|
| 212 | + // if all participants got removed, include current user |
|
| 200 | 213 | { |
| 201 | 214 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 202 | 215 | } |
| 216 | + } |
|
| 203 | 217 | if(isset($_GET['cat_id'])) |
| 204 | 218 | { |
| 205 | 219 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -261,10 +275,13 @@ discard block |
||
| 261 | 275 | */ |
| 262 | 276 | function process_edit($content) |
| 263 | 277 | { |
| 264 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 278 | + if (!is_array($content)) |
|
| 279 | + { |
|
| 280 | + // redirect from etemplate, if POST empty |
|
| 265 | 281 | { |
| 266 | 282 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 267 | 283 | } |
| 284 | + } |
|
| 268 | 285 | // clear notification errors |
| 269 | 286 | notifications::errors(true); |
| 270 | 287 | $messages = null; |
@@ -277,7 +294,11 @@ discard block |
||
| 277 | 294 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 278 | 295 | |
| 279 | 296 | list($button) = @each($content['button']); |
| 280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 297 | + if (!$button && $content['action']) |
|
| 298 | + { |
|
| 299 | + $button = $content['action']; |
|
| 300 | + } |
|
| 301 | + // action selectbox |
|
| 281 | 302 | unset($content['button']); unset($content['action']); |
| 282 | 303 | |
| 283 | 304 | $view = $content['view']; |
@@ -290,7 +311,10 @@ discard block |
||
| 290 | 311 | { |
| 291 | 312 | list($date) = each($content['recur_exception']['delete_exception']); |
| 292 | 313 | // eT2 converts time to |
| 293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 314 | + if (!is_numeric($date)) |
|
| 315 | + { |
|
| 316 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 317 | + } |
|
| 294 | 318 | unset($content['recur_exception']['delete_exception']); |
| 295 | 319 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 296 | 320 | { |
@@ -299,7 +323,10 @@ discard block |
||
| 299 | 323 | foreach ($recur_exceptions as $id) |
| 300 | 324 | { |
| 301 | 325 | if (!($exception = $this->bo->read($id)) || |
| 302 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 326 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 327 | + { |
|
| 328 | + continue; |
|
| 329 | + } |
|
| 303 | 330 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 304 | 331 | $exception['reference'] = $exception['recurrence'] = 0; |
| 305 | 332 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -357,8 +384,7 @@ discard block |
||
| 357 | 384 | // Existing event, check for change from/to whole day |
| 358 | 385 | ($old = $this->bo->read($content['cal_id'])) && $old['whole_day'] !== $content['whole_day'] && |
| 359 | 386 | ($def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]) |
| 360 | - ) |
|
| 361 | - { |
|
| 387 | + ) { |
|
| 362 | 388 | // Reset default alarm |
| 363 | 389 | $old_default = array_shift($content['alarm']); |
| 364 | 390 | $this->bo->delete_alarm($old_default['id']); |
@@ -395,7 +421,10 @@ discard block |
||
| 395 | 421 | $event['end'] = $this->bo->date2ts($event['end']); |
| 396 | 422 | } |
| 397 | 423 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 398 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 424 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 425 | + { |
|
| 426 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 427 | + } |
|
| 399 | 428 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 400 | 429 | { |
| 401 | 430 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -522,7 +551,11 @@ discard block |
||
| 522 | 551 | break; |
| 523 | 552 | |
| 524 | 553 | default: // existing participant row |
| 525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 554 | + if (!is_array($data)) |
|
| 555 | + { |
|
| 556 | + continue; |
|
| 557 | + } |
|
| 558 | + // widgets in participant tab, above participant list |
|
| 526 | 559 | $quantity = $status = $role = null; |
| 527 | 560 | foreach(array('uid','status','quantity','role') as $name) |
| 528 | 561 | { |
@@ -655,7 +688,10 @@ discard block |
||
| 655 | 688 | { |
| 656 | 689 | foreach($participants as $id => &$p_response) |
| 657 | 690 | { |
| 658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 691 | + if($type == 'u' && $id == $event['owner']) |
|
| 692 | + { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 659 | 695 | calendar_so::split_status($p_response, $quantity, $role); |
| 660 | 696 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 661 | 697 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -737,17 +773,23 @@ discard block |
||
| 737 | 773 | { |
| 738 | 774 | foreach (array_keys($event['participants']) as $uid) |
| 739 | 775 | { |
| 740 | - if ($uid[0] == 'r') //ressource detection |
|
| 776 | + if ($uid[0] == 'r') |
|
| 777 | + { |
|
| 778 | + //ressource detection |
|
| 741 | 779 | { |
| 742 | 780 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 781 | + } |
|
| 743 | 782 | $button = ''; |
| 744 | 783 | break 2; //break foreach and case |
| 745 | 784 | } |
| 746 | 785 | } |
| 747 | 786 | } |
| 748 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 787 | + if ($content['edit_single']) |
|
| 788 | + { |
|
| 789 | + // we edited a single event from a series |
|
| 749 | 790 | { |
| 750 | 791 | $event['reference'] = $event['id']; |
| 792 | + } |
|
| 751 | 793 | $event['recurrence'] = $content['edit_single']; |
| 752 | 794 | unset($event['id']); |
| 753 | 795 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -849,7 +891,10 @@ discard block |
||
| 849 | 891 | case 'no': |
| 850 | 892 | break; |
| 851 | 893 | case 'startday': |
| 852 | - if ($sameday) break; |
|
| 894 | + if ($sameday) |
|
| 895 | + { |
|
| 896 | + break; |
|
| 897 | + } |
|
| 853 | 898 | default: |
| 854 | 899 | $status_reset_to_unknown = true; |
| 855 | 900 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -1017,7 +1062,10 @@ discard block |
||
| 1017 | 1062 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 1018 | 1063 | { |
| 1019 | 1064 | $msg = lang('Series deleted'); |
| 1020 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 1065 | + if ($exceptions_kept) |
|
| 1066 | + { |
|
| 1067 | + $msg .= lang(', exceptions preserved'); |
|
| 1068 | + } |
|
| 1021 | 1069 | } |
| 1022 | 1070 | else |
| 1023 | 1071 | { |
@@ -1053,11 +1101,14 @@ discard block |
||
| 1053 | 1101 | { |
| 1054 | 1102 | $msg = lang("Can't add alarms in the past !!!"); |
| 1055 | 1103 | } |
| 1056 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1104 | + elseif ($event['id']) |
|
| 1105 | + { |
|
| 1106 | + // save the alarm immediatly |
|
| 1057 | 1107 | { |
| 1058 | 1108 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 1059 | 1109 | { |
| 1060 | 1110 | $alarm['id'] = $alarm_id; |
| 1111 | + } |
|
| 1061 | 1112 | $event['alarm'][$alarm_id] = $alarm; |
| 1062 | 1113 | |
| 1063 | 1114 | $msg = lang('Alarm added'); |
@@ -1070,7 +1121,9 @@ discard block |
||
| 1070 | 1121 | } |
| 1071 | 1122 | else |
| 1072 | 1123 | { |
| 1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1124 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1125 | + { |
|
| 1126 | +} // get a temporary non-conflicting, numeric id |
|
| 1074 | 1127 | $event['alarm'][$alarm['id']] = $alarm; |
| 1075 | 1128 | } |
| 1076 | 1129 | } |
@@ -1093,10 +1146,13 @@ discard block |
||
| 1093 | 1146 | } |
| 1094 | 1147 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1095 | 1148 | { |
| 1096 | - if ($content['lock_token']) // remove an existing lock |
|
| 1149 | + if ($content['lock_token']) |
|
| 1150 | + { |
|
| 1151 | + // remove an existing lock |
|
| 1097 | 1152 | { |
| 1098 | 1153 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1099 | 1154 | } |
| 1155 | + } |
|
| 1100 | 1156 | if ($content['no_popup']) |
| 1101 | 1157 | { |
| 1102 | 1158 | Egw::redirect_link('/index.php',array( |
@@ -1154,13 +1210,19 @@ discard block |
||
| 1154 | 1210 | } |
| 1155 | 1211 | |
| 1156 | 1212 | // Copy links |
| 1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1213 | + if(!is_array($event['link_to'])) |
|
| 1214 | + { |
|
| 1215 | + $event['link_to'] = array(); |
|
| 1216 | + } |
|
| 1158 | 1217 | $event['link_to']['to_app'] = 'calendar'; |
| 1159 | 1218 | $event['link_to']['to_id'] = 0; |
| 1160 | 1219 | |
| 1161 | 1220 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
| 1162 | 1221 | { |
| 1163 | - if(!$link['id']) continue; |
|
| 1222 | + if(!$link['id']) |
|
| 1223 | + { |
|
| 1224 | + continue; |
|
| 1225 | + } |
|
| 1164 | 1226 | if ($link['app'] != Link::VFS_APPNAME) |
| 1165 | 1227 | { |
| 1166 | 1228 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1228,8 +1290,7 @@ discard block |
||
| 1228 | 1290 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1229 | 1291 | // Adjust for requested date in the past |
| 1230 | 1292 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1231 | - ) |
|
| 1232 | - { |
|
| 1293 | + ) { |
|
| 1233 | 1294 | |
| 1234 | 1295 | unset($orig_event); |
| 1235 | 1296 | // copy event by unsetting the id(s) |
@@ -1317,7 +1378,10 @@ discard block |
||
| 1317 | 1378 | foreach($event['participants'] as $uid => $status) |
| 1318 | 1379 | { |
| 1319 | 1380 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1320 | - if (empty($status)) continue; |
|
| 1381 | + if (empty($status)) |
|
| 1382 | + { |
|
| 1383 | + continue; |
|
| 1384 | + } |
|
| 1321 | 1385 | if(!is_array($status)) |
| 1322 | 1386 | { |
| 1323 | 1387 | $quantity = $role = null; |
@@ -1328,28 +1392,43 @@ discard block |
||
| 1328 | 1392 | ); |
| 1329 | 1393 | } |
| 1330 | 1394 | $toadd = ''; |
| 1331 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1395 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1396 | + { |
|
| 1397 | + continue; |
|
| 1398 | + } |
|
| 1332 | 1399 | |
| 1333 | 1400 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1334 | 1401 | { |
| 1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1402 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1403 | + { |
|
| 1404 | + continue; |
|
| 1405 | + } |
|
| 1336 | 1406 | |
| 1337 | 1407 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1338 | 1408 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1339 | 1409 | |
| 1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1410 | + if (!in_array($toadd,$to)) |
|
| 1411 | + { |
|
| 1412 | + $to[] = $toadd; |
|
| 1413 | + } |
|
| 1341 | 1414 | } |
| 1342 | 1415 | elseif ($uid < 0) |
| 1343 | 1416 | { |
| 1344 | 1417 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1345 | 1418 | { |
| 1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1419 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1420 | + { |
|
| 1421 | + continue; |
|
| 1422 | + } |
|
| 1347 | 1423 | |
| 1348 | 1424 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1349 | 1425 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1350 | 1426 | |
| 1351 | 1427 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1428 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1429 | + { |
|
| 1430 | + $to[] = $toadd; |
|
| 1431 | + } |
|
| 1353 | 1432 | } |
| 1354 | 1433 | } |
| 1355 | 1434 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1401,7 +1480,10 @@ discard block |
||
| 1401 | 1480 | 'preset[size]' => filesize($ics_file), |
| 1402 | 1481 | ); |
| 1403 | 1482 | $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
| 1404 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1483 | + if ($asrequest) |
|
| 1484 | + { |
|
| 1485 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1486 | + } |
|
| 1405 | 1487 | $response = Api\Json\Response::get(); |
| 1406 | 1488 | $response->call('app.calendar.custom_mail', $vars); |
| 1407 | 1489 | } |
@@ -1587,9 +1669,15 @@ discard block |
||
| 1587 | 1669 | } |
| 1588 | 1670 | } |
| 1589 | 1671 | // set new start and end if given by $_GET |
| 1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1672 | + if(isset($_GET['start'])) |
|
| 1673 | + { |
|
| 1674 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1675 | + if(isset($_GET['end'])) |
|
| 1676 | + { |
|
| 1677 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1678 | + if(isset($_GET['non_blocking'])) |
|
| 1679 | + { |
|
| 1680 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1593 | 1681 | // check if the event is the whole day |
| 1594 | 1682 | $start = $this->bo->date2array($event['start']); |
| 1595 | 1683 | $end = $this->bo->date2array($event['end']); |
@@ -1602,10 +1690,13 @@ discard block |
||
| 1602 | 1690 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1603 | 1691 | { |
| 1604 | 1692 | $link_id = $link_ids[$n]; |
| 1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1693 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1694 | + { |
|
| 1695 | + // guard against XSS |
|
| 1606 | 1696 | { |
| 1607 | 1697 | continue; |
| 1608 | 1698 | } |
| 1699 | + } |
|
| 1609 | 1700 | if(!$n) |
| 1610 | 1701 | { |
| 1611 | 1702 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1614,7 +1705,10 @@ discard block |
||
| 1614 | 1705 | { |
| 1615 | 1706 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1616 | 1707 | { |
| 1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1708 | + if (($l_id=$set['link_id'][$i])) |
|
| 1709 | + { |
|
| 1710 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1711 | + } |
|
| 1618 | 1712 | } |
| 1619 | 1713 | unset($set['link_app']); |
| 1620 | 1714 | unset($set['link_id']); |
@@ -1640,10 +1734,13 @@ discard block |
||
| 1640 | 1734 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1641 | 1735 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1642 | 1736 | |
| 1643 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1737 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1738 | + { |
|
| 1739 | + // already locked --> refresh the lock |
|
| 1644 | 1740 | { |
| 1645 | 1741 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1646 | 1742 | } |
| 1743 | + } |
|
| 1647 | 1744 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1648 | 1745 | { |
| 1649 | 1746 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1677,14 +1774,20 @@ discard block |
||
| 1677 | 1774 | )); |
| 1678 | 1775 | Framework::message($msg, $msg_type); |
| 1679 | 1776 | $content['duration'] = $content['end'] - $content['start']; |
| 1680 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1777 | + if (isset($this->durations[$content['duration']])) |
|
| 1778 | + { |
|
| 1779 | + $content['end'] = ''; |
|
| 1780 | + } |
|
| 1681 | 1781 | |
| 1682 | 1782 | $row = 3; |
| 1683 | 1783 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1684 | 1784 | // preserve some ui elements, if set eg. under error-conditions |
| 1685 | 1785 | foreach(array('quantity','resource','role') as $n) |
| 1686 | 1786 | { |
| 1687 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1787 | + if (isset($event['participants'][$n])) |
|
| 1788 | + { |
|
| 1789 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1790 | + } |
|
| 1688 | 1791 | } |
| 1689 | 1792 | foreach($event['participant_types'] as $type => $participants) |
| 1690 | 1793 | { |
@@ -1726,9 +1829,13 @@ discard block |
||
| 1726 | 1829 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1727 | 1830 | |
| 1728 | 1831 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1729 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1832 | + { |
|
| 1833 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1834 | + } |
|
| 1730 | 1835 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1731 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1836 | + { |
|
| 1837 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1838 | + } |
|
| 1732 | 1839 | // todo: make the participants available as links with email as title |
| 1733 | 1840 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1734 | 1841 | // enumerate group-invitations, so people can accept/reject them |
@@ -1759,7 +1866,11 @@ discard block |
||
| 1759 | 1866 | $content['participants']['cal_resources'] = ''; |
| 1760 | 1867 | foreach($this->bo->resources as $data) |
| 1761 | 1868 | { |
| 1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1869 | + if ($data['app'] == 'email') |
|
| 1870 | + { |
|
| 1871 | + continue; |
|
| 1872 | + } |
|
| 1873 | + // make no sense, as we cant search for email |
|
| 1763 | 1874 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1764 | 1875 | } |
| 1765 | 1876 | } |
@@ -1789,9 +1900,18 @@ discard block |
||
| 1789 | 1900 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1790 | 1901 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1791 | 1902 | $label = array(); |
| 1792 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1793 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1794 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1903 | + if ($days) |
|
| 1904 | + { |
|
| 1905 | + $label[] = $days.' '.lang('days'); |
|
| 1906 | + } |
|
| 1907 | + if ($hours) |
|
| 1908 | + { |
|
| 1909 | + $label[] = $hours.' '.lang('hours'); |
|
| 1910 | + } |
|
| 1911 | + if ($minutes) |
|
| 1912 | + { |
|
| 1913 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1914 | + } |
|
| 1795 | 1915 | if (!$label) |
| 1796 | 1916 | { |
| 1797 | 1917 | $alarm['offset'] = lang('at start of the event'); |
@@ -1861,25 +1981,34 @@ discard block |
||
| 1861 | 1981 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1862 | 1982 | 'history' => !$event['id'], |
| 1863 | 1983 | ); |
| 1864 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1984 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1985 | + { |
|
| 1986 | + // no mail without mail-app |
|
| 1865 | 1987 | { |
| 1866 | 1988 | unset($sel_options['action']['mail']); |
| 1989 | + } |
|
| 1867 | 1990 | unset($sel_options['action']['sendmeetingrequest']); |
| 1868 | 1991 | } |
| 1869 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1992 | + if (!$event['id']) |
|
| 1993 | + { |
|
| 1994 | + // no ical export for new (not saved) events |
|
| 1870 | 1995 | { |
| 1871 | 1996 | $readonlys['action'] = true; |
| 1872 | 1997 | } |
| 1998 | + } |
|
| 1873 | 1999 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
| 1874 | 2000 | { |
| 1875 | 2001 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1876 | 2002 | } |
| 1877 | 2003 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1878 | 2004 | |
| 1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 2005 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 2006 | + { |
|
| 2007 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1880 | 2008 | { |
| 1881 | 2009 | $sel_options['owner'][0] = lang('All participants'); |
| 1882 | 2010 | } |
| 2011 | + } |
|
| 1883 | 2012 | if (isset($event['participant_types']['u'][$this->user])) |
| 1884 | 2013 | { |
| 1885 | 2014 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1922,7 +2051,10 @@ discard block |
||
| 1922 | 2051 | |
| 1923 | 2052 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1924 | 2053 | |
| 1925 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 2054 | + if (!empty($preserved['lock_token'])) |
|
| 2055 | + { |
|
| 2056 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 2057 | + } |
|
| 1926 | 2058 | |
| 1927 | 2059 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1928 | 2060 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2078,7 +2210,10 @@ discard block |
||
| 2078 | 2210 | { |
| 2079 | 2211 | $quantity = $role = null; |
| 2080 | 2212 | calendar_so::split_status($status, $quantity, $role); |
| 2081 | - if (!is_numeric($uid) && $role == 'CHAIR') break; |
|
| 2213 | + if (!is_numeric($uid) && $role == 'CHAIR') |
|
| 2214 | + { |
|
| 2215 | + break; |
|
| 2216 | + } |
|
| 2082 | 2217 | } |
| 2083 | 2218 | if (!(!is_numeric($uid) && $role == 'CHAIR')) |
| 2084 | 2219 | { |
@@ -2294,13 +2429,16 @@ discard block |
||
| 2294 | 2429 | |
| 2295 | 2430 | foreach (array_keys($allConflicts) as $pId) |
| 2296 | 2431 | { |
| 2297 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2432 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2433 | + { |
|
| 2434 | + // resources Allow ignore conflicts |
|
| 2298 | 2435 | { |
| 2299 | 2436 | |
| 2300 | 2437 | switch ($resources_config['ignoreconflicts']) |
| 2301 | 2438 | { |
| 2302 | 2439 | case 'no': |
| 2303 | 2440 | $readonlys['button[ignore]'] = true; |
| 2441 | + } |
|
| 2304 | 2442 | break; |
| 2305 | 2443 | case 'allusers': |
| 2306 | 2444 | $readonlys['button[ignore]'] = false; |
@@ -2444,7 +2582,10 @@ discard block |
||
| 2444 | 2582 | } |
| 2445 | 2583 | else |
| 2446 | 2584 | { |
| 2447 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2585 | + if (!$content['duration']) |
|
| 2586 | + { |
|
| 2587 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2588 | + } |
|
| 2448 | 2589 | $weekds = 0; |
| 2449 | 2590 | foreach ($content['weekdays'] as &$wdays) |
| 2450 | 2591 | { |
@@ -2466,7 +2607,10 @@ discard block |
||
| 2466 | 2607 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2467 | 2608 | |
| 2468 | 2609 | $sel_options['duration'] = $this->durations; |
| 2469 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2610 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2611 | + { |
|
| 2612 | + $content['end'] = ''; |
|
| 2613 | + } |
|
| 2470 | 2614 | |
| 2471 | 2615 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2472 | 2616 | 'participants' => $content['participants'], |
@@ -2487,7 +2631,10 @@ discard block |
||
| 2487 | 2631 | */ |
| 2488 | 2632 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2489 | 2633 | { |
| 2490 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2634 | + if ($this->debug > 2) |
|
| 2635 | + { |
|
| 2636 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2637 | + } |
|
| 2491 | 2638 | |
| 2492 | 2639 | $busy = $this->bo->search(array( |
| 2493 | 2640 | 'start' => $start, |
@@ -2504,9 +2651,17 @@ discard block |
||
| 2504 | 2651 | $n = 0; |
| 2505 | 2652 | foreach($busy as $event) |
| 2506 | 2653 | { |
| 2507 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2654 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2655 | + { |
|
| 2656 | + continue; |
|
| 2657 | + } |
|
| 2658 | + // ignore our own event |
|
| 2508 | 2659 | |
| 2509 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2660 | + if ($event['non_blocking']) |
|
| 2661 | + { |
|
| 2662 | + continue; |
|
| 2663 | + } |
|
| 2664 | + // ignore non_blocking events |
|
| 2510 | 2665 | |
| 2511 | 2666 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2512 | 2667 | $non_rejected_found = false; |
@@ -2515,7 +2670,10 @@ discard block |
||
| 2515 | 2670 | $status = $event['participants'][$uid]; |
| 2516 | 2671 | $quantity = $role = null; |
| 2517 | 2672 | calendar_so::split_status($status, $quantity, $role); |
| 2518 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
| 2673 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
| 2674 | + { |
|
| 2675 | + continue; |
|
| 2676 | + } |
|
| 2519 | 2677 | |
| 2520 | 2678 | if (isset($event['participants'][$uid]) || |
| 2521 | 2679 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2525,7 +2683,10 @@ discard block |
||
| 2525 | 2683 | break; |
| 2526 | 2684 | } |
| 2527 | 2685 | } |
| 2528 | - if (!$non_rejected_found) continue; |
|
| 2686 | + if (!$non_rejected_found) |
|
| 2687 | + { |
|
| 2688 | + continue; |
|
| 2689 | + } |
|
| 2529 | 2690 | |
| 2530 | 2691 | if ($this->debug) |
| 2531 | 2692 | { |
@@ -2556,11 +2717,17 @@ discard block |
||
| 2556 | 2717 | 'start' => $ft_start, |
| 2557 | 2718 | 'end' => $ft_end, |
| 2558 | 2719 | ); |
| 2559 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2720 | + if ($this->debug > 1) |
|
| 2721 | + { |
|
| 2722 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2723 | + } |
|
| 2560 | 2724 | } |
| 2561 | 2725 | $ft_start = $event['end']; |
| 2562 | 2726 | } |
| 2563 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2727 | + if ($this->debug > 0) |
|
| 2728 | + { |
|
| 2729 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2730 | + } |
|
| 2564 | 2731 | |
| 2565 | 2732 | return $freetime; |
| 2566 | 2733 | } |
@@ -2580,10 +2747,16 @@ discard block |
||
| 2580 | 2747 | */ |
| 2581 | 2748 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2582 | 2749 | { |
| 2583 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2750 | + if ($this->debug > 1) |
|
| 2751 | + { |
|
| 2752 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2753 | + } |
|
| 2584 | 2754 | |
| 2585 | 2755 | $freetime_daywise = array(); |
| 2586 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2756 | + if (!is_array($sel_options)) |
|
| 2757 | + { |
|
| 2758 | + $sel_options = array(); |
|
| 2759 | + } |
|
| 2587 | 2760 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2588 | 2761 | |
| 2589 | 2762 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2593,7 +2766,10 @@ discard block |
||
| 2593 | 2766 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2594 | 2767 | { |
| 2595 | 2768 | $end_time = 0; |
| 2596 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2769 | + if ($this->debug > 1) |
|
| 2770 | + { |
|
| 2771 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2772 | + } |
|
| 2597 | 2773 | } |
| 2598 | 2774 | $n = 0; |
| 2599 | 2775 | foreach($freetime as $ft) |
@@ -2614,13 +2790,19 @@ discard block |
||
| 2614 | 2790 | } |
| 2615 | 2791 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2616 | 2792 | |
| 2617 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2793 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2794 | + { |
|
| 2795 | + // start earlier then start_time |
|
| 2618 | 2796 | { |
| 2619 | 2797 | $start = $daybegin + $start_time*HOUR_s; |
| 2620 | 2798 | } |
| 2799 | + } |
|
| 2621 | 2800 | // if end_time given use it, else the original slot's end |
| 2622 | 2801 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2623 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2802 | + if ($end > $ft['end']) |
|
| 2803 | + { |
|
| 2804 | + $end = $ft['end']; |
|
| 2805 | + } |
|
| 2624 | 2806 | |
| 2625 | 2807 | // slot to small for duration |
| 2626 | 2808 | if ($end - $start < $duration) |
@@ -2662,7 +2844,10 @@ discard block |
||
| 2662 | 2844 | { |
| 2663 | 2845 | $msg = lang('Permission denied'); |
| 2664 | 2846 | |
| 2665 | - if ($return_error) return $msg; |
|
| 2847 | + if ($return_error) |
|
| 2848 | + { |
|
| 2849 | + return $msg; |
|
| 2850 | + } |
|
| 2666 | 2851 | } |
| 2667 | 2852 | else |
| 2668 | 2853 | { |
@@ -2724,27 +2909,42 @@ discard block |
||
| 2724 | 2909 | { |
| 2725 | 2910 | list($button) = each($_content['button']); |
| 2726 | 2911 | unset($_content['button']); |
| 2727 | - if ($button != 'cancel') // store changed Acl |
|
| 2912 | + if ($button != 'cancel') |
|
| 2913 | + { |
|
| 2914 | + // store changed Acl |
|
| 2728 | 2915 | { |
| 2729 | 2916 | foreach($_content as $data) |
| 2730 | 2917 | { |
| 2731 | 2918 | if (!($cat_id = $data['cat_id'])) continue; |
| 2919 | + } |
|
| 2732 | 2920 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2733 | 2921 | { |
| 2734 | 2922 | $rights = 0; |
| 2735 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2736 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2737 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2923 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2924 | + { |
|
| 2925 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2926 | + } |
|
| 2927 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2928 | + { |
|
| 2929 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2930 | + } |
|
| 2931 | + if ($account_id) |
|
| 2932 | + { |
|
| 2933 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2934 | + } |
|
| 2738 | 2935 | } |
| 2739 | 2936 | } |
| 2740 | 2937 | } |
| 2741 | - if ($button != 'apply') // end dialog |
|
| 2938 | + if ($button != 'apply') |
|
| 2939 | + { |
|
| 2940 | + // end dialog |
|
| 2742 | 2941 | { |
| 2743 | 2942 | Egw::redirect_link('/index.php', array( |
| 2744 | 2943 | 'menuaction' => 'admin.admin_ui.index', |
| 2745 | 2944 | 'ajax' => 'true' |
| 2746 | 2945 | ), 'admin'); |
| 2747 | 2946 | } |
| 2947 | + } |
|
| 2748 | 2948 | } |
| 2749 | 2949 | $content= $preserv = array(); |
| 2750 | 2950 | $n = 1; |
@@ -2758,8 +2958,14 @@ discard block |
||
| 2758 | 2958 | ); |
| 2759 | 2959 | foreach($data as $account_id => $rights) |
| 2760 | 2960 | { |
| 2761 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2762 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2961 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2962 | + { |
|
| 2963 | + $row['add'][] = $account_id; |
|
| 2964 | + } |
|
| 2965 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2966 | + { |
|
| 2967 | + $row['status'][] = $account_id; |
|
| 2968 | + } |
|
| 2763 | 2969 | } |
| 2764 | 2970 | $content[$n] = $row; |
| 2765 | 2971 | $preserv[$n] = array( |
@@ -2887,7 +3093,10 @@ discard block |
||
| 2887 | 3093 | break; |
| 2888 | 3094 | } |
| 2889 | 3095 | } |
| 2890 | - if($return) return; |
|
| 3096 | + if($return) |
|
| 3097 | + { |
|
| 3098 | + return; |
|
| 3099 | + } |
|
| 2891 | 3100 | } |
| 2892 | 3101 | $old_event=$event=$this->bo->read($eventId); |
| 2893 | 3102 | if (!$durationT) |
@@ -2981,7 +3190,10 @@ discard block |
||
| 2981 | 3190 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2982 | 3191 | |
| 2983 | 3192 | // Whole day non blocking with DAY_s would add a day |
| 2984 | - if($duration==DAY_s) $duration=0; |
|
| 3193 | + if($duration==DAY_s) |
|
| 3194 | + { |
|
| 3195 | + $duration=0; |
|
| 3196 | + } |
|
| 2985 | 3197 | } |
| 2986 | 3198 | |
| 2987 | 3199 | $status_reset_to_unknown = false; |
@@ -2999,7 +3211,10 @@ discard block |
||
| 2999 | 3211 | case 'no': |
| 3000 | 3212 | break; |
| 3001 | 3213 | case 'startday': |
| 3002 | - if ($sameday) break; |
|
| 3214 | + if ($sameday) |
|
| 3215 | + { |
|
| 3216 | + break; |
|
| 3217 | + } |
|
| 3003 | 3218 | default: |
| 3004 | 3219 | $status_reset_to_unknown = true; |
| 3005 | 3220 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -3043,7 +3258,10 @@ discard block |
||
| 3043 | 3258 | { |
| 3044 | 3259 | $response->call('egw.message', implode('<br />', $message)); |
| 3045 | 3260 | } |
| 3046 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3261 | + if($event['id'] != $eventId ) |
|
| 3262 | + { |
|
| 3263 | + $this->update_client($_eventId); |
|
| 3264 | + } |
|
| 3047 | 3265 | if ($status_reset_to_unknown) |
| 3048 | 3266 | { |
| 3049 | 3267 | foreach((array)$event['participants'] as $uid => $status) |
@@ -539,8 +539,9 @@ |
||
| 539 | 539 | * @param int &$success number of succeded actions |
| 540 | 540 | * @param int &$failed number of failed actions (not enought permissions) |
| 541 | 541 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 events 'deleted' |
| 542 | - * @param string/array $session_name 'calendar_list' |
|
| 543 | - * @return boolean true if all actions succeded, false otherwise |
|
| 542 | + * @param string $session_name 'calendar_list' |
|
| 543 | + * @param null|string $msg |
|
| 544 | + * @return null|boolean true if all actions succeded, false otherwise |
|
| 544 | 545 | */ |
| 545 | 546 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
| 546 | 547 | { |
@@ -76,8 +76,14 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function listview($_content=null,$msg='',$home=false) |
| 78 | 78 | { |
| 79 | - if ($_GET['msg']) $msg .= $_GET['msg']; |
|
| 80 | - if ($this->group_warning) $msg .= $this->group_warning; |
|
| 79 | + if ($_GET['msg']) |
|
| 80 | + { |
|
| 81 | + $msg .= $_GET['msg']; |
|
| 82 | + } |
|
| 83 | + if ($this->group_warning) |
|
| 84 | + { |
|
| 85 | + $msg .= $this->group_warning; |
|
| 86 | + } |
|
| 81 | 87 | |
| 82 | 88 | $etpl = new Etemplate('calendar.list'); |
| 83 | 89 | |
@@ -105,7 +111,8 @@ discard block |
||
| 105 | 111 | { |
| 106 | 112 | // Allow merge using the date range filter |
| 107 | 113 | if(strpos($_content['nm']['action'],'document') !== false && |
| 108 | - !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
|
| 114 | + !count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
|
| 115 | + { |
|
| 109 | 116 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 110 | 117 | } |
| 111 | 118 | if (!count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
@@ -168,15 +175,21 @@ discard block |
||
| 168 | 175 | { |
| 169 | 176 | $params = null; |
| 170 | 177 | parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
| 171 | - if (isset($params['keywords'])) // new search => set filters so every match is shown |
|
| 178 | + if (isset($params['keywords'])) |
|
| 179 | + { |
|
| 180 | + // new search => set filters so every match is shown |
|
| 172 | 181 | { |
| 173 | 182 | $this->adjust_for_search($params['keywords'], $content['nm']); |
| 174 | 183 | } |
| 184 | + } |
|
| 175 | 185 | } |
| 176 | - if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
|
| 186 | + if (isset($_REQUEST['keywords'])) |
|
| 187 | + { |
|
| 188 | + // new search => set filters so every match is shown |
|
| 177 | 189 | { |
| 178 | 190 | $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
| 179 | 191 | } |
| 192 | + } |
|
| 180 | 193 | $sel_options['filter'] = &$this->date_filters; |
| 181 | 194 | |
| 182 | 195 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
@@ -266,9 +279,12 @@ discard block |
||
| 266 | 279 | $old_params = Api\Cache::getSession('calendar', 'calendar_list'); |
| 267 | 280 | if (is_array($old_params)) |
| 268 | 281 | { |
| 269 | - if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly |
|
| 282 | + if ($old_params['filter'] && $old_params['filter'] != $params['filter']) |
|
| 283 | + { |
|
| 284 | + // filter changed => order accordingly |
|
| 270 | 285 | { |
| 271 | 286 | $params['order'] = 'cal_start'; |
| 287 | + } |
|
| 272 | 288 | $params['sort'] = $params['filter'] == 'before' ? 'DESC' : 'ASC'; |
| 273 | 289 | } |
| 274 | 290 | if ($old_params['search'] != $params['search']) |
@@ -299,7 +315,10 @@ discard block |
||
| 299 | 315 | $cfs = array(); |
| 300 | 316 | foreach($select_cols as $col) |
| 301 | 317 | { |
| 302 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 318 | + if ($col[0] == '#') |
|
| 319 | + { |
|
| 320 | + $cfs[] = substr($col,1); |
|
| 321 | + } |
|
| 303 | 322 | } |
| 304 | 323 | } |
| 305 | 324 | $search_params = array( |
@@ -534,7 +553,10 @@ discard block |
||
| 534 | 553 | { |
| 535 | 554 | $rows['format'] = '64'; |
| 536 | 555 | } |
| 537 | - if ($this->cat_id) $rows['no_cat_id'] = true; |
|
| 556 | + if ($this->cat_id) |
|
| 557 | + { |
|
| 558 | + $rows['no_cat_id'] = true; |
|
| 559 | + } |
|
| 538 | 560 | if (!$GLOBALS['egw_info']['user']['apps']['projectmanager']) |
| 539 | 561 | { |
| 540 | 562 | $params['options-selectcols']['pm_id'] = false; |
@@ -601,7 +623,10 @@ discard block |
||
| 601 | 623 | foreach($events as $key => $event) |
| 602 | 624 | { |
| 603 | 625 | $recur_date = Api\DateTime::to($event['recur_date'],'ts'); |
| 604 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]); |
|
| 626 | + if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$recur_date, $checked)) |
|
| 627 | + { |
|
| 628 | + unset($events[$key]); |
|
| 629 | + } |
|
| 605 | 630 | } |
| 606 | 631 | $checked = array_values($events); // Clear keys |
| 607 | 632 | } |
@@ -615,7 +640,10 @@ discard block |
||
| 615 | 640 | $ids = array(); |
| 616 | 641 | foreach($checked as $id) |
| 617 | 642 | { |
| 618 | - if (is_array($id)) $id = $id['id']; |
|
| 643 | + if (is_array($id)) |
|
| 644 | + { |
|
| 645 | + $id = $id['id']; |
|
| 646 | + } |
|
| 619 | 647 | // get rid of recurrences, doublicate series and calendar-integration events |
| 620 | 648 | if (($id = (int)$id)) |
| 621 | 649 | { |
@@ -629,7 +657,10 @@ discard block |
||
| 629 | 657 | exit(); |
| 630 | 658 | |
| 631 | 659 | case 'document': |
| 632 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 660 | + if (!$settings) |
|
| 661 | + { |
|
| 662 | + $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 663 | + } |
|
| 633 | 664 | $document_merge = new calendar_merge(); |
| 634 | 665 | $msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']); |
| 635 | 666 | $failed = count($checked); |
@@ -816,7 +847,8 @@ discard block |
||
| 816 | 847 | $success++; |
| 817 | 848 | |
| 818 | 849 | // Can't link to just one of a recurring series of events |
| 819 | - if(!$recur_date || $app) { |
|
| 850 | + if(!$recur_date || $app) |
|
| 851 | + { |
|
| 820 | 852 | // Create link |
| 821 | 853 | $link_id = $app ? $app_id : $id; |
| 822 | 854 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @var mixed |
| 41 | 41 | */ |
| 42 | - var $debug=false; |
|
| 42 | + var $debug = false; |
|
| 43 | 43 | /** |
| 44 | 44 | * Filternames |
| 45 | 45 | * |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 62 | 62 | */ |
| 63 | - function __construct($set_states=null) |
|
| 63 | + function __construct($set_states = null) |
|
| 64 | 64 | { |
| 65 | - parent::__construct(true,$set_states); // call the parent's constructor |
|
| 65 | + parent::__construct(true, $set_states); // call the parent's constructor |
|
| 66 | 66 | |
| 67 | - foreach($this->date_filters as $name => $label) |
|
| 67 | + foreach ($this->date_filters as $name => $label) |
|
| 68 | 68 | { |
| 69 | 69 | $this->date_filters[$name] = lang($label); |
| 70 | 70 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * Show the listview |
| 77 | 77 | */ |
| 78 | - function listview($_content=null,$msg='',$home=false) |
|
| 78 | + function listview($_content = null, $msg = '', $home = false) |
|
| 79 | 79 | { |
| 80 | 80 | if ($_GET['msg']) $msg .= $_GET['msg']; |
| 81 | 81 | if ($this->group_warning) $msg .= $this->group_warning; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $etpl = new Etemplate('calendar.list'); |
| 84 | 84 | |
| 85 | 85 | // Handle merge from sidebox |
| 86 | - if($_GET['merge']) |
|
| 86 | + if ($_GET['merge']) |
|
| 87 | 87 | { |
| 88 | 88 | $_content['nm']['action'] = 'document_'.$_GET['merge']; |
| 89 | 89 | $_content['nm']['select_all'] = true; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if (is_array($_content)) |
| 93 | 93 | { |
| 94 | 94 | // handle a single button like actions |
| 95 | - foreach(array('delete','timesheet','document') as $button) |
|
| 95 | + foreach (array('delete', 'timesheet', 'document') as $button) |
|
| 96 | 96 | { |
| 97 | 97 | if ($_content['nm']['rows'][$button]) |
| 98 | 98 | { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | if ($_content['nm']['action']) |
| 106 | 106 | { |
| 107 | 107 | // Allow merge using the date range filter |
| 108 | - if(strpos($_content['nm']['action'],'document') !== false && |
|
| 108 | + if (strpos($_content['nm']['action'], 'document') !== false && |
|
| 109 | 109 | !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
| 110 | 110 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 111 | 111 | } |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | 118 | $success = $failed = $action_msg = null; |
| 119 | - if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], |
|
| 120 | - $success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 119 | + if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'], |
|
| 120 | + $success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 121 | 121 | { |
| 122 | - $msg .= lang('%1 event(s) %2',$success,$action_msg); |
|
| 122 | + $msg .= lang('%1 event(s) %2', $success, $action_msg); |
|
| 123 | 123 | } |
| 124 | - elseif(is_null($msg)) |
|
| 124 | + elseif (is_null($msg)) |
|
| 125 | 125 | { |
| 126 | - $msg .= lang('%1 event(s) %2, %3 failed because of insufficient rights !!!',$success,$action_msg,$failed); |
|
| 126 | + $msg .= lang('%1 event(s) %2, %3 failed because of insufficient rights !!!', $success, $action_msg, $failed); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $content['nm'] = array( |
| 137 | 137 | 'get_rows' => 'calendar.calendar_uilist.get_rows', |
| 138 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 138 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 141 | 141 | 'filter' => 'after', |
| 142 | - 'order' => 'cal_start',// IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | - 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' |
|
| 142 | + 'order' => 'cal_start', // IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 144 | 144 | 'default_cols' => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id', |
| 145 | 145 | 'filter_onchange' => "app.calendar.filter_change", |
| 146 | - 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 146 | + 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 147 | 147 | 'row_modified' => 'modified', |
| 148 | 148 | 'favorites' => true, |
| 149 | 149 | 'placeholder_actions' => array('add') |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | $content['nm']['actions'] = $this->get_actions(); |
| 153 | 153 | |
| 154 | - if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters))) |
|
| 154 | + if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters))) |
|
| 155 | 155 | { |
| 156 | 156 | $content['nm']['filter'] = $_GET['filter']; |
| 157 | 157 | } |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $content['nm']['search'] = $_GET['search']; |
| 161 | 161 | } |
| 162 | - if($this->owner) |
|
| 162 | + if ($this->owner) |
|
| 163 | 163 | { |
| 164 | - $content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',',$this->owner); |
|
| 164 | + $content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',', $this->owner); |
|
| 165 | 165 | } |
| 166 | 166 | // search via jdots ajax_exec uses $_REQUEST['json_data'] instead of regular GET parameters |
| 167 | 167 | if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) && |
| 168 | 168 | !empty($json_data['request']['parameters'][0])) |
| 169 | 169 | { |
| 170 | 170 | $params = null; |
| 171 | - parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 171 | + parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 172 | 172 | if (isset($params['keywords'])) // new search => set filters so every match is shown |
| 173 | 173 | { |
| 174 | 174 | $this->adjust_for_search($params['keywords'], $content['nm']); |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
| 178 | 178 | { |
| 179 | - $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
|
| 179 | + $this->adjust_for_search($_REQUEST['keywords'], $content['nm']); |
|
| 180 | 180 | } |
| 181 | 181 | $sel_options['filter'] = &$this->date_filters; |
| 182 | 182 | |
| 183 | 183 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
| 184 | 184 | $sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar'); |
| 185 | 185 | // Prevent double encoding - widget does this on its own, but we're just grabbing the options |
| 186 | - foreach($sel_options['category'] as &$label) |
|
| 186 | + foreach ($sel_options['category'] as &$label) |
|
| 187 | 187 | { |
| 188 | - if(!is_array($label)) |
|
| 188 | + if (!is_array($label)) |
|
| 189 | 189 | { |
| 190 | - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); |
|
| 190 | + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); |
|
| 191 | 191 | } |
| 192 | - elseif($label['label']) |
|
| 192 | + elseif ($label['label']) |
|
| 193 | 193 | { |
| 194 | - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); |
|
| 194 | + $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8'); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -199,15 +199,15 @@ discard block |
||
| 199 | 199 | if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '') |
| 200 | 200 | { |
| 201 | 201 | $content['css'] .= '<style type="text/css">@media screen { .listDescription { max-height: '. |
| 202 | - (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35). // dono why em is not real lines |
|
| 202 | + (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines |
|
| 203 | 203 | 'em; overflow: auto; }}</style>'; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if($msg) |
|
| 206 | + if ($msg) |
|
| 207 | 207 | { |
| 208 | 208 | Framework::message($msg); |
| 209 | 209 | } |
| 210 | - $html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0); |
|
| 210 | + $html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0); |
|
| 211 | 211 | |
| 212 | 212 | // Not sure why this has to be echoed instead of appended, but that's what works. |
| 213 | 213 | //echo calendar_uiviews::edit_series(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * set filter for search, so that everything is shown |
| 220 | 220 | */ |
| 221 | - function adjust_for_search($keywords,&$params) |
|
| 221 | + function adjust_for_search($keywords, &$params) |
|
| 222 | 222 | { |
| 223 | 223 | $params['search'] = $keywords; |
| 224 | 224 | $params['start'] = 0; |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | * @param array &$rows returned rows/events |
| 243 | 243 | * @param array &$readonlys eg. to disable buttons based on Acl |
| 244 | 244 | */ |
| 245 | - function get_rows(&$params,&$rows,&$readonlys) |
|
| 245 | + function get_rows(&$params, &$rows, &$readonlys) |
|
| 246 | 246 | { |
| 247 | - unset($readonlys); // not used; |
|
| 247 | + unset($readonlys); // not used; |
|
| 248 | 248 | //echo "uilist::get_rows() params="; _debug_array($params); |
| 249 | 249 | $this->filter = $params['filter']; |
| 250 | 250 | if ($params['filter'] == 'custom') |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | if ($old_params['search'] != $params['search']) |
| 276 | 276 | { |
| 277 | - $this->adjust_for_search($params['search'],$params); |
|
| 277 | + $this->adjust_for_search($params['search'], $params); |
|
| 278 | 278 | $this->filter = $params['filter']; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -282,28 +282,28 @@ discard block |
||
| 282 | 282 | if (!$params['csv_export']) |
| 283 | 283 | { |
| 284 | 284 | Api\Cache::setSession('calendar', 'calendar_list', |
| 285 | - array_diff_key ($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 285 | + array_diff_key($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 286 | 286 | } |
| 287 | 287 | // do we need to query custom fields and which |
| 288 | 288 | // Check stored preference if selectcols isn't available (ie: first call) |
| 289 | 289 | $select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows']; |
| 290 | - if(!is_array($params['selectcols'])) |
|
| 290 | + if (!is_array($params['selectcols'])) |
|
| 291 | 291 | { |
| 292 | - $select_cols = explode(',',$select_cols); |
|
| 292 | + $select_cols = explode(',', $select_cols); |
|
| 293 | 293 | } |
| 294 | - if (in_array('cfs',$select_cols)) |
|
| 294 | + if (in_array('cfs', $select_cols)) |
|
| 295 | 295 | { |
| 296 | 296 | $cfs = array(); |
| 297 | - foreach($select_cols as $col) |
|
| 297 | + foreach ($select_cols as $col) |
|
| 298 | 298 | { |
| 299 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 299 | + if ($col[0] == '#') $cfs[] = substr($col, 1); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | $search_params = array( |
| 303 | 303 | 'cat_id' => $params['cat_id'] ? $params['cat_id'] : 0, |
| 304 | 304 | 'filter' => $this->filter, |
| 305 | 305 | 'query' => $params['search'], |
| 306 | - 'offset' => (int) $params['start'], |
|
| 306 | + 'offset' => (int)$params['start'], |
|
| 307 | 307 | 'num_rows'=> $params['num_rows'], |
| 308 | 308 | 'order' => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC', |
| 309 | 309 | 'cfs' => $params['csv_export'] ? array() : $cfs, |
@@ -311,24 +311,24 @@ discard block |
||
| 311 | 311 | // Non-blocking events above blocking |
| 312 | 312 | $search_params['order'] .= ', cal_non_blocking DESC'; |
| 313 | 313 | |
| 314 | - switch($this->filter) |
|
| 314 | + switch ($this->filter) |
|
| 315 | 315 | { |
| 316 | 316 | case 'all': |
| 317 | 317 | break; |
| 318 | 318 | case 'before': |
| 319 | - $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date; |
|
| 320 | - $label = lang('Before %1',$this->bo->long_date($search_params['end'])); |
|
| 319 | + $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date; |
|
| 320 | + $label = lang('Before %1', $this->bo->long_date($search_params['end'])); |
|
| 321 | 321 | break; |
| 322 | 322 | case 'custom': |
| 323 | - $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts'); |
|
| 324 | - $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1; |
|
| 325 | - $label = $this->bo->long_date($this->first,$this->last); |
|
| 323 | + $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts'); |
|
| 324 | + $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1; |
|
| 325 | + $label = $this->bo->long_date($this->first, $this->last); |
|
| 326 | 326 | break; |
| 327 | 327 | case 'today': |
| 328 | 328 | $today = new Api\DateTime(); |
| 329 | 329 | $today->setTime(0, 0, 0); |
| 330 | 330 | $this->first = $search_params['start'] = $today->format('ts'); |
| 331 | - $today->setTime(23,59,59); |
|
| 331 | + $today->setTime(23, 59, 59); |
|
| 332 | 332 | $this->last = $search_params['end'] = $today->format('ts'); |
| 333 | 333 | break; |
| 334 | 334 | case 'week': |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 341 | 341 | unset($this->last['raw']); |
| 342 | 342 | $this->last = $this->bo->date2ts($this->last); |
| 343 | - $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last); |
|
| 343 | + $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last); |
|
| 344 | 344 | $search_params['start'] = $this->first; |
| 345 | 345 | $search_params['end'] = $this->last; |
| 346 | 346 | $params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | unset($this->first['raw']); |
| 354 | 354 | $this->last = $this->first; |
| 355 | 355 | $this->last['month'] += 1; |
| 356 | - $this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 356 | + $this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 357 | 357 | $this->first = $this->bo->date2ts($this->first); |
| 358 | 358 | $this->last = $this->bo->date2ts($this->last); |
| 359 | 359 | $this->last--; |
@@ -366,22 +366,22 @@ discard block |
||
| 366 | 366 | // fall through to after given date |
| 367 | 367 | case 'after': |
| 368 | 368 | default: |
| 369 | - $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date; |
|
| 370 | - $label = lang('After %1',$this->bo->long_date($this->date)); |
|
| 369 | + $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date; |
|
| 370 | + $label = lang('After %1', $this->bo->long_date($this->date)); |
|
| 371 | 371 | $search_params['start'] = $this->date; |
| 372 | 372 | break; |
| 373 | 373 | } |
| 374 | - if($params['status_filter']) |
|
| 374 | + if ($params['status_filter']) |
|
| 375 | 375 | { |
| 376 | 376 | $search_params['filter'] = $params['status_filter']; |
| 377 | 377 | } |
| 378 | 378 | if ($params['col_filter']['participant']) |
| 379 | 379 | { |
| 380 | - $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']); |
|
| 380 | + $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']); |
|
| 381 | 381 | } |
| 382 | 382 | elseif (!$params['col_filter'] || !$params['col_filter']['participant']) |
| 383 | 383 | { |
| 384 | - $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner); |
|
| 384 | + $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner); |
|
| 385 | 385 | } |
| 386 | 386 | // Allow private to stay for all viewed owners, even if in separate calendars |
| 387 | 387 | $search_params['private_allowed'] = (array)$params['selected_owners'] + (array)$search_params['users']; |
@@ -389,9 +389,9 @@ discard block |
||
| 389 | 389 | if ($params['col_filter']) |
| 390 | 390 | { |
| 391 | 391 | $col_filter = array(); |
| 392 | - foreach($params['col_filter'] as $name => $val) |
|
| 392 | + foreach ($params['col_filter'] as $name => $val) |
|
| 393 | 393 | { |
| 394 | - if (!in_array($name, array('participant','row_id')) && (string)$val !== '') |
|
| 394 | + if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '') |
|
| 395 | 395 | { |
| 396 | 396 | $col_filter[$name] = $val; |
| 397 | 397 | } |
@@ -401,18 +401,18 @@ discard block |
||
| 401 | 401 | |
| 402 | 402 | // App header is mostly taken care of on the client side, but here we update |
| 403 | 403 | // it to match changing list filters |
| 404 | - if($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse()) |
|
| 404 | + if ($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse()) |
|
| 405 | 405 | { |
| 406 | 406 | Api\Json\Response::get()->call('app.calendar.set_app_header', |
| 407 | - (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') . |
|
| 407 | + (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : ''). |
|
| 408 | 408 | $label); |
| 409 | 409 | } |
| 410 | - foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 410 | + foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 411 | 411 | { |
| 412 | 412 | |
| 413 | 413 | if ($params['csv_export']) |
| 414 | 414 | { |
| 415 | - $event['participants'] = implode(",\n",$this->bo->participants($event,true)); |
|
| 415 | + $event['participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 416 | 416 | } |
| 417 | 417 | else |
| 418 | 418 | { |
@@ -420,23 +420,23 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $matches = null; |
| 423 | - if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches)) |
|
| 423 | + if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches)) |
|
| 424 | 424 | { |
| 425 | 425 | $app = $matches[1]; |
| 426 | 426 | $app_id = $matches[2]; |
| 427 | 427 | $icons = array(); |
| 428 | - if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event))) |
|
| 428 | + if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event))) |
|
| 429 | 429 | { |
| 430 | - $icons[] = Api\Html::image('calendar','private'); |
|
| 430 | + $icons[] = Api\Html::image('calendar', 'private'); |
|
| 431 | 431 | } |
| 432 | 432 | else |
| 433 | 433 | { |
| 434 | - $icons = calendar_uiviews::integration_get_icons($app,$app_id,$event); |
|
| 434 | + $icons = calendar_uiviews::integration_get_icons($app, $app_id, $event); |
|
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | else |
| 438 | 438 | { |
| 439 | - $is_private = !$this->bo->check_perms(Acl::READ,$event); |
|
| 439 | + $is_private = !$this->bo->check_perms(Acl::READ, $event); |
|
| 440 | 440 | } |
| 441 | 441 | if ($is_private) |
| 442 | 442 | { |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | $event['app_id'] = $event['id']; |
| 448 | 448 | |
| 449 | 449 | // Edit link |
| 450 | - if($app && $app_id) |
|
| 450 | + if ($app && $app_id) |
|
| 451 | 451 | { |
| 452 | - $popup = calendar_uiviews::integration_get_popup($app,$app_id); |
|
| 452 | + $popup = calendar_uiviews::integration_get_popup($app, $app_id); |
|
| 453 | 453 | |
| 454 | 454 | // Need to strip off 'onclick' |
| 455 | 455 | $event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup); |
@@ -460,18 +460,18 @@ discard block |
||
| 460 | 460 | // populate js_integration_data, if not already set |
| 461 | 461 | if (!isset($js_integration_data[$app])) |
| 462 | 462 | { |
| 463 | - $js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 463 | + $js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | elseif ($event['recur_type'] != MCAL_RECUR_NONE) |
| 467 | 467 | { |
| 468 | - $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts'); |
|
| 468 | + $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts'); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | // Format start and end with timezone |
| 472 | - foreach(array('start','end') as $time) |
|
| 472 | + foreach (array('start', 'end') as $time) |
|
| 473 | 473 | { |
| 474 | - $event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z'); |
|
| 474 | + $event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z'); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | $rows[] = $event; |
@@ -481,35 +481,35 @@ discard block |
||
| 481 | 481 | // set js_calendar_integration object, to use it in app.js cal_open() function |
| 482 | 482 | $params['js_integration_data'] = json_encode($js_integration_data); |
| 483 | 483 | |
| 484 | - $wv=0; |
|
| 485 | - $dv=0; |
|
| 484 | + $wv = 0; |
|
| 485 | + $dv = 0; |
|
| 486 | 486 | |
| 487 | 487 | // Add in some select options |
| 488 | - $users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']); |
|
| 488 | + $users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']); |
|
| 489 | 489 | |
| 490 | 490 | $this->bo->warnings['groupmembers'] = ''; |
| 491 | - if(($message = $this->check_owners_access($users))) |
|
| 491 | + if (($message = $this->check_owners_access($users))) |
|
| 492 | 492 | { |
| 493 | 493 | Api\Json\Response::get()->error($message); |
| 494 | 494 | } |
| 495 | - else if($this->bo->warnings['groupmembers']) |
|
| 495 | + else if ($this->bo->warnings['groupmembers']) |
|
| 496 | 496 | { |
| 497 | 497 | Api\Json\Response::get()->error($this->bo->warnings['groupmembers']); |
| 498 | 498 | } |
| 499 | 499 | $rows['sel_options']['filter'] = $this->date_filters; |
| 500 | - if($label) |
|
| 500 | + if ($label) |
|
| 501 | 501 | { |
| 502 | 502 | $rows['sel_options']['filter'][$params['filter']] = $label; |
| 503 | 503 | } |
| 504 | - foreach($users as $owner) |
|
| 504 | + foreach ($users as $owner) |
|
| 505 | 505 | { |
| 506 | - if(!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 506 | + if (!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 507 | 507 | { |
| 508 | 508 | $app = $this->bo->resources[$owner[0]]['app']; |
| 509 | - $_owner = substr($owner,1); |
|
| 509 | + $_owner = substr($owner, 1); |
|
| 510 | 510 | // Try link first |
| 511 | - $title = Link::title($app, $_owner ); |
|
| 512 | - if($title) |
|
| 511 | + $title = Link::title($app, $_owner); |
|
| 512 | + if ($title) |
|
| 513 | 513 | { |
| 514 | 514 | $rows['sel_options']['owner'][$owner] = $title; |
| 515 | 515 | } |
@@ -517,15 +517,15 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | $params['options-selectcols']['week'] = lang('Week'); |
| 519 | 519 | $params['options-selectcols']['weekday'] = lang('Weekday'); |
| 520 | - if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,') |
|
| 520 | + if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,') |
|
| 521 | 521 | { |
| 522 | - $rows['format'] = '32'; // prefix date with week-number |
|
| 523 | - $wv=1; |
|
| 522 | + $rows['format'] = '32'; // prefix date with week-number |
|
| 523 | + $wv = 1; |
|
| 524 | 524 | } |
| 525 | - if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE)) |
|
| 525 | + if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE)) |
|
| 526 | 526 | { |
| 527 | 527 | $rows['format'] = '16'; |
| 528 | - $dv=1; |
|
| 528 | + $dv = 1; |
|
| 529 | 529 | } |
| 530 | 530 | if ($wv && $dv) |
| 531 | 531 | { |
@@ -552,36 +552,36 @@ discard block |
||
| 552 | 552 | * @param string/array $session_name 'calendar_list' |
| 553 | 553 | * @return boolean true if all actions succeded, false otherwise |
| 554 | 554 | */ |
| 555 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
|
| 555 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false) |
|
| 556 | 556 | { |
| 557 | 557 | //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)"); |
| 558 | 558 | $success = $failed = 0; |
| 559 | 559 | $msg = null; |
| 560 | 560 | |
| 561 | 561 | // Split out combined values |
| 562 | - if(strpos($action, 'status') !== false) |
|
| 562 | + if (strpos($action, 'status') !== false) |
|
| 563 | 563 | { |
| 564 | 564 | list($action, $status) = explode('-', $action); |
| 565 | 565 | } |
| 566 | 566 | elseif (strpos($action, '_') !== false) |
| 567 | 567 | { |
| 568 | - list($action, $settings) = explode('_', $action,2); |
|
| 568 | + list($action, $settings) = explode('_', $action, 2); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | if ($use_all) |
| 572 | 572 | { |
| 573 | 573 | // get the whole selection |
| 574 | 574 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 575 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 576 | - $query['num_rows'] = -1; // all |
|
| 575 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 576 | + $query['num_rows'] = -1; // all |
|
| 577 | 577 | $readonlys = null; |
| 578 | - $this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document'))); // true = only return the id's |
|
| 578 | + $this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's |
|
| 579 | 579 | // Get rid of any extras (rows that aren't events) |
| 580 | - if(in_array($action,array('ical','document'))) |
|
| 580 | + if (in_array($action, array('ical', 'document'))) |
|
| 581 | 581 | { |
| 582 | - foreach($checked as $key => $event) |
|
| 582 | + foreach ($checked as $key => $event) |
|
| 583 | 583 | { |
| 584 | - if(!is_numeric($key)) |
|
| 584 | + if (!is_numeric($key)) |
|
| 585 | 585 | { |
| 586 | 586 | unset($checked[$key]); |
| 587 | 587 | } |
@@ -589,28 +589,28 @@ discard block |
||
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | // for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id |
| 592 | - elseif($action == 'document') |
|
| 592 | + elseif ($action == 'document') |
|
| 593 | 593 | { |
| 594 | 594 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 595 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 595 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 596 | 596 | $events = null; |
| 597 | - $this->get_rows($query,$events,$readonlys); |
|
| 598 | - foreach($events as $key => $event) |
|
| 597 | + $this->get_rows($query, $events, $readonlys); |
|
| 598 | + foreach ($events as $key => $event) |
|
| 599 | 599 | { |
| 600 | - $recur_date = Api\DateTime::to($event['recur_date'],'ts'); |
|
| 601 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]); |
|
| 600 | + $recur_date = Api\DateTime::to($event['recur_date'], 'ts'); |
|
| 601 | + if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]); |
|
| 602 | 602 | } |
| 603 | 603 | $checked = array_values($events); // Clear keys |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // Actions where one action is done to the group |
| 607 | - switch($action) |
|
| 607 | + switch ($action) |
|
| 608 | 608 | { |
| 609 | 609 | case 'ical': |
| 610 | 610 | // compile list of unique cal_id's, as iCal should contain whole series, not recurrences |
| 611 | 611 | // calendar_ical->exportVCal needs to read events again, to get them in server-time |
| 612 | 612 | $ids = array(); |
| 613 | - foreach($checked as $id) |
|
| 613 | + foreach ($checked as $id) |
|
| 614 | 614 | { |
| 615 | 615 | if (is_array($id)) $id = $id['id']; |
| 616 | 616 | // get rid of recurrences, doublicate series and calendar-integration events |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | $boical = new calendar_ical(); |
| 623 | - $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 623 | + $ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 624 | 624 | Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical)); |
| 625 | 625 | echo $ical; |
| 626 | 626 | exit(); |
@@ -635,19 +635,19 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // Actions where the action is applied to each entry |
| 638 | - if(strpos($action, 'timesheet') !== false) |
|
| 638 | + if (strpos($action, 'timesheet') !== false) |
|
| 639 | 639 | { |
| 640 | 640 | $timesheet_bo = new timesheet_bo(); |
| 641 | 641 | } |
| 642 | - foreach($checked as &$id) |
|
| 642 | + foreach ($checked as &$id) |
|
| 643 | 643 | { |
| 644 | 644 | $recur_date = $app = $app_id = null; |
| 645 | - if(is_array($id) && $id['id']) |
|
| 645 | + if (is_array($id) && $id['id']) |
|
| 646 | 646 | { |
| 647 | 647 | $id = $id['id']; |
| 648 | 648 | } |
| 649 | 649 | $matches = null; |
| 650 | - if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches)) |
|
| 650 | + if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches)) |
|
| 651 | 651 | { |
| 652 | 652 | $app = $matches[1]; |
| 653 | 653 | $app_id = $matches[2]; |
@@ -655,36 +655,36 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | else |
| 657 | 657 | { |
| 658 | - list($id,$recur_date) = explode(':',$id); |
|
| 658 | + list($id, $recur_date) = explode(':', $id); |
|
| 659 | 659 | } |
| 660 | - switch($action) |
|
| 660 | + switch ($action) |
|
| 661 | 661 | { |
| 662 | 662 | case 'delete': |
| 663 | 663 | $action_msg = lang('deleted'); |
| 664 | - if($settings == 'series') |
|
| 664 | + if ($settings == 'series') |
|
| 665 | 665 | { |
| 666 | 666 | // Delete the whole thing |
| 667 | 667 | $recur_date = 0; |
| 668 | 668 | } |
| 669 | - if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) |
|
| 669 | + if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification)) |
|
| 670 | 670 | { |
| 671 | 671 | $success++; |
| 672 | - if(!$recur_date && $settings == 'series') |
|
| 672 | + if (!$recur_date && $settings == 'series') |
|
| 673 | 673 | { |
| 674 | 674 | // If there are multiple events in a series selected, the next one could purge |
| 675 | - foreach($checked as $key => $c_id) |
|
| 675 | + foreach ($checked as $key => $c_id) |
|
| 676 | 676 | { |
| 677 | - list($c_id,$recur_date) = explode(':',$c_id); |
|
| 678 | - if($c_id == $id) |
|
| 677 | + list($c_id, $recur_date) = explode(':', $c_id); |
|
| 678 | + if ($c_id == $id) |
|
| 679 | 679 | { |
| 680 | 680 | unset($checked[$key]); |
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - if(Api\Json\Response::isJSONResponse()) |
|
| 685 | + if (Api\Json\Response::isJSONResponse()) |
|
| 686 | 686 | { |
| 687 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete'); |
|
| 687 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete'); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | else |
@@ -694,23 +694,23 @@ discard block |
||
| 694 | 694 | break; |
| 695 | 695 | case 'undelete': |
| 696 | 696 | $action_msg = lang('recovered'); |
| 697 | - if($settings == 'series') |
|
| 697 | + if ($settings == 'series') |
|
| 698 | 698 | { |
| 699 | 699 | // unDelete the whole thing |
| 700 | 700 | $recur_date = 0; |
| 701 | 701 | } |
| 702 | - if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) && |
|
| 702 | + if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) && |
|
| 703 | 703 | is_array($event) && $event['deleted']) |
| 704 | 704 | { |
| 705 | 705 | $event['deleted'] = null; |
| 706 | - if($this->bo->save($event)) |
|
| 706 | + if ($this->bo->save($event)) |
|
| 707 | 707 | { |
| 708 | 708 | $success++; |
| 709 | 709 | |
| 710 | - if(Api\Json\Response::isJSONResponse()) |
|
| 710 | + if (Api\Json\Response::isJSONResponse()) |
|
| 711 | 711 | { |
| 712 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 713 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit'); |
|
| 712 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 713 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit'); |
|
| 714 | 714 | } |
| 715 | 715 | break; |
| 716 | 716 | } |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | break; |
| 720 | 720 | case 'status': |
| 721 | 721 | $action_msg = lang('Status changed'); |
| 722 | - if($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 722 | + if ($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 723 | 723 | { |
| 724 | 724 | $old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']]; |
| 725 | 725 | $quantity = $role = null; |
@@ -728,12 +728,12 @@ discard block |
||
| 728 | 728 | { |
| 729 | 729 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 730 | 730 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 731 | - if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date, |
|
| 732 | - false,true,$skip_notification)) |
|
| 731 | + if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date, |
|
| 732 | + false, true, $skip_notification)) |
|
| 733 | 733 | { |
| 734 | - if(Api\Json\Response::isJSONResponse()) |
|
| 734 | + if (Api\Json\Response::isJSONResponse()) |
|
| 735 | 735 | { |
| 736 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 736 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 737 | 737 | } |
| 738 | 738 | $success++; |
| 739 | 739 | //$msg = lang('Status changed'); |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | } |
| 751 | 751 | break; |
| 752 | 752 | case 'timesheet-add': |
| 753 | - if($id && !$app) |
|
| 753 | + if ($id && !$app) |
|
| 754 | 754 | { |
| 755 | 755 | $event = $this->bo->read($id, $recur_date); |
| 756 | 756 | } |
@@ -762,10 +762,10 @@ discard block |
||
| 762 | 762 | $result = $this->bo->search($query); |
| 763 | 763 | $event = $result[$app.$app_id]; |
| 764 | 764 | } |
| 765 | - if(!$event) |
|
| 765 | + if (!$event) |
|
| 766 | 766 | { |
| 767 | 767 | $failed++; |
| 768 | - continue 2; // +1 for switch |
|
| 768 | + continue 2; // +1 for switch |
|
| 769 | 769 | } |
| 770 | 770 | $timesheet = array( |
| 771 | 771 | 'ts_title' => $event['title'], |
@@ -779,16 +779,16 @@ discard block |
||
| 779 | 779 | ); |
| 780 | 780 | |
| 781 | 781 | // Add global categories |
| 782 | - $categories = explode(',',$event['category']); |
|
| 782 | + $categories = explode(',', $event['category']); |
|
| 783 | 783 | $global_categories = array(); |
| 784 | - foreach($categories as $cat_id) |
|
| 784 | + foreach ($categories as $cat_id) |
|
| 785 | 785 | { |
| 786 | - if($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 786 | + if ($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 787 | 787 | { |
| 788 | 788 | $global_categories[] = $cat_id; |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | - if(count($global_categories)) |
|
| 791 | + if (count($global_categories)) |
|
| 792 | 792 | { |
| 793 | 793 | $timesheet['cat_id'] = implode(',', $global_categories); |
| 794 | 794 | } |
@@ -808,12 +808,12 @@ discard block |
||
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - if(!$err) |
|
| 811 | + if (!$err) |
|
| 812 | 812 | { |
| 813 | 813 | $success++; |
| 814 | 814 | |
| 815 | 815 | // Can't link to just one of a recurring series of events |
| 816 | - if(!$recur_date || $app) { |
|
| 816 | + if (!$recur_date || $app) { |
|
| 817 | 817 | // Create link |
| 818 | 818 | $link_id = $app ? $app_id : $id; |
| 819 | 819 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | protected function get_merge_range($nm) |
| 842 | 842 | { |
| 843 | 843 | $checked = array(); |
| 844 | - if($nm['filter'] == 'fixed') |
|
| 844 | + if ($nm['filter'] == 'fixed') |
|
| 845 | 845 | { |
| 846 | 846 | $checked['start'] = $nm['startdate']; |
| 847 | 847 | $last = $this->bo->date2array($nm['enddate']); |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | } |
| 851 | 851 | else |
| 852 | 852 | { |
| 853 | - switch($nm['filter']) |
|
| 853 | + switch ($nm['filter']) |
|
| 854 | 854 | { |
| 855 | 855 | case 'after': |
| 856 | 856 | $checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today'); |
@@ -863,8 +863,8 @@ discard block |
||
| 863 | 863 | $checked['end'] = $nm['enddate']; |
| 864 | 864 | break; |
| 865 | 865 | default: |
| 866 | - $date = date_create_from_format('Ymd',$this->date); |
|
| 867 | - $checked['start']= $date->format('U'); |
|
| 866 | + $date = date_create_from_format('Ymd', $this->date); |
|
| 867 | + $checked['start'] = $date->format('U'); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | return $checked; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | 'allowOnMultiple' => false, |
| 890 | 890 | 'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id', |
| 891 | 891 | 'popup' => Link::get_registry('calendar', 'view_popup'), |
| 892 | - 'group' => $group=1, |
|
| 892 | + 'group' => $group = 1, |
|
| 893 | 893 | 'onExecute' => 'javaScript:app.calendar.cal_open', |
| 894 | 894 | 'disableClass' => 'rowNoView', |
| 895 | 895 | ), |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | 'group' => $group, |
| 922 | 922 | ), |
| 923 | 923 | ); |
| 924 | - $status = array_map('lang',$this->bo->verbose_status); |
|
| 924 | + $status = array_map('lang', $this->bo->verbose_status); |
|
| 925 | 925 | unset($status['G']); |
| 926 | 926 | $actions['status'] = array( |
| 927 | 927 | 'caption' => 'Change your status', |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | 'children' => $status, |
| 931 | 931 | 'group' => ++$group, |
| 932 | 932 | ); |
| 933 | - ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 933 | + ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 934 | 934 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 935 | 935 | { |
| 936 | 936 | $actions['filemanager'] = array( |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | 'popup' => Link::get_registry('infolog', 'add_popup'), |
| 955 | 955 | ); |
| 956 | 956 | } |
| 957 | - if($GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 957 | + if ($GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 958 | 958 | { |
| 959 | 959 | //Send to email |
| 960 | 960 | $actions['email'] = array( |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | 'caption' => 'Timesheet', |
| 985 | 985 | 'group' => $group, |
| 986 | 986 | 'allowOnMultiple' => false, |
| 987 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 987 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 988 | 988 | 'onExecute' => 'javaScript:app.calendar.action_open', |
| 989 | 989 | 'open' => '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$app_id"}', |
| 990 | 990 | 'popup' => Link::get_registry('timesheet', 'add_popup'), |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | 'caption' => 'Timesheet', |
| 995 | 995 | 'group' => $group, |
| 996 | 996 | 'allowOnMultiple' => 'only', |
| 997 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 997 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 998 | 998 | ); |
| 999 | 999 | } |
| 1000 | 1000 | $actions['ical'] = array( |
@@ -1003,11 +1003,11 @@ discard block |
||
| 1003 | 1003 | 'group' => ++$group, |
| 1004 | 1004 | 'hint' => 'Download this event as iCal', |
| 1005 | 1005 | 'disableClass' => 'rowNoView', |
| 1006 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 1006 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 1007 | 1007 | ); |
| 1008 | 1008 | $actions['documents'] = calendar_merge::document_action( |
| 1009 | 1009 | $this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_', |
| 1010 | - $this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar') |
|
| 1010 | + $this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar') |
|
| 1011 | 1011 | ); |
| 1012 | 1012 | ++$group; |
| 1013 | 1013 | $actions['delete'] = array( |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | 'disableClass' => 'rowNoDelete', |
| 1018 | 1018 | ); |
| 1019 | 1019 | // Add in deleted for admins |
| 1020 | - if($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 1020 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | $actions['undelete'] = array( |
| 1023 | 1023 | 'caption' => 'Un-delete', |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | /** |
| 413 | 413 | * Displays the planner view |
| 414 | 414 | * |
| 415 | - * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 415 | + * @param null|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 416 | 416 | */ |
| 417 | 417 | function &planner($content = array(), $home=false) |
| 418 | 418 | { |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * Used for home app |
| 498 | 498 | * |
| 499 | 499 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 500 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 500 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 501 | 501 | */ |
| 502 | 502 | function &month($weeks=0,$home=false) |
| 503 | 503 | { |
@@ -580,6 +580,8 @@ discard block |
||
| 580 | 580 | * @param int &$first timestamp 0h of first day of week containing the first of the current month |
| 581 | 581 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 582 | 582 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 583 | + * @param integer $first |
|
| 584 | + * @param integer $last |
|
| 583 | 585 | */ |
| 584 | 586 | function _week_align_month(&$first,&$last,$day=1) |
| 585 | 587 | { |
@@ -604,7 +606,7 @@ discard block |
||
| 604 | 606 | * Displays the weekview, with 5 or 7 days |
| 605 | 607 | * |
| 606 | 608 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 607 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 609 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 608 | 610 | */ |
| 609 | 611 | function week($days=0,$home=false) |
| 610 | 612 | { |
@@ -740,7 +742,7 @@ discard block |
||
| 740 | 742 | /** |
| 741 | 743 | * Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider |
| 742 | 744 | * |
| 743 | - * @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 745 | + * @param string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 744 | 746 | * On return $todo_label contains the label for the todo-box |
| 745 | 747 | * @return string/boolean Api\Html with a table of open todo's or false if no hook availible |
| 746 | 748 | */ |
@@ -824,7 +826,7 @@ discard block |
||
| 824 | 826 | * - 'edit_popup' => '400x300' (optional) |
| 825 | 827 | * |
| 826 | 828 | * @param string $app |
| 827 | - * @param int|string $id |
|
| 829 | + * @param string $id |
|
| 828 | 830 | * @return string |
| 829 | 831 | */ |
| 830 | 832 | public static function integration_get_popup($app,$id) |
@@ -864,7 +866,7 @@ discard block |
||
| 864 | 866 | * Icons specified in $events['icons'] are always displayed! |
| 865 | 867 | * |
| 866 | 868 | * @param string $app |
| 867 | - * @param int|string $id |
|
| 869 | + * @param string $id |
|
| 868 | 870 | * @param array $event |
| 869 | 871 | * @return array |
| 870 | 872 | */ |
@@ -169,7 +169,10 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function week_number($time) |
| 171 | 171 | { |
| 172 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 172 | + if (!is_a($time,'DateTime')) |
|
| 173 | + { |
|
| 174 | + $time = new Api\DateTime($time); |
|
| 175 | + } |
|
| 173 | 176 | |
| 174 | 177 | // if week does not start Monday and $time is Sunday --> add one day |
| 175 | 178 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -227,7 +230,8 @@ discard block |
||
| 227 | 230 | $tmpl = new Etemplate('calendar.toolbar'); |
| 228 | 231 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 229 | 232 | // Adjust toolbar for mobile |
| 230 | - if(Api\Header\UserAgent::mobile()){ |
|
| 233 | + if(Api\Header\UserAgent::mobile()) |
|
| 234 | + { |
|
| 231 | 235 | $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
| 232 | 236 | $tmpl->setElementAttribute('toolbar','view_range', '3'); |
| 233 | 237 | } |
@@ -386,10 +390,12 @@ discard block |
||
| 386 | 390 | { |
| 387 | 391 | foreach (array_keys($actions) as $key) |
| 388 | 392 | { |
| 389 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 393 | + if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) |
|
| 394 | + { |
|
| 390 | 395 | $actions[$key]['toolbarDefault'] = false; |
| 391 | 396 | } |
| 392 | - else { |
|
| 397 | + else |
|
| 398 | + { |
|
| 393 | 399 | $actions[$key]['toolbarDefault'] = true; |
| 394 | 400 | } |
| 395 | 401 | } |
@@ -406,29 +412,38 @@ discard block |
||
| 406 | 412 | */ |
| 407 | 413 | function &planner($content = array(), $home=false) |
| 408 | 414 | { |
| 409 | - if ($this->sortby == 'month') // yearly planner with month rows |
|
| 415 | + if ($this->sortby == 'month') |
|
| 416 | + { |
|
| 417 | + // yearly planner with month rows |
|
| 410 | 418 | { |
| 411 | 419 | $this->first = $this->bo->date2array($this->date); |
| 420 | + } |
|
| 412 | 421 | $this->first['day'] = 1; |
| 413 | 422 | unset($this->first['raw']); |
| 414 | 423 | $this->last = $this->first; |
| 415 | 424 | $this->last['year']++; |
| 416 | 425 | $this->last = $this->bo->date2ts($this->last)-1; |
| 417 | 426 | } |
| 418 | - elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
|
| 427 | + elseif (!$this->planner_view || $this->planner_view == 'month') |
|
| 428 | + { |
|
| 429 | + // planner monthview |
|
| 419 | 430 | { |
| 420 | 431 | if ($this->day < 15) // show one complete month |
| 421 | 432 | { |
| 422 | 433 | $this->_week_align_month($this->first,$this->last); |
| 434 | + } |
|
| 423 | 435 | } |
| 424 | 436 | else // show 2 half month |
| 425 | 437 | { |
| 426 | 438 | $this->_week_align_month($this->first,$this->last,15); |
| 427 | 439 | } |
| 428 | 440 | } |
| 429 | - elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
|
| 441 | + elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') |
|
| 442 | + { |
|
| 443 | + // weeekview |
|
| 430 | 444 | { |
| 431 | 445 | $start = new Api\DateTime($this->date); |
| 446 | + } |
|
| 432 | 447 | $start->setWeekstart(); |
| 433 | 448 | $this->first = $start->format('ts'); |
| 434 | 449 | $this->last = $this->bo->date2array($this->first); |
@@ -467,7 +482,10 @@ discard block |
||
| 467 | 482 | $this->to_client($event); |
| 468 | 483 | } |
| 469 | 484 | |
| 470 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 485 | + if ($this->debug > 0) |
|
| 486 | + { |
|
| 487 | + $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 488 | + } |
|
| 471 | 489 | |
| 472 | 490 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 473 | 491 | |
@@ -491,7 +509,10 @@ discard block |
||
| 491 | 509 | */ |
| 492 | 510 | function &month($weeks=0,$home=false) |
| 493 | 511 | { |
| 494 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 512 | + if ($this->debug > 0) |
|
| 513 | + { |
|
| 514 | + $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 515 | + } |
|
| 495 | 516 | |
| 496 | 517 | if (!$home) |
| 497 | 518 | { |
@@ -533,7 +554,10 @@ discard block |
||
| 533 | 554 | $weekNavH = "1 month"; |
| 534 | 555 | $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
| 535 | 556 | } |
| 536 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 557 | + if ($this->debug > 0) |
|
| 558 | + { |
|
| 559 | + $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 560 | + } |
|
| 537 | 561 | |
| 538 | 562 | // Loop through, using Api\DateTime to handle DST |
| 539 | 563 | $week = 0; |
@@ -578,7 +602,10 @@ discard block |
||
| 578 | 602 | $start->setWeekstart(); |
| 579 | 603 | $first = $start->format('ts'); |
| 580 | 604 | $start->setDate($this->year,$this->month+1,$day); |
| 581 | - if ($day == 1) $start->add('-1day'); |
|
| 605 | + if ($day == 1) |
|
| 606 | + { |
|
| 607 | + $start->add('-1day'); |
|
| 608 | + } |
|
| 582 | 609 | $start->setWeekstart(); |
| 583 | 610 | // now we need to calculate the end of the last day of that week |
| 584 | 611 | // as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!! |
@@ -601,19 +628,31 @@ discard block |
||
| 601 | 628 | if (!$days) |
| 602 | 629 | { |
| 603 | 630 | $days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview']; |
| 604 | - if ($days != 5) $days = 7; |
|
| 605 | - if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
|
| 631 | + if ($days != 5) |
|
| 632 | + { |
|
| 633 | + $days = 7; |
|
| 634 | + } |
|
| 635 | + if ($days != $this->cal_prefs['days_in_weekview']) |
|
| 636 | + { |
|
| 637 | + // save the preference |
|
| 606 | 638 | { |
| 607 | 639 | $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
| 640 | + } |
|
| 608 | 641 | $GLOBALS['egw']->preferences->save_repository(); |
| 609 | 642 | $this->cal_prefs['days_in_weekview'] = $days; |
| 610 | 643 | } |
| 611 | 644 | } |
| 612 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 645 | + if ($this->debug > 0) |
|
| 646 | + { |
|
| 647 | + $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 648 | + } |
|
| 613 | 649 | |
| 614 | - if ($days <= 4) // next 4 days view |
|
| 650 | + if ($days <= 4) |
|
| 651 | + { |
|
| 652 | + // next 4 days view |
|
| 615 | 653 | { |
| 616 | 654 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 655 | + } |
|
| 617 | 656 | $this->last = strtotime("+$days days",$this->first) - 1; |
| 618 | 657 | $view = $days == 1 ? 'day' : 'day4'; |
| 619 | 658 | } |
@@ -622,12 +661,15 @@ discard block |
||
| 622 | 661 | $start = new Api\DateTime($this->date); |
| 623 | 662 | $start->setWeekstart(); |
| 624 | 663 | $wd_start = $this->first = $start->format('ts'); |
| 625 | - if ($days <= 5) // no weekend-days |
|
| 664 | + if ($days <= 5) |
|
| 665 | + { |
|
| 666 | + // no weekend-days |
|
| 626 | 667 | { |
| 627 | 668 | switch($this->cal_prefs['weekdaystarts']) |
| 628 | 669 | { |
| 629 | 670 | case 'Saturday': |
| 630 | 671 | $this->first = strtotime("+2 days",$this->first); |
| 672 | + } |
|
| 631 | 673 | break; |
| 632 | 674 | case 'Sunday': |
| 633 | 675 | $this->first = strtotime("+1 day",$this->first); |
@@ -656,7 +698,10 @@ discard block |
||
| 656 | 698 | ) + $this->search_params; |
| 657 | 699 | |
| 658 | 700 | $users = $this->search_params['users']; |
| 659 | - if (!is_array($users)) $users = array($users); |
|
| 701 | + if (!is_array($users)) |
|
| 702 | + { |
|
| 703 | + $users = array($users); |
|
| 704 | + } |
|
| 660 | 705 | |
| 661 | 706 | $content = array('view' => array()); |
| 662 | 707 | |
@@ -679,8 +724,7 @@ discard block |
||
| 679 | 724 | $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
| 680 | 725 | if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
| 681 | 726 | $days == 1 // Showing just 1 day |
| 682 | - ) |
|
| 683 | - { |
|
| 727 | + ) { |
|
| 684 | 728 | $content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) + |
| 685 | 729 | array('owner' => $users); |
| 686 | 730 | } |
@@ -783,7 +827,8 @@ discard block |
||
| 783 | 827 | $icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"'); |
| 784 | 828 | } |
| 785 | 829 | $todo['icons'] = $icons; |
| 786 | - if($todo['edit']) { |
|
| 830 | + if($todo['edit']) |
|
| 831 | + { |
|
| 787 | 832 | $todo['edit_size'] = $todo['edit']['size']; |
| 788 | 833 | unset($todo['edit']['size']); |
| 789 | 834 | $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
@@ -897,7 +942,10 @@ discard block |
||
| 897 | 942 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 898 | 943 | foreach($actions as $id => &$action) |
| 899 | 944 | { |
| 900 | - if($id=='add') continue; |
|
| 945 | + if($id=='add') |
|
| 946 | + { |
|
| 947 | + continue; |
|
| 948 | + } |
|
| 901 | 949 | if(!$action['enabled']) |
| 902 | 950 | { |
| 903 | 951 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @var mixed |
| 43 | 43 | */ |
| 44 | - var $debug=false; |
|
| 44 | + var $debug = false; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * extra rows above and below the workday |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @var boolean |
| 94 | 94 | */ |
| 95 | - var $use_time_grid=true; |
|
| 95 | + var $use_time_grid = true; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Pref value of use_time_grid preference |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @var boolean |
| 107 | 107 | */ |
| 108 | - var $scroll_to_wdstart=false; |
|
| 108 | + var $scroll_to_wdstart = false; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * counter for the current whole day event of a single day |
| 112 | 112 | * |
| 113 | 113 | * @var int |
| 114 | 114 | */ |
| 115 | - var $wholeDayPosCounter=1; |
|
| 115 | + var $wholeDayPosCounter = 1; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Switch to disable private data and possibility to view and edit events |
@@ -125,26 +125,26 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 127 | 127 | */ |
| 128 | - function __construct($set_states=null) |
|
| 128 | + function __construct($set_states = null) |
|
| 129 | 129 | { |
| 130 | - parent::__construct(false,$set_states); // call the parent's constructor |
|
| 130 | + parent::__construct(false, $set_states); // call the parent's constructor |
|
| 131 | 131 | $this->extraRowsOriginal = $this->extraRows; //save original extraRows value |
| 132 | 132 | |
| 133 | 133 | $GLOBALS['egw_info']['flags']['nonavbar'] = False; |
| 134 | 134 | |
| 135 | 135 | // Check for GET message (from merge) |
| 136 | - if($_GET['msg']) |
|
| 136 | + if ($_GET['msg']) |
|
| 137 | 137 | { |
| 138 | 138 | Framework::message($_GET['msg']); |
| 139 | 139 | unset($_GET['msg']); |
| 140 | 140 | } |
| 141 | 141 | // standard params for calling bocal::search for all views |
| 142 | - $this->owner = str_replace('%2C',',',$this->owner); |
|
| 142 | + $this->owner = str_replace('%2C', ',', $this->owner); |
|
| 143 | 143 | $this->search_params = array( |
| 144 | 144 | 'start' => $this->date, |
| 145 | - 'cat_id' => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0, |
|
| 146 | - 'users' => explode(',',$this->owner), |
|
| 147 | - 'owner' => explode(',',$this->owner), |
|
| 145 | + 'cat_id' => $this->cat_id ? (is_array($this->cat_id) ? $this->cat_id : explode(',', $this->cat_id)) : 0, |
|
| 146 | + 'users' => explode(',', $this->owner), |
|
| 147 | + 'owner' => explode(',', $this->owner), |
|
| 148 | 148 | 'filter' => $this->filter, |
| 149 | 149 | 'daywise' => True, |
| 150 | 150 | 'use_so_events' => $this->test === 'true', |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function week_number($time) |
| 172 | 172 | { |
| 173 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 173 | + if (!is_a($time, 'DateTime')) $time = new Api\DateTime($time); |
|
| 174 | 174 | |
| 175 | 175 | // if week does not start Monday and $time is Sunday --> add one day |
| 176 | 176 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * Load all views used by calendar, client side switches between them as needed |
| 190 | 190 | */ |
| 191 | - function index($content=array()) |
|
| 191 | + function index($content = array()) |
|
| 192 | 192 | { |
| 193 | - if($content['merge']) |
|
| 193 | + if ($content['merge']) |
|
| 194 | 194 | { |
| 195 | 195 | // View from sidebox is JSON encoded |
| 196 | - $this->manage_states(array_merge($content,json_decode($content['view'],true))); |
|
| 197 | - if($content['first']) |
|
| 196 | + $this->manage_states(array_merge($content, json_decode($content['view'], true))); |
|
| 197 | + if ($content['first']) |
|
| 198 | 198 | { |
| 199 | - $this->first = Api\DateTime::to($content['first'],'ts'); |
|
| 199 | + $this->first = Api\DateTime::to($content['first'], 'ts'); |
|
| 200 | 200 | } |
| 201 | - if($content['last']) |
|
| 201 | + if ($content['last']) |
|
| 202 | 202 | { |
| 203 | - $this->last = Api\DateTime::to($content['last'],'ts'); |
|
| 203 | + $this->last = Api\DateTime::to($content['last'], 'ts'); |
|
| 204 | 204 | } |
| 205 | 205 | $_GET['merge'] = $content['merge']; |
| 206 | 206 | $this->merge(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view)); |
| 217 | 217 | |
| 218 | 218 | // Sidebox & iframe for old views |
| 219 | - if(in_array($this->view,array('year')) && $_GET['view']) |
|
| 219 | + if (in_array($this->view, array('year')) && $_GET['view']) |
|
| 220 | 220 | { |
| 221 | 221 | $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
| 222 | 222 | $this->manage_states($_GET); |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | $tmpl = new Etemplate('calendar.toolbar'); |
| 229 | 229 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 230 | 230 | // Adjust toolbar for mobile |
| 231 | - if(Api\Header\UserAgent::mobile()){ |
|
| 232 | - $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
|
| 233 | - $tmpl->setElementAttribute('toolbar','view_range', '3'); |
|
| 231 | + if (Api\Header\UserAgent::mobile()) { |
|
| 232 | + $tmpl->setElementAttribute('toolbar', 'class', 'et2_head_toolbar'); |
|
| 233 | + $tmpl->setElementAttribute('toolbar', 'view_range', '3'); |
|
| 234 | 234 | } |
| 235 | - $tmpl->exec('calendar_uiviews::index',array()); |
|
| 235 | + $tmpl->exec('calendar_uiviews::index', array()); |
|
| 236 | 236 | |
| 237 | 237 | // Load the different views once, we'll switch between them on the client side |
| 238 | 238 | $todo = new Etemplate('calendar.todo'); |
| 239 | 239 | $label = ''; |
| 240 | - $todo->exec('calendar_uiviews::index',array('todos'=>'', 'label' => $label)); |
|
| 240 | + $todo->exec('calendar_uiviews::index', array('todos'=>'', 'label' => $label)); |
|
| 241 | 241 | |
| 242 | 242 | // Actually, this takes care of most of it... |
| 243 | 243 | $this->week(); |
| 244 | 244 | |
| 245 | 245 | $planner = new Etemplate('calendar.planner'); |
| 246 | 246 | // Get the actions |
| 247 | - $planner->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 248 | - $planner->exec('calendar_uiviews::index',array()); |
|
| 247 | + $planner->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 248 | + $planner->exec('calendar_uiviews::index', array()); |
|
| 249 | 249 | |
| 250 | 250 | // List view in a separate file |
| 251 | 251 | $list_ui = new calendar_uilist(); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | { |
| 388 | 388 | foreach (array_keys($actions) as $key) |
| 389 | 389 | { |
| 390 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 390 | + if (!in_array($key, array('day_view', 'week_view', 'next', 'today', 'previous'))) { |
|
| 391 | 391 | $actions[$key]['toolbarDefault'] = false; |
| 392 | 392 | } |
| 393 | 393 | else { |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
| 407 | 407 | */ |
| 408 | - function &planner($content = array(), $home=false) |
|
| 408 | + function &planner($content = array(), $home = false) |
|
| 409 | 409 | { |
| 410 | 410 | if ($this->sortby == 'month') // yearly planner with month rows |
| 411 | 411 | { |
@@ -414,17 +414,17 @@ discard block |
||
| 414 | 414 | unset($this->first['raw']); |
| 415 | 415 | $this->last = $this->first; |
| 416 | 416 | $this->last['year']++; |
| 417 | - $this->last = $this->bo->date2ts($this->last)-1; |
|
| 417 | + $this->last = $this->bo->date2ts($this->last) - 1; |
|
| 418 | 418 | } |
| 419 | 419 | elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
| 420 | 420 | { |
| 421 | 421 | if ($this->day < 15) // show one complete month |
| 422 | 422 | { |
| 423 | - $this->_week_align_month($this->first,$this->last); |
|
| 423 | + $this->_week_align_month($this->first, $this->last); |
|
| 424 | 424 | } |
| 425 | 425 | else // show 2 half month |
| 426 | 426 | { |
| 427 | - $this->_week_align_month($this->first,$this->last,15); |
|
| 427 | + $this->_week_align_month($this->first, $this->last, 15); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $start->setWeekstart(); |
| 434 | 434 | $this->first = $start->format('ts'); |
| 435 | 435 | $this->last = $this->bo->date2array($this->first); |
| 436 | - $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1; |
|
| 436 | + $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks']) - 1; |
|
| 437 | 437 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 438 | 438 | unset($this->last['raw']); |
| 439 | 439 | $this->last = $this->bo->date2ts($this->last); |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | $merge = $this->merge(); |
| 452 | - if($merge) |
|
| 452 | + if ($merge) |
|
| 453 | 453 | { |
| 454 | - Egw::redirect_link('/index.php',array( |
|
| 454 | + Egw::redirect_link('/index.php', array( |
|
| 455 | 455 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 456 | 456 | 'msg' => $merge, |
| 457 | 457 | 'ajax' => 'true' |
@@ -464,21 +464,21 @@ discard block |
||
| 464 | 464 | $search_params['end'] = $this->last; |
| 465 | 465 | $search_params['enum_groups'] = $this->sortby == 'user'; |
| 466 | 466 | $content['planner'] = $this->bo->search($search_params); |
| 467 | - foreach($content['planner'] as &$event) |
|
| 467 | + foreach ($content['planner'] as &$event) |
|
| 468 | 468 | { |
| 469 | 469 | $this->to_client($event); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 472 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3', False, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last)); |
|
| 473 | 473 | |
| 474 | 474 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 475 | 475 | |
| 476 | - $tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 477 | - $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 478 | - $tmpl->setElementAttribute('planner','owner', $search_params['users']); |
|
| 479 | - $tmpl->setElementAttribute('planner','group_by', $this->sortby); |
|
| 476 | + $tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 477 | + $tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 478 | + $tmpl->setElementAttribute('planner', 'owner', $search_params['users']); |
|
| 479 | + $tmpl->setElementAttribute('planner', 'group_by', $this->sortby); |
|
| 480 | 480 | // Get the actions |
| 481 | - $tmpl->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 481 | + $tmpl->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 482 | 482 | |
| 483 | 483 | $tmpl->exec(__METHOD__, $content); |
| 484 | 484 | } |
@@ -491,30 +491,30 @@ discard block |
||
| 491 | 491 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 492 | 492 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 493 | 493 | */ |
| 494 | - function &month($weeks=0,$home=false) |
|
| 494 | + function &month($weeks = 0, $home = false) |
|
| 495 | 495 | { |
| 496 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 496 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2', True, $weeks, $this->date); |
|
| 497 | 497 | |
| 498 | 498 | if (!$home) |
| 499 | 499 | { |
| 500 | - trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED); |
|
| 500 | + trigger_error(__METHOD__.' only used by home app', E_USER_DEPRECATED); |
|
| 501 | 501 | return; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 504 | + $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 505 | 505 | $granularity = 0; |
| 506 | - if($weeks) |
|
| 506 | + if ($weeks) |
|
| 507 | 507 | { |
| 508 | 508 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 509 | 509 | |
| 510 | 510 | $list = $this->cal_prefs['use_time_grid']; |
| 511 | - if(!is_array($list)) |
|
| 511 | + if (!is_array($list)) |
|
| 512 | 512 | { |
| 513 | - $list = explode(',',$list); |
|
| 513 | + $list = explode(',', $list); |
|
| 514 | 514 | } |
| 515 | - if(is_array($list)) |
|
| 515 | + if (is_array($list)) |
|
| 516 | 516 | { |
| 517 | - $granularity = in_array('weekN',$list) ? 0 : $granularity; |
|
| 517 | + $granularity = in_array('weekN', $list) ? 0 : $granularity; |
|
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | $content = array('view' => array()); |
@@ -524,23 +524,23 @@ discard block |
||
| 524 | 524 | $start = new Api\DateTime($this->date); |
| 525 | 525 | $start->setWeekstart(); |
| 526 | 526 | $this->first = $start->format('ts'); |
| 527 | - $this->last = strtotime("+$weeks weeks",$this->first) - 1; |
|
| 527 | + $this->last = strtotime("+$weeks weeks", $this->first) - 1; |
|
| 528 | 528 | $weekNavH = "$weeks weeks"; |
| 529 | 529 | $navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '. |
| 530 | - $this->bo->long_date($this->first,$this->last); |
|
| 530 | + $this->bo->long_date($this->first, $this->last); |
|
| 531 | 531 | } |
| 532 | 532 | else |
| 533 | 533 | { |
| 534 | - $this->_week_align_month($this->first,$this->last); |
|
| 534 | + $this->_week_align_month($this->first, $this->last); |
|
| 535 | 535 | $weekNavH = "1 month"; |
| 536 | - $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
|
| 536 | + $navHeader = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year; |
|
| 537 | 537 | } |
| 538 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 538 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4', False, $weeks, $this->date, $this->bo->date2string($this->first), $this->bo->date2string($this->last)); |
|
| 539 | 539 | |
| 540 | 540 | // Loop through, using Api\DateTime to handle DST |
| 541 | 541 | $week = 0; |
| 542 | 542 | $week_start = new EGroupware\Api\DateTime($this->first); |
| 543 | - $week_start->setTime(0,0,0); |
|
| 543 | + $week_start->setTime(0, 0, 0); |
|
| 544 | 544 | $week_end = new Api\DateTime($week_start); |
| 545 | 545 | $week_end->add(new DateInterval('P6DT23H59M59S')); |
| 546 | 546 | $last = new EGroupware\Api\DateTime($this->last); |
@@ -554,14 +554,14 @@ discard block |
||
| 554 | 554 | array( |
| 555 | 555 | 'id' => $week_start->format('Ymd') |
| 556 | 556 | ); |
| 557 | - $home->setElementAttribute("view[$week]",'onchange',false); |
|
| 558 | - $home->setElementAttribute("view[$week]",'granularity',$granularity); |
|
| 559 | - $home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']); |
|
| 557 | + $home->setElementAttribute("view[$week]", 'onchange', false); |
|
| 558 | + $home->setElementAttribute("view[$week]", 'granularity', $granularity); |
|
| 559 | + $home->setElementAttribute("view[$week]", 'show_weekend', $this->search_params['weekend']); |
|
| 560 | 560 | $week++; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // Get the actions |
| 564 | - $home->setElementAttribute('view','actions',$this->get_actions()); |
|
| 564 | + $home->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 565 | 565 | |
| 566 | 566 | $home->exec(__METHOD__, $content); |
| 567 | 567 | } |
@@ -573,13 +573,13 @@ discard block |
||
| 573 | 573 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 574 | 574 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 575 | 575 | */ |
| 576 | - function _week_align_month(&$first,&$last,$day=1) |
|
| 576 | + function _week_align_month(&$first, &$last, $day = 1) |
|
| 577 | 577 | { |
| 578 | 578 | $start = new Api\DateTime($this->date); |
| 579 | - $start->setDate($this->year,$this->month,$this->day=$day); |
|
| 579 | + $start->setDate($this->year, $this->month, $this->day = $day); |
|
| 580 | 580 | $start->setWeekstart(); |
| 581 | 581 | $first = $start->format('ts'); |
| 582 | - $start->setDate($this->year,$this->month+1,$day); |
|
| 582 | + $start->setDate($this->year, $this->month + 1, $day); |
|
| 583 | 583 | if ($day == 1) $start->add('-1day'); |
| 584 | 584 | $start->setWeekstart(); |
| 585 | 585 | // now we need to calculate the end of the last day of that week |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | $arr['day'] += 6; |
| 589 | 589 | $arr['hour'] = 23; |
| 590 | 590 | $arr['min'] = $arr['sec'] = 59; |
| 591 | - unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 591 | + unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 592 | 592 | $last = $this->bo->date2ts($arr); |
| 593 | 593 | } |
| 594 | 594 | |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 599 | 599 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 600 | 600 | */ |
| 601 | - function week($days=0,$home=false) |
|
| 601 | + function week($days = 0, $home = false) |
|
| 602 | 602 | { |
| 603 | 603 | if (!$days) |
| 604 | 604 | { |
@@ -606,17 +606,17 @@ discard block |
||
| 606 | 606 | if ($days != 5) $days = 7; |
| 607 | 607 | if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
| 608 | 608 | { |
| 609 | - $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
|
| 609 | + $GLOBALS['egw']->preferences->add('calendar', 'days_in_weekview', $days); |
|
| 610 | 610 | $GLOBALS['egw']->preferences->save_repository(); |
| 611 | 611 | $this->cal_prefs['days_in_weekview'] = $days; |
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 614 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2', True, $days, $this->date); |
|
| 615 | 615 | |
| 616 | 616 | if ($days <= 4) // next 4 days view |
| 617 | 617 | { |
| 618 | 618 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 619 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 619 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 620 | 620 | $view = $days == 1 ? 'day' : 'day4'; |
| 621 | 621 | } |
| 622 | 622 | else |
@@ -626,30 +626,30 @@ discard block |
||
| 626 | 626 | $wd_start = $this->first = $start->format('ts'); |
| 627 | 627 | if ($days <= 5) // no weekend-days |
| 628 | 628 | { |
| 629 | - switch($this->cal_prefs['weekdaystarts']) |
|
| 629 | + switch ($this->cal_prefs['weekdaystarts']) |
|
| 630 | 630 | { |
| 631 | 631 | case 'Saturday': |
| 632 | - $this->first = strtotime("+2 days",$this->first); |
|
| 632 | + $this->first = strtotime("+2 days", $this->first); |
|
| 633 | 633 | break; |
| 634 | 634 | case 'Sunday': |
| 635 | - $this->first = strtotime("+1 day",$this->first); |
|
| 635 | + $this->first = strtotime("+1 day", $this->first); |
|
| 636 | 636 | break; |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 639 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 640 | 640 | $view = 'week'; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 644 | 644 | |
| 645 | 645 | $list = $this->cal_prefs['use_time_grid']; |
| 646 | - if(!is_array($list)) |
|
| 646 | + if (!is_array($list)) |
|
| 647 | 647 | { |
| 648 | - $list = explode(',',$list); |
|
| 648 | + $list = explode(',', $list); |
|
| 649 | 649 | } |
| 650 | - if(is_array($list)) |
|
| 650 | + if (is_array($list)) |
|
| 651 | 651 | { |
| 652 | - $granularity = in_array($view,$list) ? 0 : $granularity; |
|
| 652 | + $granularity = in_array($view, $list) ? 0 : $granularity; |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | $search_params = array( |
@@ -662,15 +662,15 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | $content = array('view' => array()); |
| 664 | 664 | |
| 665 | - if(!$home) |
|
| 665 | + if (!$home) |
|
| 666 | 666 | { |
| 667 | 667 | // Fill with the minimum needed 'weeks' |
| 668 | 668 | $min = max( |
| 669 | 669 | 6, // Some months need 6 weeks for full display |
| 670 | - $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 670 | + $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 671 | 671 | $this->cal_prefs['week_consolidate'] // We collapse after this many users |
| 672 | 672 | ); |
| 673 | - for($i = 0; $i < $min; $i++) |
|
| 673 | + for ($i = 0; $i < $min; $i++) |
|
| 674 | 674 | { |
| 675 | 675 | $content['view'][] = array(); |
| 676 | 676 | } |
@@ -678,8 +678,8 @@ discard block |
||
| 678 | 678 | else |
| 679 | 679 | { |
| 680 | 680 | // Always do 7 days for a week so scrolling works properly |
| 681 | - $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
|
| 682 | - if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
|
| 681 | + $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days", $this->first) - 1); |
|
| 682 | + if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] || // for more then X users, show all in one row |
|
| 683 | 683 | $days == 1 // Showing just 1 day |
| 684 | 684 | ) |
| 685 | 685 | { |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | else |
| 690 | 690 | { |
| 691 | - foreach($users as $uid) |
|
| 691 | + foreach ($users as $uid) |
|
| 692 | 692 | { |
| 693 | 693 | $search_params['users'] = $uid; |
| 694 | 694 | $content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params)) |
@@ -696,15 +696,15 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | } |
| 699 | - $tmpl = $home ? $home :new Etemplate('calendar.view'); |
|
| 700 | - foreach(array_keys($content['view']) as $index) |
|
| 699 | + $tmpl = $home ? $home : new Etemplate('calendar.view'); |
|
| 700 | + foreach (array_keys($content['view']) as $index) |
|
| 701 | 701 | { |
| 702 | - $tmpl->setElementAttribute("view[$index]",'granularity',$granularity); |
|
| 703 | - $tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']); |
|
| 702 | + $tmpl->setElementAttribute("view[$index]", 'granularity', $granularity); |
|
| 703 | + $tmpl->setElementAttribute("view[$index]", 'show_weekend', $this->search_params['weekend']); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | // Get the actions |
| 707 | - $tmpl->setElementAttribute('view','actions',$this->get_actions()); |
|
| 707 | + $tmpl->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 708 | 708 | |
| 709 | 709 | $tmpl->exec(__METHOD__, $content); |
| 710 | 710 | } |
@@ -746,19 +746,19 @@ discard block |
||
| 746 | 746 | 'owner' => $this->owner // num. id of the user, not necessary current user |
| 747 | 747 | )); |
| 748 | 748 | |
| 749 | - if(is_array($todo_label)) |
|
| 749 | + if (is_array($todo_label)) |
|
| 750 | 750 | { |
| 751 | - list($label,$showall)=$todo_label; |
|
| 751 | + list($label, $showall) = $todo_label; |
|
| 752 | 752 | } |
| 753 | 753 | else |
| 754 | 754 | { |
| 755 | - $label=$todo_label; |
|
| 756 | - $showall=true; |
|
| 755 | + $label = $todo_label; |
|
| 756 | + $showall = true; |
|
| 757 | 757 | } |
| 758 | 758 | $maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
| 759 | - if($maxshow <= 0) |
|
| 759 | + if ($maxshow <= 0) |
|
| 760 | 760 | { |
| 761 | - $maxshow=10; |
|
| 761 | + $maxshow = 10; |
|
| 762 | 762 | } |
| 763 | 763 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
| 764 | 764 | |
@@ -766,31 +766,31 @@ discard block |
||
| 766 | 766 | $todo_list = array(); |
| 767 | 767 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
| 768 | 768 | { |
| 769 | - foreach($todos_from_hook as $todos) |
|
| 769 | + foreach ($todos_from_hook as $todos) |
|
| 770 | 770 | { |
| 771 | 771 | $i = 0; |
| 772 | 772 | if (is_array($todos)) |
| 773 | 773 | { |
| 774 | 774 | $todo_label = !empty($label) ? $label : lang("open ToDo's:"); |
| 775 | 775 | |
| 776 | - foreach($todos as &$todo) |
|
| 776 | + foreach ($todos as &$todo) |
|
| 777 | 777 | { |
| 778 | - if(!$showall && ($i++ > $maxshow)) |
|
| 778 | + if (!$showall && ($i++ > $maxshow)) |
|
| 779 | 779 | { |
| 780 | 780 | break; |
| 781 | 781 | } |
| 782 | 782 | $icons = ''; |
| 783 | - foreach($todo['icons'] as $name => $alt) |
|
| 783 | + foreach ($todo['icons'] as $name => $alt) |
|
| 784 | 784 | { |
| 785 | - $icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"'); |
|
| 785 | + $icons .= ($icons ? ' ' : '').Api\Html::image('infolog', $name, lang($alt), 'border="0" width="15" height="15"'); |
|
| 786 | 786 | } |
| 787 | 787 | $todo['icons'] = $icons; |
| 788 | - if($todo['edit']) { |
|
| 788 | + if ($todo['edit']) { |
|
| 789 | 789 | $todo['edit_size'] = $todo['edit']['size']; |
| 790 | 790 | unset($todo['edit']['size']); |
| 791 | - $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 792 | - $edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 793 | - $todo['edit'] = Framework::link('/index.php',$todo['edit'],true); |
|
| 791 | + $edit_icon_href = Api\Html::a_href($icons, $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 792 | + $edit_href = Api\Html::a_href($todo['title'], $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 793 | + $todo['edit'] = Framework::link('/index.php', $todo['edit'], true); |
|
| 794 | 794 | } |
| 795 | 795 | $todo_list[] = $todo; |
| 796 | 796 | } |
@@ -812,9 +812,9 @@ discard block |
||
| 812 | 812 | * @param int|string $id |
| 813 | 813 | * @return string |
| 814 | 814 | */ |
| 815 | - public static function integration_get_popup($app,$id) |
|
| 815 | + public static function integration_get_popup($app, $id) |
|
| 816 | 816 | { |
| 817 | - $app_data = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 817 | + $app_data = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 818 | 818 | |
| 819 | 819 | if (is_array($app_data) && isset($app_data['edit'])) |
| 820 | 820 | { |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | } |
| 825 | 825 | else |
| 826 | 826 | { |
| 827 | - $edit = Link::edit($app,$id,$popup_size); |
|
| 827 | + $edit = Link::edit($app, $id, $popup_size); |
|
| 828 | 828 | } |
| 829 | 829 | if ($edit) |
| 830 | 830 | { |
@@ -853,28 +853,28 @@ discard block |
||
| 853 | 853 | * @param array $event |
| 854 | 854 | * @return array |
| 855 | 855 | */ |
| 856 | - static function integration_get_icons($app,$id,$event) |
|
| 856 | + static function integration_get_icons($app, $id, $event) |
|
| 857 | 857 | { |
| 858 | 858 | $icons = array(); |
| 859 | 859 | if ($event['icons']) |
| 860 | 860 | { |
| 861 | - foreach(explode(',',$event['icons']) as $icon) |
|
| 861 | + foreach (explode(',', $event['icons']) as $icon) |
|
| 862 | 862 | { |
| 863 | - list($icon_app,$icon) = explode(':',$icon); |
|
| 864 | - if (Api\Image::find($icon_app,$icon)) |
|
| 863 | + list($icon_app, $icon) = explode(':', $icon); |
|
| 864 | + if (Api\Image::find($icon_app, $icon)) |
|
| 865 | 865 | { |
| 866 | - $icons[] = Api\Html::image($icon_app,$icon); |
|
| 866 | + $icons[] = Api\Html::image($icon_app, $icon); |
|
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | - $app_data = calendar_bo::integration_get_data($app,'icons'); |
|
| 870 | + $app_data = calendar_bo::integration_get_data($app, 'icons'); |
|
| 871 | 871 | if (is_null($app_data)) |
| 872 | 872 | { |
| 873 | - $icons[] = Api\Html::image($app,'navbar'); // use navbar icon |
|
| 873 | + $icons[] = Api\Html::image($app, 'navbar'); // use navbar icon |
|
| 874 | 874 | } |
| 875 | 875 | elseif ($app_data) |
| 876 | 876 | { |
| 877 | - $icons += (array)ExecMethod2($app_data,$id,$event); |
|
| 877 | + $icons += (array)ExecMethod2($app_data, $id, $event); |
|
| 878 | 878 | } |
| 879 | 879 | return $icons; |
| 880 | 880 | } |
@@ -897,22 +897,22 @@ discard block |
||
| 897 | 897 | unset($actions['select_all']); |
| 898 | 898 | |
| 899 | 899 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 900 | - foreach($actions as $id => &$action) |
|
| 900 | + foreach ($actions as $id => &$action) |
|
| 901 | 901 | { |
| 902 | - if($id=='add') continue; |
|
| 903 | - if(!$action['enabled']) |
|
| 902 | + if ($id == 'add') continue; |
|
| 903 | + if (!$action['enabled']) |
|
| 904 | 904 | { |
| 905 | 905 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
| 906 | 906 | } |
| 907 | 907 | } |
| 908 | 908 | $actions['add']['open'] = '{"app":"calendar","type":"add"}'; |
| 909 | - $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 909 | + $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 910 | 910 | $actions['copy']['open'] = '{"app": "calendar", "type": "edit", "extra": "cal_id=$id&action=copy"}'; |
| 911 | 911 | $actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 912 | 912 | $actions['print']['open'] = '{"app": "calendar", "type": "edit", "extra": "cal_id=$id&print=1"}'; |
| 913 | 913 | $actions['print']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 914 | 914 | |
| 915 | - foreach($actions['status']['children'] as $id => &$status) |
|
| 915 | + foreach ($actions['status']['children'] as $id => &$status) |
|
| 916 | 916 | { |
| 917 | 917 | $status = array( |
| 918 | 918 | 'id' => $id, |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | |
| 924 | 924 | if ($actions['filemanager']) |
| 925 | 925 | { |
| 926 | - $actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url']; |
|
| 926 | + $actions['filemanager']['url'] = '/index.php?'.$actions['filemanager']['url']; |
|
| 927 | 927 | $actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 928 | 928 | } |
| 929 | 929 | if ($actions['infolog_app']) |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | $action['onExecute'] = 'javaScript:app.calendar.action_merge'; |
| 938 | 938 | if (!empty($action['children'])) |
| 939 | 939 | { |
| 940 | - foreach($action['children'] as &$child) |
|
| 940 | + foreach ($action['children'] as &$child) |
|
| 941 | 941 | { |
| 942 | 942 | $set_execute($child); |
| 943 | 943 | } |
@@ -971,26 +971,26 @@ discard block |
||
| 971 | 971 | { |
| 972 | 972 | $start = $this->bo->date2array($event['start']); |
| 973 | 973 | $end = $this->bo->date2array($event['end']); |
| 974 | - if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 974 | + if (!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 975 | 975 | { |
| 976 | - if($event['non_blocking']) |
|
| 976 | + if ($event['non_blocking']) |
|
| 977 | 977 | { |
| 978 | - $dayEvents[$day][$num]['whole_day_on_top']=true; |
|
| 979 | - $this->whole_day_positions[$num]=($this->rowHeight*($num+2)); |
|
| 978 | + $dayEvents[$day][$num]['whole_day_on_top'] = true; |
|
| 979 | + $this->whole_day_positions[$num] = ($this->rowHeight * ($num + 2)); |
|
| 980 | 980 | $extraRowsToAdd++; |
| 981 | 981 | } |
| 982 | 982 | else |
| 983 | 983 | { |
| 984 | - $dayEvents[$day][$num]['whole_day']=true; |
|
| 984 | + $dayEvents[$day][$num]['whole_day'] = true; |
|
| 985 | 985 | } |
| 986 | 986 | } |
| 987 | 987 | $this->to_client($dayEvents[$day][$num]); |
| 988 | 988 | } |
| 989 | 989 | // check after every day if we have to increase $this->extraRows |
| 990 | - if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows) |
|
| 990 | + if (($this->extraRowsOriginal + $extraRowsToAdd) > $this->extraRows) |
|
| 991 | 991 | { |
| 992 | 992 | $this->remBotExtraRows = $extraRowsToAdd; |
| 993 | - $this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd); |
|
| 993 | + $this->extraRows = ($this->extraRowsOriginal + $extraRowsToAdd); |
|
| 994 | 994 | } |
| 995 | 995 | } |
| 996 | 996 | } |
@@ -11,6 +11,10 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | use EGroupware\Api; |
| 13 | 13 | |
| 14 | +/** |
|
| 15 | + * @param string $table |
|
| 16 | + * @param string $field |
|
| 17 | + */ |
|
| 14 | 18 | function calendar_v0_9_2to0_9_3update_owner($table, $field) |
| 15 | 19 | { |
| 16 | 20 | $GLOBALS['egw_setup']->oProc->query("select distinct($field) from $table"); |
@@ -2306,7 +2310,7 @@ discard block |
||
| 2306 | 2310 | * |
| 2307 | 2311 | * Also fix recurring events containing a reference to an other master, created when an exception is made a recurring event. |
| 2308 | 2312 | * |
| 2309 | - * @return type |
|
| 2313 | + * @return string |
|
| 2310 | 2314 | */ |
| 2311 | 2315 | function calendar_upgrade14_1() |
| 2312 | 2316 | { |
@@ -1909,7 +1909,7 @@ |
||
| 1909 | 1909 | WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1912 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1913 | 1913 | WHERE recur_interval=0',__LINE__,__FILE__); |
| 1914 | 1914 | |
| 1915 | 1915 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 34 | 34 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 35 | - $GLOBALS['egw_setup']->oProc->query("UPDATE $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 35 | + $GLOBALS['egw_setup']->oProc->query("update $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | $GLOBALS['egw_setup']->oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0)); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 189 | 189 | |
| 190 | 190 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry', |
| 191 | - Array( |
|
| 191 | + array( |
|
| 192 | 192 | 'fd' => array( |
| 193 | 193 | 'cal_id' => array('type' => 'auto', 'nullable' => false), |
| 194 | 194 | 'cal_owner' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry'); |
| 239 | 239 | |
| 240 | 240 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_user', |
| 241 | - Array( |
|
| 241 | + array( |
|
| 242 | 242 | 'fd' => array( |
| 243 | 243 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
| 244 | 244 | 'cal_login' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_user'); |
| 269 | 269 | |
| 270 | 270 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_repeats', |
| 271 | - Array( |
|
| 271 | + array( |
|
| 272 | 272 | 'fd' => array( |
| 273 | 273 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'default' => '0', 'nullable' => false), |
| 274 | 274 | 'cal_type' => array('type' => 'varchar', 'precision' => 20, 'default' => 'daily', 'nullable' => false), |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 313 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 313 | + $GLOBALS['egw_setup']->oProc->query("update {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 314 | 314 | |
| 315 | 315 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 316 | 316 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | // calendar_entry => phpgw_cal |
| 604 | 604 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal', |
| 605 | - Array( |
|
| 605 | + array( |
|
| 606 | 606 | 'fd' => array( |
| 607 | 607 | 'cal_id' => array('type' => 'auto', 'nullable' => False), |
| 608 | 608 | 'owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | // calendar_entry_repeats => phpgw_cal_repeats |
| 660 | 660 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 661 | - Array( |
|
| 661 | + array( |
|
| 662 | 662 | 'fd' => array( |
| 663 | 663 | 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
| 664 | 664 | 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | function calendar_upgrade0_9_11_003() |
| 732 | 732 | { |
| 733 | 733 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 734 | - Array( |
|
| 734 | + array( |
|
| 735 | 735 | 'fd' => array( |
| 736 | 736 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
| 737 | 737 | 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | $GLOBALS['egw_setup']->oProc->DropTable('phpgw_cal_holidays'); |
| 769 | 769 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 770 | - Array( |
|
| 770 | + array( |
|
| 771 | 771 | 'fd' => array( |
| 772 | 772 | 'hol_id' => array('type' => 'auto','nullable' => False), |
| 773 | 773 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | function calendar_upgrade0_9_13_003() |
| 855 | 855 | { |
| 856 | 856 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 857 | - Array( |
|
| 857 | + array( |
|
| 858 | 858 | 'fd' => array( |
| 859 | 859 | 'alarm_id' => array('type' => 'auto','nullable' => False), |
| 860 | 860 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | function calendar_upgrade0_9_13_005() |
| 890 | 890 | { |
| 891 | - $calendar_data = Array(); |
|
| 891 | + $calendar_data = array(); |
|
| 892 | 892 | $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
| 893 | 893 | while($GLOBALS['egw_setup']->oProc->next_record()) |
| 894 | 894 | { |
@@ -1428,13 +1428,18 @@ discard block |
||
| 1428 | 1428 | function calendar_upgrade1_0_1_008() |
| 1429 | 1429 | { |
| 1430 | 1430 | $config_data = Api\Config::read('calendar'); |
| 1431 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1431 | + if (isset($config_data['fields'])) |
|
| 1432 | + { |
|
| 1433 | + // old custom fields |
|
| 1432 | 1434 | { |
| 1433 | 1435 | $customfields = array(); |
| 1436 | + } |
|
| 1434 | 1437 | $order = 0; |
| 1435 | 1438 | foreach($config_data['fields'] as $name => $data) |
| 1436 | 1439 | { |
| 1437 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1440 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1441 | + { |
|
| 1442 | + // real not-disabled custom field |
|
| 1438 | 1443 | { |
| 1439 | 1444 | $customfields[substr($name,1)] = array( |
| 1440 | 1445 | 'type' => 'text', |
@@ -1443,6 +1448,7 @@ discard block |
||
| 1443 | 1448 | 'order' => ($order += 10), |
| 1444 | 1449 | ); |
| 1445 | 1450 | } |
| 1451 | + } |
|
| 1446 | 1452 | } |
| 1447 | 1453 | if (count($customfields)) |
| 1448 | 1454 | { |
@@ -2583,9 +2589,12 @@ discard block |
||
| 2583 | 2589 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2584 | 2590 | 'cal_user_type' => 'e', |
| 2585 | 2591 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2586 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2592 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2593 | + { |
|
| 2594 | + // order A, T, U, X |
|
| 2587 | 2595 | { |
| 2588 | 2596 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2597 | + } |
|
| 2589 | 2598 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2590 | 2599 | array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
| 2591 | 2600 | __LINE__, __FILE__, 'calendar'); |
@@ -2735,8 +2744,12 @@ discard block |
||
| 2735 | 2744 | function calendar_upgrade16_1_002() |
| 2736 | 2745 | { |
| 2737 | 2746 | // Explicitly add months as showing list of events, no times |
| 2738 | - $change = function($attr, $old_value, $owner) { |
|
| 2739 | - if($owner == Api\Preferences::FORCED_ID) return; |
|
| 2747 | + $change = function($attr, $old_value, $owner) |
|
| 2748 | + { |
|
| 2749 | + if($owner == Api\Preferences::FORCED_ID) |
|
| 2750 | + { |
|
| 2751 | + return; |
|
| 2752 | + } |
|
| 2740 | 2753 | if(is_array($old_value) && !in_array('month', $old_value)) |
| 2741 | 2754 | { |
| 2742 | 2755 | $old_value[] = 'month'; |
@@ -2758,8 +2771,13 @@ discard block |
||
| 2758 | 2771 | function calendar_upgrade17_1() |
| 2759 | 2772 | { |
| 2760 | 2773 | // Update birthdays as events preference from boolean |
| 2761 | - $change = function($attr, $old_value, $owner) { |
|
| 2762 | - if (!isset($old_value)) return null; // do not set anything, if nothing was set before |
|
| 2774 | + $change = function($attr, $old_value, $owner) |
|
| 2775 | + { |
|
| 2776 | + if (!isset($old_value)) |
|
| 2777 | + { |
|
| 2778 | + return null; |
|
| 2779 | + } |
|
| 2780 | + // do not set anything, if nothing was set before |
|
| 2763 | 2781 | return $old_value ? 'birthday' : 'none'; |
| 2764 | 2782 | }; |
| 2765 | 2783 | Api\Preferences::change_preference('calendar', 'birthdays_as_events', $change); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $owner[count($owner)] = $GLOBALS['egw_setup']->oProc->f($field); |
| 21 | 21 | } |
| 22 | - if($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'],'0.9.10pre4')) |
|
| 22 | + if ($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.10pre4')) |
|
| 23 | 23 | { |
| 24 | 24 | $acctstbl = 'accounts'; |
| 25 | 25 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $acctstbl = 'phpgw_accounts'; |
| 29 | 29 | } |
| 30 | - for($i=0;$i<count($owner);$i++) |
|
| 30 | + for ($i = 0; $i < count($owner); $i++) |
|
| 31 | 31 | { |
| 32 | 32 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->next_record(); |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | function calendar_upgrade0_9_3pre1() |
| 42 | 42 | { |
| 43 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by'); |
|
| 44 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login'); |
|
| 43 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry', 'cal_create_by'); |
|
| 44 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry_user', 'cal_login'); |
|
| 45 | 45 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3pre2'; |
| 46 | 46 | return $GLOBALS['setup_info']['calendar']['currentver']; |
| 47 | 47 | } |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | ) |
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__); |
|
| 211 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry', __LINE__, __FILE__); |
|
| 212 | 212 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 213 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 213 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 214 | 214 | { |
| 215 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 216 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 215 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 216 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 217 | 217 | { |
| 218 | 218 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 219 | 219 | $cal_owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
@@ -223,13 +223,13 @@ discard block |
||
| 223 | 223 | $cal_access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 224 | 224 | $cal_name = $GLOBALS['egw_setup']->oProc->f('cal_name'); |
| 225 | 225 | $cal_description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 226 | - $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),0,4))); |
|
| 227 | - $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),0,4))); |
|
| 228 | - $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 226 | + $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 0, 4))); |
|
| 227 | + $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 0, 4))); |
|
| 228 | + $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 229 | 229 | $db2->next_record(); |
| 230 | 230 | $cal_group = $db2->f('groups'); |
| 231 | 231 | $db2->query('INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) ' |
| 232 | - .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__); |
|
| 232 | + .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')", __LINE__, __FILE__); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -250,17 +250,17 @@ discard block |
||
| 250 | 250 | ) |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__); |
|
| 253 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user', __LINE__, __FILE__); |
|
| 254 | 254 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 255 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 255 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 256 | 256 | { |
| 257 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__); |
|
| 258 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 257 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id', __LINE__, __FILE__); |
|
| 258 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 259 | 259 | { |
| 260 | 260 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 261 | 261 | $cal_login = $GLOBALS['egw_setup']->oProc->f('cal_login'); |
| 262 | 262 | $cal_status = $GLOBALS['egw_setup']->oProc->f('cal_status'); |
| 263 | - $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')",__LINE__,__FILE__); |
|
| 263 | + $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')", __LINE__, __FILE__); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | ) |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__); |
|
| 286 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats', __LINE__, __FILE__); |
|
| 287 | 287 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 288 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 288 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 289 | 289 | { |
| 290 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__); |
|
| 291 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 290 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id', __LINE__, __FILE__); |
|
| 291 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 292 | 292 | { |
| 293 | 293 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 294 | 294 | $cal_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 295 | - if(isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 295 | + if (isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 296 | 296 | { |
| 297 | - $enddate = mktime(0,0,0,intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),0,4))); |
|
| 297 | + $enddate = mktime(0, 0, 0, intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 0, 4))); |
|
| 298 | 298 | $useend = 1; |
| 299 | 299 | } |
| 300 | 300 | else |
@@ -304,12 +304,12 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | $cal_frequency = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 306 | 306 | $cal_days = $GLOBALS['egw_setup']->oProc->f('cal_days'); |
| 307 | - $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__); |
|
| 307 | + $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')", __LINE__, __FILE__); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 312 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 312 | + $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'", __LINE__, __FILE__); |
|
| 313 | 313 | |
| 314 | 314 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 315 | 315 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -321,19 +321,19 @@ discard block |
||
| 321 | 321 | $db2 = $GLOBALS['egw_setup']->db; |
| 322 | 322 | |
| 323 | 323 | $GLOBALS['egw_setup']->oProc->RenameColumn('calendar_entry', 'cal_duration', 'cal_edatetime'); |
| 324 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 325 | - if($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 324 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 325 | + if ($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 326 | 326 | { |
| 327 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 327 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 328 | 328 | { |
| 329 | - $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'),__LINE__,__FILE__); |
|
| 329 | + $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'), __LINE__, __FILE__); |
|
| 330 | 330 | $db2->next_record(); |
| 331 | 331 | $tz = $db2->f('preference_value'); |
| 332 | 332 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 333 | 333 | $datetime = $GLOBALS['egw_setup']->oProc->f('cal_datetime') - ((60 * 60) * $tz); |
| 334 | 334 | $mdatetime = $GLOBALS['egw_setup']->oProc->f('cal_mdatetime') - ((60 * 60) * $tz); |
| 335 | 335 | $edatetime = $datetime + (60 * $GLOBALS['egw_setup']->oProc->f('cal_edatetime')); |
| 336 | - $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 336 | + $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
@@ -581,22 +581,22 @@ discard block |
||
| 581 | 581 | { |
| 582 | 582 | $db2 = $GLOBALS['egw_setup']->db; |
| 583 | 583 | |
| 584 | - if(extension_loaded('mcal') == False) |
|
| 584 | + if (extension_loaded('mcal') == False) |
|
| 585 | 585 | { |
| 586 | - define(RECUR_NONE,0); |
|
| 587 | - define(RECUR_DAILY,1); |
|
| 588 | - define(RECUR_WEEKLY,2); |
|
| 589 | - define(RECUR_MONTHLY_MDAY,3); |
|
| 590 | - define(RECUR_MONTHLY_WDAY,4); |
|
| 591 | - define(RECUR_YEARLY,5); |
|
| 592 | - |
|
| 593 | - define(M_SUNDAY,1); |
|
| 594 | - define(M_MONDAY,2); |
|
| 595 | - define(M_TUESDAY,4); |
|
| 596 | - define(M_WEDNESDAY,8); |
|
| 597 | - define(M_THURSDAY,16); |
|
| 598 | - define(M_FRIDAY,32); |
|
| 599 | - define(M_SATURDAY,64); |
|
| 586 | + define(RECUR_NONE, 0); |
|
| 587 | + define(RECUR_DAILY, 1); |
|
| 588 | + define(RECUR_WEEKLY, 2); |
|
| 589 | + define(RECUR_MONTHLY_MDAY, 3); |
|
| 590 | + define(RECUR_MONTHLY_WDAY, 4); |
|
| 591 | + define(RECUR_YEARLY, 5); |
|
| 592 | + |
|
| 593 | + define(M_SUNDAY, 1); |
|
| 594 | + define(M_MONDAY, 2); |
|
| 595 | + define(M_TUESDAY, 4); |
|
| 596 | + define(M_WEDNESDAY, 8); |
|
| 597 | + define(M_THURSDAY, 16); |
|
| 598 | + define(M_FRIDAY, 32); |
|
| 599 | + define(M_SATURDAY, 64); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | // calendar_entry => phpgw_cal |
@@ -623,13 +623,13 @@ discard block |
||
| 623 | 623 | ) |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry',__LINE__,__FILE__); |
|
| 627 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 626 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry', __LINE__, __FILE__); |
|
| 627 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 628 | 628 | { |
| 629 | 629 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 630 | 630 | $owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
| 631 | 631 | $access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 632 | - switch($access) |
|
| 632 | + switch ($access) |
|
| 633 | 633 | { |
| 634 | 634 | case 'private': |
| 635 | 635 | $is_public = 0; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 652 | 652 | |
| 653 | 653 | $db2->query("INSERT INTO phpgw_cal(cal_id,owner,groups,datetime,mdatetime,edatetime,priority,cal_type,is_public,title,description) " |
| 654 | - . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')",__LINE__,__FILE__); |
|
| 654 | + . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')", __LINE__, __FILE__); |
|
| 655 | 655 | } |
| 656 | 656 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry'); |
| 657 | 657 | |
@@ -659,12 +659,12 @@ discard block |
||
| 659 | 659 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 660 | 660 | Array( |
| 661 | 661 | 'fd' => array( |
| 662 | - 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 663 | - 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 664 | - 'recur_use_end' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 665 | - 'recur_enddate' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 666 | - 'recur_interval' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1'), |
|
| 667 | - 'recur_data' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1') |
|
| 662 | + 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 663 | + 'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 664 | + 'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 665 | + 'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 666 | + 'recur_interval' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1'), |
|
| 667 | + 'recur_data' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1') |
|
| 668 | 668 | ), |
| 669 | 669 | 'pk' => array(), |
| 670 | 670 | 'fk' => array(), |
@@ -672,12 +672,12 @@ discard block |
||
| 672 | 672 | 'uc' => array() |
| 673 | 673 | ) |
| 674 | 674 | ); |
| 675 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__); |
|
| 676 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 675 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats', __LINE__, __FILE__); |
|
| 676 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 677 | 677 | { |
| 678 | 678 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 679 | 679 | $recur_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 680 | - switch($recur_type) |
|
| 680 | + switch ($recur_type) |
|
| 681 | 681 | { |
| 682 | 682 | case 'daily': |
| 683 | 683 | $recur_type_num = RECUR_DAILY; |
@@ -700,20 +700,20 @@ discard block |
||
| 700 | 700 | $recur_interval = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 701 | 701 | $days = strtoupper($GLOBALS['egw_setup']->oProc->f('cal_days')); |
| 702 | 702 | $recur_data = 0; |
| 703 | - $recur_data += (substr($days,0,1)=='Y'?M_SUNDAY:0); |
|
| 704 | - $recur_data += (substr($days,1,1)=='Y'?M_MONDAY:0); |
|
| 705 | - $recur_data += (substr($days,2,1)=='Y'?M_TUESDAY:0); |
|
| 706 | - $recur_data += (substr($days,3,1)=='Y'?M_WEDNESDAY:0); |
|
| 707 | - $recur_data += (substr($days,4,1)=='Y'?M_THURSDAY:0); |
|
| 708 | - $recur_data += (substr($days,5,1)=='Y'?M_FRIDAY:0); |
|
| 709 | - $recur_data += (substr($days,6,1)=='Y'?M_SATURDAY:0); |
|
| 703 | + $recur_data += (substr($days, 0, 1) == 'Y' ?M_SUNDAY:0); |
|
| 704 | + $recur_data += (substr($days, 1, 1) == 'Y' ?M_MONDAY:0); |
|
| 705 | + $recur_data += (substr($days, 2, 1) == 'Y' ?M_TUESDAY:0); |
|
| 706 | + $recur_data += (substr($days, 3, 1) == 'Y' ?M_WEDNESDAY:0); |
|
| 707 | + $recur_data += (substr($days, 4, 1) == 'Y' ?M_THURSDAY:0); |
|
| 708 | + $recur_data += (substr($days, 5, 1) == 'Y' ?M_FRIDAY:0); |
|
| 709 | + $recur_data += (substr($days, 6, 1) == 'Y' ?M_SATURDAY:0); |
|
| 710 | 710 | $db2->query("INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_use_end,recur_enddate,recur_interval,recur_data) " |
| 711 | - . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)",__LINE__,__FILE__); |
|
| 711 | + . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)", __LINE__, __FILE__); |
|
| 712 | 712 | } |
| 713 | 713 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry_repeats'); |
| 714 | 714 | |
| 715 | 715 | // calendar_entry_user => phpgw_cal_user |
| 716 | - $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user','phpgw_cal_user'); |
|
| 716 | + $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user', 'phpgw_cal_user'); |
|
| 717 | 717 | |
| 718 | 718 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.002'; |
| 719 | 719 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -732,11 +732,11 @@ discard block |
||
| 732 | 732 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 733 | 733 | Array( |
| 734 | 734 | 'fd' => array( |
| 735 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 736 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 737 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 735 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 736 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 737 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 738 | 738 | ), |
| 739 | - 'pk' => array('locale','name'), |
|
| 739 | + 'pk' => array('locale', 'name'), |
|
| 740 | 740 | 'fk' => array(), |
| 741 | 741 | 'ix' => array(), |
| 742 | 742 | 'uc' => array() |
@@ -768,10 +768,10 @@ discard block |
||
| 768 | 768 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 769 | 769 | Array( |
| 770 | 770 | 'fd' => array( |
| 771 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 772 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 773 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 774 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 771 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 772 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 773 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 774 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 775 | 775 | ), |
| 776 | 776 | 'pk' => array('hol_id'), |
| 777 | 777 | 'fk' => array(), |
@@ -788,10 +788,10 @@ discard block |
||
| 788 | 788 | function calendar_upgrade0_9_11_007() |
| 789 | 789 | { |
| 790 | 790 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 791 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','mday',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 792 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','month_num',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 793 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','occurence',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 794 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','dow',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 791 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'mday', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 792 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'month_num', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 793 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'occurence', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 794 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'dow', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 795 | 795 | |
| 796 | 796 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.008'; |
| 797 | 797 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | function calendar_upgrade0_9_11_009() |
| 809 | 809 | { |
| 810 | 810 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 811 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','observance_rule',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 811 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'observance_rule', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 812 | 812 | |
| 813 | 813 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.010'; |
| 814 | 814 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | function calendar_upgrade0_9_13_002() |
| 845 | 845 | { |
| 846 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 846 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'reference', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 847 | 847 | |
| 848 | 848 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.003'; |
| 849 | 849 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 856 | 856 | Array( |
| 857 | 857 | 'fd' => array( |
| 858 | - 'alarm_id' => array('type' => 'auto','nullable' => False), |
|
| 858 | + 'alarm_id' => array('type' => 'auto', 'nullable' => False), |
|
| 859 | 859 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 860 | 860 | 'cal_owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 861 | 861 | 'cal_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -868,8 +868,8 @@ discard block |
||
| 868 | 868 | ) |
| 869 | 869 | ); |
| 870 | 870 | |
| 871 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','uid',array('type' => 'varchar', 'precision' => 255,'nullable' => False)); |
|
| 872 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','location',array('type' => 'varchar', 'precision' => 255,'nullable' => True)); |
|
| 871 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'uid', array('type' => 'varchar', 'precision' => 255, 'nullable' => False)); |
|
| 872 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'location', array('type' => 'varchar', 'precision' => 255, 'nullable' => True)); |
|
| 873 | 873 | |
| 874 | 874 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.004'; |
| 875 | 875 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | |
| 879 | 879 | function calendar_upgrade0_9_13_004() |
| 880 | 880 | { |
| 881 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm','alarm_enabled',array('type' => 'int', 'precision' => 4,'nullable' => False, 'default' => '1')); |
|
| 881 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm', 'alarm_enabled', array('type' => 'int', 'precision' => 4, 'nullable' => False, 'default' => '1')); |
|
| 882 | 882 | |
| 883 | 883 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.005'; |
| 884 | 884 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -888,18 +888,18 @@ discard block |
||
| 888 | 888 | function calendar_upgrade0_9_13_005() |
| 889 | 889 | { |
| 890 | 890 | $calendar_data = Array(); |
| 891 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
|
| 892 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 891 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal', __LINE__, __FILE__); |
|
| 892 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 893 | 893 | { |
| 894 | 894 | $calendar_data[$GLOBALS['egw_setup']->oProc->f('cal_id')] = $GLOBALS['egw_setup']->oProc->f('category'); |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','category',array('type' => 'varchar', 'precision' => 30,'nullable' => True)); |
|
| 897 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'category', array('type' => 'varchar', 'precision' => 30, 'nullable' => True)); |
|
| 898 | 898 | |
| 899 | 899 | @reset($calendar_data); |
| 900 | - while($calendar_data && list($cal_id,$category) = each($calendar_data)) |
|
| 900 | + while ($calendar_data && list($cal_id, $category) = each($calendar_data)) |
|
| 901 | 901 | { |
| 902 | - $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); |
|
| 902 | + $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id, __LINE__, __FILE__); |
|
| 903 | 903 | } |
| 904 | 904 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.006'; |
| 905 | 905 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | |
| 909 | 909 | function calendar_upgrade0_9_13_006() |
| 910 | 910 | { |
| 911 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_exception',array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 911 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats', 'recur_exception', array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 912 | 912 | |
| 913 | 913 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007'; |
| 914 | 914 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -918,20 +918,20 @@ discard block |
||
| 918 | 918 | |
| 919 | 919 | function calendar_upgrade0_9_13_007() |
| 920 | 920 | { |
| 921 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user','cal_type',array( |
|
| 921 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user', 'cal_type', array( |
|
| 922 | 922 | 'type' => 'varchar', |
| 923 | 923 | 'precision' => '1', |
| 924 | 924 | 'nullable' => False, |
| 925 | 925 | 'default' => 'u' |
| 926 | 926 | )); |
| 927 | 927 | |
| 928 | - $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra',array( |
|
| 928 | + $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra', array( |
|
| 929 | 929 | 'fd' => array( |
| 930 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 931 | - 'cal_extra_name' => array('type' => 'varchar','precision' => '40','nullable' => False), |
|
| 932 | - 'cal_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '') |
|
| 930 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 931 | + 'cal_extra_name' => array('type' => 'varchar', 'precision' => '40', 'nullable' => False), |
|
| 932 | + 'cal_extra_value' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '') |
|
| 933 | 933 | ), |
| 934 | - 'pk' => array('cal_id','cal_extra_name'), |
|
| 934 | + 'pk' => array('cal_id', 'cal_extra_name'), |
|
| 935 | 935 | 'fk' => array(), |
| 936 | 936 | 'ix' => array(), |
| 937 | 937 | 'uc' => array() |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | function calendar_upgrade0_9_16_001() |
| 949 | 949 | { |
| 950 | 950 | // this is to set the default as schema_proc was not setting an empty default |
| 951 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user','cal_type',array( |
|
| 951 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user', 'cal_type', array( |
|
| 952 | 952 | 'type' => 'varchar', |
| 953 | 953 | 'precision' => '1', |
| 954 | 954 | 'nullable' => False, |
@@ -965,15 +965,15 @@ discard block |
||
| 965 | 965 | |
| 966 | 966 | function calendar_upgrade0_9_16_002() |
| 967 | 967 | { |
| 968 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 968 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 969 | 969 | 'fd' => array( |
| 970 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 971 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 972 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 973 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 974 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 975 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 976 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 970 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 971 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 972 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 973 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 974 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 975 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 976 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 977 | 977 | ), |
| 978 | 978 | 'pk' => array(), |
| 979 | 979 | 'fk' => array(), |
@@ -989,14 +989,14 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | function calendar_upgrade0_9_16_003() |
| 991 | 991 | { |
| 992 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user',array( |
|
| 992 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user', array( |
|
| 993 | 993 | 'fd' => array( |
| 994 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 995 | - 'cal_login' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 996 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A'), |
|
| 997 | - 'cal_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u') |
|
| 994 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 995 | + 'cal_login' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 996 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A'), |
|
| 997 | + 'cal_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u') |
|
| 998 | 998 | ), |
| 999 | - 'pk' => array('cal_id','cal_login','cal_type'), |
|
| 999 | + 'pk' => array('cal_id', 'cal_login', 'cal_type'), |
|
| 1000 | 1000 | 'fk' => array(), |
| 1001 | 1001 | 'ix' => array(), |
| 1002 | 1002 | 'uc' => array() |
@@ -1010,16 +1010,16 @@ discard block |
||
| 1010 | 1010 | |
| 1011 | 1011 | function calendar_upgrade0_9_16_004() |
| 1012 | 1012 | { |
| 1013 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays',array( |
|
| 1013 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays', array( |
|
| 1014 | 1014 | 'fd' => array( |
| 1015 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 1016 | - 'locale' => array('type' => 'char','precision' => '2','nullable' => False), |
|
| 1017 | - 'name' => array('type' => 'varchar','precision' => '50','nullable' => False), |
|
| 1018 | - 'mday' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1019 | - 'month_num' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1020 | - 'occurence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1021 | - 'dow' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1022 | - 'observance_rule' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1015 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1016 | + 'locale' => array('type' => 'char', 'precision' => '2', 'nullable' => False), |
|
| 1017 | + 'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False), |
|
| 1018 | + 'mday' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1019 | + 'month_num' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1020 | + 'occurence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1021 | + 'dow' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1022 | + 'observance_rule' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1023 | 1023 | ), |
| 1024 | 1024 | 'pk' => array('hol_id'), |
| 1025 | 1025 | 'fk' => array(), |
@@ -1037,13 +1037,13 @@ discard block |
||
| 1037 | 1037 | { |
| 1038 | 1038 | // creates uid's for all entries which do not have unique ones, they are '[email protected]' |
| 1039 | 1039 | // very old entries even have an empty uid, see 0.9.16.006 update |
| 1040 | - $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'",__LINE__,__FILE__); |
|
| 1040 | + $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'", __LINE__, __FILE__); |
|
| 1041 | 1041 | while ($GLOBALS['egw_setup']->oProc->next_record()) |
| 1042 | 1042 | { |
| 1043 | 1043 | $config[$GLOBALS['egw_setup']->oProc->f(0)] = $GLOBALS['egw_setup']->oProc->f(1); |
| 1044 | 1044 | } |
| 1045 | 1045 | $GLOBALS['egw_setup']->oProc->query('UPDATE phpgw_cal SET uid='. |
| 1046 | - $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'),'cal_id', |
|
| 1046 | + $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'), 'cal_id', |
|
| 1047 | 1047 | $GLOBALS['egw_setup']->db->quote('-'.$config['install_id'].'@'. |
| 1048 | 1048 | ($config['mail_suffix'] ? $config['mail_suffix'] : 'local'))). |
| 1049 | 1049 | " WHERE uid LIKE '-@%' OR uid=''"); |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | function calendar_upgrade0_9_16_007() |
| 1067 | 1067 | { |
| 1068 | 1068 | // update the sequenzes for refreshed tables (postgres only) |
| 1069 | - $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays','hol_id'); |
|
| 1069 | + $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays', 'hol_id'); |
|
| 1070 | 1070 | |
| 1071 | 1071 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0'; |
| 1072 | 1072 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1076,19 +1076,19 @@ discard block |
||
| 1076 | 1076 | |
| 1077 | 1077 | function calendar_upgrade1_0_0() |
| 1078 | 1078 | { |
| 1079 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','uid','cal_uid'); |
|
| 1080 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','owner','cal_owner'); |
|
| 1081 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','category','cal_category'); |
|
| 1082 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','groups','cal_groups'); |
|
| 1083 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','datetime','cal_starttime'); |
|
| 1084 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','mdatetime','cal_modified'); |
|
| 1085 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','edatetime','cal_endtime'); |
|
| 1086 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','priority','cal_priority'); |
|
| 1087 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','is_public','cal_public'); |
|
| 1088 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','title','cal_title'); |
|
| 1089 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','description','cal_description'); |
|
| 1090 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','location','cal_location'); |
|
| 1091 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','reference','cal_reference'); |
|
| 1079 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'uid', 'cal_uid'); |
|
| 1080 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'owner', 'cal_owner'); |
|
| 1081 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'category', 'cal_category'); |
|
| 1082 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'groups', 'cal_groups'); |
|
| 1083 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'datetime', 'cal_starttime'); |
|
| 1084 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'mdatetime', 'cal_modified'); |
|
| 1085 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'edatetime', 'cal_endtime'); |
|
| 1086 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'priority', 'cal_priority'); |
|
| 1087 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'is_public', 'cal_public'); |
|
| 1088 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'title', 'cal_title'); |
|
| 1089 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'description', 'cal_description'); |
|
| 1090 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'location', 'cal_location'); |
|
| 1091 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'reference', 'cal_reference'); |
|
| 1092 | 1092 | |
| 1093 | 1093 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.001'; |
| 1094 | 1094 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1098,13 +1098,13 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | function calendar_upgrade1_0_0_001() |
| 1100 | 1100 | { |
| 1101 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','locale','hol_locale'); |
|
| 1102 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','name','hol_name'); |
|
| 1103 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','mday','hol_mday'); |
|
| 1104 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','month_num','hol_month_num'); |
|
| 1105 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','occurence','hol_occurence'); |
|
| 1106 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','dow','hol_dow'); |
|
| 1107 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','observance_rule','hol_observance_rule'); |
|
| 1101 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'locale', 'hol_locale'); |
|
| 1102 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'name', 'hol_name'); |
|
| 1103 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'mday', 'hol_mday'); |
|
| 1104 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'month_num', 'hol_month_num'); |
|
| 1105 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'occurence', 'hol_occurence'); |
|
| 1106 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'dow', 'hol_dow'); |
|
| 1107 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'observance_rule', 'hol_observance_rule'); |
|
| 1108 | 1108 | |
| 1109 | 1109 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.002'; |
| 1110 | 1110 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1114,8 +1114,8 @@ discard block |
||
| 1114 | 1114 | |
| 1115 | 1115 | function calendar_upgrade1_0_0_002() |
| 1116 | 1116 | { |
| 1117 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_login','cal_user_id'); |
|
| 1118 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_type','cal_user_type'); |
|
| 1117 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_login', 'cal_user_id'); |
|
| 1118 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_type', 'cal_user_type'); |
|
| 1119 | 1119 | |
| 1120 | 1120 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.003'; |
| 1121 | 1121 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | |
| 1126 | 1126 | function calendar_upgrade1_0_0_003() |
| 1127 | 1127 | { |
| 1128 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','cal_title',array( |
|
| 1128 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'cal_title', array( |
|
| 1129 | 1129 | 'type' => 'varchar', |
| 1130 | 1130 | 'precision' => '255', |
| 1131 | 1131 | 'nullable' => False, |
@@ -1140,15 +1140,15 @@ discard block |
||
| 1140 | 1140 | |
| 1141 | 1141 | function calendar_upgrade1_0_0_004() |
| 1142 | 1142 | { |
| 1143 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 1143 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 1144 | 1144 | 'fd' => array( |
| 1145 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1146 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1147 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1148 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1149 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1150 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1151 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1145 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1146 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1147 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1148 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1149 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1150 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1151 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1152 | 1152 | ), |
| 1153 | 1153 | 'pk' => array('cal_id'), |
| 1154 | 1154 | 'fk' => array(), |
@@ -1165,19 +1165,19 @@ discard block |
||
| 1165 | 1165 | function calendar_upgrade1_0_0_005() |
| 1166 | 1166 | { |
| 1167 | 1167 | // change prefix of all calendar tables to egw_ |
| 1168 | - foreach(array('cal_user','cal_repeats','cal_extra','cal_holidays','cal') as $name) |
|
| 1168 | + foreach (array('cal_user', 'cal_repeats', 'cal_extra', 'cal_holidays', 'cal') as $name) |
|
| 1169 | 1169 | { |
| 1170 | - $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name,'egw_'.$name); |
|
| 1170 | + $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name, 'egw_'.$name); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | // create new dates table, with content from the egw_cal table |
| 1174 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates',array( |
|
| 1174 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates', array( |
|
| 1175 | 1175 | 'fd' => array( |
| 1176 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1177 | - 'cal_start' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1178 | - 'cal_end' => array('type' => 'int','precision' => '8','nullable' => False) |
|
| 1176 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1177 | + 'cal_start' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1178 | + 'cal_end' => array('type' => 'int', 'precision' => '8', 'nullable' => False) |
|
| 1179 | 1179 | ), |
| 1180 | - 'pk' => array('cal_id','cal_start'), |
|
| 1180 | + 'pk' => array('cal_id', 'cal_start'), |
|
| 1181 | 1181 | 'fk' => array(), |
| 1182 | 1182 | 'ix' => array(), |
| 1183 | 1183 | 'uc' => array() |
@@ -1185,49 +1185,49 @@ discard block |
||
| 1185 | 1185 | $GLOBALS['egw_setup']->oProc->query("INSERT INTO egw_cal_dates SELECT cal_id,cal_starttime,cal_endtime FROM egw_cal"); |
| 1186 | 1186 | |
| 1187 | 1187 | // drop the fields transfered to the dates table |
| 1188 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1188 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1189 | 1189 | 'fd' => array( |
| 1190 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1191 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1192 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1193 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1194 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1195 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1196 | - 'cal_endtime' => array('type' => 'int','precision' => '8'), |
|
| 1197 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1198 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1199 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1200 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1190 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1191 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1192 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1193 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1194 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1195 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1196 | + 'cal_endtime' => array('type' => 'int', 'precision' => '8'), |
|
| 1197 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1198 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1199 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1200 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1201 | 1201 | 'cal_description' => array('type' => 'text'), |
| 1202 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1203 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1202 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1203 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1204 | 1204 | ), |
| 1205 | 1205 | 'pk' => array('cal_id'), |
| 1206 | 1206 | 'fk' => array(), |
| 1207 | 1207 | 'ix' => array(), |
| 1208 | 1208 | 'uc' => array() |
| 1209 | - ),'cal_starttime'); |
|
| 1210 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1209 | + ), 'cal_starttime'); |
|
| 1210 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1211 | 1211 | 'fd' => array( |
| 1212 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1213 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1214 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1215 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1216 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1217 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1218 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1219 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1220 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1221 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1212 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1213 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1214 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1215 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1216 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1217 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1218 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1219 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1220 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1221 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1222 | 1222 | 'cal_description' => array('type' => 'text'), |
| 1223 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1224 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1223 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1224 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1225 | 1225 | ), |
| 1226 | 1226 | 'pk' => array('cal_id'), |
| 1227 | 1227 | 'fk' => array(), |
| 1228 | 1228 | 'ix' => array(), |
| 1229 | 1229 | 'uc' => array() |
| 1230 | - ),'cal_endtime'); |
|
| 1230 | + ), 'cal_endtime'); |
|
| 1231 | 1231 | |
| 1232 | 1232 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.001'; |
| 1233 | 1233 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1243,15 +1243,15 @@ discard block |
||
| 1243 | 1243 | 'precision' => '8', |
| 1244 | 1244 | 'default' => '0' |
| 1245 | 1245 | ));*/ |
| 1246 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 1246 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 1247 | 1247 | 'fd' => array( |
| 1248 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1249 | - 'cal_recur_date' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1250 | - 'cal_user_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u'), |
|
| 1251 | - 'cal_user_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1252 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A') |
|
| 1248 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1249 | + 'cal_recur_date' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1250 | + 'cal_user_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u'), |
|
| 1251 | + 'cal_user_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1252 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A') |
|
| 1253 | 1253 | ), |
| 1254 | - 'pk' => array('cal_id','cal_recur_date','cal_user_type','cal_user_id'), |
|
| 1254 | + 'pk' => array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'), |
|
| 1255 | 1255 | 'fk' => array(), |
| 1256 | 1256 | 'ix' => array(), |
| 1257 | 1257 | 'uc' => array() |
@@ -1265,50 +1265,50 @@ discard block |
||
| 1265 | 1265 | |
| 1266 | 1266 | function calendar_upgrade1_0_1_002() |
| 1267 | 1267 | { |
| 1268 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1268 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1269 | 1269 | 'fd' => array( |
| 1270 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1271 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1272 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1273 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1274 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1275 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1276 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1277 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1278 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1270 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1271 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1272 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1273 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1274 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1275 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1276 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1277 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1278 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1279 | 1279 | 'cal_description' => array('type' => 'text'), |
| 1280 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1281 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1280 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1281 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1282 | 1282 | ), |
| 1283 | 1283 | 'pk' => array('cal_id'), |
| 1284 | 1284 | 'fk' => array(), |
| 1285 | 1285 | 'ix' => array(), |
| 1286 | 1286 | 'uc' => array() |
| 1287 | - ),'cal_type'); |
|
| 1288 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_owner',array( |
|
| 1287 | + ), 'cal_type'); |
|
| 1288 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_owner', array( |
|
| 1289 | 1289 | 'type' => 'int', |
| 1290 | 1290 | 'precision' => '4', |
| 1291 | 1291 | 'nullable' => False |
| 1292 | 1292 | )); |
| 1293 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_priority',array( |
|
| 1293 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_priority', array( |
|
| 1294 | 1294 | 'type' => 'int', |
| 1295 | 1295 | 'precision' => '2', |
| 1296 | 1296 | 'nullable' => False, |
| 1297 | 1297 | 'default' => '2' |
| 1298 | 1298 | )); |
| 1299 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_public',array( |
|
| 1299 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_public', array( |
|
| 1300 | 1300 | 'type' => 'int', |
| 1301 | 1301 | 'precision' => '2', |
| 1302 | 1302 | 'nullable' => False, |
| 1303 | 1303 | 'default' => '1' |
| 1304 | 1304 | )); |
| 1305 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_reference',array( |
|
| 1305 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_reference', array( |
|
| 1306 | 1306 | 'type' => 'int', |
| 1307 | 1307 | 'precision' => '4', |
| 1308 | 1308 | 'nullable' => False, |
| 1309 | 1309 | 'default' => '0' |
| 1310 | 1310 | )); |
| 1311 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_modifier',array( |
|
| 1311 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_modifier', array( |
|
| 1312 | 1312 | 'type' => 'int', |
| 1313 | 1313 | 'precision' => '4' |
| 1314 | 1314 | )); |
@@ -1321,36 +1321,36 @@ discard block |
||
| 1321 | 1321 | |
| 1322 | 1322 | function calendar_upgrade1_0_1_003() |
| 1323 | 1323 | { |
| 1324 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 1324 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 1325 | 1325 | 'fd' => array( |
| 1326 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1327 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1328 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1329 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1330 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1331 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1326 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1327 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1328 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1329 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1330 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1331 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1332 | 1332 | ), |
| 1333 | 1333 | 'pk' => array('cal_id'), |
| 1334 | 1334 | 'fk' => array(), |
| 1335 | 1335 | 'ix' => array(), |
| 1336 | 1336 | 'uc' => array() |
| 1337 | - ),'recur_use_end'); |
|
| 1338 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','cal_id',array( |
|
| 1337 | + ), 'recur_use_end'); |
|
| 1338 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'cal_id', array( |
|
| 1339 | 1339 | 'type' => 'int', |
| 1340 | 1340 | 'precision' => '4', |
| 1341 | 1341 | 'nullable' => False |
| 1342 | 1342 | )); |
| 1343 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_type',array( |
|
| 1343 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_type', array( |
|
| 1344 | 1344 | 'type' => 'int', |
| 1345 | 1345 | 'precision' => '2', |
| 1346 | 1346 | 'nullable' => False |
| 1347 | 1347 | )); |
| 1348 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_interval',array( |
|
| 1348 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_interval', array( |
|
| 1349 | 1349 | 'type' => 'int', |
| 1350 | 1350 | 'precision' => '2', |
| 1351 | 1351 | 'default' => '1' |
| 1352 | 1352 | )); |
| 1353 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_data',array( |
|
| 1353 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_data', array( |
|
| 1354 | 1354 | 'type' => 'int', |
| 1355 | 1355 | 'precision' => '2', |
| 1356 | 1356 | 'default' => '1' |
@@ -1364,13 +1364,13 @@ discard block |
||
| 1364 | 1364 | |
| 1365 | 1365 | function calendar_upgrade1_0_1_004() |
| 1366 | 1366 | { |
| 1367 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1367 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1368 | 1368 | 'type' => 'int', |
| 1369 | 1369 | 'precision' => '4', |
| 1370 | 1370 | 'nullable' => False, |
| 1371 | 1371 | 'default' => '0' |
| 1372 | 1372 | )); |
| 1373 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1373 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1374 | 1374 | 'type' => 'int', |
| 1375 | 1375 | 'precision' => '4', |
| 1376 | 1376 | 'nullable' => False, |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | |
| 1386 | 1386 | function calendar_upgrade1_0_1_005() |
| 1387 | 1387 | { |
| 1388 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_quantity',array( |
|
| 1388 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1389 | 1389 | 'type' => 'int', |
| 1390 | 1390 | 'precision' => '4', |
| 1391 | 1391 | 'default' => '1' |
@@ -1399,7 +1399,7 @@ discard block |
||
| 1399 | 1399 | |
| 1400 | 1400 | function calendar_upgrade1_0_1_006() |
| 1401 | 1401 | { |
| 1402 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_non_blocking',array( |
|
| 1402 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_non_blocking', array( |
|
| 1403 | 1403 | 'type' => 'int', |
| 1404 | 1404 | 'precision' => '2', |
| 1405 | 1405 | 'default' => '0' |
@@ -1413,9 +1413,9 @@ discard block |
||
| 1413 | 1413 | |
| 1414 | 1414 | function calendar_upgrade1_0_1_007() |
| 1415 | 1415 | { |
| 1416 | - $GLOBALS['egw_setup']->db->update('egw_cal_repeats',array('recur_exception' => null),array('recur_exception' => ''),__LINE__,__FILE__,'calendar'); |
|
| 1416 | + $GLOBALS['egw_setup']->db->update('egw_cal_repeats', array('recur_exception' => null), array('recur_exception' => ''), __LINE__, __FILE__, 'calendar'); |
|
| 1417 | 1417 | |
| 1418 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_exception',array( |
|
| 1418 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_exception', array( |
|
| 1419 | 1419 | 'type' => 'text' |
| 1420 | 1420 | )); |
| 1421 | 1421 | |
@@ -1432,11 +1432,11 @@ discard block |
||
| 1432 | 1432 | { |
| 1433 | 1433 | $customfields = array(); |
| 1434 | 1434 | $order = 0; |
| 1435 | - foreach($config_data['fields'] as $name => $data) |
|
| 1435 | + foreach ($config_data['fields'] as $name => $data) |
|
| 1436 | 1436 | { |
| 1437 | 1437 | if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
| 1438 | 1438 | { |
| 1439 | - $customfields[substr($name,1)] = array( |
|
| 1439 | + $customfields[substr($name, 1)] = array( |
|
| 1440 | 1440 | 'type' => 'text', |
| 1441 | 1441 | 'len' => $data['length'].($data['shown'] ? ','.$data['shown'] : ''), |
| 1442 | 1442 | 'label' => $data['name'], |
@@ -1459,38 +1459,38 @@ discard block |
||
| 1459 | 1459 | function calendar_upgrade1_0_1_009() |
| 1460 | 1460 | { |
| 1461 | 1461 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 1462 | - $GLOBALS['egw_setup']->db->select('egw_cal','DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date',"cal_groups != ''",__LINE__,__FILE__, |
|
| 1463 | - False,'','calendar',0,',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1464 | - while(($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1462 | + $GLOBALS['egw_setup']->db->select('egw_cal', 'DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date', "cal_groups != ''", __LINE__, __FILE__, |
|
| 1463 | + False, '', 'calendar', 0, ',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1464 | + while (($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1465 | 1465 | { |
| 1466 | 1466 | $row['cal_user_type'] = 'u'; |
| 1467 | - foreach(explode(',',$row['cal_groups']) as $group) |
|
| 1467 | + foreach (explode(',', $row['cal_groups']) as $group) |
|
| 1468 | 1468 | { |
| 1469 | 1469 | $row['cal_user_id'] = $group; |
| 1470 | - $db2->insert('egw_cal_user',array('cal_status' => 'U'),$row,__LINE__,__FILE__,'calendar'); |
|
| 1470 | + $db2->insert('egw_cal_user', array('cal_status' => 'U'), $row, __LINE__, __FILE__, 'calendar'); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | } |
| 1473 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1473 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1474 | 1474 | 'fd' => array( |
| 1475 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1476 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1477 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1478 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1479 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1480 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1481 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1482 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1475 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1476 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1477 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1478 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1479 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1480 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1481 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1482 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1483 | 1483 | 'cal_description' => array('type' => 'text'), |
| 1484 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1485 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1486 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1487 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0') |
|
| 1484 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1485 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1486 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1487 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0') |
|
| 1488 | 1488 | ), |
| 1489 | 1489 | 'pk' => array('cal_id'), |
| 1490 | 1490 | 'fk' => array(), |
| 1491 | 1491 | 'ix' => array(), |
| 1492 | 1492 | 'uc' => array() |
| 1493 | - ),'cal_groups'); |
|
| 1493 | + ), 'cal_groups'); |
|
| 1494 | 1494 | |
| 1495 | 1495 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2'; |
| 1496 | 1496 | } |
@@ -1500,7 +1500,7 @@ discard block |
||
| 1500 | 1500 | function calendar_upgrade1_2() |
| 1501 | 1501 | { |
| 1502 | 1502 | // get old alarms (saved before 1.2) working again |
| 1503 | - $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'",__LINE__,__FILE__); |
|
| 1503 | + $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'", __LINE__, __FILE__); |
|
| 1504 | 1504 | |
| 1505 | 1505 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2.001'; |
| 1506 | 1506 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | |
| 1509 | 1509 | function calendar_upgrade1_2_001() |
| 1510 | 1510 | { |
| 1511 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_special',array( |
|
| 1511 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_special', array( |
|
| 1512 | 1512 | 'type' => 'int', |
| 1513 | 1513 | 'precision' => '2', |
| 1514 | 1514 | 'default' => '0' |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | |
| 1527 | 1527 | function calendar_upgrade1_4() |
| 1528 | 1528 | { |
| 1529 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_etag',array( |
|
| 1529 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_etag', array( |
|
| 1530 | 1530 | 'type' => 'int', |
| 1531 | 1531 | 'precision' => '4', |
| 1532 | 1532 | 'default' => '0' |
@@ -1538,59 +1538,59 @@ discard block |
||
| 1538 | 1538 | |
| 1539 | 1539 | function calendar_upgrade1_5() |
| 1540 | 1540 | { |
| 1541 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1541 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1542 | 1542 | 'fd' => array( |
| 1543 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1544 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1545 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1546 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1547 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1548 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1549 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1550 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1543 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1544 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1545 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1546 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1547 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1548 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1549 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1550 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1551 | 1551 | 'cal_description' => array('type' => 'text'), |
| 1552 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1553 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1554 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1555 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1556 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1557 | - 'cal_etag' => array('type' => 'int','precision' => '4'), |
|
| 1558 | - 'cal_edit_time' => array('type' => 'int','precision' => '8') |
|
| 1552 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1553 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1554 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1555 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1556 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1557 | + 'cal_etag' => array('type' => 'int', 'precision' => '4'), |
|
| 1558 | + 'cal_edit_time' => array('type' => 'int', 'precision' => '8') |
|
| 1559 | 1559 | ), |
| 1560 | 1560 | 'pk' => array('cal_id'), |
| 1561 | 1561 | 'fk' => array(), |
| 1562 | 1562 | 'ix' => array(), |
| 1563 | 1563 | 'uc' => array() |
| 1564 | - ),'cal_edit_user'); |
|
| 1565 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1564 | + ), 'cal_edit_user'); |
|
| 1565 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1566 | 1566 | 'fd' => array( |
| 1567 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1568 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1569 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1570 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1571 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1572 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1573 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1574 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1567 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1568 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1569 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1570 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1571 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1572 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1573 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1574 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1575 | 1575 | 'cal_description' => array('type' => 'text'), |
| 1576 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1577 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1578 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1579 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1580 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1581 | - 'cal_etag' => array('type' => 'int','precision' => '4') |
|
| 1576 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1577 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1578 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1579 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1580 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1581 | + 'cal_etag' => array('type' => 'int', 'precision' => '4') |
|
| 1582 | 1582 | ), |
| 1583 | 1583 | 'pk' => array('cal_id'), |
| 1584 | 1584 | 'fk' => array(), |
| 1585 | 1585 | 'ix' => array(), |
| 1586 | 1586 | 'uc' => array() |
| 1587 | - ),'cal_edit_time'); |
|
| 1588 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_etag',array( |
|
| 1587 | + ), 'cal_edit_time'); |
|
| 1588 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_etag', array( |
|
| 1589 | 1589 | 'type' => 'int', |
| 1590 | 1590 | 'precision' => '4', |
| 1591 | 1591 | 'default' => '0' |
| 1592 | 1592 | )); |
| 1593 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL',__LINE__,__FILE__); |
|
| 1593 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL', __LINE__, __FILE__); |
|
| 1594 | 1594 | |
| 1595 | 1595 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.5.001'; |
| 1596 | 1596 | } |
@@ -1598,12 +1598,12 @@ discard block |
||
| 1598 | 1598 | |
| 1599 | 1599 | function calendar_upgrade1_5_001() |
| 1600 | 1600 | { |
| 1601 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1601 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1602 | 1602 | 'type' => 'int', |
| 1603 | 1603 | 'precision' => '4', |
| 1604 | 1604 | 'nullable' => False |
| 1605 | 1605 | )); |
| 1606 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1606 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1607 | 1607 | 'type' => 'varchar', |
| 1608 | 1608 | 'precision' => '128', |
| 1609 | 1609 | 'nullable' => False |
@@ -1617,12 +1617,12 @@ discard block |
||
| 1617 | 1617 | { |
| 1618 | 1618 | // update the alarm methods |
| 1619 | 1619 | $async = new Api\Asyncservice(); |
| 1620 | - foreach((array)$async->read('cal:%') as $job) |
|
| 1620 | + foreach ((array)$async->read('cal:%') as $job) |
|
| 1621 | 1621 | { |
| 1622 | 1622 | if ($job['method'] == 'calendar.bocalupdate.send_alarm') |
| 1623 | 1623 | { |
| 1624 | 1624 | $job['method'] = 'calendar.calendar_boupdate.send_alarm'; |
| 1625 | - $async->write($job,true); |
|
| 1625 | + $async->write($job, true); |
|
| 1626 | 1626 | } |
| 1627 | 1627 | } |
| 1628 | 1628 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.6'; |
@@ -1639,48 +1639,48 @@ discard block |
||
| 1639 | 1639 | { |
| 1640 | 1640 | // Set UID of series exception to UID of series master |
| 1641 | 1641 | // update cal_etag, cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1642 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1642 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1643 | 1643 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1644 | 1644 | FROM egw_cal cal_ex |
| 1645 | 1645 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1646 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1646 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1647 | 1647 | { |
| 1648 | 1648 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1649 | 1649 | { |
| 1650 | 1650 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1651 | 1651 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1652 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1652 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1653 | 1653 | } |
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | // Search series exception for nearest exception in series master and add that RECURRENCE-ID |
| 1657 | 1657 | // as cal_reference (for 1.6.003 and move it to new field cal_recurrence in 1.7.001) |
| 1658 | 1658 | $diff = null; |
| 1659 | - foreach($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1659 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1660 | 1660 | JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id |
| 1661 | 1661 | JOIN egw_cal_repeats ON cal_reference=egw_cal_repeats.cal_id |
| 1662 | - WHERE cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1662 | + WHERE cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1663 | 1663 | { |
| 1664 | 1664 | $recurrence = null; |
| 1665 | - foreach(explode(',',$row['recur_exception']) as $ts) |
|
| 1665 | + foreach (explode(',', $row['recur_exception']) as $ts) |
|
| 1666 | 1666 | { |
| 1667 | - if (is_null($recurrence) || abs($ts-$row['cal_start']) < $diff) |
|
| 1667 | + if (is_null($recurrence) || abs($ts - $row['cal_start']) < $diff) |
|
| 1668 | 1668 | { |
| 1669 | 1669 | $recurrence = $ts; |
| 1670 | - $diff = abs($ts-$row['cal_start']); |
|
| 1670 | + $diff = abs($ts - $row['cal_start']); |
|
| 1671 | 1671 | } |
| 1672 | 1672 | } |
| 1673 | 1673 | if ($recurrence) |
| 1674 | 1674 | { |
| 1675 | 1675 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$recurrence. |
| 1676 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1676 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | else |
| 1679 | 1679 | { |
| 1680 | 1680 | // if we cannot determine the RECURRENCE-ID use cal_start |
| 1681 | 1681 | // because RECURRENCE-ID must be present |
| 1682 | 1682 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$row['cal_start']. |
| 1683 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1683 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1684 | 1684 | } |
| 1685 | 1685 | } |
| 1686 | 1686 | |
@@ -1695,33 +1695,33 @@ discard block |
||
| 1695 | 1695 | */ |
| 1696 | 1696 | function calendar_upgrade1_6_003() |
| 1697 | 1697 | { |
| 1698 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_creator',array( |
|
| 1698 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_creator', array( |
|
| 1699 | 1699 | 'type' => 'int', |
| 1700 | 1700 | 'precision' => '4', |
| 1701 | 1701 | 'comment' => 'creating user' |
| 1702 | 1702 | )); |
| 1703 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner',__LINE__,__FILE__); |
|
| 1704 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_creator',array( |
|
| 1703 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner', __LINE__, __FILE__); |
|
| 1704 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_creator', array( |
|
| 1705 | 1705 | 'type' => 'int', |
| 1706 | 1706 | 'precision' => '4', |
| 1707 | 1707 | 'nullable' => False, |
| 1708 | 1708 | 'comment' => 'creating user' |
| 1709 | 1709 | )); |
| 1710 | 1710 | |
| 1711 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_created',array( |
|
| 1711 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_created', array( |
|
| 1712 | 1712 | 'type' => 'int', |
| 1713 | 1713 | 'precision' => '8', |
| 1714 | 1714 | 'comment' => 'creation time of event' |
| 1715 | 1715 | )); |
| 1716 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified',__LINE__,__FILE__); |
|
| 1717 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_created',array( |
|
| 1716 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified', __LINE__, __FILE__); |
|
| 1717 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_created', array( |
|
| 1718 | 1718 | 'type' => 'int', |
| 1719 | 1719 | 'precision' => '8', |
| 1720 | 1720 | 'nullable' => False, |
| 1721 | 1721 | 'comment' => 'creation time of event' |
| 1722 | 1722 | )); |
| 1723 | 1723 | |
| 1724 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_recurrence',array( |
|
| 1724 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_recurrence', array( |
|
| 1725 | 1725 | 'type' => 'int', |
| 1726 | 1726 | 'precision' => '8', |
| 1727 | 1727 | 'nullable' => False, |
@@ -1732,14 +1732,14 @@ discard block |
||
| 1732 | 1732 | // move RECURRENCE-ID from temporarily (1.6.003) |
| 1733 | 1733 | // used field cal_reference to new field cal_recurrence |
| 1734 | 1734 | // and restore cal_reference field of series exceptions with id of the series master |
| 1735 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1735 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1736 | 1736 | SELECT cal_ex.cal_id AS cal_id_ex,cal_master.cal_id AS cal_id_master, |
| 1737 | 1737 | cal_ex.cal_reference AS cal_reference_ex,cal_ex.cal_uid AS cal_uid_ex, |
| 1738 | 1738 | cal_master.cal_uid AS cal_uid_master |
| 1739 | 1739 | FROM egw_cal cal_ex |
| 1740 | 1740 | JOIN egw_cal cal_master |
| 1741 | 1741 | ON cal_ex.cal_uid=cal_master.cal_uid AND cal_master.cal_reference = 0 AND cal_ex.cal_owner = cal_master.cal_owner |
| 1742 | - WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__,__FILE__) as $row) |
|
| 1742 | + WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__, __FILE__) as $row) |
|
| 1743 | 1743 | { |
| 1744 | 1744 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_recurrence='.(int)$row['cal_reference_ex']. |
| 1745 | 1745 | ', cal_reference='.(int)$row['cal_id_master']. |
@@ -1756,7 +1756,7 @@ discard block |
||
| 1756 | 1756 | */ |
| 1757 | 1757 | function calendar_upgrade1_7_001() |
| 1758 | 1758 | { |
| 1759 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_role',array( |
|
| 1759 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_role', array( |
|
| 1760 | 1760 | 'type' => 'varchar', |
| 1761 | 1761 | 'precision' => '64', |
| 1762 | 1762 | 'default' => 'REQ-PARTICIPANT' |
@@ -1772,14 +1772,14 @@ discard block |
||
| 1772 | 1772 | */ |
| 1773 | 1773 | function calendar_upgrade1_7_002() |
| 1774 | 1774 | { |
| 1775 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones',array( |
|
| 1775 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones', array( |
|
| 1776 | 1776 | 'fd' => array( |
| 1777 | - 'tz_id' => array('type' => 'auto','nullable' => False), |
|
| 1778 | - 'tz_tzid' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
| 1779 | - 'tz_alias' => array('type' => 'int','precision' => '4','comment' => 'tz_id for data'), |
|
| 1780 | - 'tz_latitude' => array('type' => 'int','precision' => '4'), |
|
| 1781 | - 'tz_longitude' => array('type' => 'int','precision' => '4'), |
|
| 1782 | - 'tz_component' => array('type' => 'text','comment' => 'iCal VTIMEZONE component') |
|
| 1777 | + 'tz_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1778 | + 'tz_tzid' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
| 1779 | + 'tz_alias' => array('type' => 'int', 'precision' => '4', 'comment' => 'tz_id for data'), |
|
| 1780 | + 'tz_latitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1781 | + 'tz_longitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1782 | + 'tz_component' => array('type' => 'text', 'comment' => 'iCal VTIMEZONE component') |
|
| 1783 | 1783 | ), |
| 1784 | 1784 | 'pk' => array('tz_id'), |
| 1785 | 1785 | 'fk' => array(), |
@@ -1799,38 +1799,38 @@ discard block |
||
| 1799 | 1799 | */ |
| 1800 | 1800 | function calendar_upgrade1_7_003() |
| 1801 | 1801 | { |
| 1802 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_type',array( |
|
| 1802 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_type', array( |
|
| 1803 | 1803 | 'type' => 'varchar', |
| 1804 | 1804 | 'precision' => '1', |
| 1805 | 1805 | 'nullable' => False, |
| 1806 | 1806 | 'default' => 'u', |
| 1807 | 1807 | 'comment' => 'u=user, g=group, c=contact, r=resource, e=email' |
| 1808 | 1808 | )); |
| 1809 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1809 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1810 | 1810 | 'type' => 'varchar', |
| 1811 | 1811 | 'precision' => '128', |
| 1812 | 1812 | 'nullable' => False, |
| 1813 | 1813 | 'comment' => 'id or email-address for type=e' |
| 1814 | 1814 | )); |
| 1815 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_status',array( |
|
| 1815 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_status', array( |
|
| 1816 | 1816 | 'type' => 'char', |
| 1817 | 1817 | 'precision' => '1', |
| 1818 | 1818 | 'default' => 'A', |
| 1819 | 1819 | 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative' |
| 1820 | 1820 | )); |
| 1821 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_quantity',array( |
|
| 1821 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1822 | 1822 | 'type' => 'int', |
| 1823 | 1823 | 'precision' => '4', |
| 1824 | 1824 | 'default' => '1', |
| 1825 | 1825 | 'comment' => 'only for certain types (eg. resources)' |
| 1826 | 1826 | )); |
| 1827 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_role',array( |
|
| 1827 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_role', array( |
|
| 1828 | 1828 | 'type' => 'varchar', |
| 1829 | 1829 | 'precision' => '64', |
| 1830 | 1830 | 'default' => 'REQ-PARTICIPANT', |
| 1831 | 1831 | 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id' |
| 1832 | 1832 | )); |
| 1833 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_modified',array( |
|
| 1833 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_modified', array( |
|
| 1834 | 1834 | 'type' => 'timestamp', |
| 1835 | 1835 | 'default' => 'current_timestamp', |
| 1836 | 1836 | 'comment' => 'automatic timestamp of last update' |
@@ -1846,19 +1846,19 @@ discard block |
||
| 1846 | 1846 | */ |
| 1847 | 1847 | function calendar_upgrade1_7_004() |
| 1848 | 1848 | { |
| 1849 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_start',array( |
|
| 1849 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_start', array( |
|
| 1850 | 1850 | 'type' => 'int', |
| 1851 | 1851 | 'precision' => '8', |
| 1852 | 1852 | 'nullable' => False, |
| 1853 | 1853 | 'comment' => 'starttime in server time' |
| 1854 | 1854 | )); |
| 1855 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_end',array( |
|
| 1855 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_end', array( |
|
| 1856 | 1856 | 'type' => 'int', |
| 1857 | 1857 | 'precision' => '8', |
| 1858 | 1858 | 'nullable' => False, |
| 1859 | 1859 | 'comment' => 'endtime in server time' |
| 1860 | 1860 | )); |
| 1861 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','tz_id',array( |
|
| 1861 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'tz_id', array( |
|
| 1862 | 1862 | 'type' => 'int', |
| 1863 | 1863 | 'precision' => '4', |
| 1864 | 1864 | 'comment' => 'key into egw_cal_timezones' |
@@ -1867,7 +1867,7 @@ discard block |
||
| 1867 | 1867 | // set id of server timezone for existing events, as that's the timezone their recurrences are using |
| 1868 | 1868 | if (($tzid = date_default_timezone_get()) && ($tz_id = calendar_timezones::tz2id($tzid))) |
| 1869 | 1869 | { |
| 1870 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id,__LINE__,__FILE__); |
|
| 1870 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id, __LINE__, __FILE__); |
|
| 1871 | 1871 | } |
| 1872 | 1872 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.005'; |
| 1873 | 1873 | } |
@@ -1894,22 +1894,22 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | function calendar_upgrade1_7_006() |
| 1896 | 1896 | { |
| 1897 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1898 | - WHERE (cal_end-cal_start)%86400=86340',__LINE__,__FILE__) as $row) |
|
| 1897 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1898 | + WHERE (cal_end-cal_start)%86400=86340',__LINE__, __FILE__) as $row) |
|
| 1899 | 1899 | { |
| 1900 | 1900 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end+59 |
| 1901 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1901 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1902 | 1902 | } |
| 1903 | 1903 | |
| 1904 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1905 | - WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__,__FILE__) as $row) |
|
| 1904 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1905 | + WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__, __FILE__) as $row) |
|
| 1906 | 1906 | { |
| 1907 | 1907 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end-1 |
| 1908 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1908 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | 1911 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
| 1912 | - WHERE recur_interval=0',__LINE__,__FILE__); |
|
| 1912 | + WHERE recur_interval=0',__LINE__, __FILE__); |
|
| 1913 | 1913 | |
| 1914 | 1914 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
| 1915 | 1915 | } |
@@ -1925,17 +1925,17 @@ discard block |
||
| 1925 | 1925 | { |
| 1926 | 1926 | // Set UID of series exception to UID of series master |
| 1927 | 1927 | // update cal_etag,cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1928 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1928 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1929 | 1929 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1930 | 1930 | FROM egw_cal cal_ex |
| 1931 | 1931 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1932 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1932 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1933 | 1933 | { |
| 1934 | 1934 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1935 | 1935 | { |
| 1936 | 1936 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1937 | 1937 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1938 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1938 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1939 | 1939 | } |
| 1940 | 1940 | } |
| 1941 | 1941 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.008'; |
@@ -1948,7 +1948,7 @@ discard block |
||
| 1948 | 1948 | */ |
| 1949 | 1949 | function calendar_upgrade1_7_008() |
| 1950 | 1950 | { |
| 1951 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user',array('cal_user_type','cal_user_id')); |
|
| 1951 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', array('cal_user_type', 'cal_user_id')); |
|
| 1952 | 1952 | |
| 1953 | 1953 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.009'; |
| 1954 | 1954 | } |
@@ -1960,22 +1960,22 @@ discard block |
||
| 1960 | 1960 | */ |
| 1961 | 1961 | function calendar_upgrade1_7_009() |
| 1962 | 1962 | { |
| 1963 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_uid'); |
|
| 1964 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_owner'); |
|
| 1963 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_uid'); |
|
| 1964 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_owner'); |
|
| 1965 | 1965 | |
| 1966 | 1966 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010'; |
| 1967 | 1967 | } |
| 1968 | 1968 | |
| 1969 | 1969 | function calendar_upgrade1_7_010() |
| 1970 | 1970 | { |
| 1971 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_deleted',array( |
|
| 1971 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_deleted', array( |
|
| 1972 | 1972 | 'type' => 'bool', |
| 1973 | 1973 | 'nullable' => False, |
| 1974 | 1974 | 'default' => '0', |
| 1975 | 1975 | 'comment' => '1 if the event has been deleted, but you want to keep it around' |
| 1976 | 1976 | )); |
| 1977 | 1977 | |
| 1978 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1978 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | 1981 | function calendar_upgrade1_7_011() |
@@ -2005,36 +2005,36 @@ discard block |
||
| 2005 | 2005 | 'precision' => '8', |
| 2006 | 2006 | 'comment' => 'ts when event was deleted' |
| 2007 | 2007 | ));*/ |
| 2008 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal',array( |
|
| 2008 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal', array( |
|
| 2009 | 2009 | 'fd' => array( |
| 2010 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 2011 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'unique id of event(-series)'), |
|
| 2012 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'event owner / calendar'), |
|
| 2013 | - 'cal_category' => array('type' => 'varchar','precision' => '30','comment' => 'category id'), |
|
| 2014 | - 'cal_modified' => array('type' => 'int','precision' => '8','comment' => 'ts of last modification'), |
|
| 2015 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 2016 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1','comment' => '1=public, 0=private event'), |
|
| 2017 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 2010 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 2011 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'unique id of event(-series)'), |
|
| 2012 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'event owner / calendar'), |
|
| 2013 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30', 'comment' => 'category id'), |
|
| 2014 | + 'cal_modified' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts of last modification'), |
|
| 2015 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 2016 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1', 'comment' => '1=public, 0=private event'), |
|
| 2017 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 2018 | 2018 | 'cal_description' => array('type' => 'text'), |
| 2019 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 2020 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0','comment' => 'cal_id of series for exception'), |
|
| 2021 | - 'cal_modifier' => array('type' => 'int','precision' => '4','comment' => 'user who last modified event'), |
|
| 2022 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0','comment' => '1 for non-blocking events'), |
|
| 2023 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 2024 | - 'cal_etag' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'etag for optimistic locking'), |
|
| 2025 | - 'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'), |
|
| 2026 | - 'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'), |
|
| 2027 | - 'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'), |
|
| 2028 | - 'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'), |
|
| 2029 | - 'cal_deleted' => array('type' => 'int','precision' => '8','comment' => 'ts when event was deleted') |
|
| 2019 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 2020 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0', 'comment' => 'cal_id of series for exception'), |
|
| 2021 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4', 'comment' => 'user who last modified event'), |
|
| 2022 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'comment' => '1 for non-blocking events'), |
|
| 2023 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 2024 | + 'cal_etag' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'etag for optimistic locking'), |
|
| 2025 | + 'cal_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'creating user'), |
|
| 2026 | + 'cal_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'comment' => 'creation time of event'), |
|
| 2027 | + 'cal_recurrence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'cal_start of original recurrence for exception'), |
|
| 2028 | + 'tz_id' => array('type' => 'int', 'precision' => '4', 'comment' => 'key into egw_cal_timezones'), |
|
| 2029 | + 'cal_deleted' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts when event was deleted') |
|
| 2030 | 2030 | ), |
| 2031 | 2031 | 'pk' => array('cal_id'), |
| 2032 | 2032 | 'fk' => array(), |
| 2033 | - 'ix' => array('cal_uid','cal_owner','cal_deleted'), |
|
| 2033 | + 'ix' => array('cal_uid', 'cal_owner', 'cal_deleted'), |
|
| 2034 | 2034 | 'uc' => array() |
| 2035 | - ),array( |
|
| 2035 | + ), array( |
|
| 2036 | 2036 | // for deleted rows use cal_modified as deleted date, NULL for not deleted ones |
| 2037 | - 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN cal_modified ELSE NULL END', |
|
| 2037 | + 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true, 'bool').' THEN cal_modified ELSE NULL END', |
|
| 2038 | 2038 | )); |
| 2039 | 2039 | |
| 2040 | 2040 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.002'; |
@@ -2046,16 +2046,16 @@ discard block |
||
| 2046 | 2046 | */ |
| 2047 | 2047 | function calendar_upgrade1_9_002() |
| 2048 | 2048 | { |
| 2049 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','caldav_name',array( |
|
| 2049 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'caldav_name', array( |
|
| 2050 | 2050 | 'type' => 'varchar', |
| 2051 | 2051 | 'precision' => '64', |
| 2052 | 2052 | 'comment' => 'name part of CalDAV URL, if specified by client' |
| 2053 | 2053 | )); |
| 2054 | - $GLOBALS['egw_setup']->db->query($sql='UPDATE egw_cal SET caldav_name='. |
|
| 2054 | + $GLOBALS['egw_setup']->db->query($sql = 'UPDATE egw_cal SET caldav_name='. |
|
| 2055 | 2055 | $GLOBALS['egw_setup']->db->concat( |
| 2056 | - $GLOBALS['egw_setup']->db->to_varchar('cal_id'),"'.ics'"),__LINE__,__FILE__); |
|
| 2056 | + $GLOBALS['egw_setup']->db->to_varchar('cal_id'), "'.ics'"), __LINE__, __FILE__); |
|
| 2057 | 2057 | |
| 2058 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','caldav_name'); |
|
| 2058 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'caldav_name'); |
|
| 2059 | 2059 | |
| 2060 | 2060 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.003'; |
| 2061 | 2061 | } |
@@ -2066,8 +2066,8 @@ discard block |
||
| 2066 | 2066 | */ |
| 2067 | 2067 | function calendar_upgrade1_9_003() |
| 2068 | 2068 | { |
| 2069 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_modified'); |
|
| 2070 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user','cal_user_modified'); |
|
| 2069 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_modified'); |
|
| 2070 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', 'cal_user_modified'); |
|
| 2071 | 2071 | |
| 2072 | 2072 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.004'; |
| 2073 | 2073 | } |
@@ -2079,7 +2079,7 @@ discard block |
||
| 2079 | 2079 | */ |
| 2080 | 2080 | function calendar_upgrade1_9_004() |
| 2081 | 2081 | { |
| 2082 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates','recur_exception',array( |
|
| 2082 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates', 'recur_exception', array( |
|
| 2083 | 2083 | 'type' => 'bool', |
| 2084 | 2084 | 'default' => '', |
| 2085 | 2085 | 'null' => false, |
@@ -2087,16 +2087,16 @@ discard block |
||
| 2087 | 2087 | )); |
| 2088 | 2088 | |
| 2089 | 2089 | // migrate existing exceptions to egw_cal_dates |
| 2090 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2090 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2091 | 2091 | 'egw_cal_repeats.cal_id AS cal_id,egw_cal_repeats.recur_exception AS recur_exception,MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
| 2092 | 2092 | 'egw_cal_repeats.recur_exception IS NOT NULL', __LINE__, __FILE__, false, |
| 2093 | 2093 | 'GROUP BY egw_cal_repeats.cal_id,egw_cal_repeats.recur_exception', 'calendar', '', |
| 2094 | 2094 | 'JOIN egw_cal_dates ON egw_cal_repeats.cal_id=egw_cal_dates.cal_id') as $row) |
| 2095 | 2095 | { |
| 2096 | - foreach($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2096 | + foreach ($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2097 | 2097 | { |
| 2098 | 2098 | $GLOBALS['egw_setup']->db->insert('egw_cal_dates', array( |
| 2099 | - 'cal_end' => $recur_exception+$row['cal_end']-$row['cal_start'], |
|
| 2099 | + 'cal_end' => $recur_exception + $row['cal_end'] - $row['cal_start'], |
|
| 2100 | 2100 | 'recur_exception' => true, |
| 2101 | 2101 | ), array( |
| 2102 | 2102 | 'cal_id' => $row['cal_id'], |
@@ -2108,11 +2108,11 @@ discard block |
||
| 2108 | 2108 | |
| 2109 | 2109 | $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
| 2110 | 2110 | 'fd' => array( |
| 2111 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2112 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2113 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 2114 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2115 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2111 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2112 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2113 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 2114 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2115 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2116 | 2116 | ), |
| 2117 | 2117 | 'pk' => array('cal_id'), |
| 2118 | 2118 | 'fk' => array(), |
@@ -2133,19 +2133,19 @@ discard block |
||
| 2133 | 2133 | // returns NULL, if there are no rows! |
| 2134 | 2134 | if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384) |
| 2135 | 2135 | { |
| 2136 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_description',array( |
|
| 2136 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_description', array( |
|
| 2137 | 2137 | 'type' => 'varchar', |
| 2138 | 2138 | 'precision' => '16384' |
| 2139 | 2139 | )); |
| 2140 | 2140 | } |
| 2141 | 2141 | // allow more categories |
| 2142 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2142 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2143 | 2143 | 'type' => 'varchar', |
| 2144 | 2144 | 'precision' => '64', |
| 2145 | 2145 | 'comment' => 'category id(s)' |
| 2146 | 2146 | )); |
| 2147 | 2147 | // remove silly default of 1 |
| 2148 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_title',array( |
|
| 2148 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_title', array( |
|
| 2149 | 2149 | 'type' => 'varchar', |
| 2150 | 2150 | 'precision' => '255', |
| 2151 | 2151 | 'nullable' => False |
@@ -2160,14 +2160,14 @@ discard block |
||
| 2160 | 2160 | { |
| 2161 | 2161 | // PostgreSQL needs temporary a nullable column, to not stall on broken events without dates! |
| 2162 | 2162 | // We add that constrain in 1.9.007, after deleting all rows with range_start=0 OR range_start IS NULL |
| 2163 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_start',array( |
|
| 2163 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_start', array( |
|
| 2164 | 2164 | 'type' => 'int', |
| 2165 | 2165 | 'precision' => '8', |
| 2166 | 2166 | 'comment' => 'startdate (of range)' |
| 2167 | 2167 | )); |
| 2168 | 2168 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_start = (SELECT MIN(cal_start) FROM egw_cal_dates WHERE egw_cal_dates.cal_id=egw_cal.cal_id)', __LINE__, __FILE__); |
| 2169 | 2169 | |
| 2170 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_end',array( |
|
| 2170 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_end', array( |
|
| 2171 | 2171 | 'type' => 'int', |
| 2172 | 2172 | 'precision' => '8', |
| 2173 | 2173 | 'comment' => 'enddate (of range, UNTIL of RRULE)' |
@@ -2183,18 +2183,18 @@ discard block |
||
| 2183 | 2183 | { |
| 2184 | 2184 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_end=recur_enddate FROM egw_cal_repeats WHERE egw_cal.cal_id=egw_cal_repeats.cal_id', __LINE__, __FILE__); |
| 2185 | 2185 | } |
| 2186 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 2186 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 2187 | 2187 | 'fd' => array( |
| 2188 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2189 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2190 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2191 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1') |
|
| 2188 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2189 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2190 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2191 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1') |
|
| 2192 | 2192 | ), |
| 2193 | 2193 | 'pk' => array('cal_id'), |
| 2194 | 2194 | 'fk' => array(), |
| 2195 | 2195 | 'ix' => array(), |
| 2196 | 2196 | 'uc' => array() |
| 2197 | - ),'recur_enddate'); |
|
| 2197 | + ), 'recur_enddate'); |
|
| 2198 | 2198 | |
| 2199 | 2199 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.007'; |
| 2200 | 2200 | } |
@@ -2206,14 +2206,14 @@ discard block |
||
| 2206 | 2206 | */ |
| 2207 | 2207 | function calendar_upgrade1_9_007() |
| 2208 | 2208 | { |
| 2209 | - foreach(array('egw_cal_repeats','egw_cal_dates','egw_cal_user','egw_cal_extra') as $table) |
|
| 2209 | + foreach (array('egw_cal_repeats', 'egw_cal_dates', 'egw_cal_user', 'egw_cal_extra') as $table) |
|
| 2210 | 2210 | { |
| 2211 | 2211 | $GLOBALS['egw_setup']->db->query("DELETE FROM $table WHERE cal_id IN (SELECT cal_id FROM egw_cal WHERE range_start=0 OR range_start IS NULL)", __LINE__, __FILE__); |
| 2212 | 2212 | } |
| 2213 | 2213 | $GLOBALS['egw_setup']->db->query("DELETE FROM egw_cal WHERE range_start=0 OR range_start IS NULL", __LINE__, __FILE__); |
| 2214 | 2214 | |
| 2215 | 2215 | // now we can remove temporary default of 0 from range_start and set it NOT NULL |
| 2216 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','range_start',array( |
|
| 2216 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'range_start', array( |
|
| 2217 | 2217 | 'type' => 'int', |
| 2218 | 2218 | 'precision' => '8', |
| 2219 | 2219 | 'nullable' => False, |
@@ -2278,7 +2278,7 @@ discard block |
||
| 2278 | 2278 | |
| 2279 | 2279 | function calendar_upgrade1_9_010() |
| 2280 | 2280 | { |
| 2281 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2281 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2282 | 2282 | 'type' => 'varchar', |
| 2283 | 2283 | 'precision' => '200', |
| 2284 | 2284 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2308,7 +2308,7 @@ discard block |
||
| 2308 | 2308 | SET cal_reference=0,cal_recurrence=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time()." |
| 2309 | 2309 | WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__); |
| 2310 | 2310 | |
| 2311 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2311 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2312 | 2312 | "SELECT DISTINCT master.cal_id,egw_cal_user.cal_user_type,egw_cal_user.cal_user_id,'E' AS cal_status |
| 2313 | 2313 | FROM egw_cal_user |
| 2314 | 2314 | JOIN egw_cal ON egw_cal_user.cal_id=egw_cal.cal_id |
@@ -2335,7 +2335,7 @@ discard block |
||
| 2335 | 2335 | */ |
| 2336 | 2336 | function calendar_upgrade14_1_001() |
| 2337 | 2337 | { |
| 2338 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2338 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2339 | 2339 | "SELECT egw_cal.cal_id AS cal_id,cal_start,cal_end,range_start,range_end,egw_cal_repeats.*,tz_tzid AS tzid |
| 2340 | 2340 | FROM egw_cal |
| 2341 | 2341 | JOIN egw_cal_repeats ON egw_cal_repeats.cal_id=egw_cal.cal_id |
@@ -2363,7 +2363,7 @@ discard block |
||
| 2363 | 2363 | $enddate->modify(($event['end'] - $event['start']).' second'); |
| 2364 | 2364 | if (($range_end = $enddate->format('server')) != $event['range_end']) |
| 2365 | 2365 | { |
| 2366 | - $GLOBALS['egw_setup']->db->update('egw_cal',array( |
|
| 2366 | + $GLOBALS['egw_setup']->db->update('egw_cal', array( |
|
| 2367 | 2367 | 'range_end' => $range_end, |
| 2368 | 2368 | 'cal_etag=cal_etag+1', |
| 2369 | 2369 | 'cal_modified' => time(), |
@@ -2373,7 +2373,7 @@ discard block |
||
| 2373 | 2373 | //error_log(__FUNCTION__."() #$event[id], start=".date('Y-m-d H:i:s', $event['start']).', end='.date('Y-m-d H:i:s', $event['end']).', range_end='.date('Y-m-d H:i:s', $event['recur_enddate']).' --> '.date('Y-m-d H:i:s', $range_end)); |
| 2374 | 2374 | } |
| 2375 | 2375 | } |
| 2376 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2376 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2377 | 2377 | } |
| 2378 | 2378 | |
| 2379 | 2379 | /** |
@@ -2397,7 +2397,7 @@ discard block |
||
| 2397 | 2397 | // if maximum is bigger then 3 |
| 2398 | 2398 | if ($values[1] > 3) |
| 2399 | 2399 | { |
| 2400 | - switch($GLOBALS['egw_setup']->db->Type) |
|
| 2400 | + switch ($GLOBALS['egw_setup']->db->Type) |
|
| 2401 | 2401 | { |
| 2402 | 2402 | case 'mysql': |
| 2403 | 2403 | $sql = "UPDATE egw_cal |
@@ -2442,7 +2442,7 @@ discard block |
||
| 2442 | 2442 | |
| 2443 | 2443 | function calendar_upgrade14_2_003() |
| 2444 | 2444 | { |
| 2445 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_uid',array( |
|
| 2445 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_uid', array( |
|
| 2446 | 2446 | 'type' => 'ascii', |
| 2447 | 2447 | 'precision' => '128', |
| 2448 | 2448 | 'nullable' => False, |
@@ -2454,13 +2454,13 @@ discard block |
||
| 2454 | 2454 | { |
| 2455 | 2455 | $GLOBALS['egw_setup']->db->query("UPDATE egw_cal SET cal_category='' WHERE cal_category NOT REGEXP '^[0-9,]*$'", __LINE__, __FILE__); |
| 2456 | 2456 | } |
| 2457 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2457 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2458 | 2458 | 'type' => 'ascii', |
| 2459 | 2459 | 'meta' => 'category', |
| 2460 | 2460 | 'precision' => '64', |
| 2461 | 2461 | 'comment' => 'category id(s)' |
| 2462 | 2462 | )); |
| 2463 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2463 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2464 | 2464 | 'type' => 'ascii', |
| 2465 | 2465 | 'precision' => '128', |
| 2466 | 2466 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2517,22 +2517,22 @@ discard block |
||
| 2517 | 2517 | 'type' => 'auto', |
| 2518 | 2518 | 'nullable' => False |
| 2519 | 2519 | ));*/ |
| 2520 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 2520 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 2521 | 2521 | 'fd' => array( |
| 2522 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2523 | - 'cal_recur_date' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0'), |
|
| 2524 | - 'cal_user_type' => array('type' => 'ascii','precision' => '1','nullable' => False,'default' => 'u','comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2525 | - 'cal_user_id' => array('type' => 'varchar','meta' => array("cal_user_type='u'" => 'account'),'precision' => '128','nullable' => False,'comment' => 'id or email-address for type=e'), |
|
| 2526 | - 'cal_status' => array('type' => 'ascii','precision' => '1','default' => 'A','comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2527 | - 'cal_quantity' => array('type' => 'int','precision' => '4','default' => '1','comment' => 'only for certain types (eg. resources)'), |
|
| 2528 | - 'cal_role' => array('type' => 'ascii','precision' => '64','default' => 'REQ-PARTICIPANT','comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2529 | - 'cal_user_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'automatic timestamp of last update'), |
|
| 2530 | - 'cal_user_auto' => array('type' => 'auto','nullable' => False) |
|
| 2522 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2523 | + 'cal_recur_date' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 2524 | + 'cal_user_type' => array('type' => 'ascii', 'precision' => '1', 'nullable' => False, 'default' => 'u', 'comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2525 | + 'cal_user_id' => array('type' => 'varchar', 'meta' => array("cal_user_type='u'" => 'account'), 'precision' => '128', 'nullable' => False, 'comment' => 'id or email-address for type=e'), |
|
| 2526 | + 'cal_status' => array('type' => 'ascii', 'precision' => '1', 'default' => 'A', 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2527 | + 'cal_quantity' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'comment' => 'only for certain types (eg. resources)'), |
|
| 2528 | + 'cal_role' => array('type' => 'ascii', 'precision' => '64', 'default' => 'REQ-PARTICIPANT', 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2529 | + 'cal_user_modified' => array('type' => 'timestamp', 'default' => 'current_timestamp', 'comment' => 'automatic timestamp of last update'), |
|
| 2530 | + 'cal_user_auto' => array('type' => 'auto', 'nullable' => False) |
|
| 2531 | 2531 | ), |
| 2532 | 2532 | 'pk' => array('cal_user_auto'), |
| 2533 | 2533 | 'fk' => array(), |
| 2534 | - 'ix' => array('cal_user_modified',array('cal_user_type','cal_user_id')), |
|
| 2535 | - 'uc' => array(array('cal_id','cal_recur_date','cal_user_type','cal_user_id')) |
|
| 2534 | + 'ix' => array('cal_user_modified', array('cal_user_type', 'cal_user_id')), |
|
| 2535 | + 'uc' => array(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id')) |
|
| 2536 | 2536 | )); |
| 2537 | 2537 | |
| 2538 | 2538 | return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.005'; |
@@ -2541,12 +2541,12 @@ discard block |
||
| 2541 | 2541 | |
| 2542 | 2542 | function calendar_upgrade14_2_005() |
| 2543 | 2543 | { |
| 2544 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_tzid',array( |
|
| 2544 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_tzid', array( |
|
| 2545 | 2545 | 'type' => 'ascii', |
| 2546 | 2546 | 'precision' => '128', |
| 2547 | 2547 | 'nullable' => False |
| 2548 | 2548 | )); |
| 2549 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_component',array( |
|
| 2549 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_component', array( |
|
| 2550 | 2550 | 'type' => 'ascii', |
| 2551 | 2551 | 'precision' => '8192', |
| 2552 | 2552 | 'comment' => 'iCal VTIMEZONE component' |
@@ -2562,7 +2562,7 @@ discard block |
||
| 2562 | 2562 | */ |
| 2563 | 2563 | function calendar_upgrade14_3() |
| 2564 | 2564 | { |
| 2565 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_attendee',array( |
|
| 2565 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_attendee', array( |
|
| 2566 | 2566 | 'type' => 'varchar', |
| 2567 | 2567 | 'precision' => '255', |
| 2568 | 2568 | 'comment' => 'email or json object with attr. cn, url, ...' |
@@ -2573,12 +2573,12 @@ discard block |
||
| 2573 | 2573 | |
| 2574 | 2574 | // delete all but one row, which would give a doublicate key, after above normalising of email addresses |
| 2575 | 2575 | // by ordering by status we prever accepted over tentative over unknow over deleted |
| 2576 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2576 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2577 | 2577 | 'cal_user_type' => 'e', |
| 2578 | 2578 | ), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1", 'calendar') as $row) |
| 2579 | 2579 | { |
| 2580 | 2580 | $n = 0; |
| 2581 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2581 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2582 | 2582 | 'cal_id' => $row['cal_id'], |
| 2583 | 2583 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2584 | 2584 | 'cal_user_type' => 'e', |
@@ -2587,7 +2587,7 @@ discard block |
||
| 2587 | 2587 | { |
| 2588 | 2588 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2589 | 2589 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2590 | - array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
|
| 2590 | + array_intersect_key($user, array_flip(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id', 'cal_status'))), |
|
| 2591 | 2591 | __LINE__, __FILE__, 'calendar'); |
| 2592 | 2592 | } |
| 2593 | 2593 | } |
@@ -2597,7 +2597,7 @@ discard block |
||
| 2597 | 2597 | "UPDATE egw_cal_user SET cal_user_attendee=cal_user_id,cal_user_id=MD5($email) WHERE cal_user_type='e'", |
| 2598 | 2598 | __LINE__, __FILE__); |
| 2599 | 2599 | |
| 2600 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 2600 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 2601 | 2601 | 'type' => 'ascii', |
| 2602 | 2602 | 'meta' => array( |
| 2603 | 2603 | "cal_user_type='u'" => 'account' |
@@ -2619,7 +2619,7 @@ discard block |
||
| 2619 | 2619 | { |
| 2620 | 2620 | $GLOBALS['calendar_upgrade14_3_001-run'] = true; |
| 2621 | 2621 | |
| 2622 | - foreach($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2622 | + foreach ($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2623 | 2623 | FROM egw_cal_user |
| 2624 | 2624 | JOIN egw_cal_user euser ON euser.cal_id=egw_cal_user.cal_id AND euser.cal_user_type='e' AND euser.cal_user_id=egw_cal_user.cal_user_id AND euser.cal_user_attendee IS NULL |
| 2625 | 2625 | WHERE egw_cal_user.cal_user_type='e' AND egw_cal_user.cal_user_attendee IS NOT NULL |
@@ -2670,8 +2670,8 @@ discard block |
||
| 2670 | 2670 | { |
| 2671 | 2671 | Api\Preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner) |
| 2672 | 2672 | { |
| 2673 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2674 | - if($old_value['state'] && is_array($old_value['state'])) |
|
| 2673 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2674 | + if ($old_value['state'] && is_array($old_value['state'])) |
|
| 2675 | 2675 | { |
| 2676 | 2676 | unset($old_value['state']['date']); |
| 2677 | 2677 | unset($old_value['state']['startdate']); |
@@ -2691,15 +2691,15 @@ discard block |
||
| 2691 | 2691 | { |
| 2692 | 2692 | Api\Preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner) |
| 2693 | 2693 | { |
| 2694 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2695 | - switch($old_value) |
|
| 2694 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2695 | + switch ($old_value) |
|
| 2696 | 2696 | { |
| 2697 | 2697 | case 'all': |
| 2698 | 2698 | return 0; |
| 2699 | 2699 | case 'day_week': |
| 2700 | - return ['day','day4','week']; |
|
| 2700 | + return ['day', 'day4', 'week']; |
|
| 2701 | 2701 | case 'day4': |
| 2702 | - return ['day','day4']; |
|
| 2702 | + return ['day', 'day4']; |
|
| 2703 | 2703 | } |
| 2704 | 2704 | return null; |
| 2705 | 2705 | }); |
@@ -2724,7 +2724,7 @@ discard block |
||
| 2724 | 2724 | function calendar_upgrade16_1_001() |
| 2725 | 2725 | { |
| 2726 | 2726 | $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_extra', 'cal_extra_value', |
| 2727 | - array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')); |
|
| 2727 | + array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => '')); |
|
| 2728 | 2728 | |
| 2729 | 2729 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'forced'); |
| 2730 | 2730 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'default'); |
@@ -2736,8 +2736,8 @@ discard block |
||
| 2736 | 2736 | { |
| 2737 | 2737 | // Explicitly add months as showing list of events, no times |
| 2738 | 2738 | $change = function($attr, $old_value, $owner) { |
| 2739 | - if($owner == Api\Preferences::FORCED_ID) return; |
|
| 2740 | - if(is_array($old_value) && !in_array('month', $old_value)) |
|
| 2739 | + if ($owner == Api\Preferences::FORCED_ID) return; |
|
| 2740 | + if (is_array($old_value) && !in_array('month', $old_value)) |
|
| 2741 | 2741 | { |
| 2742 | 2742 | $old_value[] = 'month'; |
| 2743 | 2743 | } |
@@ -2759,7 +2759,7 @@ discard block |
||
| 2759 | 2759 | { |
| 2760 | 2760 | // Update birthdays as events preference from boolean |
| 2761 | 2761 | $change = function($attr, $old_value, $owner) { |
| 2762 | - if (!isset($old_value)) return null; // do not set anything, if nothing was set before |
|
| 2762 | + if (!isset($old_value)) return null; // do not set anything, if nothing was set before |
|
| 2763 | 2763 | return $old_value ? 'birthday' : 'none'; |
| 2764 | 2764 | }; |
| 2765 | 2765 | Api\Preferences::change_preference('calendar', 'birthdays_as_events', $change); |
@@ -2775,13 +2775,13 @@ discard block |
||
| 2775 | 2775 | |
| 2776 | 2776 | function calendar_upgrade17_1_002() |
| 2777 | 2777 | { |
| 2778 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_uid',array( |
|
| 2778 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_uid', array( |
|
| 2779 | 2779 | 'type' => 'ascii', |
| 2780 | 2780 | 'precision' => '255', |
| 2781 | 2781 | 'nullable' => False, |
| 2782 | 2782 | 'comment' => 'unique id of event(-series)' |
| 2783 | 2783 | )); |
| 2784 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2784 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2785 | 2785 | 'type' => 'ascii', |
| 2786 | 2786 | 'precision' => '260', |
| 2787 | 2787 | 'comment' => 'name part of CalDAV URL, if specified by client' |