Completed
Push — 16.1 ( b39e15...d98aac )
by Klaus
18:52
created
calendar/setup/tables_current.inc.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -12,41 +12,41 @@  discard block
 block discarded – undo
12 12
 $phpgw_baseline = array(
13 13
 	'egw_cal' => array(
14 14
 		'fd' => array(
15
-			'cal_id' => array('type' => 'auto','nullable' => False,'comment' => 'calendar id'),
16
-			'cal_uid' => array('type' => 'ascii','precision' => '128','nullable' => False,'comment' => 'unique id of event(-series)'),
17
-			'cal_owner' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'event owner / calendar'),
18
-			'cal_category' => array('type' => 'ascii','meta' => 'category','precision' => '64','comment' => 'category id(s)'),
19
-			'cal_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'ts of last modification'),
20
-			'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2','comment' => 'priority: 1=Low, 2=Normal, 3=High'),
21
-			'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1','comment' => '1=public, 0=private event'),
22
-			'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'title of event'),
23
-			'cal_description' => array('type' => 'varchar','precision' => '16384','comment' => 'description'),
24
-			'cal_location' => array('type' => 'varchar','precision' => '255','comment' => 'location'),
25
-			'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0','comment' => 'cal_id of series for exception'),
26
-			'cal_modifier' => array('type' => 'int','meta' => 'user','precision' => '4','comment' => 'user who last modified event'),
27
-			'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0','comment' => '1 for non-blocking events'),
28
-			'cal_special' => array('type' => 'int','precision' => '2','default' => '0'),
29
-			'cal_etag' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'etag for optimistic locking'),
30
-			'cal_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False,'comment' => 'creating user'),
31
-			'cal_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'creation time of event'),
32
-			'cal_recurrence' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'),
33
-			'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'),
34
-			'cal_deleted' => array('type' => 'int','precision' => '8','comment' => 'ts when event was deleted'),
35
-			'caldav_name' => array('type' => 'ascii','precision' => '128','comment' => 'name part of CalDAV URL, if specified by client'),
36
-			'range_start' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'startdate (of range)'),
37
-			'range_end' => array('type' => 'int','meta' => 'timestamp','precision' => '8','comment' => 'enddate (of range, UNTIL of RRULE)')
15
+			'cal_id' => array('type' => 'auto', 'nullable' => False, 'comment' => 'calendar id'),
16
+			'cal_uid' => array('type' => 'ascii', 'precision' => '128', 'nullable' => False, 'comment' => 'unique id of event(-series)'),
17
+			'cal_owner' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'event owner / calendar'),
18
+			'cal_category' => array('type' => 'ascii', 'meta' => 'category', 'precision' => '64', 'comment' => 'category id(s)'),
19
+			'cal_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'comment' => 'ts of last modification'),
20
+			'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2', 'comment' => 'priority: 1=Low, 2=Normal, 3=High'),
21
+			'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1', 'comment' => '1=public, 0=private event'),
22
+			'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'title of event'),
23
+			'cal_description' => array('type' => 'varchar', 'precision' => '16384', 'comment' => 'description'),
24
+			'cal_location' => array('type' => 'varchar', 'precision' => '255', 'comment' => 'location'),
25
+			'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0', 'comment' => 'cal_id of series for exception'),
26
+			'cal_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'comment' => 'user who last modified event'),
27
+			'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'comment' => '1 for non-blocking events'),
28
+			'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'),
29
+			'cal_etag' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'etag for optimistic locking'),
30
+			'cal_creator' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False, 'comment' => 'creating user'),
31
+			'cal_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'creation time of event'),
32
+			'cal_recurrence' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'cal_start of original recurrence for exception'),
33
+			'tz_id' => array('type' => 'int', 'precision' => '4', 'comment' => 'key into egw_cal_timezones'),
34
+			'cal_deleted' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts when event was deleted'),
35
+			'caldav_name' => array('type' => 'ascii', 'precision' => '128', 'comment' => 'name part of CalDAV URL, if specified by client'),
36
+			'range_start' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'startdate (of range)'),
37
+			'range_end' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'comment' => 'enddate (of range, UNTIL of RRULE)')
38 38
 		),
39 39
 		'pk' => array('cal_id'),
40 40
 		'fk' => array(),
41
-		'ix' => array('cal_uid','cal_owner','cal_modified','cal_reference','cal_deleted','caldav_name'),
41
+		'ix' => array('cal_uid', 'cal_owner', 'cal_modified', 'cal_reference', 'cal_deleted', 'caldav_name'),
42 42
 		'uc' => array()
43 43
 	),
44 44
 	'egw_cal_repeats' => array(
45 45
 		'fd' => array(
46
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
47
-			'recur_type' => array('type' => 'int','precision' => '2','nullable' => False),
48
-			'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'),
49
-			'recur_data' => array('type' => 'int','precision' => '2','default' => '1')
46
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
47
+			'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False),
48
+			'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'),
49
+			'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1')
50 50
 		),
51 51
 		'pk' => array('cal_id'),
52 52
 		'fk' => array(),
@@ -55,53 +55,53 @@  discard block
 block discarded – undo
55 55
 	),
56 56
 	'egw_cal_user' => array(
57 57
 		'fd' => array(
58
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
59
-			'cal_recur_date' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0'),
60
-			'cal_user_type' => array('type' => 'ascii','precision' => '1','nullable' => False,'default' => 'u','comment' => 'u=user, g=group, c=contact, r=resource, e=email'),
61
-			'cal_user_id' => array('type' => 'ascii','meta' => array("cal_user_type='u'" => 'account'),'precision' => '32','nullable' => False,'comment' => 'id or md5(email-address) for type=e'),
62
-			'cal_status' => array('type' => 'ascii','precision' => '1','default' => 'A','comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'),
63
-			'cal_quantity' => array('type' => 'int','precision' => '4','default' => '1','comment' => 'only for certain types (eg. resources)'),
64
-			'cal_role' => array('type' => 'ascii','precision' => '64','default' => 'REQ-PARTICIPANT','comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'),
65
-			'cal_user_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'automatic timestamp of last update'),
66
-			'cal_user_auto' => array('type' => 'auto','nullable' => False),
67
-			'cal_user_attendee' => array('type' => 'varchar','precision' => '255','comment' => 'email or json object with attr. cn, url, ...')
58
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
59
+			'cal_recur_date' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0'),
60
+			'cal_user_type' => array('type' => 'ascii', 'precision' => '1', 'nullable' => False, 'default' => 'u', 'comment' => 'u=user, g=group, c=contact, r=resource, e=email'),
61
+			'cal_user_id' => array('type' => 'ascii', 'meta' => array("cal_user_type='u'" => 'account'), 'precision' => '32', 'nullable' => False, 'comment' => 'id or md5(email-address) for type=e'),
62
+			'cal_status' => array('type' => 'ascii', 'precision' => '1', 'default' => 'A', 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'),
63
+			'cal_quantity' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'comment' => 'only for certain types (eg. resources)'),
64
+			'cal_role' => array('type' => 'ascii', 'precision' => '64', 'default' => 'REQ-PARTICIPANT', 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'),
65
+			'cal_user_modified' => array('type' => 'timestamp', 'default' => 'current_timestamp', 'comment' => 'automatic timestamp of last update'),
66
+			'cal_user_auto' => array('type' => 'auto', 'nullable' => False),
67
+			'cal_user_attendee' => array('type' => 'varchar', 'precision' => '255', 'comment' => 'email or json object with attr. cn, url, ...')
68 68
 		),
69 69
 		'pk' => array('cal_user_auto'),
70 70
 		'fk' => array(),
71
-		'ix' => array('cal_user_modified',array('cal_user_type','cal_user_id')),
72
-		'uc' => array(array('cal_id','cal_recur_date','cal_user_type','cal_user_id'))
71
+		'ix' => array('cal_user_modified', array('cal_user_type', 'cal_user_id')),
72
+		'uc' => array(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'))
73 73
 	),
74 74
 	'egw_cal_extra' => array(
75 75
 		'fd' => array(
76
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
77
-			'cal_extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '40','nullable' => False),
78
-			'cal_extra_value' => array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')
76
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
77
+			'cal_extra_name' => array('type' => 'varchar', 'meta' => 'cfname', 'precision' => '40', 'nullable' => False),
78
+			'cal_extra_value' => array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => '')
79 79
 		),
80
-		'pk' => array('cal_id','cal_extra_name'),
80
+		'pk' => array('cal_id', 'cal_extra_name'),
81 81
 		'fk' => array(),
82 82
 		'ix' => array(),
83 83
 		'uc' => array()
84 84
 	),
85 85
 	'egw_cal_dates' => array(
86 86
 		'fd' => array(
87
-			'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
88
-			'cal_start' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'starttime in server time'),
89
-			'cal_end' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'comment' => 'endtime in server time'),
90
-			'recur_exception' => array('type' => 'bool','nullable' => False,'default' => '','comment' => 'date is an exception')
87
+			'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False),
88
+			'cal_start' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'starttime in server time'),
89
+			'cal_end' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'comment' => 'endtime in server time'),
90
+			'recur_exception' => array('type' => 'bool', 'nullable' => False, 'default' => '', 'comment' => 'date is an exception')
91 91
 		),
92
-		'pk' => array('cal_id','cal_start'),
92
+		'pk' => array('cal_id', 'cal_start'),
93 93
 		'fk' => array(),
94
-		'ix' => array(array('recur_exception','cal_id')),
94
+		'ix' => array(array('recur_exception', 'cal_id')),
95 95
 		'uc' => array()
96 96
 	),
97 97
 	'egw_cal_timezones' => array(
98 98
 		'fd' => array(
99
-			'tz_id' => array('type' => 'auto','nullable' => False),
100
-			'tz_tzid' => array('type' => 'ascii','precision' => '128','nullable' => False),
101
-			'tz_alias' => array('type' => 'int','precision' => '4','comment' => 'tz_id for data'),
102
-			'tz_latitude' => array('type' => 'int','precision' => '4'),
103
-			'tz_longitude' => array('type' => 'int','precision' => '4'),
104
-			'tz_component' => array('type' => 'ascii','precision' => '8192','comment' => 'iCal VTIMEZONE component')
99
+			'tz_id' => array('type' => 'auto', 'nullable' => False),
100
+			'tz_tzid' => array('type' => 'ascii', 'precision' => '128', 'nullable' => False),
101
+			'tz_alias' => array('type' => 'int', 'precision' => '4', 'comment' => 'tz_id for data'),
102
+			'tz_latitude' => array('type' => 'int', 'precision' => '4'),
103
+			'tz_longitude' => array('type' => 'int', 'precision' => '4'),
104
+			'tz_component' => array('type' => 'ascii', 'precision' => '8192', 'comment' => 'iCal VTIMEZONE component')
105 105
 		),
106 106
 		'pk' => array('tz_id'),
107 107
 		'fk' => array(),
Please login to merge, or discard this patch.
calendar/setup/tz_aliases.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	'Arab Standard Time' => 'Asia/Riyadh',
25 25
 	'Arabian Standard Time' => 'Asia/Dubai',
26 26
 	'Arabic Standard Time' => 'Asia/Baghdad',
27
-	'Argentina Standard Time' => 'America/Argentina/Buenos_Aires',	// was 'America/Buenos_Aires',
27
+	'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', // was 'America/Buenos_Aires',
28 28
 	'Atlantic Standard Time' => 'America/Halifax',
29 29
 	'Azerbaijan Standard Time' => 'Asia/Baku',
30 30
 	'Azores Standard Time' => 'Atlantic/Azores',
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	'Greenland Standard Time' => 'America/Godthab',
60 60
 	'Greenwich Standard Time' => 'Atlantic/Reykjavik',
61 61
 	'Hawaiian Standard Time' => 'Pacific/Honolulu',
62
-	'India Standard Time' => 'Asia/Kolkata',	// Asia/Calcutta is an alias to Asia/Kolkata
62
+	'India Standard Time' => 'Asia/Kolkata', // Asia/Calcutta is an alias to Asia/Kolkata
63 63
 	'Iran Standard Time' => 'Asia/Tehran',
64 64
 	'Israel Standard Time' => 'Asia/Jerusalem',
65 65
 	'Jordan Standard Time' => 'Asia/Amman',
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein',
199 199
 
200 200
 	// various aliases collected over time
201
-	'America/Creston' => 'America/Dawson_Creek',	// not in sqlight DB of Thunderbird version 1.2011n, Dawson Creek is also UTC-7 without DS
201
+	'America/Creston' => 'America/Dawson_Creek', // not in sqlight DB of Thunderbird version 1.2011n, Dawson Creek is also UTC-7 without DS
202 202
 	'Armenian Standard Time' => 'Asia/Yerevan',
203 203
 	'Asia/Katmandu' => 'Asia/Kathmandu',
204 204
 	'Asia/Calcutta' => 'Asia/Kolkata',
Please login to merge, or discard this patch.
calendar/setup/default_records.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // enable auto-loading of holidays from localhost by default
13
-foreach(array(
13
+foreach (array(
14 14
 	'auto_load_holidays' => 'True',
15 15
 	'holidays_url_path'  => 'localhost',
16 16
 ) as $name => $value)
17 17
 {
18
-	$oProc->insert($GLOBALS['egw_setup']->config_table,array(
18
+	$oProc->insert($GLOBALS['egw_setup']->config_table, array(
19 19
 		'config_value' => $value,
20
-	),array(
20
+	), array(
21 21
 		'config_app' => 'phpgwapi',
22 22
 		'config_name' => $name,
23
-	),__FILE__,__LINE__);
23
+	), __FILE__, __LINE__);
24 24
 }
25 25
 
26 26
 // import timezone data
Please login to merge, or discard this patch.
calendar/freebusy.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 	$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
42 42
 }
43 43
 // fix for SOGo connector, which does not decode the = in our f/b url
44
-if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D')
44
+if (strpos($_SERVER['QUERY_STRING'], '=3D') !== false && substr($_GET['user'], 0, 2) == '3D')
45 45
 {
46
-	$_GET['user'] = substr($_GET['user'],2);
47
-	if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2);
48
-	if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2);
46
+	$_GET['user'] = substr($_GET['user'], 2);
47
+	if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'], 2);
48
+	if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'], 2);
49 49
 }
50 50
 if (!is_numeric($user = $_GET['user']))
51 51
 {
52 52
 	// check if user contains the current domain --> remove it
53
-	list(,$domain) = explode('@',$user);
53
+	list(,$domain) = explode('@', $user);
54 54
 	if ($domain === $GLOBALS['egw_info']['user']['domain'])
55
-	list($user) = explode('@',$user);
56
-	$user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u');
55
+	list($user) = explode('@', $user);
56
+	$user = $GLOBALS['egw']->accounts->name2id($user, 'account_lid', 'u');
57 57
 }
58 58
 if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user)))
59 59
 {
60
-	fail_exit(lang("freebusy: Unknow user '%1', wrong password or not availible to not loged in users !!!"." $username($user)",$_GET['user']));
60
+	fail_exit(lang("freebusy: Unknow user '%1', wrong password or not availible to not loged in users !!!"." $username($user)", $_GET['user']));
61 61
 }
62 62
 if (!$loged_in)
63 63
 {
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 		if (strpos($authuser, '@') === false)
79 79
 		{
80 80
 			$domain = $GLOBALS['egw_info']['server']['default_domain'];
81
-			$authuser .= '@' . $domain;
81
+			$authuser .= '@'.$domain;
82 82
 		}
83 83
 		else
84 84
 		{
85
-			list(, $domain) = explode('@',$authuser, 2);
85
+			list(, $domain) = explode('@', $authuser, 2);
86 86
 		}
87 87
 		if (array_key_exists($domain, $GLOBALS['egw_domain']))
88 88
 		{
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 			$GLOBALS['egw_info']['user']['domain'] = $domain;
93 93
 			$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
94 94
 			$GLOBALS['egw_info']['flags']['noapi'] = false;
95
-			require_once(EGW_API_INC . '/functions.inc.php');
96
-			$loged_in =  $GLOBALS['egw']->session->create($authuser, $password, 'text');
95
+			require_once(EGW_API_INC.'/functions.inc.php');
96
+			$loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text');
97 97
 			session_unset();
98 98
 			session_destroy();
99 99
 		}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 }
110 110
 else
111 111
 {
112
-	Api\Header\Content::type('freebusy.ifb','text/calendar');
112
+	Api\Header\Content::type('freebusy.ifb', 'text/calendar');
113 113
 }
114 114
 $ical = new calendar_ical();
115 115
 echo $ical->freebusy($user, $_GET['end']);
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,15 +44,23 @@
 block discarded – undo
44 44
 if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D')
45 45
 {
46 46
 	$_GET['user'] = substr($_GET['user'],2);
47
-	if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2);
48
-	if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2);
49
-}
47
+	if (isset($_GET['password']))
48
+	{
49
+		$_GET['password'] = substr($_GET['password'],2);
50
+	}
51
+	if (isset($_GET['cred']))
52
+	{
53
+		$_GET['cred'] = substr($_GET['cred'],2);
54
+	}
55
+	}
50 56
 if (!is_numeric($user = $_GET['user']))
51 57
 {
52 58
 	// check if user contains the current domain --> remove it
53 59
 	list(,$domain) = explode('@',$user);
54 60
 	if ($domain === $GLOBALS['egw_info']['user']['domain'])
55
-	list($user) = explode('@',$user);
61
+	{
62
+		list($user) = explode('@',$user);
63
+	}
56 64
 	$user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u');
57 65
 }
58 66
 if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user)))
Please login to merge, or discard this patch.
calendar/inc/class.calendar_zpush.inc.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 	 * @param int $cutoffdate =null
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180
-  	 */
180
+	 */
181 181
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
Please login to merge, or discard this patch.
Spacing   +176 added lines, -177 removed lines patch added patch discarded remove patch
@@ -84,19 +84,19 @@  discard block
 block discarded – undo
84 84
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
85 85
 
86 86
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
87
-		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
87
+		$cals = $cals_pref ? explode(',', $cals_pref) : array('P'); // implicit default of 'P'
88 88
 		$folderlist = array();
89 89
 
90 90
 		foreach ($this->calendar->list_cals() as $entry)
91 91
 		{
92 92
 			$account_id = $entry['grantor'];
93
-			if (in_array('A',$cals) || in_array($account_id,$cals) ||
94
-				$account_id == $GLOBALS['egw_info']['user']['account_id'] ||	// always incl. own calendar!
95
-				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals))
93
+			if (in_array('A', $cals) || in_array($account_id, $cals) ||
94
+				$account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar!
95
+				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals))
96 96
 			{
97 97
 				$folderlist[] = $f = array(
98
-					'id'	=>	$this->backend->createID('calendar',$account_id),
99
-					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'),
98
+					'id'	=>	$this->backend->createID('calendar', $account_id),
99
+					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'),
100 100
 					'parent'=>	'0',
101 101
 				);
102 102
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$folderObj = new SyncFolder();
121 121
 		$folderObj->serverid = $id;
122 122
 		$folderObj->parentid = '0';
123
-		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname');
123
+		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname');
124 124
 		if ($owner == $GLOBALS['egw_info']['user']['account_id'])
125 125
 		{
126 126
 			$folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 		$stat = array(
156 156
 			'id'	 => $id,
157
-			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'),
157
+			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'),
158 158
 			'parent' => '0',
159 159
 		);
160 160
 		//error_log(__METHOD__."('$id') folderObj=".array2string($stat));
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180 180
   	 */
181
-	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
181
+	function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
184 184
 
185 185
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
186 186
 		$type = $user = null;
187
-		$this->backend->splitID($id,$type,$user);
187
+		$this->backend->splitID($id, $type, $user);
188 188
 
189
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
189
+		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences
190 190
 
191 191
 		$filter = array(
192 192
 			'users' => $user,
193
-			'start' => $cutoffdate,	// default one month back -30 breaks all sync recurrences
193
+			'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences
194 194
 			'enum_recuring' => false,
195 195
 			'daywise' => false,
196 196
 			'date_format' => 'server',
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 			'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default',
200 200
 			// @todo return only etag relevant information (seems not to work ...)
201 201
 			//'cols'		=> array('egw_cal.cal_id', 'cal_start',	'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'),
202
-			'query' => array('cal_recurrence' => 0),	// do NOT return recurrence exceptions
202
+			'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions
203 203
 		);
204 204
 
205 205
 		$messagelist = array();
206 206
 		// reading events in chunks of 100, to keep memory down for huge calendars
207 207
 		$num_rows = 100;
208
-		for($start=0; ($events = $this->calendar->search($filter+array(
208
+		for ($start = 0; ($events = $this->calendar->search($filter + array(
209 209
 			'offset'   => $start,
210 210
 			'num_rows' => $num_rows,
211 211
 		))); $start += $num_rows)
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @param int $cutoffdate =null
241 241
 	 * @return array
242 242
 	 */
243
-	function GetMeetingRequests(array $not_uids, $cutoffdate=NULL)
243
+	function GetMeetingRequests(array $not_uids, $cutoffdate = NULL)
244 244
 	{
245 245
 		unset($not_uids, $cutoffdate);
246 246
 		return array();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	function StatMeetingRequest($id)
268 268
 	{
269
-		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']);	// users personal calendar
269
+		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar
270 270
 
271 271
 		$ret = $this->StatMessage($folderid, abs($id));
272 272
 		$ret['id'] = $id;
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 * @param bool $mimesupport
286 286
 	 * @return SyncMail
287 287
 	 */
288
-	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
288
+	function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
289 289
 	{
290
-		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
290
+		unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature
291 291
 
292 292
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
293 293
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 			$message = new SyncMail();
301 301
 			$message->read = false;
302 302
 			$message->subject = $event['title'];
303
-			$message->importance = 1;	// 0=Low, 1=Normal, 2=High
303
+			$message->importance = 1; // 0=Low, 1=Normal, 2=High
304 304
 			$message->datereceived = $event['created'];
305 305
 			$message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email'];
306
-			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname').
307
-				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>';
306
+			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname').
307
+				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>';
308 308
 			$message->internetcpid = 65001;
309
-			$message->contentclass="urn:content-classes:message";
309
+			$message->contentclass = "urn:content-classes:message";
310 310
 
311 311
 			$message->meetingrequest = self::meetingRequest($event);
312 312
 			$message->messageclass = "IPM.Schedule.Meeting.Request";
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			else
322 322
 			{
323 323
 				$message->airsyncbasebody = new SyncAirSyncBaseBody();
324
-				$message->airsyncbasenativebodytype=1;
324
+				$message->airsyncbasenativebodytype = 1;
325 325
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody);
326 326
 			}
327 327
 		}
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 			$as_tz = self::tz2as($event['tzid']);
357 357
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
358 358
 		}
359
-		catch(Exception $e) {
359
+		catch (Exception $e) {
360 360
 			unset($e);
361 361
 			// ignore exception, simply set no timezone, as it is optional
362 362
 		}
363 363
 		// copying timestamps (they are already read in servertime, so non tz conversation)
364
-		foreach(array(
364
+		foreach (array(
365 365
 			'start' => 'starttime',
366 366
 			'end'   => 'endtime',
367 367
 			'created' => 'dtstamp',
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 		}
372 372
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
373 373
 		{
374
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
374
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
375 375
 		}
376 376
 		// copying strings
377
-		foreach(array(
377
+		foreach (array(
378 378
 			'title' => 'subject',
379 379
 			'location' => 'location',
380 380
 		) as $key => $attr)
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 		}
384 384
 		$message->organizer = $event['organizer'];
385 385
 
386
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
386
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
387 387
 
388 388
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
389 389
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
390 390
 
391 391
 		// ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ...
392
-		$message->instancetype = 0;	// 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
392
+		$message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
393 393
 
394
-		$message->responserequested = 1;	//0=No, 1=Yes
395
-		$message->disallownewtimeproposal = 1;	//1=forbidden, 0=allowed
394
+		$message->responserequested = 1; //0=No, 1=Yes
395
+		$message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed
396 396
 		//$message->messagemeetingtype;	// email2
397 397
 
398 398
 		// ToDo: alarme: Reminder
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 			// check if event already exist (invitation of or already imported by other user)
439 439
 			if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server')))
440 440
 			{
441
-				$event = $parsed_event;	// create new event from external invitation
441
+				$event = $parsed_event; // create new event from external invitation
442 442
 			}
443
-			elseif(!isset($event['participants'][$uid]))
443
+			elseif (!isset($event['participants'][$uid]))
444 444
 			{
445 445
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event));
446 446
 				// maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ...
447 447
 			}
448
-			elseif($event['deleted'])
448
+			elseif ($event['deleted'])
449 449
 			{
450 450
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false");
451 451
 				return false;
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 		else
469 469
 		{
470 470
 			$event['participants'][$uid] = $status;
471
-			$ret = $this->calendar->update($event, true);	// true = ignore conflicts, as there seems no conflict handling in AS
471
+			$ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS
472 472
 		}
473 473
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret));
474 474
 		return $ret;
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 	 * @var array
481 481
 	 */
482 482
 	static $status2as = array(
483
-		'U' => 0,	// unknown
484
-		'T' => 2,	// tentative
485
-		'A' => 3,	// accepted
486
-		'R' => 4,	// decline
483
+		'U' => 0, // unknown
484
+		'T' => 2, // tentative
485
+		'A' => 3, // accepted
486
+		'R' => 4, // decline
487 487
 		// 5 = not responded
488 488
 	);
489 489
 	/**
@@ -492,9 +492,9 @@  discard block
 block discarded – undo
492 492
 	 * @var array
493 493
 	 */
494 494
 	static $role2as = array(
495
-		'REQ-PARTICIPANT' => 1,	// required
496
-		'CHAIR' => 1,			// required
497
-		'OPT-PARTICIPANT' => 2,	// optional
495
+		'REQ-PARTICIPANT' => 1, // required
496
+		'CHAIR' => 1, // required
497
+		'OPT-PARTICIPANT' => 2, // optional
498 498
 		'NON-PARTICIPANT' => 2,
499 499
 		// 3 = ressource
500 500
 	);
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	static $recur_type2as = array(
507 507
 		calendar_rrule::DAILY => 0,
508 508
 		calendar_rrule::WEEKLY => 1,
509
-		calendar_rrule::MONTHLY_MDAY => 2,	// monthly
510
-		calendar_rrule::MONTHLY_WDAY => 3,	// monthly on nth day
509
+		calendar_rrule::MONTHLY_MDAY => 2, // monthly
510
+		calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day
511 511
 		calendar_rrule::YEARLY => 5,
512 512
 		// 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears)
513 513
 	);
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	public function ChangeMessage($folderid, $_id, $message, $contentParameters)
536 536
 	{
537
-		unset($contentParameters);	// unused, but required by function signature
537
+		unset($contentParameters); // unused, but required by function signature
538 538
 
539 539
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
540 540
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 
545 545
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account");
546 546
 
547
-		list($id,$recur_date) = explode(':', $_id);
547
+		list($id, $recur_date) = explode(':', $_id);
548 548
 
549 549
 		if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server')))
550 550
 		{
@@ -557,21 +557,21 @@  discard block
 block discarded – undo
557 557
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
558 558
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
559 559
 		}
560
-		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
560
+		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0, $account))
561 561
 		{
562 562
 			// @todo: write in users calendar and make account only a participant
563 563
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!");
564 564
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
565 565
 			return false;
566 566
 		}
567
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
567
+		if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events
568 568
 
569 569
 		$event = $this->message2event($message, $account, $old_event);
570 570
 
571 571
 		// store event, ignore conflicts and skip notifications, as AS clients do their own notifications
572 572
 		$skip_notification = false;
573 573
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
574
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send')
574
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'send')
575 575
 		{
576 576
 			$skip_notification = true; // to avoid double notification from client AND Server
577 577
 		}
@@ -584,16 +584,16 @@  discard block
 block discarded – undo
584 584
 		// store non-delete exceptions
585 585
 		if ($message->exceptions)
586 586
 		{
587
-			foreach($message->exceptions as $exception)
587
+			foreach ($message->exceptions as $exception)
588 588
 			{
589 589
 				if (!$exception->deleted)
590 590
 				{
591 591
 					$ex_event = $event;
592 592
 					unset($ex_event['id']);
593 593
 					unset($ex_event['etag']);
594
-					foreach(array_keys($ex_event) as $name)
594
+					foreach (array_keys($ex_event) as $name)
595 595
 					{
596
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
596
+						if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]);
597 597
 					}
598 598
 					$ex_event['recur_type'] = calendar_rrule::NONE;
599 599
 
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
 						'user' => $account,
602 602
 						'enum_recuring' => false,
603 603
 						'daywise' => false,
604
-						'filter' => 'owner',  // return all possible entries
604
+						'filter' => 'owner', // return all possible entries
605 605
 						'query' => array(
606 606
 							'cal_uid' => $event['uid'],
607
-							'cal_recurrence' => $exception->exceptionstarttime,	// in servertime
607
+							'cal_recurrence' => $exception->exceptionstarttime, // in servertime
608 608
 						),
609 609
 					))))
610 610
 					{
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 						$participants = $event['participants'];
617 617
 					}
618 618
 					$save_event = $this->message2event($exception, $account, $ex_event);
619
-					$save_event['participants'] = $participants;	// not contained in $exception
619
+					$save_event['participants'] = $participants; // not contained in $exception
620 620
 					$save_event['reference'] = $event['id'];
621 621
 					$save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime);
622 622
 					$ex_ok = $this->calendar->save($save_event);
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 	 * @param array $event =array()
639 639
 	 * @return array
640 640
 	 */
641
-	private function message2event(SyncAppointment $message, $account, $event=array())
641
+	private function message2event(SyncAppointment $message, $account, $event = array())
642 642
 	{
643 643
 		// timestamps (created & modified are updated automatically)
644
-		foreach(array(
644
+		foreach (array(
645 645
 			'start' => 'starttime',
646 646
 			'end' => 'endtime',
647 647
 		) as $key => $attr)
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
650 650
 		}
651 651
 		// copying strings
652
-		foreach(array(
652
+		foreach (array(
653 653
 			'title' => 'subject',
654 654
 			'uid'   => 'uid',
655 655
 			'location' => 'location',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		{
665 665
 			$event['description'] = $description;
666 666
 		}
667
-		$event['public'] = (int)($message->sensitivity < 1);	// 0=normal, 1=personal, 2=private, 3=confidential
667
+		$event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential
668 668
 
669 669
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
670 670
 		if (isset($message->busystatus))
@@ -674,21 +674,21 @@  discard block
 block discarded – undo
674 674
 
675 675
 		if (($event['whole_day'] = $message->alldayevent))
676 676
 		{
677
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
678
-			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
677
+			if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day
678
+			$event['end']--; // otherwise our whole-day event code in save makes it one more day!
679 679
 		}
680 680
 
681 681
 		$participants = array();
682
-		foreach((array)$message->attendees as $attendee)
682
+		foreach ((array)$message->attendees as $attendee)
683 683
 		{
684
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
684
+			if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later
685 685
 
686 686
 			$matches = null;
687
-			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
687
+			if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches))
688 688
 			{
689 689
 				$uid = $matches[1];
690 690
 			}
691
-			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email')))
691
+			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email')))
692 692
 			{
693 693
 				$search = array(
694 694
 					'email' => $attendee->email,
@@ -698,13 +698,13 @@  discard block
 block discarded – undo
698 698
 				// search addressbook for participant
699 699
 				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
700 700
 				if ((list($data) = $this->addressbook->search($search,
701
-					array('id','egw_addressbook.account_id as account_id','n_fn'),
701
+					array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
702 702
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
703
-					'','',false,'OR')))
703
+					'', '', false, 'OR')))
704 704
 				{
705 705
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
706 706
 				}
707
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
707
+				elseif ($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
708 708
 				{
709 709
 					$uid = 'e'.$attendee->email;
710 710
 				}
@@ -722,8 +722,8 @@  discard block
 block discarded – undo
722 722
 				//ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role");
723 723
 			}
724 724
 			// check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set
725
-			elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) ||
726
-				(isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>']))))
725
+			elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) ||
726
+				(isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>']))))
727 727
 			{
728 728
 				$status = $event['participants'][$u];
729 729
 				calendar_so::split_status($status, $quantity, $role);
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
 				$role = 'REQ-PARTICIPANT';
737 737
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
738 738
 			}
739
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
739
+			if ($role == 'CHAIR') $chair_set = true; // by role from existing participant
740 740
 
741
-			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
741
+			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as)))
742 742
 			{
743 743
 				$status = $s;
744 744
 			}
@@ -748,29 +748,29 @@  discard block
 block discarded – undo
748 748
 				$chair_set = true;
749 749
 			}
750 750
 			elseif (isset($attendee->attendeetype) &&
751
-				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
752
-				($r = array_search($attendee->attendeetype,self::$role2as)) &&
751
+				!($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER
752
+				($r = array_search($attendee->attendeetype, self::$role2as)) &&
753 753
 				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
754 754
 			{
755 755
 				$role = $r;
756 756
 			}
757 757
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
758
-			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
758
+			$participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role);
759 759
 		}
760 760
 		// if organizer is not already participant, add him as chair
761
-		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid]))
761
+		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid]))
762 762
 		{
763 763
 			$participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ?
764
-				'A' : 'U',1,'CHAIR');
764
+				'A' : 'U', 1, 'CHAIR');
765 765
 			$chair_set = true;
766 766
 		}
767 767
 		// preserve all resource types not account, contact or email (eg. resources) for existing events
768 768
 		// $account is also preserved, as AS does not add him as participant!
769
-		foreach((array)$event['participant_types'] as $type => $parts)
769
+		foreach ((array)$event['participant_types'] as $type => $parts)
770 770
 		{
771
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
771
+			if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS
772 772
 
773
-			foreach($parts as $id => $status)
773
+			foreach ($parts as $id => $status)
774 774
 			{
775 775
 				// accounts are represented correctly, but the event owner which is no participant in AS
776 776
 				if ($type == 'u' && $id != $account) continue;
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 		if (!$event['id'] || !$participants || !isset($participants[$account]))
787 787
 		{
788 788
 			$participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ?
789
-				'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
789
+				'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
790 790
 		}
791 791
 		$event['participants'] = $participants;
792 792
 
793 793
 		if (isset($message->categories))
794 794
 		{
795
-			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen'));
795
+			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen'));
796 796
 		}
797 797
 
798 798
 		// check if event is recurring and import recur information (incl. timezone)
@@ -802,8 +802,7 @@  discard block
 block discarded – undo
802 802
 			{
803 803
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
804 804
 			}
805
-			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
806
-				array_search($message->recurrence->type, self::$recur_type2as);
805
+			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as);
807 806
 			$event['recur_interval'] = $message->recurrence->interval;
808 807
 
809 808
 			switch ($event['recur_type'])
@@ -812,7 +811,7 @@  discard block
 block discarded – undo
812 811
 					// $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date
813 812
 					// fall throught
814 813
 				case calendar_rrule::WEEKLY:
815
-					$event['recur_data'] = $message->recurrence->dayofweek;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
814
+					$event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
816 815
 					break;
817 816
 				case calendar_rrule::MONTHLY_MDAY:
818 817
 					// $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date
@@ -828,7 +827,7 @@  discard block
 block discarded – undo
828 827
 			$event['recur_exceptions'] = array();
829 828
 			if ($message->exceptions)
830 829
 			{
831
-				foreach($message->exceptions as $exception)
830
+				foreach ($message->exceptions as $exception)
832 831
 				{
833 832
 					$event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime);
834 833
 				}
@@ -838,7 +837,7 @@  discard block
 block discarded – undo
838 837
 			{
839 838
 				// calculate enddate from occurences count, as we only support enddate
840 839
 				$count = $message->recurrence->occurrences;
841
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
840
+				foreach (calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
842 841
 				{
843 842
 					if (--$count <= 0) break;
844 843
 				}
@@ -848,11 +847,11 @@  discard block
 block discarded – undo
848 847
 		// only import alarms in own calendar
849 848
 		if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id'])
850 849
 		{
851
-			foreach((array)$event['alarm'] as $alarm)
850
+			foreach ((array)$event['alarm'] as $alarm)
852 851
 			{
853
-				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder)
852
+				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder)
854 853
 				{
855
-					$alarm = true;	// alarm already exists --> do nothing
854
+					$alarm = true; // alarm already exists --> do nothing
856 855
 					break;
857 856
 				}
858 857
 			}
@@ -861,16 +860,16 @@  discard block
 block discarded – undo
861 860
 				// delete all earlier alarms of that user
862 861
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
863 862
 				// --> if a later alarm is returned, user probably modifed an existing alarm
864
-				foreach((array)$event['alarm'] as $key => $alarm)
863
+				foreach ((array)$event['alarm'] as $key => $alarm)
865 864
 				{
866
-					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
865
+					if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder)
867 866
 					{
868 867
 						unset($event['alarm'][$key]);
869 868
 					}
870 869
 				}
871 870
 				$event['alarm'][] = $alarm = array(
872 871
 					'owner' => $account,
873
-					'offset' => 60*$message->reminder,
872
+					'offset' => 60 * $message->reminder,
874 873
 				);
875 874
 			}
876 875
 		}
@@ -944,7 +943,7 @@  discard block
 block discarded – undo
944 943
 	 */
945 944
 	public function DeleteMessage($folderid, $id, $contentParameters)
946 945
 	{
947
-		unset($contentParameters);	// not used, but required by function signature
946
+		unset($contentParameters); // not used, but required by function signature
948 947
 
949 948
 		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
950 949
 
@@ -972,7 +971,7 @@  discard block
 block discarded – undo
972 971
 	 */
973 972
 	function SetReadFlag($folderid, $id, $flags, $contentParameters)
974 973
 	{
975
-		unset($contentParameters);	// not used, but required by function signature
974
+		unset($contentParameters); // not used, but required by function signature
976 975
 
977 976
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, ".array2string($flags)." NOT supported!");
978 977
 		return false;
@@ -1006,7 +1005,7 @@  discard block
 block discarded – undo
1006 1005
 	 * @param string $class ='SyncAppointment' or 'SyncAppointmentException'
1007 1006
 	 * @return SyncAppointment|boolean false on error
1008 1007
 	 */
1009
-	public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment')
1008
+	public function GetMessage($folderid, $id, $contentparameters, $class = 'SyncAppointment')
1010 1009
 	{
1011 1010
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1012 1011
 		//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace());
@@ -1024,17 +1023,17 @@  discard block
 block discarded – undo
1024 1023
 		}
1025 1024
 		else
1026 1025
 		{
1027
-			list($id,$recur_date) = explode(':',$id);
1028
-			if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account)))
1026
+			list($id, $recur_date) = explode(':', $id);
1027
+			if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account)))
1029 1028
 			{
1030 1029
 				error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false");
1031 1030
 				return false;
1032 1031
 			}
1033 1032
 		}
1034
-		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence']));
1035
-		foreach((array)$event['recur_exception'] as $ex)
1033
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence']));
1034
+		foreach ((array)$event['recur_exception'] as $ex)
1036 1035
 		{
1037
-			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s',$ex));
1036
+			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s', $ex));
1038 1037
 		}
1039 1038
 		$message = new $class();
1040 1039
 
@@ -1043,14 +1042,14 @@  discard block
 block discarded – undo
1043 1042
 			$as_tz = self::tz2as($event['tzid']);
1044 1043
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
1045 1044
 		}
1046
-		catch(Exception $e) {
1045
+		catch (Exception $e) {
1047 1046
 			unset($e);
1048 1047
 			// z-push (2.3 at least) requires a timezone for recurring events
1049 1048
 			if ($event['recur_type']) $message->timezone = self::UTC_BLOB;
1050 1049
 		}
1051 1050
 
1052 1051
 		// copying timestamps (they are already read in servertime, so non tz conversation)
1053
-		foreach(array(
1052
+		foreach (array(
1054 1053
 			'start' => 'starttime',
1055 1054
 			'end'   => 'endtime',
1056 1055
 			'created' => 'dtstamp',
@@ -1061,10 +1060,10 @@  discard block
 block discarded – undo
1061 1060
 		}
1062 1061
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1063 1062
 		{
1064
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
1063
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
1065 1064
 		}
1066 1065
 		// copying strings
1067
-		foreach(array(
1066
+		foreach (array(
1068 1067
 			'title' => 'subject',
1069 1068
 			'uid'   => 'uid',
1070 1069
 			'location' => 'location',
@@ -1086,21 +1085,21 @@  discard block
 block discarded – undo
1086 1085
 			{
1087 1086
 				ZLog::Write(LOGLEVEL_DEBUG, "airsyncbasebody!");
1088 1087
 				$message->asbody = new SyncBaseBody();
1089
-				$message->nativebodytype=1;
1088
+				$message->nativebodytype = 1;
1090 1089
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->asbody);
1091 1090
 			}
1092 1091
 		}
1093
-		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname');
1092
+		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname');
1094 1093
 		// at least iOS calendar crashes, if organizer has no email address (true = generate an email, if user has none)
1095 1094
 		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email', true);
1096 1095
 
1097
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
1096
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
1098 1097
 
1099 1098
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
1100 1099
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
1101 1100
 
1102 1101
 		$message->attendees = array();
1103
-		foreach($event['participants'] as $uid => $status)
1102
+		foreach ($event['participants'] as $uid => $status)
1104 1103
 		{
1105 1104
 			// AS does NOT want calendar owner as participant
1106 1105
 			if ($uid == $account) continue;
@@ -1112,13 +1111,13 @@  discard block
 block discarded – undo
1112 1111
 			$attendee->attendeetype = (int)self::$role2as[$role];
1113 1112
 			if (is_numeric($uid))
1114 1113
 			{
1115
-				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname');
1114
+				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname');
1116 1115
 				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email', true);
1117 1116
 			}
1118 1117
 			else
1119 1118
 			{
1120 1119
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1121
-					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1120
+					ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false);
1122 1121
 
1123 1122
 				if (!$info) continue;
1124 1123
 
@@ -1136,7 +1135,7 @@  discard block
 block discarded – undo
1136 1135
 					$message->organizeremail = $attendee->email;
1137 1136
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1138 1137
 				}
1139
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1138
+				if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource
1140 1139
 			}
1141 1140
 			// email must NOT be empty, but MAY be an arbitrary text
1142 1141
 			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
@@ -1144,7 +1143,7 @@  discard block
 block discarded – undo
1144 1143
 			$message->attendees[] = $attendee;
1145 1144
 		}
1146 1145
 		$message->categories = array();
1147
-		foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id)
1146
+		foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id)
1148 1147
 		{
1149 1148
 			$message->categories[] = Api\Categories::id2name($cat_id);
1150 1149
 		}
@@ -1153,25 +1152,25 @@  discard block
 block discarded – undo
1153 1152
 		if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date)
1154 1153
 		{
1155 1154
 			$message->recurrence = $recurrence = new SyncRecurrence();
1156
-			$rrule = calendar_rrule::event2rrule($event,false);	// false = timestamps in $event are servertime
1155
+			$rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime
1157 1156
 			$recurrence->type = (int)self::$recur_type2as[$rrule->type];
1158 1157
 			$recurrence->interval = $rrule->interval;
1159 1158
 			switch ($rrule->type)
1160 1159
 			{
1161 1160
 				case calendar_rrule::MONTHLY_WDAY:
1162 1161
 					$recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ?
1163
-						$rrule->monthly_byday_num : 5;	// 1..5=last week of month, not -1
1162
+						$rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1
1164 1163
 					// fall throught
1165 1164
 				case calendar_rrule::WEEKLY:
1166
-					$recurrence->dayofweek = $rrule->weekdays;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1165
+					$recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1167 1166
 					break;
1168 1167
 				case calendar_rrule::MONTHLY_MDAY:
1169
-					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ?	// 1..31
1170
-						$rrule->monthly_bymonthday : 31;	// not -1 for last day of month!
1168
+					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31
1169
+						$rrule->monthly_bymonthday : 31; // not -1 for last day of month!
1171 1170
 					break;
1172 1171
 				case calendar_rrule::YEARLY:
1173
-					$recurrence->dayofmonth = (int)$rrule->time->format('d');	// 1..31
1174
-					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1172
+					$recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31
1173
+					$recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12
1175 1174
 					break;
1176 1175
 			}
1177 1176
 			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
@@ -1187,9 +1186,9 @@  discard block
 block discarded – undo
1187 1186
 				// search real / non-virtual exceptions
1188 1187
 				if (!empty($event['uid']))
1189 1188
 				{
1190
-					$ex_events =& $this->calendar->search(array(
1189
+					$ex_events = & $this->calendar->search(array(
1191 1190
 						'query' => array('cal_uid' => $event['uid']),
1192
-						'filter' => 'owner',  // return all possible entries
1191
+						'filter' => 'owner', // return all possible entries
1193 1192
 						'daywise' => false,
1194 1193
 						'date_format' => 'server',
1195 1194
 					));
@@ -1198,36 +1197,36 @@  discard block
 block discarded – undo
1198 1197
 				{
1199 1198
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1200 1199
 				}
1201
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1200
+				if (count($ex_events) >= 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1202 1201
 
1203 1202
 				$message->exceptions = array();
1204
-				foreach($ex_events as $ex_event)
1203
+				foreach ($ex_events as $ex_event)
1205 1204
 				{
1206
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1205
+					if ($ex_event['id'] == $event['id']) continue; // ignore series master
1207 1206
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException');
1208 1207
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1209
-					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
1208
+					foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported)
1210 1209
 					{
1211
-						$exception->$not_supported = null;	// not allowed in exceptions :-(
1210
+						$exception->$not_supported = null; // not allowed in exceptions :-(
1212 1211
 					}
1213 1212
 					$exception->deleted = 0;
1214
-					if (($key = array_search($exception_time,$event['recur_exception'])) !== false)
1213
+					if (($key = array_search($exception_time, $event['recur_exception'])) !== false)
1215 1214
 					{
1216 1215
 						unset($event['recur_exception'][$key]);
1217 1216
 					}
1218
-					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1217
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1219 1218
 					$message->exceptions[] = $exception;
1220 1219
 				}
1221 1220
 				// add rest of exceptions as deleted
1222
-				foreach($event['recur_exception'] as $exception_time)
1221
+				foreach ($event['recur_exception'] as $exception_time)
1223 1222
 				{
1224 1223
 					if (!empty($exception_time))
1225 1224
 					{
1226 1225
 						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1227
-						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1226
+						$exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required
1228 1227
 						$exception->deleted = 1;
1229 1228
 						$exception->exceptionstarttime = $exception_time;
1230
-						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1229
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1231 1230
 						$message->exceptions[] = $exception;
1232 1231
 					}
1233 1232
 				}
@@ -1249,12 +1248,12 @@  discard block
 block discarded – undo
1249 1248
 		// only return alarms if in own calendar
1250 1249
 		if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm'])
1251 1250
 		{
1252
-			foreach($event['alarm'] as $alarm)
1251
+			foreach ($event['alarm'] as $alarm)
1253 1252
 			{
1254 1253
 				if ($alarm['all'] || $alarm['owner'] == $account)
1255 1254
 				{
1256
-					$message->reminder = $alarm['offset']/60;	// is in minutes, not seconds as in EGw
1257
-					break;	// AS supports only one alarm! (we use the next/earliest one)
1255
+					$message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw
1256
+					break; // AS supports only one alarm! (we use the next/earliest one)
1258 1257
 				}
1259 1258
 			}
1260 1259
 		}
@@ -1277,7 +1276,7 @@  discard block
 block discarded – undo
1277 1276
 	 */
1278 1277
 	public function StatMessage($folderid, $id)
1279 1278
 	{
1280
-		unset($folderid);	// not used ($id is unique), but required by function signature
1279
+		unset($folderid); // not used ($id is unique), but required by function signature
1281 1280
 
1282 1281
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1283 1282
 
@@ -1288,7 +1287,7 @@  discard block
 block discarded – undo
1288 1287
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1289 1288
 			$backup = $this->calendar->debug;
1290 1289
 			//$this->calendar->debug = 2;
1291
-			list($id) = explode(':',$id);
1290
+			list($id) = explode(':', $id);
1292 1291
 			$this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server');
1293 1292
 			$this->calendar->debug = $backup;
1294 1293
 		}
@@ -1322,7 +1321,7 @@  discard block
 block discarded – undo
1322 1321
 
1323 1322
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1324 1323
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1325
-		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1324
+		$syncstate = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too
1326 1325
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1327 1326
 		if ($syncstate == 0) $syncstate = 1;
1328 1327
 
@@ -1402,8 +1401,8 @@  discard block
 block discarded – undo
1402 1401
 
1403 1402
 		if ($tz === 'UTC') return $data;
1404 1403
 
1405
-		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1406
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1404
+		$name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz;
1405
+		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component');
1407 1406
 		// parse ical timezone defintion
1408 1407
 		$ical = self::ical2array($component);
1409 1408
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1412,11 +1411,11 @@  discard block
 block discarded – undo
1412 1411
 		if (!isset($standard))
1413 1412
 		{
1414 1413
 			$matches = null;
1415
-			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches))
1414
+			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches))
1416 1415
 			{
1417 1416
 				$standard = array(
1418
-					'TZOFFSETTO'   => sprintf('%s%02d00',$matches[1],$matches[2]),
1419
-					'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]),
1417
+					'TZOFFSETTO'   => sprintf('%s%02d00', $matches[1], $matches[2]),
1418
+					'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]),
1420 1419
 				);
1421 1420
 				unset($daylight);
1422 1421
 			}
@@ -1427,15 +1426,15 @@  discard block
 block discarded – undo
1427 1426
 		}
1428 1427
 		// get bias and dstbias from standard component, which is present in all tz's
1429 1428
 		// (dstbias is relative to bias and almost always 60 or 0)
1430
-		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2));
1431
-		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']);
1429
+		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2));
1430
+		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']);
1432 1431
 
1433 1432
 		// check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving
1434 1433
 		if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE']))
1435 1434
 		{
1436
-			foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp)
1435
+			foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp)
1437 1436
 			{
1438
-				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches))
1437
+				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches))
1439 1438
 				{
1440 1439
 					$data[$prefix.'month'] = (int)$matches[2];
1441 1440
 					$data[$prefix.'week'] = (int)$matches[1];
@@ -1452,20 +1451,20 @@  discard block
 block discarded – undo
1452 1451
 						$data[$prefix.'week'] = 5;
1453 1452
 						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1454 1453
 					}
1455
-					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1456
-					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
1454
+					static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6);
1455
+					$data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)];
1457 1456
 				}
1458
-				if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches))
1457
+				if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches))
1459 1458
 				{
1460
-					$data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60;
1461
-					$data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60;
1462
-					$data[$prefix.'second'] = (int)substr($matches[1],4,2);
1459
+					$data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60;
1460
+					$data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60;
1461
+					$data[$prefix.'second'] = (int)substr($matches[1], 4, 2);
1463 1462
 				}
1464 1463
 			}
1465 1464
 			// for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute
1466 1465
 			if ($data['dststartmonth'] > $data['dstendmonth'])
1467 1466
 			{
1468
-				$start = $data['dststarthour'];   $data['dststarthour'] = $data['dstendhour'];     $data['dstendhour'] = $start;
1467
+				$start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start;
1469 1468
 				$end = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $end;
1470 1469
 			}
1471 1470
 		}
@@ -1523,20 +1522,20 @@  discard block
 block discarded – undo
1523 1522
 	 * @param string|array $ical lines of ical file
1524 1523
 	 * @return array with parsed ical components
1525 1524
 	 */
1526
-	static public function ical2array(&$ical,$section=null)
1525
+	static public function ical2array(&$ical, $section = null)
1527 1526
 	{
1528 1527
 		$arr = array();
1529 1528
 		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1530 1529
 		while (($line = array_shift($ical)))
1531 1530
 		{
1532
-			list($name,$value) = explode(':',$line,2);
1531
+			list($name, $value) = explode(':', $line, 2);
1533 1532
 			if ($name == 'BEGIN')
1534 1533
 			{
1535
-				$arr[$value] = self::ical2array($ical,$value);
1534
+				$arr[$value] = self::ical2array($ical, $value);
1536 1535
 			}
1537
-			elseif($name == 'END')
1536
+			elseif ($name == 'END')
1538 1537
 			{
1539
-				if ($section && $section==$value) return $arr;
1538
+				if ($section && $section == $value) return $arr;
1540 1539
 				break;
1541 1540
 			}
1542 1541
 			else
@@ -1559,13 +1558,13 @@  discard block
 block discarded – undo
1559 1558
 	 */
1560 1559
 	public static function as2tz(array $data)
1561 1560
 	{
1562
-		static $cache=null;	// some caching withing the request
1561
+		static $cache = null; // some caching withing the request
1563 1562
 
1564
-		unset($data['name']);	// not used, but can stall the match
1563
+		unset($data['name']); // not used, but can stall the match
1565 1564
 
1566 1565
 		$key = serialize($data);
1567 1566
 
1568
-		for($n = 0; !isset($cache[$key]); ++$n)
1567
+		for ($n = 0; !isset($cache[$key]); ++$n)
1569 1568
 		{
1570 1569
 			if (!$n)	// check users timezone first
1571 1570
 			{
@@ -1584,7 +1583,7 @@  discard block
 block discarded – undo
1584 1583
 					break;
1585 1584
 				}
1586 1585
 			}
1587
-			catch(Exception $e) {
1586
+			catch (Exception $e) {
1588 1587
 				unset($e);
1589 1588
 				// simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component
1590 1589
 			}
@@ -1599,8 +1598,8 @@  discard block
 block discarded – undo
1599 1598
 	 */
1600 1599
 	static public function _getTZFromSyncBlob($data)
1601 1600
 	{
1602
-		$tz = unpack(	"lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" .
1603
-						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" .
1601
+		$tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/".
1602
+						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/".
1604 1603
 						"ldstbias", $data);
1605 1604
 
1606 1605
 		return $tz;
@@ -1613,7 +1612,7 @@  discard block
 block discarded – undo
1613 1612
 	 */
1614 1613
 	static public function _getSyncBlobFromTZ($tz)
1615 1614
 	{
1616
-		$packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l",
1615
+		$packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l",
1617 1616
 				$tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"],
1618 1617
 				$tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"],
1619 1618
 				$tz["dstbias"]);
@@ -1637,7 +1636,7 @@  discard block
 block discarded – undo
1637 1636
 				$account_id = $entry['grantor'];
1638 1637
 				$cals[$account_id] = $entry['name'];
1639 1638
 			}
1640
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1639
+			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user
1641 1640
 		}
1642 1641
 		$cals['G'] = lang('Primary group');
1643 1642
 		$cals['A'] = lang('All');
@@ -1673,8 +1672,8 @@  discard block
 block discarded – undo
1673 1672
 		)
1674 1673
 	);
1675 1674
 	require_once('../../header.inc.php');
1676
-	ini_set('display_errors',1);
1677
-	error_reporting(E_ALL & ~E_NOTICE);
1675
+	ini_set('display_errors', 1);
1676
+	error_reporting(E_ALL&~E_NOTICE);
1678 1677
 
1679 1678
 	echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n";
1680 1679
 	echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\n";
@@ -1688,7 +1687,7 @@  discard block
 block discarded – undo
1688 1687
 	</script>\n";
1689 1688
 
1690 1689
 	// TZID => AS timezone blobs reported by various devices
1691
-	foreach(array(
1690
+	foreach (array(
1692 1691
 		'Europe/Berlin'    => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==',
1693 1692
 		'Europe/Helsinki'  => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==',
1694 1693
 		'Asia/Tokyo'       => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==',
@@ -1702,7 +1701,7 @@  discard block
 block discarded – undo
1702 1701
 	) as $tz => $sync_blob)
1703 1702
 	{
1704 1703
 		// get as timezone data for a given timezone
1705
-		$ical = calendar_timezones::tz2id($tz,'component');
1704
+		$ical = calendar_timezones::tz2id($tz, 'component');
1706 1705
 		//echo "<pre>".print_r($ical,true)."</pre>\n";
1707 1706
 		$ical_tz = $ical;
1708 1707
 		$ical_arr = calendar_zpush::ical2array($ical_tz);
@@ -1719,22 +1718,22 @@  discard block
 block discarded – undo
1719 1718
 		//echo array2string($matched);
1720 1719
 
1721 1720
 		echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n";
1722
-		foreach(array('dststart','dstend') as $prefix)
1721
+		foreach (array('dststart', 'dstend') as $prefix)
1723 1722
 		{
1724 1723
 			echo "<td>\n";
1725
-			foreach(array($as_tz_org,$as_tz) as $n => $arr)
1724
+			foreach (array($as_tz_org, $as_tz) as $n => $arr)
1726 1725
 			{
1727 1726
 				$parts = array();
1728
-				foreach(array('year','month','day','week','hour','minute','second') as $postfix)
1727
+				foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix)
1729 1728
 				{
1730 1729
 					$failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix];
1731
-					$parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':'');
1730
+					$parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : '');
1732 1731
 				}
1733
-				echo implode(' ', $parts).(!$n?'<br/>':'');
1732
+				echo implode(' ', $parts).(!$n ? '<br/>' : '');
1734 1733
 			}
1735 1734
 			echo "</td>\n";
1736 1735
 		}
1737
-		echo "<td>&nbsp;<br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n";
1736
+		echo "<td>&nbsp;<br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n";
1738 1737
 	}
1739 1738
 	echo "</tbody></table>\n";
1740 1739
 	echo "</body></html>\n";
Please login to merge, or discard this patch.
Braces   +235 added lines, -57 removed lines patch added patch discarded remove patch
@@ -20,8 +20,12 @@  discard block
 block discarded – undo
20 20
  */
21 21
 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
22 22
 {
23
-	interface activesync_plugin_write {}
24
-	interface activesync_plugin_meeting_requests {}
23
+	interface activesync_plugin_write
24
+	{
25
+}
26
+	interface activesync_plugin_meeting_requests
27
+	{
28
+}
25 29
 }
26 30
 
27 31
 /**
@@ -81,7 +85,10 @@  discard block
 block discarded – undo
81 85
 	 */
82 86
 	public function GetFolderList()
83 87
 	{
84
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
88
+		if (!isset($this->calendar))
89
+		{
90
+			$this->calendar = new calendar_boupdate();
91
+		}
85 92
 
86 93
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
87 94
 		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
@@ -180,13 +187,20 @@  discard block
 block discarded – undo
180 187
   	 */
181 188
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 189
 	{
183
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
190
+		if (!isset($this->calendar))
191
+		{
192
+			$this->calendar = new calendar_boupdate();
193
+		}
184 194
 
185 195
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
186 196
 		$type = $user = null;
187 197
 		$this->backend->splitID($id,$type,$user);
188 198
 
189
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
199
+		if (!$cutoffdate)
200
+		{
201
+			$cutoffdate = $this->bo->now - 100*24*3600;
202
+		}
203
+		// default three month back -30 breaks all sync recurrences
190 204
 
191 205
 		$filter = array(
192 206
 			'users' => $user,
@@ -212,7 +226,10 @@  discard block
 block discarded – undo
212 226
 		{
213 227
 			foreach ($events as $event)
214 228
 			{
215
-				if ($not_uids && in_array($event['uid'], $not_uids)) continue;
229
+				if ($not_uids && in_array($event['uid'], $not_uids))
230
+				{
231
+					continue;
232
+				}
216 233
 				$messagelist[] = $this->StatMessage($id, $event);
217 234
 
218 235
 				// add virtual exceptions for recuring events too
@@ -227,7 +244,10 @@  discard block
 block discarded – undo
227 244
 					}
228 245
 				}*/
229 246
 			}
230
-			if (count($events) < $num_rows) break;
247
+			if (count($events) < $num_rows)
248
+			{
249
+				break;
250
+			}
231 251
 		}
232 252
 		//error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace());
233 253
 		return $messagelist;
@@ -289,7 +309,10 @@  discard block
 block discarded – undo
289 309
 	{
290 310
 		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
291 311
 
292
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
312
+		if (!isset($this->calendar))
313
+		{
314
+			$this->calendar = new calendar_boupdate();
315
+		}
293 316
 
294 317
 		if (!($event = $this->calendar->read(abs($id), 0, false, 'server')))
295 318
 		{
@@ -367,7 +390,10 @@  discard block
 block discarded – undo
367 390
 			'created' => 'dtstamp',
368 391
 		) as $key => $attr)
369 392
 		{
370
-			if (!empty($event[$key])) $message->$attr = $event[$key];
393
+			if (!empty($event[$key]))
394
+			{
395
+				$message->$attr = $event[$key];
396
+			}
371 397
 		}
372 398
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
373 399
 		{
@@ -379,7 +405,10 @@  discard block
 block discarded – undo
379 405
 			'location' => 'location',
380 406
 		) as $key => $attr)
381 407
 		{
382
-			if (!empty($event[$key])) $message->$attr = $event[$key];
408
+			if (!empty($event[$key]))
409
+			{
410
+				$message->$attr = $event[$key];
411
+			}
383 412
 		}
384 413
 		$message->organizer = $event['organizer'];
385 414
 
@@ -414,7 +443,10 @@  discard block
 block discarded – undo
414 443
 	 */
415 444
 	function MeetingResponse($folderid, $requestid, $response)
416 445
 	{
417
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
446
+		if (!isset($this->calendar))
447
+		{
448
+			$this->calendar = new calendar_boupdate();
449
+		}
418 450
 
419 451
 		static $as2status = array(	// different from self::$status2as!
420 452
 			1 => 'A',
@@ -424,9 +456,12 @@  discard block
 block discarded – undo
424 456
 		$status_in = isset($as2status[$response]) ? $as2status[$response] : 'U';
425 457
 		$uid = $GLOBALS['egw_info']['user']['account_id'];
426 458
 
427
-		if (!is_numeric($requestid))	// iCal from fmail
459
+		if (!is_numeric($requestid))
460
+		{
461
+			// iCal from fmail
428 462
 		{
429 463
 			$ical = new calendar_ical();
464
+		}
430 465
 			if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1)
431 466
 			{
432 467
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!");
@@ -536,7 +571,10 @@  discard block
 block discarded – undo
536 571
 	{
537 572
 		unset($contentParameters);	// unused, but required by function signature
538 573
 
539
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
574
+		if (!isset($this->calendar))
575
+		{
576
+			$this->calendar = new calendar_boupdate();
577
+		}
540 578
 
541 579
 		$old_event = array();
542 580
 		$type = $account = null;
@@ -551,10 +589,13 @@  discard block
 block discarded – undo
551 589
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing");
552 590
 			return false;
553 591
 		}
554
-		if ($recur_date)	// virtual exception
592
+		if ($recur_date)
593
+		{
594
+			// virtual exception
555 595
 		{
556 596
 			// @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed
557 597
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
598
+		}
558 599
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
559 600
 		}
560 601
 		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
@@ -564,7 +605,11 @@  discard block
 block discarded – undo
564 605
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
565 606
 			return false;
566 607
 		}
567
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
608
+		if (!$id)
609
+		{
610
+			$old_event['owner'] = $account;
611
+		}
612
+		// we do NOT allow to change the owner of existing events
568 613
 
569 614
 		$event = $this->message2event($message, $account, $old_event);
570 615
 
@@ -593,7 +638,10 @@  discard block
 block discarded – undo
593 638
 					unset($ex_event['etag']);
594 639
 					foreach(array_keys($ex_event) as $name)
595 640
 					{
596
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
641
+						if (substr($name,0,6) == 'recur_')
642
+						{
643
+							unset($ex_event[$name]);
644
+						}
597 645
 					}
598 646
 					$ex_event['recur_type'] = calendar_rrule::NONE;
599 647
 
@@ -646,7 +694,10 @@  discard block
 block discarded – undo
646 694
 			'end' => 'endtime',
647 695
 		) as $key => $attr)
648 696
 		{
649
-			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
697
+			if (isset($message->$attr))
698
+			{
699
+				$event[$key] = Api\DateTime::server2user($message->$attr);
700
+			}
650 701
 		}
651 702
 		// copying strings
652 703
 		foreach(array(
@@ -655,7 +706,10 @@  discard block
 block discarded – undo
655 706
 			'location' => 'location',
656 707
 		) as $key => $attr)
657 708
 		{
658
-			if (isset($message->$attr)) $event[$key] = $message->$attr;
709
+			if (isset($message->$attr))
710
+			{
711
+				$event[$key] = $message->$attr;
712
+			}
659 713
 		}
660 714
 
661 715
 		// only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse
@@ -674,14 +728,22 @@  discard block
 block discarded – undo
674 728
 
675 729
 		if (($event['whole_day'] = $message->alldayevent))
676 730
 		{
677
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
731
+			if ($event['end'] == $event['start'])
732
+			{
733
+				$event['end'] += 24*3600;
734
+			}
735
+			// some clients send equal start&end for 1day
678 736
 			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
679 737
 		}
680 738
 
681 739
 		$participants = array();
682 740
 		foreach((array)$message->attendees as $attendee)
683 741
 		{
684
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
742
+			if ($attendee->type == 3)
743
+			{
744
+				continue;
745
+			}
746
+			// we can not identify resources and re-add them anyway later
685 747
 
686 748
 			$matches = null;
687 749
 			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
@@ -696,7 +758,10 @@  discard block
 block discarded – undo
696 758
 					//'n_fn' => $attendee->name,	// not sure if we want matches without email
697 759
 				);
698 760
 				// search addressbook for participant
699
-				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
761
+				if (!isset($this->addressbook))
762
+				{
763
+					$this->addressbook = new Api\Contacts();
764
+				}
700 765
 				if ((list($data) = $this->addressbook->search($search,
701 766
 					array('id','egw_addressbook.account_id as account_id','n_fn'),
702 767
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
@@ -704,10 +769,13 @@  discard block
 block discarded – undo
704 769
 				{
705 770
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
706 771
 				}
707
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
772
+				elseif($attendee->name === $attendee->email || empty($attendee->name))
773
+				{
774
+					// dont store empty or email as name
708 775
 				{
709 776
 					$uid = 'e'.$attendee->email;
710 777
 				}
778
+				}
711 779
 				else	// store just the email
712 780
 				{
713 781
 					$uid = 'e'.$attendee->name.' <'.$attendee->email.'>';
@@ -736,7 +804,11 @@  discard block
 block discarded – undo
736 804
 				$role = 'REQ-PARTICIPANT';
737 805
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
738 806
 			}
739
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
807
+			if ($role == 'CHAIR')
808
+			{
809
+				$chair_set = true;
810
+			}
811
+			// by role from existing participant
740 812
 
741 813
 			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
742 814
 			{
@@ -750,10 +822,13 @@  discard block
 block discarded – undo
750 822
 			elseif (isset($attendee->attendeetype) &&
751 823
 				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
752 824
 				($r = array_search($attendee->attendeetype,self::$role2as)) &&
753
-				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
825
+				(int)self::$role2as[$role] != $attendee->attendeetype)
826
+			{
827
+				// if old role gives same type, use old role, as we have a lot more roles then AS
754 828
 			{
755 829
 				$role = $r;
756 830
 			}
831
+			}
757 832
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
758 833
 			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
759 834
 		}
@@ -768,12 +843,19 @@  discard block
 block discarded – undo
768 843
 		// $account is also preserved, as AS does not add him as participant!
769 844
 		foreach((array)$event['participant_types'] as $type => $parts)
770 845
 		{
771
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
846
+			if (in_array($type,array('c','e')))
847
+			{
848
+				continue;
849
+			}
850
+			// they are correctly representable in AS
772 851
 
773 852
 			foreach($parts as $id => $status)
774 853
 			{
775 854
 				// accounts are represented correctly, but the event owner which is no participant in AS
776
-				if ($type == 'u' && $id != $account) continue;
855
+				if ($type == 'u' && $id != $account)
856
+				{
857
+					continue;
858
+				}
777 859
 
778 860
 				$uid = calendar_so::combine_user($type, $id);
779 861
 				if (!isset($participants[$uid]))
@@ -798,10 +880,13 @@  discard block
 block discarded – undo
798 880
 		// check if event is recurring and import recur information (incl. timezone)
799 881
 		if ($message->recurrence)
800 882
 		{
801
-			if ($message->timezone && !$event['id'])	// dont care for timezone, if no new and recurring event
883
+			if ($message->timezone && !$event['id'])
884
+			{
885
+				// dont care for timezone, if no new and recurring event
802 886
 			{
803 887
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
804 888
 			}
889
+			}
805 890
 			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
806 891
 				array_search($message->recurrence->type, self::$recur_type2as);
807 892
 			$event['recur_interval'] = $message->recurrence->interval;
@@ -838,10 +923,13 @@  discard block
 block discarded – undo
838 923
 			{
839 924
 				// calculate enddate from occurences count, as we only support enddate
840 925
 				$count = $message->recurrence->occurrences;
841
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
926
+				foreach(calendar_rrule::event2rrule($event, true) as $rtime)
927
+				{
928
+					// true = timestamps are user time here, because of save!
842 929
 				{
843 930
 					if (--$count <= 0) break;
844 931
 				}
932
+				}
845 933
 				$event['recur_enddate'] = $rtime->format('ts');
846 934
 			}
847 935
 		}
@@ -856,7 +944,9 @@  discard block
 block discarded – undo
856 944
 					break;
857 945
 				}
858 946
 			}
859
-			if ($alarm !== true)	// new alarm
947
+			if ($alarm !== true)
948
+			{
949
+				// new alarm
860 950
 			{
861 951
 				// delete all earlier alarms of that user
862 952
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
@@ -866,6 +956,7 @@  discard block
 block discarded – undo
866 956
 					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
867 957
 					{
868 958
 						unset($event['alarm'][$key]);
959
+			}
869 960
 					}
870 961
 				}
871 962
 				$event['alarm'][] = $alarm = array(
@@ -946,7 +1037,10 @@  discard block
 block discarded – undo
946 1037
 	{
947 1038
 		unset($contentParameters);	// not used, but required by function signature
948 1039
 
949
-		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
1040
+		if (!isset($this->caledar))
1041
+		{
1042
+			$this->calendar = new calendar_boupdate();
1043
+		}
950 1044
 
951 1045
 		$ret = $this->calendar->delete($id);
952 1046
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -1008,7 +1102,10 @@  discard block
 block discarded – undo
1008 1102
 	 */
1009 1103
 	public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment')
1010 1104
 	{
1011
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1105
+		if (!isset($this->calendar))
1106
+		{
1107
+			$this->calendar = new calendar_boupdate();
1108
+		}
1012 1109
 		//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace());
1013 1110
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
1014 1111
 		$mimesupport = $contentparameters->GetMimeSupport();
@@ -1046,7 +1143,10 @@  discard block
 block discarded – undo
1046 1143
 		catch(Exception $e) {
1047 1144
 			unset($e);
1048 1145
 			// z-push (2.3 at least) requires a timezone for recurring events
1049
-			if ($event['recur_type']) $message->timezone = self::UTC_BLOB;
1146
+			if ($event['recur_type'])
1147
+			{
1148
+				$message->timezone = self::UTC_BLOB;
1149
+			}
1050 1150
 		}
1051 1151
 
1052 1152
 		// copying timestamps (they are already read in servertime, so non tz conversation)
@@ -1057,7 +1157,10 @@  discard block
 block discarded – undo
1057 1157
 			'modified' => 'dtstamp',
1058 1158
 		) as $key => $attr)
1059 1159
 		{
1060
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1160
+			if (!empty($event[$key]))
1161
+			{
1162
+				$message->$attr = $event[$key];
1163
+			}
1061 1164
 		}
1062 1165
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1063 1166
 		{
@@ -1070,7 +1173,10 @@  discard block
 block discarded – undo
1070 1173
 			'location' => 'location',
1071 1174
 		) as $key => $attr)
1072 1175
 		{
1073
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1176
+			if (!empty($event[$key]))
1177
+			{
1178
+				$message->$attr = $event[$key];
1179
+			}
1074 1180
 		}
1075 1181
 
1076 1182
 		// appoint description
@@ -1103,7 +1209,10 @@  discard block
 block discarded – undo
1103 1209
 		foreach($event['participants'] as $uid => $status)
1104 1210
 		{
1105 1211
 			// AS does NOT want calendar owner as participant
1106
-			if ($uid == $account) continue;
1212
+			if ($uid == $account)
1213
+			{
1214
+				continue;
1215
+			}
1107 1216
 			$quantity = $role = null;
1108 1217
 			calendar_so::split_status($status, $quantity, $role);
1109 1218
 
@@ -1120,7 +1229,10 @@  discard block
 block discarded – undo
1120 1229
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1121 1230
 					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1122 1231
 
1123
-				if (!$info) continue;
1232
+				if (!$info)
1233
+				{
1234
+					continue;
1235
+				}
1124 1236
 
1125 1237
 				if (!$info['email'] && $info['responsible'])
1126 1238
 				{
@@ -1136,10 +1248,17 @@  discard block
 block discarded – undo
1136 1248
 					$message->organizeremail = $attendee->email;
1137 1249
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1138 1250
 				}
1139
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1251
+				if ($uid[0] == 'r')
1252
+				{
1253
+					$attendee->type = 3;
1254
+				}
1255
+				// 3 = resource
1140 1256
 			}
1141 1257
 			// email must NOT be empty, but MAY be an arbitrary text
1142
-			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
1258
+			if (empty($attendee->email))
1259
+			{
1260
+				$attendee->email = 'noreply-'.$uid.'[email protected]';
1261
+			}
1143 1262
 
1144 1263
 			$message->attendees[] = $attendee;
1145 1264
 		}
@@ -1174,9 +1293,12 @@  discard block
 block discarded – undo
1174 1293
 					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1175 1294
 					break;
1176 1295
 			}
1177
-			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
1296
+			if ($rrule->enddate)
1297
+			{
1298
+				// enddate is only a date, but AS needs a time incl. correct starttime!
1178 1299
 			{
1179 1300
 				$enddate = clone $rrule->time;
1301
+			}
1180 1302
 				$enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'),
1181 1303
 					$rrule->enddate->format('d'));
1182 1304
 				$recurrence->until = $enddate->format('server');
@@ -1198,12 +1320,19 @@  discard block
 block discarded – undo
1198 1320
 				{
1199 1321
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1200 1322
 				}
1201
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1323
+				if (count($ex_events)>=1)
1324
+				{
1325
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1326
+				}
1202 1327
 
1203 1328
 				$message->exceptions = array();
1204 1329
 				foreach($ex_events as $ex_event)
1205 1330
 				{
1206
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1331
+					if ($ex_event['id'] == $event['id'])
1332
+					{
1333
+						continue;
1334
+					}
1335
+					// ignore series master
1207 1336
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException');
1208 1337
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1209 1338
 					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
@@ -1223,7 +1352,10 @@  discard block
 block discarded – undo
1223 1352
 				{
1224 1353
 					if (!empty($exception_time))
1225 1354
 					{
1226
-						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1355
+						if (empty($event['uid']))
1356
+						{
1357
+							ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1358
+						}
1227 1359
 						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1228 1360
 						$exception->deleted = 1;
1229 1361
 						$exception->exceptionstarttime = $exception_time;
@@ -1279,12 +1411,18 @@  discard block
 block discarded – undo
1279 1411
 	{
1280 1412
 		unset($folderid);	// not used ($id is unique), but required by function signature
1281 1413
 
1282
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1414
+		if (!isset($this->calendar))
1415
+		{
1416
+			$this->calendar = new calendar_boupdate();
1417
+		}
1283 1418
 
1284 1419
 		$nul = null;
1285
-		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))	// last true: $only_master=true
1420
+		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))
1421
+		{
1422
+			// last true: $only_master=true
1286 1423
 		{
1287 1424
 			$stat = false;
1425
+		}
1288 1426
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1289 1427
 			$backup = $this->calendar->debug;
1290 1428
 			//$this->calendar->debug = 2;
@@ -1318,13 +1456,22 @@  discard block
 block discarded – undo
1318 1456
 		$type = $owner = null;
1319 1457
 		$this->backend->splitID($folderid, $type, $owner);
1320 1458
 
1321
-		if ($type != 'calendar') return false;
1459
+		if ($type != 'calendar')
1460
+		{
1461
+			return false;
1462
+		}
1322 1463
 
1323
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1464
+		if (!isset($this->calendar))
1465
+		{
1466
+			$this->calendar = new calendar_boupdate();
1467
+		}
1324 1468
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1325 1469
 		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1326 1470
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1327
-		if ($syncstate == 0) $syncstate = 1;
1471
+		if ($syncstate == 0)
1472
+		{
1473
+			$syncstate = 1;
1474
+		}
1328 1475
 
1329 1476
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'");
1330 1477
 	}
@@ -1400,10 +1547,16 @@  discard block
 block discarded – undo
1400 1547
 			'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0,
1401 1548
 		);
1402 1549
 
1403
-		if ($tz === 'UTC') return $data;
1550
+		if ($tz === 'UTC')
1551
+		{
1552
+			return $data;
1553
+		}
1404 1554
 
1405 1555
 		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1406
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1556
+		if (strpos($component, 'VTIMEZONE') === false)
1557
+		{
1558
+			$component = calendar_timezones::tz2id($name,'component');
1559
+		}
1407 1560
 		// parse ical timezone defintion
1408 1561
 		$ical = self::ical2array($component);
1409 1562
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1446,11 +1599,17 @@  discard block
 block discarded – undo
1446 1599
 						$data[$prefix.'week'] = 5;
1447 1600
 					}
1448 1601
 					// if both start and end use 1SU use week=5 and decrement month
1449
-					if ($prefix == 'dststart') $start_byday = $matches[1];
1602
+					if ($prefix == 'dststart')
1603
+					{
1604
+						$start_byday = $matches[1];
1605
+					}
1450 1606
 					if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU')
1451 1607
 					{
1452 1608
 						$data[$prefix.'week'] = 5;
1453
-						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1609
+						if ($prefix == 'dstend')
1610
+						{
1611
+							$data[$prefix.'month'] -= 1;
1612
+						}
1454 1613
 					}
1455 1614
 					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1456 1615
 					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
@@ -1526,7 +1685,10 @@  discard block
 block discarded – undo
1526 1685
 	static public function ical2array(&$ical,$section=null)
1527 1686
 	{
1528 1687
 		$arr = array();
1529
-		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1688
+		if (!is_array($ical))
1689
+		{
1690
+			$ical = preg_split("/[\r\n]+/m", $ical);
1691
+		}
1530 1692
 		while (($line = array_shift($ical)))
1531 1693
 		{
1532 1694
 			list($name,$value) = explode(':',$line,2);
@@ -1536,7 +1698,10 @@  discard block
 block discarded – undo
1536 1698
 			}
1537 1699
 			elseif($name == 'END')
1538 1700
 			{
1539
-				if ($section && $section==$value) return $arr;
1701
+				if ($section && $section==$value)
1702
+				{
1703
+					return $arr;
1704
+				}
1540 1705
 				break;
1541 1706
 			}
1542 1707
 			else
@@ -1567,13 +1732,19 @@  discard block
 block discarded – undo
1567 1732
 
1568 1733
 		for($n = 0; !isset($cache[$key]); ++$n)
1569 1734
 		{
1570
-			if (!$n)	// check users timezone first
1735
+			if (!$n)
1736
+			{
1737
+				// check users timezone first
1571 1738
 			{
1572 1739
 				$tz = Api\DateTime::$user_timezone->getName();
1573 1740
 			}
1574
-			elseif (!($tz = calendar_timezones::id2tz($n)))	// no further timezones to check
1741
+			}
1742
+			elseif (!($tz = calendar_timezones::id2tz($n)))
1743
+			{
1744
+				// no further timezones to check
1575 1745
 			{
1576 1746
 				$cache[$key] = 'UTC';
1747
+			}
1577 1748
 				error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!');
1578 1749
 				break;
1579 1750
 			}
@@ -1637,7 +1808,11 @@  discard block
 block discarded – undo
1637 1808
 				$account_id = $entry['grantor'];
1638 1809
 				$cals[$account_id] = $entry['name'];
1639 1810
 			}
1640
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1811
+			if ($hook_data['account_id'] > 0)
1812
+			{
1813
+				unset($cals[$hook_data['account_id']]);
1814
+			}
1815
+			// skip current user
1641 1816
 		}
1642 1817
 		$cals['G'] = lang('Primary group');
1643 1818
 		$cals['A'] = lang('All');
@@ -1665,13 +1840,16 @@  discard block
 block discarded – undo
1665 1840
  *
1666 1841
  * You need to comment implements activesync_plugin_write
1667 1842
  */
1668
-if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)	// some tests
1843
+if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
1844
+{
1845
+	// some tests
1669 1846
 {
1670 1847
 	$GLOBALS['egw_info'] = array(
1671 1848
 		'flags' => array(
1672 1849
 			'currentapp' => 'login'
1673 1850
 		)
1674 1851
 	);
1852
+}
1675 1853
 	require_once('../../header.inc.php');
1676 1854
 	ini_set('display_errors',1);
1677 1855
 	error_reporting(E_ALL & ~E_NOTICE);
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param int $truncsize
283 283
 	 * @param int $bodypreference
284 284
 	 * @param $optionbodypreference
285
-	 * @param bool $mimesupport
285
+	 * @param integer $mimesupport
286 286
 	 * @return SyncMail
287 287
 	 */
288 288
 	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @param string $id of the folder to delete
901 901
 	 *
902 902
 	 * @return
903
-	 * @TODO check what is to be returned
903
+	 boolean @TODO check what is to be returned
904 904
 	 */
905 905
 	public function DeleteFolder($parentid, $id)
906 906
 	{
@@ -1596,6 +1596,7 @@  discard block
 block discarded – undo
1596 1596
 	 * Unpack timezone info from Sync
1597 1597
 	 *
1598 1598
 	 * copied from backend/ics.php
1599
+	 * @param string $data
1599 1600
 	 */
1600 1601
 	static public function _getTZFromSyncBlob($data)
1601 1602
 	{
Please login to merge, or discard this patch.
calendar/inc/class.calendar_egw_record.inc.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 	public static $types = array(
26 26
 		'select-cat'    => array('category'),
27
-		'select-account'=> array('owner','creator', 'modifier'),
28
-		'date-time'     => array('modified', 'created','start','end','recur_date'),
27
+		'select-account'=> array('owner', 'creator', 'modifier'),
28
+		'date-time'     => array('modified', 'created', 'start', 'end', 'recur_date'),
29 29
 		'date'			=> array('recur_enddate'),
30 30
 		'select-bool'	=> array('public', 'non_blocking'),
31 31
 		'select'	=> array('priority'),
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $_identifier
39 39
 	 */
40
-	public function __construct( $_identifier='' ){
40
+	public function __construct($_identifier = '') {
41 41
 		$this->identifier = $_identifier;
42
-		if(!is_object($this->bo)) {
42
+		if (!is_object($this->bo)) {
43 43
 			$this->bo = new calendar_bo();
44 44
 		}
45
-		if($this->identifier) {
45
+		if ($this->identifier) {
46 46
 			$this->record = $this->bo->read($this->identifier);
47 47
 		}
48 48
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @todo add some checks
97 97
 	 * @return void
98 98
 	 */
99
-	public function set_record(array $_record){
99
+	public function set_record(array $_record) {
100 100
 		$this->record = $_record;
101 101
 	}
102 102
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return string identifier
126 126
 	 */
127
-	public function save ( $_dst_identifier ) {
127
+	public function save($_dst_identifier) {
128 128
 		// Not yet implemeted
129 129
 		$this->identifier = $_dst_identifier;
130 130
 	}
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @param string $_dst_identifier
136 136
 	 * @return string dst_identifier
137 137
 	 */
138
-	public function copy ( $_dst_identifier ) {
139
-		unset($_dst_identifier);	// not used
138
+	public function copy($_dst_identifier) {
139
+		unset($_dst_identifier); // not used
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 	 * @param string $_dst_identifier
147 147
 	 * @return string dst_identifier
148 148
 	 */
149
-	public function move ( $_dst_identifier ) {
150
-		unset($_dst_identifier);	// not used
149
+	public function move($_dst_identifier) {
150
+		unset($_dst_identifier); // not used
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * delets current record from backend
155 155
 	 *
156 156
 	 */
157
-	public function delete () {
157
+	public function delete() {
158 158
 
159 159
 	}
160 160
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,12 +37,15 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $_identifier
39 39
 	 */
40
-	public function __construct( $_identifier='' ){
40
+	public function __construct( $_identifier='' )
41
+	{
41 42
 		$this->identifier = $_identifier;
42
-		if(!is_object($this->bo)) {
43
+		if(!is_object($this->bo))
44
+		{
43 45
 			$this->bo = new calendar_bo();
44 46
 		}
45
-		if($this->identifier) {
47
+		if($this->identifier)
48
+		{
46 49
 			$this->record = $this->bo->read($this->identifier);
47 50
 		}
48 51
 	}
@@ -52,7 +55,8 @@  discard block
 block discarded – undo
52 55
 	 *
53 56
 	 * @param string $_attribute_name
54 57
 	 */
55
-	public function __get($_attribute_name) {
58
+	public function __get($_attribute_name)
59
+	{
56 60
 		return $this->record[$_attribute_name];
57 61
 	}
58 62
 
@@ -62,11 +66,13 @@  discard block
 block discarded – undo
62 66
 	 * @param string $_attribute_name
63 67
 	 * @param data $data
64 68
 	 */
65
-	public function __set($_attribute_name, $data) {
69
+	public function __set($_attribute_name, $data)
70
+	{
66 71
 		$this->record[$_attribute_name] = $data;
67 72
 	}
68 73
 
69
-	public function __unset($_attribute_name) {
74
+	public function __unset($_attribute_name)
75
+	{
70 76
 		unset($this->record[$_attribute_name]);
71 77
 	}
72 78
 
@@ -78,7 +84,8 @@  discard block
 block discarded – undo
78 84
 	 *
79 85
 	 * @return array complete record as associative array
80 86
 	 */
81
-	public function get_record_array() {
87
+	public function get_record_array()
88
+	{
82 89
 		return $this->record;
83 90
 	}
84 91
 
@@ -87,8 +94,10 @@  discard block
 block discarded – undo
87 94
 	 *
88 95
 	 *@return string tiltle
89 96
 	 */
90
-	public function get_title() {
91
-		if (empty($this->record)) {
97
+	public function get_title()
98
+	{
99
+		if (empty($this->record))
100
+		{
92 101
 			$this->get_record();
93 102
 		}
94 103
 		return $this->record['title'];
@@ -100,7 +109,8 @@  discard block
 block discarded – undo
100 109
 	 * @todo add some checks
101 110
 	 * @return void
102 111
 	 */
103
-	public function set_record(array $_record){
112
+	public function set_record(array $_record)
113
+	{
104 114
 		$this->record = $_record;
105 115
 	}
106 116
 
@@ -109,7 +119,8 @@  discard block
 block discarded – undo
109 119
 	 *
110 120
 	 * @return string identifier of current record
111 121
 	 */
112
-	public function get_identifier() {
122
+	public function get_identifier()
123
+	{
113 124
 		return $this->identifier;
114 125
 	}
115 126
 
@@ -119,7 +130,8 @@  discard block
 block discarded – undo
119 130
 	 *
120 131
 	 * @return string Full URL of an icon, or appname/icon_name
121 132
 	 */
122
-	public function get_icon() {
133
+	public function get_icon()
134
+	{
123 135
 		return 'calendar/navbar';
124 136
 	}
125 137
 
@@ -128,7 +140,8 @@  discard block
 block discarded – undo
128 140
 	 *
129 141
 	 * @return string identifier
130 142
 	 */
131
-	public function save ( $_dst_identifier ) {
143
+	public function save ( $_dst_identifier )
144
+	{
132 145
 		// Not yet implemeted
133 146
 		$this->identifier = $_dst_identifier;
134 147
 	}
@@ -139,7 +152,8 @@  discard block
 block discarded – undo
139 152
 	 * @param string $_dst_identifier
140 153
 	 * @return string dst_identifier
141 154
 	 */
142
-	public function copy ( $_dst_identifier ) {
155
+	public function copy ( $_dst_identifier )
156
+	{
143 157
 		unset($_dst_identifier);	// not used
144 158
 	}
145 159
 
@@ -150,7 +164,8 @@  discard block
 block discarded – undo
150 164
 	 * @param string $_dst_identifier
151 165
 	 * @return string dst_identifier
152 166
 	 */
153
-	public function move ( $_dst_identifier ) {
167
+	public function move ( $_dst_identifier )
168
+	{
154 169
 		unset($_dst_identifier);	// not used
155 170
 	}
156 171
 
@@ -158,7 +173,8 @@  discard block
 block discarded – undo
158 173
 	 * delets current record from backend
159 174
 	 *
160 175
 	 */
161
-	public function delete () {
176
+	public function delete ()
177
+	{
162 178
 
163 179
 	}
164 180
 
@@ -166,7 +182,8 @@  discard block
 block discarded – undo
166 182
 	 * destructor
167 183
 	 *
168 184
 	 */
169
-	public function __destruct() {
185
+	public function __destruct()
186
+	{
170 187
 	}
171 188
 
172 189
 }
173 190
\ No newline at end of file
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ui.inc.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -387,11 +387,11 @@
 block discarded – undo
387 387
 	}
388 388
 
389 389
 	/**
390
-	* gets the icons displayed for a given event
391
-	*
392
-	* @param array $event
393
-	* @return array of 'img' / 'title' pairs
394
-	*/
390
+	 * gets the icons displayed for a given event
391
+	 *
392
+	 * @param array $event
393
+	 * @return array of 'img' / 'title' pairs
394
+	 */
395 395
 	function event_icons($event)
396 396
 	{
397 397
 		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 
109 109
 		if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile())
110 110
 		{
111
-			$file = Array(
111
+			$file = array(
112 112
 				'Site configuration' => Egw::link('/index.php',array(
113 113
 					'menuaction' => 'infolog.infolog_ui.admin' )),
114 114
 				'Global Categories'  => Egw::link('/index.php',array(
Please login to merge, or discard this patch.
Braces   +49 added lines, -13 removed lines patch added patch discarded remove patch
@@ -166,7 +166,10 @@  discard block
 block discarded – undo
166 166
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
167 167
 
168 168
 		// make sure the hook for export_limit is registered
169
-		if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true);
169
+		if (!Api\Hooks::exists('export_limit','calendar'))
170
+		{
171
+			Api\Hooks::read(true);
172
+		}
170 173
 	}
171 174
 
172 175
 	/**
@@ -279,11 +282,15 @@  discard block
 block discarded – undo
279 282
 				{
280 283
 					// only change the owners of the same resource-type as given in set_state[owner]
281 284
 					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']);
282
-					if ((string)$set_owners[0] === '0')	// set exactly the specified owners (without the 0)
285
+					if ((string)$set_owners[0] === '0')
286
+					{
287
+						// set exactly the specified owners (without the 0)
283 288
 					{
284 289
 						if ($set_states['owner'] === '0,r0')	// small fix for resources
285 290
 						{
286
-							$set_states['owner'] = $default;	// --> set default, instead of none
291
+							$set_states['owner'] = $default;
292
+					}
293
+					// --> set default, instead of none
287 294
 						}
288 295
 						else
289 296
 						{
@@ -369,7 +376,10 @@  discard block
 block discarded – undo
369 376
 		}
370 377
 		$this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index';
371 378
 
372
-		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
379
+		if ($this->debug > 0 || $this->debug == 'manage_states')
380
+		{
381
+			$this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
382
+		}
373 383
 		// save the states in the session only when we are in calendar
374 384
 		if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar')
375 385
 		{
@@ -505,8 +515,11 @@  discard block
 block discarded – undo
505 515
 
506 516
 		// resources menu hooks
507 517
  		foreach ($this->bo->resources as $resource)
508
-		{
509
-			if(!is_array($resource['cal_sidebox'])) continue;
518
+ 		{
519
+			if(!is_array($resource['cal_sidebox']))
520
+			{
521
+				continue;
522
+			}
510 523
 			$menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']);
511 524
 			$file = ExecMethod($resource['cal_sidebox']['file'],array(
512 525
 				'menuaction' => $this->view_menuaction,
@@ -553,7 +566,10 @@  discard block
 block discarded – undo
553 566
 		$sidebox = new Etemplate('calendar.sidebox');
554 567
 
555 568
 		$cont = $this->cal_prefs['saved_states'];
556
-		if (!is_array($cont)) $cont = array();
569
+		if (!is_array($cont))
570
+		{
571
+			$cont = array();
572
+		}
557 573
 		$cont['view'] = $this->view ? $this->view : 'week';
558 574
 		$cont['date'] = $this->date ? $this->date : Api\DateTime();
559 575
 
@@ -612,7 +628,10 @@  discard block
 block discarded – undo
612 628
 	 */
613 629
 	public function update_client($event_id, Api\DateTime $recurrence_date = null)
614 630
 	{
615
-		if(!$event_id) return false;
631
+		if(!$event_id)
632
+		{
633
+			return false;
634
+		}
616 635
 
617 636
 		// Directly update stored data.
618 637
 		// Make sure we have the whole event
@@ -678,7 +697,10 @@  discard block
 block discarded – undo
678 697
 	 */
679 698
 	public function to_client(&$event)
680 699
 	{
681
-		if(!$event || !is_array($event)) return false;
700
+		if(!$event || !is_array($event))
701
+		{
702
+			return false;
703
+		}
682 704
 
683 705
 		if (!$this->bo->check_perms(Acl::EDIT,$event))
684 706
 		{
@@ -699,8 +721,16 @@  discard block
 block discarded – undo
699 721
 
700 722
 		$event['recure'] = $this->bo->recure2string($event);
701 723
 
702
-		if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
703
-		if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
724
+		if (empty($event['description']))
725
+		{
726
+			$event['description'] = ' ';
727
+		}
728
+		// no description screws the titles horz. alignment
729
+		if (empty($event['location']))
730
+		{
731
+			$event['location'] = ' ';
732
+		}
733
+		// no location screws the owner horz. alignment
704 734
 
705 735
 		// respect category permissions
706 736
 		if(!empty($event['category']))
@@ -777,8 +807,14 @@  discard block
 block discarded – undo
777 807
 			if(!$timespan)
778 808
 			{
779 809
 				// Try to make time span into appropriate ranges to match
780
-				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month';
781
-				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week';
810
+				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false)
811
+				{
812
+					$template = 'month';
813
+				}
814
+				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false)
815
+				{
816
+					$template = 'week';
817
+				}
782 818
 				//error_log("Detected template $template");
783 819
 				switch ($template)
784 820
 				{
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var $debug mixed integer level or string function-name
35 35
 	 */
36
-	var $debug=false;
36
+	var $debug = false;
37 37
 	/**
38 38
 	 * instance of the bocal or bocalupdate class
39 39
 	 *
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	/**
128 128
 	 * @var array $states_to_save all states that will be saved to the user prefs
129 129
 	 */
130
-	var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend');
130
+	var $states_to_save = array('owner', 'status_filter', 'filter', 'cat_id', 'view', 'sortby', 'planner_view', 'weekend');
131 131
 
132 132
 	/**
133 133
 	 * Constructor
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param boolean $use_boupdate use bocalupdate as parenent instead of bocal
136 136
 	 * @param array $set_states to manualy set / change one of the states, default NULL = use $_REQUEST
137 137
 	 */
138
-	function __construct($use_boupdate=false,$set_states=NULL)
138
+	function __construct($use_boupdate = false, $set_states = NULL)
139 139
 	{
140 140
 		if ($use_boupdate)
141 141
 		{
@@ -146,27 +146,27 @@  discard block
 block discarded – undo
146 146
 			$this->bo = new calendar_bo();
147 147
 		}
148 148
 
149
-		$this->categories = new Api\Categories($this->user,'calendar');
149
+		$this->categories = new Api\Categories($this->user, 'calendar');
150 150
 
151
-		$this->common_prefs	= &$GLOBALS['egw_info']['user']['preferences']['common'];
151
+		$this->common_prefs = &$GLOBALS['egw_info']['user']['preferences']['common'];
152 152
 		$this->cal_prefs	= &$GLOBALS['egw_info']['user']['preferences']['calendar'];
153 153
 		$this->bo->check_set_default_prefs();
154 154
 
155
-		$this->wd_start		= 60*$this->cal_prefs['workdaystarts'];
156
-		$this->wd_end		= 60*$this->cal_prefs['workdayends'];
157
-		$this->interval_m	= $this->cal_prefs['interval'];
155
+		$this->wd_start		= 60 * $this->cal_prefs['workdaystarts'];
156
+		$this->wd_end = 60 * $this->cal_prefs['workdayends'];
157
+		$this->interval_m = $this->cal_prefs['interval'];
158 158
 
159 159
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
160 160
 
161 161
 		$this->manage_states($set_states);
162 162
 
163
-		$GLOBALS['uical'] = &$this;	// make us available for ExecMethod, else it creates a new instance
163
+		$GLOBALS['uical'] = &$this; // make us available for ExecMethod, else it creates a new instance
164 164
 
165 165
 		// calendar does not work with hidden sidebox atm.
166 166
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
167 167
 
168 168
 		// make sure the hook for export_limit is registered
169
-		if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true);
169
+		if (!Api\Hooks::exists('export_limit', 'calendar')) Api\Hooks::read(true);
170 170
 	}
171 171
 
172 172
 	/**
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	function check_owners_access($users = null, &$no_access = array())
180 180
 	{
181 181
 		$no_access = $no_access_group = array();
182
-		$owner_array = $users ? $users : explode(',',$this->owner);
183
-		foreach($owner_array as $idx => $owner)
182
+		$owner_array = $users ? $users : explode(',', $this->owner);
183
+		foreach ($owner_array as $idx => $owner)
184 184
 		{
185 185
 			$owner = trim($owner);
186 186
 			if (is_numeric($owner) && $GLOBALS['egw']->accounts->get_type($owner) == 'g')
187 187
 			{
188
-				foreach($GLOBALS['egw']->accounts->members($owner, true) as $member)
188
+				foreach ($GLOBALS['egw']->accounts->members($owner, true) as $member)
189 189
 				{
190
-					if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$member))
190
+					if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $member))
191 191
 					{
192 192
 						$no_access_group[$member] = $this->bo->participant_name($member);
193 193
 					}
194 194
 				}
195 195
 			}
196
-			elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$owner))
196
+			elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $owner))
197 197
 			{
198 198
 				$no_access[$owner] = $this->bo->participant_name($owner);
199 199
 				unset($owner_array[$idx]);
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 		}
202 202
 		if (count($no_access))
203 203
 		{
204
-			$message = lang('Access denied to the calendar of %1 !!!',implode(', ',$no_access));
205
-			Framework::message($message,'error');
206
-			$this->owner = implode(',',$owner_array);
204
+			$message = lang('Access denied to the calendar of %1 !!!', implode(', ', $no_access));
205
+			Framework::message($message, 'error');
206
+			$this->owner = implode(',', $owner_array);
207 207
 			return $message;
208 208
 		}
209 209
 		if (count($no_access_group))
210 210
 		{
211
-			$this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group));
211
+			$this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.', implode(', ', $no_access_group));
212 212
 		}
213 213
 		return false;
214 214
 	}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 *	- view: the actual view, where dialogs should return to or which they refresh
228 228
 	 * @param array $set_states array to manualy set / change one of the states, default NULL = use $_REQUEST
229 229
 	 */
230
-	function manage_states($set_states=NULL)
230
+	function manage_states($set_states = NULL)
231 231
 	{
232 232
 		// retrieve saved states from prefs
233 233
 		$states = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 				}
248 248
 				else
249 249
 				{
250
-					parse_str(substr($json_data['request']['parameters'][0], 10), $set_states);	// cut off "/index.php?"
250
+					parse_str(substr($json_data['request']['parameters'][0], 10), $set_states); // cut off "/index.php?"
251 251
 				}
252 252
 			}
253 253
 			else
254 254
 			{
255
-				$set_states = substr($_GET['menuaction'],0,9) == 'calendar.' ? $_REQUEST : array();
255
+				$set_states = substr($_GET['menuaction'], 0, 9) == 'calendar.' ? $_REQUEST : array();
256 256
 			}
257 257
 		}
258 258
 		if (!$states['date'] && $states['year'] && $states['month'] && $states['day'])
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 			$states['date'] = $this->bo->date2string($states);
261 261
 		}
262 262
 
263
-		foreach(array(
263
+		foreach (array(
264 264
 			'date'       => $this->bo->date2string($this->bo->now_su),
265 265
 			'cat_id'     => 0,
266 266
 			'status_filter'     => 'default',
267 267
 			'owner'      => $this->user,
268 268
 			'save_owner' => 0,
269 269
 			'sortby'     => 'category',
270
-			'planner_view'=> 'month',	// full month
271
-			'view'       => ($this->bo->cal_prefs['defaultcalendar']?$this->bo->cal_prefs['defaultcalendar']:'day'), // use pref, if exists else use the dayview
272
-			'listview_days'=> '',	// no range
270
+			'planner_view'=> 'month', // full month
271
+			'view'       => ($this->bo->cal_prefs['defaultcalendar'] ? $this->bo->cal_prefs['defaultcalendar'] : 'day'), // use pref, if exists else use the dayview
272
+			'listview_days'=> '', // no range
273 273
 			'test'       => 'false',
274 274
 		) as $state => $default)
275 275
 		{
@@ -278,42 +278,42 @@  discard block
 block discarded – undo
278 278
 				if ($state == 'owner')
279 279
 				{
280 280
 					// only change the owners of the same resource-type as given in set_state[owner]
281
-					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']);
281
+					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',', $set_states['owner']);
282 282
 					if ((string)$set_owners[0] === '0')	// set exactly the specified owners (without the 0)
283 283
 					{
284 284
 						if ($set_states['owner'] === '0,r0')	// small fix for resources
285 285
 						{
286
-							$set_states['owner'] = $default;	// --> set default, instead of none
286
+							$set_states['owner'] = $default; // --> set default, instead of none
287 287
 						}
288 288
 						else
289 289
 						{
290
-							$set_states['owner'] = substr($set_states['owner'],2);
290
+							$set_states['owner'] = substr($set_states['owner'], 2);
291 291
 						}
292 292
 					}
293 293
 					else	// change only the owners of the given type
294 294
 					{
295 295
 						$res_type = is_numeric($set_owners[0]) ? false : $set_owners[0][0];
296 296
 						$owners = $states['owner'] ? $states['owner'] : $default;
297
-						if(!is_array($owners))
297
+						if (!is_array($owners))
298 298
 						{
299
-							$owners = explode(',',$owners);
299
+							$owners = explode(',', $owners);
300 300
 						}
301
-						foreach($owners as $key => $owner)
301
+						foreach ($owners as $key => $owner)
302 302
 						{
303 303
 							if (!$res_type && is_numeric($owner) || $res_type && $owner[0] == $res_type)
304 304
 							{
305 305
 								unset($owners[$key]);
306 306
 							}
307 307
 						}
308
-						if (!$res_type || !in_array($res_type.'0',$set_owners))
308
+						if (!$res_type || !in_array($res_type.'0', $set_owners))
309 309
 						{
310
-							$owners = array_merge($owners,$set_owners);
310
+							$owners = array_merge($owners, $set_owners);
311 311
 						}
312
-						$set_states['owner'] = implode(',',$owners);
312
+						$set_states['owner'] = implode(',', $owners);
313 313
 					}
314 314
 				}
315 315
 				// for the uiforms class (eg. edit), dont store the (new) owner, as it might change the view
316
-				if (substr($_GET['menuaction'],0,25) == 'calendar.calendar_uiforms')
316
+				if (substr($_GET['menuaction'], 0, 25) == 'calendar.calendar_uiforms')
317 317
 				{
318 318
 					$this->owner = $set_states[$state];
319 319
 					continue;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			if ($state == 'date')
328 328
 			{
329 329
 				$date_arr = $this->bo->date2array($states['date']);
330
-				foreach(array('year','month','day') as $name)
330
+				foreach (array('year', 'month', 'day') as $name)
331 331
 				{
332 332
 					$this->$name = $states[$name] = $date_arr[$name];
333 333
 				}
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 			$this->$state = $states[$state];
336 336
 		}
337 337
 		// remove a given calendar from the view
338
-		if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners=explode(',',$this->owner))) !== false)
338
+		if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners = explode(',', $this->owner))) !== false)
339 339
 		{
340 340
 			unset($owners[$k]);
341
-			$this->owner = $states['owner'] = implode(',',$owners);
341
+			$this->owner = $states['owner'] = implode(',', $owners);
342 342
 		}
343
-		if(is_array($this->owner))
343
+		if (is_array($this->owner))
344 344
 		{
345
-			$this->owner = implode(',',$this->owner);
345
+			$this->owner = implode(',', $this->owner);
346 346
 		}
347
-		if (substr($this->view,0,8) == 'planner_')
347
+		if (substr($this->view, 0, 8) == 'planner_')
348 348
 		{
349 349
 			$states['sortby'] = $this->sortby = $this->view == 'planner_cat' ? 'category' : 'user';
350 350
 			$states['view'] = $this->view = 'planner';
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		// set the actual view as return_to
353 353
 		if (isset($_GET['menuaction']))
354 354
 		{
355
-			list(,$class,$func) = explode('.',$_GET['menuaction']);
355
+			list(,$class, $func) = explode('.', $_GET['menuaction']);
356 356
 			if ($func == 'index')
357 357
 			{
358
-				$func = $this->view; $this->view = 'index';	// switch to the default view
358
+				$func = $this->view; $this->view = 'index'; // switch to the default view
359 359
 			}
360 360
 		}
361 361
 		else	// eg. calendar/index.php
@@ -369,18 +369,18 @@  discard block
 block discarded – undo
369 369
 		}
370 370
 		$this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index';
371 371
 
372
-		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
372
+		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3', True, $set_states, $states);
373 373
 		// save the states in the session only when we are in calendar
374
-		if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar')
374
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'calendar')
375 375
 		{
376 376
 			// save defined states into the user-prefs
377
-			if(!empty($states) && is_array($states))
377
+			if (!empty($states) && is_array($states))
378 378
 			{
379
-				$saved_states = array_intersect_key($states,array_flip($this->states_to_save));
379
+				$saved_states = array_intersect_key($states, array_flip($this->states_to_save));
380 380
 				if ($saved_states != $this->cal_prefs['saved_states'])
381 381
 				{
382
-					$GLOBALS['egw']->preferences->add('calendar','saved_states',$saved_states);
383
-					$GLOBALS['egw']->preferences->save_repository(false,'user',true);
382
+					$GLOBALS['egw']->preferences->add('calendar', 'saved_states', $saved_states);
383
+					$GLOBALS['egw']->preferences->save_repository(false, 'user', true);
384 384
 				}
385 385
 			}
386 386
 		}
@@ -394,35 +394,35 @@  discard block
 block discarded – undo
394 394
 	*/
395 395
 	function event_icons($event)
396 396
 	{
397
-		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event);
397
+		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ, $event);
398 398
 
399 399
 		$icons = array();
400 400
 		if (!$is_private)
401 401
 		{
402
-			if($event['priority'] == 3)
402
+			if ($event['priority'] == 3)
403 403
 			{
404
-				$icons[] = Api\Html::image('calendar','high',lang('high priority'));
404
+				$icons[] = Api\Html::image('calendar', 'high', lang('high priority'));
405 405
 			}
406
-			if($event['recur_type'] != MCAL_RECUR_NONE)
406
+			if ($event['recur_type'] != MCAL_RECUR_NONE)
407 407
 			{
408
-				$icons[] = Api\Html::image('calendar','recur',lang('recurring event'));
408
+				$icons[] = Api\Html::image('calendar', 'recur', lang('recurring event'));
409 409
 			}
410 410
 			// icons for single user, multiple users or group(s) and resources
411
-			foreach(array_keys($event['participants']) as  $uid)
411
+			foreach (array_keys($event['participants']) as  $uid)
412 412
 			{
413
-				if(is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon']))
413
+				if (is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon']))
414 414
 				{
415 415
 					if (isset($icons['single']) || $GLOBALS['egw']->accounts->get_type($uid) == 'g')
416 416
 					{
417 417
 						unset($icons['single']);
418
-						$icons['multiple'] = Api\Html::image('calendar','users');
418
+						$icons['multiple'] = Api\Html::image('calendar', 'users');
419 419
 					}
420 420
 					elseif (!isset($icons['multiple']))
421 421
 					{
422
-						$icons['single'] = Api\Html::image('calendar','single');
422
+						$icons['single'] = Api\Html::image('calendar', 'single');
423 423
 					}
424 424
 				}
425
-				elseif(!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon']))
425
+				elseif (!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon']))
426 426
 				{
427 427
 				 	$icons[$uid[0]] = Api\Html::image($this->bo->resources[$uid[0]]['app'],
428 428
 				 		($this->bo->resources[$uid[0]]['icon'] ? $this->bo->resources[$uid[0]]['icon'] : 'navbar'),
@@ -431,21 +431,21 @@  discard block
 block discarded – undo
431 431
 				}
432 432
 			}
433 433
 		}
434
-		if($event['non_blocking'])
434
+		if ($event['non_blocking'])
435 435
 		{
436
-			$icons[] = Api\Html::image('calendar','nonblocking',lang('non blocking'));
436
+			$icons[] = Api\Html::image('calendar', 'nonblocking', lang('non blocking'));
437 437
 		}
438
-		if($event['public'] == 0)
438
+		if ($event['public'] == 0)
439 439
 		{
440
-			$icons[] = Api\Html::image('calendar','private',lang('private'));
440
+			$icons[] = Api\Html::image('calendar', 'private', lang('private'));
441 441
 		}
442
-		if(isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
442
+		if (isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
443 443
 		{
444
-			$icons[] = Api\Html::image('calendar','alarm',lang('alarm'));
444
+			$icons[] = Api\Html::image('calendar', 'alarm', lang('alarm'));
445 445
 		}
446
-		if($event['participants'][$this->user][0] == 'U')
446
+		if ($event['participants'][$this->user][0] == 'U')
447 447
 		{
448
-			$icons[] = Api\Html::image('calendar','needs-action',lang('Needs action'));
448
+			$icons[] = Api\Html::image('calendar', 'needs-action', lang('Needs action'));
449 449
 		}
450 450
 		return $icons;
451 451
 	}
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 	 * @param array $vars
461 461
 	 * @return string the link incl. content
462 462
 	 */
463
-	function add_link($content,$date=null,$hour=null,$minute=0,array $vars=null)
463
+	function add_link($content, $date = null, $hour = null, $minute = 0, array $vars = null)
464 464
 	{
465 465
 		$vars['menuaction'] = 'calendar.calendar_uiforms.edit';
466
-		$vars['date'] =  $date ? $date : $this->date;
466
+		$vars['date'] = $date ? $date : $this->date;
467 467
 
468 468
 		if (!is_null($hour))
469 469
 		{
470 470
 			$vars['hour'] = $hour;
471 471
 			$vars['minute'] = $minute;
472 472
 		}
473
-		return Api\Html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
473
+		return Api\Html::a_href($content, '', $vars, ' data-date="'.$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
474 474
 				. '" title="'.Api\Html::htmlspecialchars(lang('Add')).'"');
475 475
 	}
476 476
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		// Magic etemplate2 favorites menu (from framework)
483 483
 		display_sidebox('calendar', lang('Favorites'), Framework\Favorites::list_favorites('calendar'));
484 484
 
485
-		$file = array('menuOpened' => true);	// menu open by default
485
+		$file = array('menuOpened' => true); // menu open by default
486 486
 
487 487
 		// Target for etemplate
488 488
 		$file[] = array(
@@ -495,38 +495,38 @@  discard block
 block discarded – undo
495 495
 		// Merge print placeholders (selectbox in etemplate)
496 496
 		if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])
497 497
 		{
498
-			$file['Placeholders'] = Egw::link('/index.php','menuaction=calendar.calendar_merge.show_replacements');
498
+			$file['Placeholders'] = Egw::link('/index.php', 'menuaction=calendar.calendar_merge.show_replacements');
499 499
 		}
500 500
 		$appname = 'calendar';
501 501
 		$menu_title = lang('Calendar Menu');
502
-		display_sidebox($appname,$menu_title,$file);
502
+		display_sidebox($appname, $menu_title, $file);
503 503
 
504 504
 		$this->sidebox_etemplate();
505 505
 
506 506
 		// resources menu hooks
507 507
  		foreach ($this->bo->resources as $resource)
508 508
 		{
509
-			if(!is_array($resource['cal_sidebox'])) continue;
509
+			if (!is_array($resource['cal_sidebox'])) continue;
510 510
 			$menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']);
511
-			$file = ExecMethod($resource['cal_sidebox']['file'],array(
511
+			$file = ExecMethod($resource['cal_sidebox']['file'], array(
512 512
 				'menuaction' => $this->view_menuaction,
513 513
 				'owner' => $this->owner,
514 514
 			));
515
-			display_sidebox($appname,$menu_title,$file);
515
+			display_sidebox($appname, $menu_title, $file);
516 516
 		}
517 517
 
518 518
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
519 519
 		{
520 520
 			$file = Array(
521
-				'Site configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
522
-				'Custom Fields'=>Egw::link('/index.php','menuaction=admin.customfields.index&appname=calendar&ajax=true'),
523
-				'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar&ajax=true'),
521
+				'Site configuration'=>Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
522
+				'Custom Fields'=>Egw::link('/index.php', 'menuaction=admin.customfields.index&appname=calendar&ajax=true'),
523
+				'Global Categories' =>Egw::link('/index.php', 'menuaction=admin.admin_categories.index&appname=calendar&ajax=true'),
524 524
 			);
525
-			$GLOBALS['egw']->framework->sidebox($appname,lang('Admin'),$file,'admin');
525
+			$GLOBALS['egw']->framework->sidebox($appname, lang('Admin'), $file, 'admin');
526 526
 		}
527 527
 		display_sidebox('calendar', lang('Utilities'), array('Category report' => "javascript:egw_openWindowCentered2('".
528
-					Egw::link('/index.php',array('menuaction'=>'calendar.calendar_category_report.index','ajax'=>true),false).
529
-					"','_blank',870,500,'yes')" ));
528
+					Egw::link('/index.php', array('menuaction'=>'calendar.calendar_category_report.index', 'ajax'=>true), false).
529
+					"','_blank',870,500,'yes')"));
530 530
 	}
531 531
 
532 532
 	/**
@@ -534,15 +534,15 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	function sidebox_etemplate($content = array())
536 536
 	{
537
-		if($content['merge'])
537
+		if ($content['merge'])
538 538
 		{
539 539
 			// View from sidebox is JSON encoded
540
-			$this->manage_states(array_merge($content,json_decode($content['view'],true)));
541
-			if($content['first'])
540
+			$this->manage_states(array_merge($content, json_decode($content['view'], true)));
541
+			if ($content['first'])
542 542
 			{
543
-				$this->first = Api\DateTime::to($content['first'],'ts');
543
+				$this->first = Api\DateTime::to($content['first'], 'ts');
544 544
 			}
545
-			if($content['last'])
545
+			if ($content['last'])
546 546
 			{
547 547
 				$this->last = new Api\DateTime($content['last']);
548 548
 				$this->last->setTime(23, 59, 59);
@@ -560,25 +560,25 @@  discard block
 block discarded – undo
560 560
 		$cont['view'] = $this->view ? $this->view : 'week';
561 561
 		$cont['date'] = $this->date ? $this->date : new Api\DateTime();
562 562
 
563
-		$cont['year'] = (int)Api\DateTime::to($cont['date'],'Y');
563
+		$cont['year'] = (int)Api\DateTime::to($cont['date'], 'Y');
564 564
 		$cont['holidays'] = $this->bo->read_holidays($cont['year']);
565 565
 
566 566
 		$readonlys = array();
567 567
 		$sel_options['status_filter'] = array(
568
-			array('value' => 'default',     'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
569
-			array('value' => 'accepted',    'label' => lang('Accepted'), 'title' => lang('Show only accepted events')),
570
-			array('value' => 'unknown',     'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')),
571
-			array('value' => 'tentative',   'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')),
572
-			array('value' => 'delegated',   'label' => lang('Delegated'), 'title' => lang('Show only delegated events')),
573
-			array('value' => 'rejected',    'label' => lang('Rejected'),'title' => lang('Show only rejected events')),
574
-			array('value' => 'owner',       'label' => lang('Owner too'),'title' => lang('Show also events just owned by selected user')),
575
-			array('value' => 'all',         'label' => lang('All incl. rejected'),'title' => lang('Show all status incl. rejected events')),
576
-			array('value' => 'hideprivate', 'label' => lang('Hide private infos'),'title' => lang('Show all events, as if they were private')),
577
-			array('value' => 'showonlypublic',  'label' => lang('Hide private events'),'title' => lang('Show only events flagged as public, (not checked as private)')),
578
-			array('value' => 'no-enum-groups', 'label' => lang('only group-events'),'title' => lang('Do not include events of group members')),
579
-			array('value' => 'not-unknown', 'label' => lang('No meeting requests'),'title' => lang('Show all status, but unknown')),
568
+			array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
569
+			array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')),
570
+			array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')),
571
+			array('value' => 'tentative', 'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')),
572
+			array('value' => 'delegated', 'label' => lang('Delegated'), 'title' => lang('Show only delegated events')),
573
+			array('value' => 'rejected', 'label' => lang('Rejected'), 'title' => lang('Show only rejected events')),
574
+			array('value' => 'owner', 'label' => lang('Owner too'), 'title' => lang('Show also events just owned by selected user')),
575
+			array('value' => 'all', 'label' => lang('All incl. rejected'), 'title' => lang('Show all status incl. rejected events')),
576
+			array('value' => 'hideprivate', 'label' => lang('Hide private infos'), 'title' => lang('Show all events, as if they were private')),
577
+			array('value' => 'showonlypublic', 'label' => lang('Hide private events'), 'title' => lang('Show only events flagged as public, (not checked as private)')),
578
+			array('value' => 'no-enum-groups', 'label' => lang('only group-events'), 'title' => lang('Do not include events of group members')),
579
+			array('value' => 'not-unknown', 'label' => lang('No meeting requests'), 'title' => lang('Show all status, but unknown')),
580 580
 		);
581
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
581
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
582 582
 		{
583 583
 			$sel_options['status_filter'][] = array('value' => 'deleted', 'label' => lang('Deleted'), 'title' => lang('Show events that have been deleted'));
584 584
 		}
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		// Merge print
587 587
 		if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])
588 588
 		{
589
-			$sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null,'calendar');
589
+			$sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null, 'calendar');
590 590
 		}
591 591
 		else
592 592
 		{
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
 	 */
616 616
 	public function update_client($event_id, Api\DateTime $recurrence_date = null)
617 617
 	{
618
-		if(!$event_id) return false;
619
-		if(is_string($event_id) && strpos($event_id,':') !== FALSE)
618
+		if (!$event_id) return false;
619
+		if (is_string($event_id) && strpos($event_id, ':') !== FALSE)
620 620
 		{
621
-			list($event_id, $date) = explode(':',$event_id);
621
+			list($event_id, $date) = explode(':', $event_id);
622 622
 			$recurrence_date = new Api\DateTime($date);
623 623
 		}
624 624
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 		// Check filters to see if they still match, may have to remove
632 632
 		// the event because it should no longer be displayed
633 633
 		$filter_match = true;
634
-		if($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' ||
634
+		if ($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' ||
635 635
 			$this->cal_prefs['saved_states']['cat_id']))
636 636
 		{
637 637
 			$filter_check = array(
@@ -644,20 +644,20 @@  discard block
 block discarded – undo
644 644
 			$filter_match = count($this->bo->search($filter_check, $this->bo->so->cal_table.".cal_id = {$event['id']}")) > 0;
645 645
 		}
646 646
 
647
-		if(!$event || !$filter_match)
647
+		if (!$event || !$filter_match)
648 648
 		{
649 649
 			// Sending null will trigger a removal
650 650
 			$response->generic('data', array('uid' => 'calendar::'.$event_id, 'data' => null));
651 651
 			return false;
652 652
 		}
653 653
 
654
-		if(!$event['recur_type'] || $recurrence_date)
654
+		if (!$event['recur_type'] || $recurrence_date)
655 655
 		{
656 656
 			$this->to_client($event);
657 657
 			$response->generic('data', array('uid' => 'calendar::'.$event['row_id'], 'data' => $event));
658 658
 		}
659 659
 		// If it's recurring, try to send the next month or so
660
-		else if($event['recur_type'] )
660
+		else if ($event['recur_type'])
661 661
 		{
662 662
 			$this_month = new Api\DateTime('next month');
663 663
 			$rrule = calendar_rrule::event2rrule($event, true);
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 				$response->generic('data', array('uid' => 'calendar::'.$converted['row_id'], 'data' => $converted));
671 671
 				$rrule->next();
672 672
 			}
673
-			while ($rrule->valid() && $occurrence <= $this_month );
673
+			while ($rrule->valid() && $occurrence <= $this_month);
674 674
 		}
675 675
 		return true;
676 676
 	}
@@ -686,15 +686,15 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	public function to_client(&$event)
688 688
 	{
689
-		if(!$event || !is_array($event)) return false;
689
+		if (!$event || !is_array($event)) return false;
690 690
 
691
-		if (!$this->bo->check_perms(Acl::EDIT,$event))
691
+		if (!$this->bo->check_perms(Acl::EDIT, $event))
692 692
 		{
693 693
 			$event['class'] .= 'rowNoEdit ';
694 694
 		}
695 695
 
696 696
 		// Delete disabled for other applications
697
-		if (!$this->bo->check_perms(Acl::DELETE,$event) || !is_numeric($event['id']))
697
+		if (!$this->bo->check_perms(Acl::DELETE, $event) || !is_numeric($event['id']))
698 698
 		{
699 699
 			$event['class'] .= 'rowNoDelete ';
700 700
 		}
@@ -707,32 +707,32 @@  discard block
 block discarded – undo
707 707
 
708 708
 		$event['recure'] = $this->bo->recure2string($event);
709 709
 
710
-		if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
711
-		if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
710
+		if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment
711
+		if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment
712 712
 
713 713
 		// respect category permissions
714
-		if(!empty($event['category']))
714
+		if (!empty($event['category']))
715 715
 		{
716 716
 			$event['category'] = $this->categories->check_list(Acl::READ, $event['category']);
717 717
 		}
718 718
 		$event['non_blocking'] = (bool)$event['non_blocking'];
719 719
 
720 720
 		$matches = null;
721
-		if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
721
+		if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
722 722
 		{
723 723
 			$app = $matches[1];
724 724
 			$app_id = $matches[2];
725 725
 			$icons = array();
726
-			if(!($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
726
+			if (!($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
727 727
 			{
728
-				$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
728
+				$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
729 729
 			}
730 730
 			$event['app'] = $app;
731 731
 			$event['app_id'] = $app_id;
732 732
 		}
733 733
 		else
734 734
 		{
735
-			$is_private = !$this->bo->check_perms(Acl::READ,$event);
735
+			$is_private = !$this->bo->check_perms(Acl::READ, $event);
736 736
 		}
737 737
 		if ($is_private)
738 738
 		{
@@ -740,27 +740,27 @@  discard block
 block discarded – undo
740 740
 			$event['class'] .= 'rowNoView ';
741 741
 		}
742 742
 
743
-		if(!$event['app'])
743
+		if (!$event['app'])
744 744
 		{
745 745
 			$event['app'] = 'calendar';
746 746
 		}
747
-		if(!$event['app_id'])
747
+		if (!$event['app_id'])
748 748
 		{
749 749
 			$event['app_id'] = $event['id'];
750 750
 		}
751 751
 
752 752
 		if ($event['recur_type'] != MCAL_RECUR_NONE)
753 753
 		{
754
-			$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
754
+			$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
755 755
 		}
756 756
 		// set id for grid
757
-		$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts') : '');
757
+		$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts') : '');
758 758
 
759 759
 		// Set up participant section of tooltip
760
-		$participants = $this->bo->participants($event,false);
761
-		$event['parts'] = implode("\n",$participants);
760
+		$participants = $this->bo->participants($event, false);
761
+		$event['parts'] = implode("\n", $participants);
762 762
 		$event['participant_types'] = array();
763
-		foreach($participants as $uid => $text)
763
+		foreach ($participants as $uid => $text)
764 764
 		{
765 765
 			$user_type = $user_id = null;
766 766
 			calendar_so::split_user($uid, $user_type, $user_id);
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 		$event['date'] = $this->bo->date2string($event['start']);
771 771
 
772 772
 		// Change dates
773
-		foreach(calendar_egw_record::$types['date-time'] as $field)
773
+		foreach (calendar_egw_record::$types['date-time'] as $field)
774 774
 		{
775
-			if(is_int($event[$field]))
775
+			if (is_int($event[$field]))
776 776
 			{
777 777
 				$event[$field] = Api\DateTime::to($event[$field], Api\DateTime::ET2);
778 778
 			}
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function merge($timespan = array())
791 791
 	{
792 792
 		// Merge print
793
-		if($_GET['merge'])
793
+		if ($_GET['merge'])
794 794
 		{
795
-			if(!$timespan)
795
+			if (!$timespan)
796 796
 			{
797 797
 				// Try to make time span into appropriate ranges to match
798
-				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month';
799
-				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week';
798
+				if (stripos($_GET['merge'], 'month') !== false || stripos($_GET['merge'], lang('month')) !== false) $template = 'month';
799
+				if (stripos($_GET['merge'], 'week') !== false || stripos($_GET['merge'], lang('week')) !== false) $template = 'week';
800 800
 				//error_log("Detected template $template");
801 801
 				switch ($template)
802 802
 				{
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 						// Trim to _only_ the month, do not pad to week start / end
805 805
 						$time = new Api\DateTime($this->date);
806 806
 						$timespan = array(array(
807
-							'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'),'ts'),
808
-							'end'	=> Api\DateTime::to($time->format('Y-m-t 23:59:59'),'ts')
807
+							'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'), 'ts'),
808
+							'end'	=> Api\DateTime::to($time->format('Y-m-t 23:59:59'), 'ts')
809 809
 						));
810 810
 						break;
811 811
 					case 'week':
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 						$start = new Api\DateTime($this->first);
814 814
 						$t = clone $start;
815 815
 						$t->modify('+1 week')->modify('-1 second');
816
-						if($t->format('ts') < Api\DateTime::to($this->last,'ts'))
816
+						if ($t->format('ts') < Api\DateTime::to($this->last, 'ts'))
817 817
 						{
818 818
 							do
819 819
 							{
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 								);
824 824
 								$start->modify('+1 week');
825 825
 								$t->modify('+1 week');
826
-							} while( $start->format('ts') < $this->last);
826
+							} while ($start->format('ts') < $this->last);
827 827
 							break;
828 828
 						}
829 829
 						// Fall through
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 			Framework::refresh_opener($error, 'calendar');
842 842
 		}
843 843
 		unset($_GET['merge']);
844
-		if($error)
844
+		if ($error)
845 845
 		{
846 846
 			// This doesn't give message either, but at least it doesn't give a blank screen
847 847
 			Framework::redirect_link('/index.php', array(
Please login to merge, or discard this patch.
calendar/inc/class.calendar_rrule.inc.php 3 patches
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	static private $recur_egw2ical_2_0 = array(
77 77
 		self::DAILY        => 'DAILY',
78 78
 		self::WEEKLY       => 'WEEKLY',
79
-		self::MONTHLY_WDAY => 'MONTHLY',	// BYDAY={1..7, -1}{MO..SO, last workday}
80
-		self::MONTHLY_MDAY => 'MONTHLY',	// BYMONHTDAY={1..31, -1 for last day of month}
79
+		self::MONTHLY_WDAY => 'MONTHLY', // BYDAY={1..7, -1}{MO..SO, last workday}
80
+		self::MONTHLY_MDAY => 'MONTHLY', // BYMONHTDAY={1..31, -1 for last day of month}
81 81
 		self::YEARLY       => 'YEARLY',
82 82
 	);
83 83
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	static private $recur_egw2ical_1_0 = array(
88 88
 		self::DAILY        => 'D',
89 89
 		self::WEEKLY       => 'W',
90
-		self::MONTHLY_WDAY => 'MP',	// BYDAY={1..7,-1}{MO..SO, last workday}
91
-		self::MONTHLY_MDAY => 'MD',	// BYMONHTDAY={1..31,-1}
90
+		self::MONTHLY_WDAY => 'MP', // BYDAY={1..7,-1}{MO..SO, last workday}
91
+		self::MONTHLY_MDAY => 'MD', // BYMONHTDAY={1..31,-1}
92 92
 		self::YEARLY       => 'YM',
93 93
 	);
94 94
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	const THURSDAY  = 16;
145 145
 	const FRIDAY    = 32;
146 146
 	const SATURDAY  = 64;
147
-	const WORKDAYS  = 62;	// Mo, ..., Fr
147
+	const WORKDAYS  = 62; // Mo, ..., Fr
148 148
 	const ALLDAYS   = 127;
149 149
 	/**
150 150
 	 * Translate weekday bitmasks to labels
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @var array
174 174
 	 */
175
-	public $exceptions=array();
175
+	public $exceptions = array();
176 176
 
177 177
 	/**
178 178
 	 * Array of exceptions as DateTime/egw_time objects
179 179
 	 *
180 180
 	 * @var array
181 181
 	 */
182
-	public $exceptions_objs=array();
182
+	public $exceptions_objs = array();
183 183
 
184 184
 	/**
185 185
 	 * Starttime of series
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 	 * @param int $weekdays =0 self::SUNDAY=1|self::MONDAY=2|...|self::SATURDAY=64
223 223
 	 * @param array $exceptions =null DateTime objects with exceptions
224 224
 	 */
225
-	public function __construct(DateTime $time,$type,$interval=1,DateTime $enddate=null,$weekdays=0,array $exceptions=null)
225
+	public function __construct(DateTime $time, $type, $interval = 1, DateTime $enddate = null, $weekdays = 0, array $exceptions = null)
226 226
 	{
227
-		switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
227
+		switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
228 228
 		{
229 229
 			case 'Sunday':
230 230
 				$this->lastdayofweek = self::SATURDAY;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 		$this->time = $time instanceof Api\DateTime ? $time : new Api\DateTime($time);
240 240
 
241
-		if (!in_array($type,array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY)))
241
+		if (!in_array($type, array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY)))
242 242
 		{
243 243
 			throw new Api\Exception\WrongParameter(__METHOD__."($time,$type,$interval,$enddate,$weekdays,...) type $type is NOT valid!");
244 244
 		}
@@ -248,16 +248,16 @@  discard block
 block discarded – undo
248 248
 		if ($type == self::MONTHLY_WDAY)
249 249
 		{
250 250
 			// check for last week of month
251
-			if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time)-7)
251
+			if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time) - 7)
252 252
 			{
253 253
 				$this->monthly_byday_num = -1;
254 254
 			}
255 255
 			else
256 256
 			{
257
-				$this->monthly_byday_num = 1 + floor(($this->time->format('d')-1) / 7);
257
+				$this->monthly_byday_num = 1 + floor(($this->time->format('d') - 1) / 7);
258 258
 			}
259 259
 		}
260
-		elseif($type == self::MONTHLY_MDAY)
260
+		elseif ($type == self::MONTHLY_MDAY)
261 261
 		{
262 262
 			$this->monthly_bymonthday = (int)$this->time->format('d');
263 263
 			// check for last day of month
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 		if ((int)$interval < 1)
276 276
 		{
277
-			$interval = 1;	// calendar stores no (extra) interval as null, so using default 1 here
277
+			$interval = 1; // calendar stores no (extra) interval as null, so using default 1 here
278 278
 		}
279 279
 		$this->interval = (int)$interval;
280 280
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		}
305 305
 		if ($exceptions)
306 306
 		{
307
-			foreach($exceptions as $exception)
307
+			foreach ($exceptions as $exception)
308 308
 			{
309 309
 				$exception->setTimezone($this->time->getTimezone());
310 310
 				$this->exceptions[] = $exception->format('Ymd');
@@ -320,22 +320,22 @@  discard block
 block discarded – undo
320 320
 	 * @param int $interval =1
321 321
 	 * @return int
322 322
 	 */
323
-	public static function recurrence_interval($type, $interval=1)
323
+	public static function recurrence_interval($type, $interval = 1)
324 324
 	{
325
-		switch($type)
325
+		switch ($type)
326 326
 		{
327 327
 			case self::DAILY:
328
-				$duration = 24*3600;
328
+				$duration = 24 * 3600;
329 329
 				break;
330 330
 			case self::WEEKLY:
331
-				$duration = 7*24*3600;
331
+				$duration = 7 * 24 * 3600;
332 332
 				break;
333 333
 			case self::MONTHLY_MDAY:
334 334
 			case self::MONTHLY_WDAY:
335
-				$duration = 31*24*3600;
335
+				$duration = 31 * 24 * 3600;
336 336
 				break;
337 337
 			case self::YEARLY:
338
-				$duration = 366*24*3600;
338
+				$duration = 366 * 24 * 3600;
339 339
 				break;
340 340
 		}
341 341
 		if ($interval > 1) $duration *= $interval;
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	private static function daysInMonth(DateTime $time)
353 353
 	{
354
-		list($year,$month) = explode('-',$time->format('Y-m'));
354
+		list($year, $month) = explode('-', $time->format('Y-m'));
355 355
 		$last_day = new Api\DateTime();
356
-		$last_day->setDate($year,$month+1,0);
356
+		$last_day->setDate($year, $month + 1, 0);
357 357
 
358 358
 		return (int)$last_day->format('d');
359 359
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	public function next_no_exception()
385 385
 	{
386
-		switch($this->type)
386
+		switch ($this->type)
387 387
 		{
388 388
 			case self::NONE:	// need to add at least one day, to end "series", as enddate == current date
389 389
 			case self::DAILY:
@@ -398,28 +398,28 @@  discard block
 block discarded – undo
398 398
 					// --> on the last day of the week we have to additionally advance interval-1 weeks
399 399
 					if ($this->interval > 1 && self::getWeekday($this->current) == $this->lastdayofweek)
400 400
 					{
401
-						$this->current->modify(($this->interval-1).' week');
401
+						$this->current->modify(($this->interval - 1).' week');
402 402
 					}
403 403
 					$this->current->modify('1 day');
404 404
 					//echo __METHOD__.'() '.$this->current->format('l').', '.$this->current.": $this->weekdays & ".self::getWeekday($this->current)."<br />\n";
405 405
 				}
406
-				while(!($this->weekdays & self::getWeekday($this->current)));
406
+				while (!($this->weekdays&self::getWeekday($this->current)));
407 407
 				break;
408 408
 
409 409
 			case self::MONTHLY_WDAY:	// iCal: BYDAY={1, ..., 5, -1}{MO..SO}
410 410
 				// advance to start of next month
411
-				list($year,$month) = explode('-',$this->current->format('Y-m'));
412
-				$month += $this->interval+($this->monthly_byday_num < 0 ? 1 : 0);
413
-				$this->current->setDate($year,$month,$this->monthly_byday_num < 0 ? 0 : 1);
411
+				list($year, $month) = explode('-', $this->current->format('Y-m'));
412
+				$month += $this->interval + ($this->monthly_byday_num < 0 ? 1 : 0);
413
+				$this->current->setDate($year, $month, $this->monthly_byday_num < 0 ? 0 : 1);
414 414
 				//echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).": setDate($year,$month,1): ".$this->current->format('l').', '.$this->current."<br />\n";
415 415
 				// now advance to n-th week
416 416
 				if ($this->monthly_byday_num > 1)
417 417
 				{
418
-					$this->current->modify(($this->monthly_byday_num-1).' week');
418
+					$this->current->modify(($this->monthly_byday_num - 1).' week');
419 419
 					//echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify('.($this->monthly_byday_num-1).' week): '.$this->current->format('l').', '.$this->current."<br />\n";
420 420
 				}
421 421
 				// advance to given weekday
422
-				while(!($this->weekdays & self::getWeekday($this->current)))
422
+				while (!($this->weekdays&self::getWeekday($this->current)))
423 423
 				{
424 424
 					$this->current->modify(($this->monthly_byday_num < 0 ? -1 : 1).' day');
425 425
 					//echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify(1 day): '.$this->current->format('l').', '.$this->current."<br />\n";
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 				break;
428 428
 
429 429
 			case self::MONTHLY_MDAY:	// iCal: monthly_bymonthday={1, ..., 31, -1}
430
-				list($year,$month) = explode('-',$this->current->format('Y-m'));
431
-				$day = $this->monthly_bymonthday+($this->monthly_bymonthday < 0 ? 1 : 0);
432
-				$month += $this->interval+($this->monthly_bymonthday < 0 ? 1 : 0);
433
-				$this->current->setDate($year,$month,$day);
430
+				list($year, $month) = explode('-', $this->current->format('Y-m'));
431
+				$day = $this->monthly_bymonthday + ($this->monthly_bymonthday < 0 ? 1 : 0);
432
+				$month += $this->interval + ($this->monthly_bymonthday < 0 ? 1 : 0);
433
+				$this->current->setDate($year, $month, $day);
434 434
 				//echo __METHOD__."() setDate($year,$month,$day): ".$this->current->format('l').', '.$this->current."<br />\n";
435 435
 				break;
436 436
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		{
453 453
 			$this->next_no_exception();
454 454
 		}
455
-		while($this->exceptions && in_array($this->current->format('Ymd'),$this->exceptions));
455
+		while ($this->exceptions && in_array($this->current->format('Ymd'), $this->exceptions));
456 456
 	}
457 457
 
458 458
 	/**
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 		if (isset($this->current)) $backup = $this->current;
485 485
 		$this->rewind();
486 486
 
487
-		while(--$count > 0)
487
+		while (--$count > 0)
488 488
 		{
489 489
 			$this->next_no_exception();
490 490
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		// if enddate is now before next acurrence, but not on same day, we use previous recurrence
510 510
 		// this can happen if client gives an enddate which is NOT a recurrence date
511 511
 		// eg. for a on Monday recurring weekly event a Tuesday as enddate
512
-		if ($this->enddate < $this->current  && $this->current->format('Ymd') != $this->enddate->format('Ymd'))
512
+		if ($this->enddate < $this->current && $this->current->format('Ymd') != $this->enddate->format('Ymd'))
513 513
 		{
514 514
 			$last = $previous;
515 515
 		}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		$this->current = clone $this->time;
529 529
 		while ($this->valid() &&
530 530
 			$this->exceptions &&
531
-			in_array($this->current->format('Ymd'),$this->exceptions))
531
+			in_array($this->current->format('Ymd'), $this->exceptions))
532 532
 		{
533 533
 			$this->next_no_exception();
534 534
 		}
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 *
540 540
 	 * @return boolean
541 541
 	 */
542
-	public function valid ()
542
+	public function valid()
543 543
 	{
544 544
 		return $this->current->format('Ymd') <= $this->enddate_ymd;
545 545
 	}
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 	{
554 554
 		$str = '';
555 555
 		// Repeated Events
556
-		if($this->type != self::NONE)
556
+		if ($this->type != self::NONE)
557 557
 		{
558
-			list($str) = explode(' (',lang(self::$types[$this->type]));	// remove (by day/date) from Monthly
558
+			list($str) = explode(' (', lang(self::$types[$this->type])); // remove (by day/date) from Monthly
559 559
 
560 560
 			$str_extra = array();
561 561
 			switch ($this->type)
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 					{
572 572
 						$repeat_days[] = $this->type == self::WEEKLY ? lang('all') : lang('day');
573 573
 					}
574
-					elseif($this->weekdays == self::WORKDAYS)
574
+					elseif ($this->weekdays == self::WORKDAYS)
575 575
 					{
576 576
 						$repeat_days[] = $this->type == self::WEEKLY ? lang('workdays') : lang('workday');
577 577
 					}
@@ -579,24 +579,24 @@  discard block
 block discarded – undo
579 579
 					{
580 580
 						foreach (self::$days as $mask => $label)
581 581
 						{
582
-							if ($this->weekdays & $mask)
582
+							if ($this->weekdays&$mask)
583 583
 							{
584 584
 								$repeat_days[] = lang($label);
585 585
 							}
586 586
 						}
587 587
 					}
588
-					if($this->type == self::WEEKLY && count($repeat_days))
588
+					if ($this->type == self::WEEKLY && count($repeat_days))
589 589
 					{
590
-						$str_extra[] = lang('days repeated').': '.implode(', ',$repeat_days);
590
+						$str_extra[] = lang('days repeated').': '.implode(', ', $repeat_days);
591 591
 					}
592
-					elseif($this->type == self::MONTHLY_WDAY)
592
+					elseif ($this->type == self::MONTHLY_WDAY)
593 593
 					{
594
-						$str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ',$repeat_days);
594
+						$str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ', $repeat_days);
595 595
 					}
596 596
 					break;
597 597
 
598 598
 			}
599
-			if($this->interval > 1)
599
+			if ($this->interval > 1)
600 600
 			{
601 601
 				$str_extra[] = lang('Interval').': '.$this->interval;
602 602
 			}
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 			{
613 613
 				$str_extra[] = $this->time->getTimezone()->getName();
614 614
 			}
615
-			if(count($str_extra))
615
+			if (count($str_extra))
616 616
 			{
617
-				$str .= ' ('.implode(', ',$str_extra).')';
617
+				$str .= ' ('.implode(', ', $str_extra).')';
618 618
 			}
619 619
 		}
620 620
 		return $str;
@@ -626,24 +626,24 @@  discard block
 block discarded – undo
626 626
 	 *
627 627
 	 * $return array	vCalendar RRULE
628 628
 	 */
629
-	public function generate_rrule($version='2.0')
629
+	public function generate_rrule($version = '2.0')
630 630
 	{
631 631
 		$repeat_days = array();
632 632
 		$rrule = array();
633 633
 
634
-		if ($this->type == self::NONE) return false;	// no recuring event
634
+		if ($this->type == self::NONE) return false; // no recuring event
635 635
 
636 636
 		if ($version == '1.0')
637 637
 		{
638
-			$rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type] . $this->interval;
638
+			$rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type].$this->interval;
639 639
 			switch ($this->type)
640 640
 			{
641 641
 				case self::WEEKLY:
642 642
 					foreach (self::$days as $mask => $label)
643 643
 					{
644
-						if ($this->weekdays & $mask)
644
+						if ($this->weekdays&$mask)
645 645
 						{
646
-							$repeat_days[] = strtoupper(substr($label,0,2));
646
+							$repeat_days[] = strtoupper(substr($label, 0, 2));
647 647
 						}
648 648
 					}
649 649
 					$rrule['BYDAY'] = implode(' ', $repeat_days);
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 				case self::MONTHLY_WDAY:	// weekday of the month: BDAY={1..5}+ {MO..SO}
657 657
 					$rrule['BYDAY'] = abs($this->monthly_byday_num);
658 658
 					$rrule['BYDAY'] .= ($this->monthly_byday_num < 0) ? '- ' : '+ ';
659
-					$rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'),0,2));
659
+					$rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'), 0, 2));
660 660
 					$rrule['FREQ'] = $rrule['FREQ'].' '.$rrule['BYDAY'];
661 661
 					break;
662 662
 			}
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 				case self::WEEKLY:
675 675
 					foreach (self::$days as $mask => $label)
676 676
 					{
677
-						if ($this->weekdays & $mask)
677
+						if ($this->weekdays&$mask)
678 678
 						{
679
-							$repeat_days[] = strtoupper(substr($label,0,2));
679
+							$repeat_days[] = strtoupper(substr($label, 0, 2));
680 680
 						}
681 681
 					}
682 682
 					$rrule['BYDAY'] = implode(',', $repeat_days);
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 					break;
688 688
 
689 689
 				case self::MONTHLY_WDAY:	// weekday of the month: BDAY={1..5}{MO..SO}
690
-					$rrule['BYDAY'] = $this->monthly_byday_num .
691
-						strtoupper(substr($this->time->format('l'),0,2));
690
+					$rrule['BYDAY'] = $this->monthly_byday_num.
691
+						strtoupper(substr($this->time->format('l'), 0, 2));
692 692
 					break;
693 693
 			}
694 694
 			if ($this->interval > 1)
@@ -723,12 +723,12 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return calendar_rrule		false on error
725 725
 	 */
726
-	public static function event2rrule(array $event,$usertime=true,$to_tz=null)
726
+	public static function event2rrule(array $event, $usertime = true, $to_tz = null)
727 727
 	{
728
-		if (!is_array($event)  || !isset($event['tzid'])) return false;
728
+		if (!is_array($event) || !isset($event['tzid'])) return false;
729 729
 		if (!$to_tz) $to_tz = $event['tzid'];
730 730
 		$timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone;
731
-		$time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz);
731
+		$time = is_a($event['start'], 'DateTime') ? $event['start'] : new Api\DateTime($event['start'], $timestamp_tz);
732 732
 
733 733
 		if (!isset(self::$tz_cache[$to_tz]))
734 734
 		{
@@ -741,16 +741,16 @@  discard block
 block discarded – undo
741 741
 
742 742
 		if ($event['recur_enddate'])
743 743
 		{
744
-			$enddate = is_a($event['recur_enddate'],'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],$timestamp_tz);
744
+			$enddate = is_a($event['recur_enddate'], 'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], $timestamp_tz);
745 745
 		}
746 746
 		if (is_array($event['recur_exception']))
747 747
 		{
748
-			foreach($event['recur_exception'] as $exception)
748
+			foreach ($event['recur_exception'] as $exception)
749 749
 			{
750
-				$exceptions[] = is_a($exception,'DateTime') ? $exception : new Api\DateTime($exception,$timestamp_tz);
750
+				$exceptions[] = is_a($exception, 'DateTime') ? $exception : new Api\DateTime($exception, $timestamp_tz);
751 751
 			}
752 752
 		}
753
-		return new calendar_rrule($time,$event['recur_type'],$event['recur_interval'],$enddate,$event['recur_data'],$exceptions);
753
+		return new calendar_rrule($time, $event['recur_type'], $event['recur_interval'], $enddate, $event['recur_data'], $exceptions);
754 754
 	}
755 755
 
756 756
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 	 * @param DateTime/string		starttime of the event (in servertime)
777 777
 	 * @param string $to_tz			new timezone
778 778
 	 */
779
-	public static function rrule2tz(array &$event,$starttime,$to_tz)
779
+	public static function rrule2tz(array &$event, $starttime, $to_tz)
780 780
 	{
781 781
 		// We assume that the difference between timezones can result
782 782
 		// in a maximum of one day
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 			self::$tz_cache[$to_tz] = calendar_timezones::DateTimeZone($to_tz);
798 798
 		}
799 799
 
800
-		$time = is_a($starttime,'DateTime') ?
800
+		$time = is_a($starttime, 'DateTime') ?
801 801
 			$starttime : new Api\DateTime($starttime, Api\DateTime::$server_timezone);
802 802
 		$time->setTimezone(self::$tz_cache[$event['tzid']]);
803 803
 		$remote = clone $time;
@@ -815,11 +815,11 @@  discard block
 block discarded – undo
815 815
 					if ($delta == 1 || $delta == -6)
816 816
 					{
817 817
 						$mask = $mask << 1;
818
-						if ($mask & 128) $mask = $mask - 127; // overflow
818
+						if ($mask&128) $mask = $mask - 127; // overflow
819 819
 					}
820 820
 					else
821 821
 					{
822
-						if ($mask & 1) $mask = $mask + 128; // underflow
822
+						if ($mask&1) $mask = $mask + 128; // underflow
823 823
 						$mask = $mask >> 1;
824 824
 					}
825 825
 					$event['recur_data'] = $mask;
@@ -830,15 +830,15 @@  discard block
 block discarded – undo
830 830
 
831 831
 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)	// some tests
832 832
 {
833
-	ini_set('display_errors',1);
834
-	error_reporting(E_ALL & ~E_NOTICE);
833
+	ini_set('display_errors', 1);
834
+	error_reporting(E_ALL&~E_NOTICE);
835 835
 	function lang($str) { return $str; }
836 836
 	$GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin';
837 837
 	require_once('../../api/src/autoload.php');
838 838
 
839 839
 	if (!isset($_REQUEST['time']))
840 840
 	{
841
-		$now = new Api\DateTime('now',new DateTimeZone($_REQUEST['tz'] = 'UTC'));
841
+		$now = new Api\DateTime('now', new DateTimeZone($_REQUEST['tz'] = 'UTC'));
842 842
 		$_REQUEST['time'] = $now->format();
843 843
 		$_REQUEST['type'] = calendar_rrule::WEEKLY;
844 844
 		$_REQUEST['interval'] = 2;
@@ -847,29 +847,29 @@  discard block
 block discarded – undo
847 847
 		$_REQUEST['user-tz'] = 'Europe/Berlin';
848 848
 	}
849 849
 	echo "<html>\n<head>\n\t<title>Test calendar_rrule class</title>\n</head>\n<body>\n<form method='GET'>\n";
850
-	echo "<p>Date+Time: ".Api\Html::input('time',$_REQUEST['time']).
851
-		Api\Html::select('tz',$_REQUEST['tz'],Api\DateTime::getTimezones())."</p>\n";
852
-	echo "<p>Type: ".Api\Html::select('type',$_REQUEST['type'],calendar_rrule::$types)."\n".
853
-		"Interval: ".Api\Html::input('interval',$_REQUEST['interval'])."</p>\n";
850
+	echo "<p>Date+Time: ".Api\Html::input('time', $_REQUEST['time']).
851
+		Api\Html::select('tz', $_REQUEST['tz'], Api\DateTime::getTimezones())."</p>\n";
852
+	echo "<p>Type: ".Api\Html::select('type', $_REQUEST['type'], calendar_rrule::$types)."\n".
853
+		"Interval: ".Api\Html::input('interval', $_REQUEST['interval'])."</p>\n";
854 854
 	echo "<table><tr><td>\n";
855
-	echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays',$_REQUEST['weekdays'],calendar_rrule::$days,false,'','7',false,'height: 150px;')."\n";
855
+	echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays', $_REQUEST['weekdays'], calendar_rrule::$days, false, '', '7', false, 'height: 150px;')."\n";
856 856
 	echo "</td><td>\n";
857
-	echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions',$_REQUEST['exceptions'],'style="height: 150px;"')."\n";
857
+	echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions', $_REQUEST['exceptions'], 'style="height: 150px;"')."\n";
858 858
 	echo "</td></tr></table>\n";
859
-	echo "<p>Enddate: ".Api\Html::input('enddate',$_REQUEST['enddate'])."</p>\n";
860
-	echo "<p>Display recurances in ".Api\Html::select('user-tz',$_REQUEST['user-tz'],Api\DateTime::getTimezones())."</p>\n";
861
-	echo "<p>".Api\Html::submit_button('calc','Calculate')."</p>\n";
859
+	echo "<p>Enddate: ".Api\Html::input('enddate', $_REQUEST['enddate'])."</p>\n";
860
+	echo "<p>Display recurances in ".Api\Html::select('user-tz', $_REQUEST['user-tz'], Api\DateTime::getTimezones())."</p>\n";
861
+	echo "<p>".Api\Html::submit_button('calc', 'Calculate')."</p>\n";
862 862
 	echo "</form>\n";
863 863
 
864 864
 	$tz = new DateTimeZone($_REQUEST['tz']);
865
-	$time = new Api\DateTime($_REQUEST['time'],$tz);
866
-	if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz);
867
-	$weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; }
868
-	if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); }
865
+	$time = new Api\DateTime($_REQUEST['time'], $tz);
866
+	if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'], $tz);
867
+	$weekdays = 0; foreach ((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; }
868
+	if ($_REQUEST['exceptions']) foreach (preg_split("/[,\r\n]+ ?/", $_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); }
869 869
 
870
-	$rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions);
870
+	$rrule = new calendar_rrule($time, $_REQUEST['type'], $_REQUEST['interval'], $enddate, $weekdays, $exceptions);
871 871
 	echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n";
872
-	foreach($rrule as $rtime)
872
+	foreach ($rrule as $rtime)
873 873
 	{
874 874
 		$rtime->setTimezone(Api\DateTime::$user_timezone);
875 875
 		echo ++$n.': '.$rtime->format('l').', '.$rtime."<br />\n";
Please login to merge, or discard this patch.
Braces   +58 added lines, -14 removed lines patch added patch discarded remove patch
@@ -338,7 +338,10 @@  discard block
 block discarded – undo
338 338
 				$duration = 366*24*3600;
339 339
 				break;
340 340
 		}
341
-		if ($interval > 1) $duration *= $interval;
341
+		if ($interval > 1)
342
+		{
343
+			$duration *= $interval;
344
+		}
342 345
 
343 346
 		return $duration;
344 347
 	}
@@ -481,7 +484,10 @@  discard block
 block discarded – undo
481 484
 		{
482 485
 			return clone $this->time;
483 486
 		}
484
-		if (isset($this->current)) $backup = $this->current;
487
+		if (isset($this->current))
488
+		{
489
+			$backup = $this->current;
490
+		}
485 491
 		$this->rewind();
486 492
 
487 493
 		while(--$count > 0)
@@ -489,7 +495,10 @@  discard block
 block discarded – undo
489 495
 			$this->next_no_exception();
490 496
 		}
491 497
 		$ret = clone $this->current;
492
-		if ($backup) $this->current = $backup;
498
+		if ($backup)
499
+		{
500
+			$this->current = $backup;
501
+		}
493 502
 		return $ret;
494 503
 	}
495 504
 
@@ -631,7 +640,11 @@  discard block
 block discarded – undo
631 640
 		$repeat_days = array();
632 641
 		$rrule = array();
633 642
 
634
-		if ($this->type == self::NONE) return false;	// no recuring event
643
+		if ($this->type == self::NONE)
644
+		{
645
+			return false;
646
+		}
647
+		// no recuring event
635 648
 
636 649
 		if ($version == '1.0')
637 650
 		{
@@ -725,8 +738,14 @@  discard block
 block discarded – undo
725 738
 	 */
726 739
 	public static function event2rrule(array $event,$usertime=true,$to_tz=null)
727 740
 	{
728
-		if (!is_array($event)  || !isset($event['tzid'])) return false;
729
-		if (!$to_tz) $to_tz = $event['tzid'];
741
+		if (!is_array($event)  || !isset($event['tzid']))
742
+		{
743
+			return false;
744
+		}
745
+		if (!$to_tz)
746
+		{
747
+			$to_tz = $event['tzid'];
748
+		}
730 749
 		$timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone;
731 750
 		$time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz);
732 751
 
@@ -786,7 +805,10 @@  discard block
 block discarded – undo
786 805
 			$event['recur_type'] == self::NONE ||
787 806
 			empty($event['recur_data']) || $event['recur_data'] == ALLDAYS ||
788 807
 			empty($event['tzid']) || empty($to_tz) ||
789
-			$event['tzid'] == $to_tz) return;
808
+			$event['tzid'] == $to_tz)
809
+		{
810
+			return;
811
+		}
790 812
 
791 813
 		if (!isset(self::$tz_cache[$event['tzid']]))
792 814
 		{
@@ -815,11 +837,19 @@  discard block
 block discarded – undo
815 837
 					if ($delta == 1 || $delta == -6)
816 838
 					{
817 839
 						$mask = $mask << 1;
818
-						if ($mask & 128) $mask = $mask - 127; // overflow
840
+						if ($mask & 128)
841
+						{
842
+							$mask = $mask - 127;
843
+						}
844
+						// overflow
819 845
 					}
820 846
 					else
821 847
 					{
822
-						if ($mask & 1) $mask = $mask + 128; // underflow
848
+						if ($mask & 1)
849
+						{
850
+							$mask = $mask + 128;
851
+						}
852
+						// underflow
823 853
 						$mask = $mask >> 1;
824 854
 					}
825 855
 					$event['recur_data'] = $mask;
@@ -828,11 +858,16 @@  discard block
 block discarded – undo
828 858
 	}
829 859
 }
830 860
 
831
-if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)	// some tests
861
+if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
862
+{
863
+	// some tests
832 864
 {
833 865
 	ini_set('display_errors',1);
866
+}
834 867
 	error_reporting(E_ALL & ~E_NOTICE);
835
-	function lang($str) { return $str; }
868
+	function lang($str)
869
+	{
870
+return $str; }
836 871
 	$GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin';
837 872
 	require_once('../../api/src/autoload.php');
838 873
 
@@ -863,9 +898,18 @@  discard block
 block discarded – undo
863 898
 
864 899
 	$tz = new DateTimeZone($_REQUEST['tz']);
865 900
 	$time = new Api\DateTime($_REQUEST['time'],$tz);
866
-	if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz);
867
-	$weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; }
868
-	if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); }
901
+	if ($_REQUEST['enddate'])
902
+	{
903
+		$enddate = new Api\DateTime($_REQUEST['enddate'],$tz);
904
+	}
905
+	$weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask)
906
+	{
907
+$weekdays |= $mask; }
908
+	if ($_REQUEST['exceptions'])
909
+	{
910
+		foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception);
911
+	}
912
+	}
869 913
 
870 914
 	$rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions);
871 915
 	echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n";
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 	 *
62 62
 	 * @var array
63 63
 	 */
64
-	static public $types = Array(
64
+	static public $types = array(
65 65
 		self::NONE         => 'None',
66 66
 		self::DAILY        => 'Daily',
67 67
 		self::WEEKLY       => 'Weekly',
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 5 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1490,13 +1490,13 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 	/**
1493
-	* Converts a participant into a (readable) user- or resource-name
1494
-	*
1495
-	* @param string|int $id id of user or resource
1496
-	* @param string|boolean $use_type =false type-letter or false
1497
-	* @param boolean $append_email =false append email (Name <email>)
1498
-	* @return string with name
1499
-	*/
1493
+	 * Converts a participant into a (readable) user- or resource-name
1494
+	 *
1495
+	 * @param string|int $id id of user or resource
1496
+	 * @param string|boolean $use_type =false type-letter or false
1497
+	 * @param boolean $append_email =false append email (Name <email>)
1498
+	 * @return string with name
1499
+	 */
1500 1500
 	function participant_name($id,$use_type=false, $append_email=false)
1501 1501
 	{
1502 1502
 		static $id2lid = array();
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
 	}
1526 1526
 
1527 1527
 	/**
1528
-	* Converts participants array of an event into array of (readable) participant-names with status
1529
-	*
1530
-	* @param array $event event-data
1531
-	* @param boolean $long_status =false should the long/verbose status or an icon be use
1532
-	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
-	* @return array with id / names with status pairs
1534
-	*/
1528
+	 * Converts participants array of an event into array of (readable) participant-names with status
1529
+	 *
1530
+	 * @param array $event event-data
1531
+	 * @param boolean $long_status =false should the long/verbose status or an icon be use
1532
+	 * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
+	 * @return array with id / names with status pairs
1534
+	 */
1535 1535
 	function participants($event,$long_status=false,$show_group_invitation=false)
1536 1536
 	{
1537 1537
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 	}
1602 1602
 
1603 1603
 	/**
1604
-	* Converts category string of an event into array of (readable) category-names
1605
-	*
1606
-	* @param string $category cat-id (multiple id's commaseparated)
1607
-	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
-	* @return array with id / names
1609
-	*/
1604
+	 * Converts category string of an event into array of (readable) category-names
1605
+	 *
1606
+	 * @param string $category cat-id (multiple id's commaseparated)
1607
+	 * @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
+	 * @return array with id / names
1609
+	 */
1610 1610
 	function categories($category,&$color)
1611 1611
 	{
1612 1612
 		static $id2cat = array();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * @var array recur_types translates MCAL recur-types to verbose labels
124 124
 	 */
125
-	var $recur_types = Array(
125
+	var $recur_types = array(
126 126
 		MCAL_RECUR_NONE         => 'No recurrence',
127 127
 		MCAL_RECUR_DAILY        => 'Daily',
128 128
 		MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 * @param string $pattern pattern to search
1898 1898
 	 * @return array with cal_id - title pairs of the matching entries
1899 1899
 	 */
1900
-	function link_query($pattern, Array &$options = array())
1900
+	function link_query($pattern, array &$options = array())
1901 1901
 	{
1902 1902
 		$result = array();
1903 1903
 		$query = array(
Please login to merge, or discard this patch.
Braces   +206 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Link;
16 16
 use EGroupware\Api\Acl;
17 17
 
18
-if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
18
+if (!defined('ACL_TYPE_IDENTIFER'))
19
+{
20
+	// used to mark ACL-values for the debug_message methode
19 21
 {
20 22
 	define('ACL_TYPE_IDENTIFER','***ACL***');
21 23
 }
24
+}
22 25
 
23 26
 define('HOUR_s',60*60);
24 27
 define('DAY_s',24*HOUR_s);
@@ -222,7 +225,10 @@  discard block
 block discarded – undo
222 225
 	 */
223 226
 	function __construct()
224 227
 	{
225
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
228
+		if ($this->debug > 0)
229
+		{
230
+			$this->debug_message('calendar_bo::bocal() started',True);
231
+		}
226 232
 
227 233
 		$this->so = new calendar_so();
228 234
 
@@ -308,7 +314,10 @@  discard block
 block discarded – undo
308 314
 	 */
309 315
 	static function email_info($ids)
310 316
 	{
311
-		if (!$ids) return null;
317
+		if (!$ids)
318
+		{
319
+			return null;
320
+		}
312 321
 
313 322
 		$data = array();
314 323
 		foreach((array)$ids as $id)
@@ -391,10 +400,13 @@  discard block
 block discarded – undo
391 400
 				$contact = 'c'.$contact['id'];
392 401
 				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
393 402
 				{
394
-					if ($contact && !in_array($contact,$contact_list))	// already added?
403
+					if ($contact && !in_array($contact,$contact_list))
404
+					{
405
+						// already added?
395 406
 					{
396 407
 						$contact_list[] = $contact;
397 408
 					}
409
+					}
398 410
 				}
399 411
 			}
400 412
 		}
@@ -454,31 +466,43 @@  discard block
 block discarded – undo
454 466
 			{
455 467
 				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
456 468
 				{
457
-					if ($contact && !in_array($contact,$users))	// already added?
469
+					if ($contact && !in_array($contact,$users))
470
+					{
471
+						// already added?
458 472
 					{
459 473
 						$users[] = $contact;
460 474
 					}
475
+					}
461 476
 				}
462 477
 				continue;
463 478
 			}
464 479
 			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
465 480
 			{
466
-				if ($user && !in_array($user,$users))	// already added?
481
+				if ($user && !in_array($user,$users))
482
+				{
483
+					// already added?
467 484
 				{
468 485
 					$users[] = $user;
469 486
 				}
487
+				}
470 488
 			}
471 489
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
472 490
 			{
473 491
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
474 492
 			}
475 493
 			// the further code is only for real users
476
-			if (!is_numeric($user)) continue;
494
+			if (!is_numeric($user))
495
+			{
496
+				continue;
497
+			}
477 498
 
478 499
 			// for groups we have to include the members
479 500
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
480 501
 			{
481
-				if ($no_enum_groups) continue;
502
+				if ($no_enum_groups)
503
+				{
504
+					continue;
505
+				}
482 506
 
483 507
 				$members = $GLOBALS['egw']->accounts->members($user, true);
484 508
 				if (is_array($members))
@@ -558,11 +582,14 @@  discard block
 block discarded – undo
558 582
 		}
559 583
 
560 584
 		if (!isset($params['users']) || !$params['users'] ||
561
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
585
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
586
+		{
587
+			// null or '' casted to an array
562 588
 		{
563 589
 			// for a search use all account you have read grants from
564 590
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
565 591
 		}
592
+		}
566 593
 		// resolve users to add memberships for users and members for groups
567 594
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
568 595
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -573,7 +600,10 @@  discard block
 block discarded – undo
573 600
 			$params['private_grants'] = array();
574 601
 			foreach($this->grants as $user => $rights)
575 602
 			{
576
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
603
+				if ($rights & Acl::PRIVAT)
604
+				{
605
+					$params['private_grants'][] = $user;
606
+				}
577 607
 			}
578 608
 		}
579 609
 
@@ -588,7 +618,10 @@  discard block
 block discarded – undo
588 618
 		{
589 619
 			return false;
590 620
 		}
591
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
621
+		if (isset($params['start']))
622
+		{
623
+			$start = $this->date2ts($params['start']);
624
+		}
592 625
 
593 626
 		if (isset($params['end']))
594 627
 		{
@@ -652,10 +685,13 @@  discard block
 block discarded – undo
652 685
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
653 686
 			}
654 687
 			// create empty entries for each day in the reported time
655
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
688
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
689
+			{
690
+				// good enough for array creation, but see while loop below.
656 691
 			{
657 692
 				$daysEvents[$this->date2string($ts)] = array();
658 693
 			}
694
+			}
659 695
 			foreach($events as $k => $event)
660 696
 			{
661 697
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -707,7 +743,10 @@  discard block
 block discarded – undo
707 743
 			$integration_data = calendar_so::get_integration_data();
708 744
 		}
709 745
 
710
-		if (!isset($integration_data[$app])) return null;
746
+		if (!isset($integration_data[$app]))
747
+		{
748
+			return null;
749
+		}
711 750
 
712 751
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
713 752
 	}
@@ -754,8 +793,14 @@  discard block
 block discarded – undo
754 793
 	 */
755 794
 	function clear_private_infos(&$event,$allowed_participants = array())
756 795
 	{
757
-		if ($event == false) return;
758
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
796
+		if ($event == false)
797
+		{
798
+			return;
799
+		}
800
+		if (!is_array($event['participants']))
801
+		{
802
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
803
+		}
759 804
 
760 805
 		$event = array(
761 806
 			'id'    => $event['id'],
@@ -800,19 +845,29 @@  discard block
 block discarded – undo
800 845
 		}
801 846
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
802 847
 
803
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
848
+		if ($new_horizont <= $this->config['horizont'])
849
+		{
850
+			// no move necessary
804 851
 		{
805 852
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
853
+		}
806 854
 			return;
807 855
 		}
808 856
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
809 857
 		{
810 858
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
811 859
 		}
812
-		if (empty($maxdays)) $maxdays = 1000; // old default
813
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
860
+		if (empty($maxdays))
861
+		{
862
+			$maxdays = 1000;
863
+		}
864
+		// old default
865
+		if ($new_horizont > time()+$maxdays*DAY_s)
866
+		{
867
+			// some user tries to "look" more then the maximum number of days in the future
814 868
 		{
815 869
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
870
+		}
816 871
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
817 872
 			return;
818 873
 		}
@@ -840,7 +895,10 @@  discard block
 block discarded – undo
840 895
 		// update the horizont
841 896
 		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
842 897
 
843
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
898
+		if ($this->debug == 'check_move_horizont')
899
+		{
900
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
901
+		}
844 902
 	}
845 903
 
846 904
 	/**
@@ -871,7 +929,10 @@  discard block
 block discarded – undo
871 929
 				$event['end'] = $event_read['end'];
872 930
 			}
873 931
 		}
874
-		if (!$start) $start = $event['start'];
932
+		if (!$start)
933
+		{
934
+			$start = $event['start'];
935
+		}
875 936
 
876 937
 		$events = array();
877 938
 		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
@@ -911,7 +972,10 @@  discard block
 block discarded – undo
911 972
 	 */
912 973
 	function db2data(&$events,$date_format='ts')
913 974
 	{
914
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
975
+		if (!is_array($events))
976
+		{
977
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
978
+		}
915 979
 		foreach ($events as &$event)
916 980
 		{
917 981
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -995,7 +1059,10 @@  discard block
 block discarded – undo
995 1059
 	 */
996 1060
 	function date2usertime($ts,$date_format='ts')
997 1061
 	{
998
-		if (empty($ts) || $date_format == 'server') return $ts;
1062
+		if (empty($ts) || $date_format == 'server')
1063
+		{
1064
+			return $ts;
1065
+		}
999 1066
 
1000 1067
 		return Api\DateTime::server2user($ts,$date_format);
1001 1068
 	}
@@ -1013,9 +1080,15 @@  discard block
 block discarded – undo
1013 1080
 	 */
1014 1081
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1015 1082
 	{
1016
-		if (!$ids) return false;
1083
+		if (!$ids)
1084
+		{
1085
+			return false;
1086
+		}
1017 1087
 
1018
-		if ($date) $date = $this->date2ts($date);
1088
+		if ($date)
1089
+		{
1090
+			$date = $this->date2ts($date);
1091
+		}
1019 1092
 
1020 1093
 		$return = null;
1021 1094
 
@@ -1180,7 +1253,10 @@  discard block
 block discarded – undo
1180 1253
 	{
1181 1254
 		static $res_info_cache = array();
1182 1255
 
1183
-		if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1256
+		if (!is_scalar($uid))
1257
+		{
1258
+			throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1259
+		}
1184 1260
 
1185 1261
 		if (!isset($res_info_cache[$uid]))
1186 1262
 		{
@@ -1235,7 +1311,10 @@  discard block
 block discarded – undo
1235 1311
 	 */
1236 1312
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1237 1313
 	{
1238
-		if (!$user) $user = $this->user;
1314
+		if (!$user)
1315
+		{
1316
+			$user = $this->user;
1317
+		}
1239 1318
 		if ($user == $this->user)
1240 1319
 		{
1241 1320
 			$grants = $this->grants;
@@ -1274,7 +1353,10 @@  discard block
 block discarded – undo
1274 1353
 		$grant = $grants[$owner];
1275 1354
 
1276 1355
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1277
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1356
+		if ($grant & ~self::ACL_INVITE)
1357
+		{
1358
+			$grant |= self::ACL_FREEBUSY;
1359
+		}
1278 1360
 
1279 1361
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1280 1362
 		{
@@ -1300,7 +1382,10 @@  discard block
 block discarded – undo
1300 1382
 					elseif (!is_numeric($uid))
1301 1383
 					{
1302 1384
 						// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
1303
-						if ($grant == self::ACL_FREEBUSY) continue;
1385
+						if ($grant == self::ACL_FREEBUSY)
1386
+						{
1387
+							continue;
1388
+						}
1304 1389
 						// if we have a resource as participant
1305 1390
 						$resource = $this->resource_info($uid);
1306 1391
 						$grant |= $resource['rights'];
@@ -1451,14 +1536,20 @@  discard block
 block discarded – undo
1451 1536
 						$param = $param ? 'True' : 'False';
1452 1537
 						break;
1453 1538
 					case 'integer':
1454
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1539
+						if ($param >= mktime(0,0,0,1,1,2000))
1540
+						{
1541
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1542
+						}
1455 1543
 						break;
1456 1544
 				}
1457 1545
 			}
1458 1546
 			$msg = str_replace('%'.($i-1),$param,$msg);
1459 1547
 		}
1460 1548
 		error_log($msg);
1461
-		if ($backtrace) error_log(function_backtrace(1));
1549
+		if ($backtrace)
1550
+		{
1551
+			error_log(function_backtrace(1));
1552
+		}
1462 1553
 	}
1463 1554
 
1464 1555
 	/**
@@ -1566,14 +1657,20 @@  discard block
 block discarded – undo
1566 1657
 	function timespan($start_m,$end_m,$both=false)
1567 1658
 	{
1568 1659
 		$duration = $end_m - $start_m;
1569
-		if ($end_m == 24*60-1) ++$duration;
1660
+		if ($end_m == 24*60-1)
1661
+		{
1662
+			++$duration;
1663
+		}
1570 1664
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1571 1665
 
1572 1666
 		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1573 1667
 
1574
-		if ($both)	// end-time too
1668
+		if ($both)
1669
+		{
1670
+			// end-time too
1575 1671
 		{
1576 1672
 			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1673
+		}
1577 1674
 			// dont double am/pm if they are the same in both times
1578 1675
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1579 1676
 			{
@@ -1597,7 +1694,10 @@  discard block
 block discarded – undo
1597 1694
 		static $id2lid = array();
1598 1695
 		static $id2email = array();
1599 1696
 
1600
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1697
+		if ($use_type && $use_type != 'u')
1698
+		{
1699
+			$id = $use_type.$id;
1700
+		}
1601 1701
 
1602 1702
 		if (!isset($id2lid[$id]))
1603 1703
 		{
@@ -1607,7 +1707,10 @@  discard block
 block discarded – undo
1607 1707
 				if (($info = $this->resource_info($id)))
1608 1708
 				{
1609 1709
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1610
-					if ($info['name']) $id2email[$id] = $info['email'];
1710
+					if ($info['name'])
1711
+					{
1712
+						$id2email[$id] = $info['email'];
1713
+					}
1611 1714
 				}
1612 1715
 			}
1613 1716
 			else
@@ -1633,11 +1736,18 @@  discard block
 block discarded – undo
1633 1736
 		$names = array();
1634 1737
 		foreach((array)$event['participants'] as $id => $status)
1635 1738
 		{
1636
-			if (!is_string($status)) continue;
1739
+			if (!is_string($status))
1740
+			{
1741
+				continue;
1742
+			}
1637 1743
 			$quantity = $role = null;
1638 1744
 			calendar_so::split_status($status,$quantity,$role);
1639 1745
 
1640
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1746
+			if ($status == 'G' && !$show_group_invitation)
1747
+			{
1748
+				continue;
1749
+			}
1750
+			// dont show group-invitation
1641 1751
 
1642 1752
 			$lang_status = lang($this->verbose_status[$status]);
1643 1753
 			if (!$long_status)
@@ -1710,7 +1820,10 @@  discard block
 block discarded – undo
1710 1820
 
1711 1821
 		foreach(explode(',',$category) as $cat_id)
1712 1822
 		{
1713
-			if (!$cat_id) continue;
1823
+			if (!$cat_id)
1824
+			{
1825
+				continue;
1826
+			}
1714 1827
 
1715 1828
 			if (!isset($id2cat[$cat_id]))
1716 1829
 			{
@@ -1776,7 +1889,10 @@  discard block
 block discarded – undo
1776 1889
 	 */
1777 1890
 	public static function list_calendars($user, array $grants=null)
1778 1891
 	{
1779
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1892
+		if (is_null($grants))
1893
+		{
1894
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1895
+		}
1780 1896
 
1781 1897
 		$users = $groups = array();
1782 1898
 		foreach(array_keys($grants) as $id)
@@ -1824,7 +1940,10 @@  discard block
 block discarded – undo
1824 1940
 	 */
1825 1941
 	function recure2string($event)
1826 1942
 	{
1827
-		if (!is_array($event)) return false;
1943
+		if (!is_array($event))
1944
+		{
1945
+			return false;
1946
+		}
1828 1947
 		return (string)calendar_rrule::event2rrule($event);
1829 1948
 	}
1830 1949
 
@@ -1843,12 +1962,18 @@  discard block
 block discarded – undo
1843 1962
 	 */
1844 1963
 	function read_holidays($year=0)
1845 1964
 	{
1846
-		if (!$year) $year = (int) date('Y',$this->now_su);
1965
+		if (!$year)
1966
+		{
1967
+			$year = (int) date('Y',$this->now_su);
1968
+		}
1847 1969
 
1848
-		if (!$this->cached_holidays)	// try reading the holidays from the session
1970
+		if (!$this->cached_holidays)
1971
+		{
1972
+			// try reading the holidays from the session
1849 1973
 		{
1850 1974
 			$this->cached_holidays = Api\Cache::getSession('calendar', 'holidays');
1851 1975
 		}
1976
+		}
1852 1977
 		if (!isset($this->cached_holidays[$year]))
1853 1978
 		{
1854 1979
 			$this->cached_holidays[$year] = calendar_holidays::read(
@@ -1891,7 +2016,11 @@  discard block
 block discarded – undo
1891 2016
 							continue;
1892 2017
 						}
1893 2018
 						list($y,$m,$d) = explode('-',$pers['bday']);
1894
-						if ($y > $year) continue; 	// not yet born
2019
+						if ($y > $year)
2020
+						{
2021
+							continue;
2022
+						}
2023
+						// not yet born
1895 2024
 						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1896 2025
 							'day'       => $d,
1897 2026
 							'month'     => $m,
@@ -1984,7 +2113,10 @@  discard block
 block discarded – undo
1984 2113
 				}
1985 2114
 			}
1986 2115
 			$str_fields = implode(', ',$extra_fields);
1987
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2116
+			if (is_array($extra_fields))
2117
+			{
2118
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2119
+			}
1988 2120
 		}
1989 2121
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1990 2122
 	}
@@ -2005,7 +2137,8 @@  discard block
 block discarded – undo
2005 2137
 			'offset' =>	$options['start'],
2006 2138
 			'order' => 'cal_start DESC',
2007 2139
 		);
2008
-		if($options['num_rows']) {
2140
+		if($options['num_rows'])
2141
+		{
2009 2142
 			$query['num_rows'] = $options['num_rows'];
2010 2143
 		}
2011 2144
 		foreach((array) $this->search($query) as $event)
@@ -2066,7 +2199,10 @@  discard block
 block discarded – undo
2066 2199
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2067 2200
 			{
2068 2201
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2069
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2202
+				if ($type == 'forced')
2203
+				{
2204
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2205
+				}
2070 2206
 				$this->cal_prefs[$var] = $default;
2071 2207
 				$need_save = True;
2072 2208
 			}
@@ -2086,7 +2222,10 @@  discard block
 block discarded – undo
2086 2222
 	 */
2087 2223
 	static function freebusy_url($user='',$pw=null)
2088 2224
 	{
2089
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2225
+		if (is_numeric($user))
2226
+		{
2227
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2228
+		}
2090 2229
 
2091 2230
 		$credentials = '';
2092 2231
 
@@ -2154,13 +2293,19 @@  discard block
 block discarded – undo
2154 2293
 	 */
2155 2294
 	public function get_ctag($user, $filter='owner', $master_only=false)
2156 2295
 	{
2157
-		if ($this->debug > 1) $startime = microtime(true);
2296
+		if ($this->debug > 1)
2297
+		{
2298
+			$startime = microtime(true);
2299
+		}
2158 2300
 
2159 2301
 		// resolve users to add memberships for users and members for groups
2160 2302
 		$users = $this->resolve_users($user);
2161 2303
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2162 2304
 
2163
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2305
+		if ($this->debug > 1)
2306
+		{
2307
+			error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2308
+		}
2164 2309
 		return $ctag;
2165 2310
 	}
2166 2311
 
@@ -2202,15 +2347,21 @@  discard block
 block discarded – undo
2202 2347
 				$content['link_app'][] = $link['app'];
2203 2348
 				$content['link_id'][]  = $link['id'];
2204 2349
 			}
2205
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2350
+			if ($link['app'] == 'addressbook')
2351
+			{
2352
+				// prefering contact as primary contact over calendar entry set above
2206 2353
 			{
2207 2354
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2208 2355
 			}
2356
+			}
2209 2357
 		}
2210 2358
 		// Copy same custom fields
2211 2359
 		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2212 2360
 		{
2213
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2361
+			if ($this->customfields[$name])
2362
+			{
2363
+				$content['#'.$name] = $calendar['#'.$name];
2364
+			}
2214 2365
 		}
2215 2366
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2216 2367
 		return $content;
@@ -2233,7 +2384,11 @@  discard block
 block discarded – undo
2233 2384
 			$set['ts_title'] = $this->link_title($event);
2234 2385
 			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2235 2386
 			$set['ts_description'] = $event['description'];
2236
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2387
+			if ($this->isWholeDay($event))
2388
+			{
2389
+				$event['end']++;
2390
+			}
2391
+			// whole day events are 1sec short
2237 2392
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2238 2393
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2239 2394
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -12 removed lines patch added patch discarded remove patch
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
 	 * or an ExecMethod callback with parameters $id,$event
633 633
 	 *
634 634
 	 * @param string $app
635
-	 * @param int|string $id
636
-	 * @return string
635
+	 * @param string $id
636
+	 * @return boolean
637 637
 	 */
638 638
 	static function integration_get_private($app,$id,$event)
639 639
 	{
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 	 * This methods operates in usertime, while $this->config['horizont'] is in servertime!
763 763
 	 *
764 764
 	 * @param array $event
765
-	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
765
+	 * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event
766 766
 	 */
767 767
 	function set_recurrences($event,$start=0)
768 768
 	{
@@ -982,10 +982,9 @@  discard block
 block discarded – undo
982 982
 	 * Recurrences get calculated by rrule iterator implemented in calendar_rrule class.
983 983
 	 *
984 984
 	 * @param array $event repeating event whos repetions should be inserted
985
-	 * @param mixed $start start-date
985
+	 * @param mixed $_start start-date
986 986
 	 * @param mixed $end end-date
987 987
 	 * @param array $events where the repetions get inserted
988
-	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
989 988
 	 */
990 989
 	function insert_all_recurrences($event,$_start,$end,&$events)
991 990
 	{
@@ -1139,7 +1138,7 @@  discard block
 block discarded – undo
1139 1138
 	 *	even if you have no general read-grant from that user.
1140 1139
 	 *
1141 1140
 	 * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE}
1142
-	 * @param mixed $event event as array or the event-id or 0 for a general check
1141
+	 * @param integer $event event as array or the event-id or 0 for a general check
1143 1142
 	 * @param int $other uid to check (if event==0) or 0 to check against $this->user
1144 1143
 	 * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
1145 1144
 	 * @param mixed $date_to_read =null date used for reading, internal param for the caching
@@ -1312,8 +1311,6 @@  discard block
 block discarded – undo
1312 1311
 	 * @param string $msg message with parameters/variables like lang(), eg. '%1'
1313 1312
 	 * @param boolean $backtrace =True include a function-backtrace, default True=On
1314 1313
 	 *	should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!!
1315
-	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1316
-	 *	arrays get serialized with print_r() !
1317 1314
 	 */
1318 1315
 	static function debug_message($msg,$backtrace=True)
1319 1316
 	{
@@ -1378,7 +1375,7 @@  discard block
 block discarded – undo
1378 1375
 	 * Formats one or two dates (range) as long date (full monthname), optionaly with a time
1379 1376
 	 *
1380 1377
 	 * @param mixed $_first first date
1381
-	 * @param mixed $last =0 last date if != 0 (default)
1378
+	 * @param integer $last =0 last date if != 0 (default)
1382 1379
 	 * @param boolean $display_time =false should a time be displayed too
1383 1380
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1384 1381
 	 * @return string with formated date
@@ -1847,7 +1844,6 @@  discard block
 block discarded – undo
1847 1844
 	 *
1848 1845
 	 * Is called as hook to participate in the linking
1849 1846
 	 *
1850
-	 * @param int|array $entry int cal_id or array with event
1851 1847
 	 * @param string|boolean string with title, null if not found or false if not read perms
1852 1848
 	 */
1853 1849
 	function link_title($event)
@@ -2036,6 +2032,7 @@  discard block
 block discarded – undo
2036 2032
 	 *
2037 2033
 	 * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions
2038 2034
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2035
+	 * @param string $schedule_tag
2039 2036
 	 * @return string|boolean string with etag or false
2040 2037
 	 */
2041 2038
 	function get_etag($entry, &$schedule_tag=null)
@@ -2076,7 +2073,6 @@  discard block
 block discarded – undo
2076 2073
 	 * Hook for infolog  to set some extra data and links
2077 2074
 	 *
2078 2075
 	 * @param array $data event-array preset by infolog plus
2079
-	 * @param int $data[id] cal_id
2080 2076
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
2081 2077
 	 */
2082 2078
 	function infolog_set($data)
@@ -2128,7 +2124,6 @@  discard block
 block discarded – undo
2128 2124
 	 * Hook for timesheet to set some extra data and links
2129 2125
 	 *
2130 2126
 	 * @param array $data
2131
-	 * @param int $data[id] cal_id:recurrence
2132 2127
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
2133 2128
 	 */
2134 2129
 	function timesheet_set($data)
Please login to merge, or discard this patch.
Spacing   +308 added lines, -309 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
19 19
 {
20
-	define('ACL_TYPE_IDENTIFER','***ACL***');
20
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
21 21
 }
22 22
 
23
-define('HOUR_s',60*60);
24
-define('DAY_s',24*HOUR_s);
25
-define('WEEK_s',7*DAY_s);
23
+define('HOUR_s', 60 * 60);
24
+define('DAY_s', 24 * HOUR_s);
25
+define('WEEK_s', 7 * DAY_s);
26 26
 
27 27
 /**
28 28
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
72 72
 	 *	5 = function-calls to private functions
73 73
 	 */
74
-	var $debug=false;
74
+	var $debug = false;
75 75
 
76 76
 	/**
77 77
 	 * @var int $now timestamp in server-time
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var int $user nummerical id of the current user-id
103 103
 	 */
104
-	var $user=0;
104
+	var $user = 0;
105 105
 
106 106
 	/**
107 107
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
108 108
 	 */
109
-	var $grants=array();
109
+	var $grants = array();
110 110
 
111 111
 	/**
112 112
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	function __construct()
224 224
 	{
225
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
225
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
226 226
 
227 227
 		$this->so = new calendar_so();
228 228
 
229
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
230
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
229
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
230
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
231 231
 
232 232
 		$this->now = time();
233
-		$this->now_su = Api\DateTime::server2user($this->now,'ts');
233
+		$this->now_su = Api\DateTime::server2user($this->now, 'ts');
234 234
 
235 235
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
236 236
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
240 240
 		{
241 241
 			$this->resources = array();
242
-			foreach(Api\Hooks::process('calendar_resources') as $app => $data)
242
+			foreach (Api\Hooks::process('calendar_resources') as $app => $data)
243 243
 			{
244 244
 				if ($data && $data['type'])
245 245
 				{
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 				'app'  => 'email',
253 253
 			);
254 254
 			$this->resources['l'] = array(
255
-				'type' => 'l',// one char type-identifier for this resources
256
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
255
+				'type' => 'l', // one char type-identifier for this resources
256
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
257 257
 				'app' => 'Distribution list'
258 258
 			);
259 259
 			$this->resources[''] = array(
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 				'app' => 'api-accounts',
262 262
 			);
263 263
 			$this->resources['l'] = array(
264
-				'type' => 'l',// one char type-identifier for this resources
265
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
264
+				'type' => 'l', // one char type-identifier for this resources
265
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
266 266
 				'app' => 'Distribution list'
267 267
 			);
268 268
 			Api\Cache::setSession('calendar', 'resources', $this->resources);
269 269
 		}
270 270
 		//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
271 271
 
272
-		$this->config = Api\Config::read('calendar');	// only used for horizont, regular calendar config is under phpgwapi
272
+		$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
273 273
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
274 274
 
275
-		$this->categories = new Api\Categories($this->user,'calendar');
275
+		$this->categories = new Api\Categories($this->user, 'calendar');
276 276
 
277 277
 		$this->customfields = Api\Storage\Customfields::get('calendar');
278 278
 
279
-		foreach($this->alarms as $secs => &$label)
279
+		foreach ($this->alarms as $secs => &$label)
280 280
 		{
281 281
 			$label = self::secs2label($secs);
282 282
 		}
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 	{
293 293
 		if ($secs <= 3600)
294 294
 		{
295
-			$label = lang('%1 minutes', $secs/60);
295
+			$label = lang('%1 minutes', $secs / 60);
296 296
 		}
297
-		elseif($secs <= 86400)
297
+		elseif ($secs <= 86400)
298 298
 		{
299
-			$label = lang('%1 hours', $secs/3600);
299
+			$label = lang('%1 hours', $secs / 3600);
300 300
 		}
301 301
 		else
302 302
 		{
303
-			$label = lang('%1 days', $secs/86400);
303
+			$label = lang('%1 days', $secs / 86400);
304 304
 		}
305 305
 		return $label;
306 306
 	}
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 		if (!$ids) return null;
317 317
 
318 318
 		$data = array();
319
-		foreach((array)$ids as $id)
319
+		foreach ((array)$ids as $id)
320 320
 		{
321 321
 			$email = $id;
322 322
 			$name = '';
323 323
 			$matches = null;
324
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
324
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
325 325
 			{
326 326
 				$name = $matches[1];
327 327
 				$email = $matches[2];
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	static function mailing_lists($ids)
347 347
 	{
348
-		if(!is_array($ids))
348
+		if (!is_array($ids))
349 349
 		{
350 350
 			$ids = array($ids);
351 351
 		}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 		// Email list
355 355
 		$contacts_obj = new Api\Contacts();
356 356
 		$bo = new calendar_bo();
357
-		foreach($ids as $id)
357
+		foreach ($ids as $id)
358 358
 		{
359 359
 			$list = $contacts_obj->read_list((int)$id);
360 360
 
@@ -381,22 +381,22 @@  discard block
 block discarded – undo
381 381
 	 *
382 382
 	 * @return array
383 383
 	 */
384
-	public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true)
384
+	public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true)
385 385
 	{
386 386
 		$contact_list = array();
387 387
 		$contacts = new Api\Contacts();
388
-		if($contacts->check_list((int)substr($id,1), ACL::READ))
388
+		if ($contacts->check_list((int)substr($id, 1), ACL::READ))
389 389
 		{
390
-			$options = array('list' => substr($id,1));
391
-			$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
392
-			if(!$lists)
390
+			$options = array('list' => substr($id, 1));
391
+			$lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options);
392
+			if (!$lists)
393 393
 			{
394 394
 				return $contact_list;
395 395
 			}
396
-			foreach($lists as &$contact)
396
+			foreach ($lists as &$contact)
397 397
 			{
398 398
 				// Check for user account
399
-				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'],'person_id')))
399
+				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'], 'person_id')))
400 400
 				{
401 401
 					$contact = ''.$account_id;
402 402
 				}
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
 				{
405 405
 					$contact = 'c'.$contact['id'];
406 406
 				}
407
-				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
407
+				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $contact))
408 408
 				{
409
-					if ($contact && !in_array($contact,$contact_list))	// already added?
409
+					if ($contact && !in_array($contact, $contact_list))	// already added?
410 410
 					{
411 411
 						$contact_list[] = $contact;
412 412
 					}
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
 	function enum_groups(&$event)
426 426
 	{
427 427
 		$added = 0;
428
-		foreach(array_keys($event['participants']) as $uid)
428
+		foreach (array_keys($event['participants']) as $uid)
429 429
 		{
430 430
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
431 431
 				($members = $GLOBALS['egw']->accounts->members($uid, true)))
432 432
 			{
433
-				foreach($members as $member)
433
+				foreach ($members as $member)
434 434
 				{
435 435
 					if (!isset($event['participants'][$member]))
436 436
 					{
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
453 453
 	 * @return array of user-ids
454 454
 	 */
455
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
455
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
456 456
 	{
457 457
 		if (!is_array($_users))
458 458
 		{
@@ -460,35 +460,35 @@  discard block
 block discarded – undo
460 460
 		}
461 461
 		// only query calendars of users, we have READ-grants from
462 462
 		$users = array();
463
-		foreach($_users as $user)
463
+		foreach ($_users as $user)
464 464
 		{
465 465
 			$user = trim($user);
466 466
 			
467 467
 			// Handle email lists
468
-			if(!is_numeric($user) && $user[0] == 'l')
468
+			if (!is_numeric($user) && $user[0] == 'l')
469 469
 			{
470
-				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
470
+				foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
471 471
 				{
472
-					if ($contact && !in_array($contact,$users))	// already added?
472
+					if ($contact && !in_array($contact, $users))	// already added?
473 473
 					{
474 474
 						$users[] = $contact;
475 475
 					}
476 476
 				}
477 477
 				continue;
478 478
 			}
479
-			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
479
+			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $user))
480 480
 			{
481
-				if ($user && !in_array($user,$users))	// already added?
481
+				if ($user && !in_array($user, $users))	// already added?
482 482
 				{
483 483
 					// General expansion check
484 484
 					if (!is_numeric($user) && $this->resources[$user[0]]['info'])
485 485
 					{
486 486
 						$info = $this->resource_info($user);
487
-						if($info && $info['resources'])
487
+						if ($info && $info['resources'])
488 488
 						{
489
-							foreach($info['resources'] as $_user)
489
+							foreach ($info['resources'] as $_user)
490 490
 							{
491
-								if($_user && !in_array($_user, $users))
491
+								if ($_user && !in_array($_user, $users))
492 492
 								{
493 493
 									$users[] = $_user;
494 494
 								}
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			}
502 502
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
503 503
 			{
504
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
504
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
505 505
 			}
506 506
 			// the further code is only for real users
507 507
 			if (!is_numeric($user)) continue;
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 				$members = $GLOBALS['egw']->accounts->members($user, true);
515 515
 				if (is_array($members))
516 516
 				{
517
-					foreach($members as $member)
517
+					foreach ($members as $member)
518 518
 					{
519 519
 						// use only members which gave the user a read-grant
520 520
 						if (!in_array($member, $users) &&
521
-							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
521
+							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $member)))
522 522
 						{
523 523
 							$users[] = $member;
524 524
 						}
@@ -530,9 +530,9 @@  discard block
 block discarded – undo
530 530
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
531 531
 				if (is_array($memberships))
532 532
 				{
533
-					foreach($memberships as $group)
533
+					foreach ($memberships as $group)
534 534
 					{
535
-						if (!in_array($group,$users))
535
+						if (!in_array($group, $users))
536 536
 						{
537 537
 							$users[] = $group;
538 538
 						}
@@ -573,18 +573,18 @@  discard block
 block discarded – undo
573 573
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
574 574
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
575 575
 	 */
576
-	function &search($params,$sql_filter=null)
576
+	function &search($params, $sql_filter = null)
577 577
 	{
578 578
 		$params_in = $params;
579 579
 
580
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
580
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
581 581
 
582 582
 		// check if any resource wants to hook into
583
-		foreach($this->resources as $data)
583
+		foreach ($this->resources as $data)
584 584
 		{
585 585
 			if (isset($data['search_filter']))
586 586
 			{
587
-				$params = ExecMethod($data['search_filter'],$params);
587
+				$params = ExecMethod($data['search_filter'], $params);
588 588
 			}
589 589
 		}
590 590
 
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
 		if (!empty($params['query']))
603 603
 		{
604 604
 			$params['private_grants'] = array();
605
-			foreach($this->grants as $user => $rights)
605
+			foreach ($this->grants as $user => $rights)
606 606
 			{
607
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
607
+				if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user;
608 608
 			}
609 609
 		}
610 610
 
@@ -630,49 +630,49 @@  discard block
 block discarded – undo
630 630
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
631 631
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
632 632
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
633
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
633
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
634 634
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
635 635
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
636 636
 		$users_in = (array)$params_in['users'];
637
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
637
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
638 638
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
639 639
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
640 640
 
641 641
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
642 642
 		{
643 643
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
644
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
644
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
645 645
 		}
646 646
 		// date2ts(,true) converts to server time, db2data converts again to user-time
647
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
648
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
647
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
648
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
649 649
 
650 650
 		if (isset($params['cols']))
651 651
 		{
652 652
 			return $events;
653 653
 		}
654 654
 		$this->total = $this->so->total;
655
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
655
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
656 656
 
657 657
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
658
-		foreach($events as $id => $event)
658
+		foreach ($events as $id => $event)
659 659
 		{
660 660
 			if ($params['enum_groups'] && $this->enum_groups($event))
661 661
 			{
662 662
 				$events[$id] = $event;
663 663
 			}
664 664
 			$matches = null;
665
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
665
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
666 666
 			{
667
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
667
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
668 668
 			}
669 669
 			else
670 670
 			{
671
-				$is_private = !$this->check_perms(Acl::READ,$event);
671
+				$is_private = !$this->check_perms(Acl::READ, $event);
672 672
 			}
673 673
 			if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
674 674
 			{
675
-				$this->clear_private_infos($events[$id],$users);
675
+				$this->clear_private_infos($events[$id], $users);
676 676
 			}
677 677
 		}
678 678
 
@@ -680,18 +680,18 @@  discard block
 block discarded – undo
680 680
 		{
681 681
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
682 682
 			{
683
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
683
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
684 684
 			}
685 685
 			// create empty entries for each day in the reported time
686
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
686
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
687 687
 			{
688 688
 				$daysEvents[$this->date2string($ts)] = array();
689 689
 			}
690
-			foreach($events as $k => $event)
690
+			foreach ($events as $k => $event)
691 691
 			{
692
-				$e_start = max($this->date2ts($event['start']),$start);
692
+				$e_start = max($this->date2ts($event['start']), $start);
693 693
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
694
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
694
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
695 695
 
696 696
 				// add event to each day in the reported time
697 697
 				$ts = $e_start;
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
 				$ymd = null;
701 701
 				while ($ts <= $e_end)
702 702
 				{
703
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
704
-					$ts = strtotime("+1 day",$ts);
703
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
704
+					$ts = strtotime("+1 day", $ts);
705 705
 				}
706 706
 				if ($ymd != ($last = $this->date2string($e_end)))
707 707
 				{
708
-					$daysEvents[$last][] =& $events[$k];
708
+					$daysEvents[$last][] = & $events[$k];
709 709
 				}
710 710
 			}
711
-			$events =& $daysEvents;
711
+			$events = & $daysEvents;
712 712
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
713 713
 			{
714
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
714
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
715 715
 			}
716 716
 		}
717 717
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
718 718
 		{
719
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
719
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
720 720
 		}
721 721
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
722 722
 		return $events;
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 	 * @param string $part
730 730
 	 * @return array
731 731
 	 */
732
-	static function integration_get_data($app,$part=null)
732
+	static function integration_get_data($app, $part = null)
733 733
 	{
734
-		static $integration_data=null;
734
+		static $integration_data = null;
735 735
 
736 736
 		if (!isset($integration_data))
737 737
 		{
@@ -753,14 +753,14 @@  discard block
 block discarded – undo
753 753
 	 * @param int|string $id
754 754
 	 * @return string
755 755
 	 */
756
-	static function integration_get_private($app,$id,$event)
756
+	static function integration_get_private($app, $id, $event)
757 757
 	{
758
-		$app_data = self::integration_get_data($app,'is_private');
758
+		$app_data = self::integration_get_data($app, 'is_private');
759 759
 
760 760
 		// no method, fall back to link title
761 761
 		if (is_null($app_data))
762 762
 		{
763
-			$is_private = !Link::title($app,$id);
763
+			$is_private = !Link::title($app, $id);
764 764
 		}
765 765
 		// boolean value to make all events of $app public (false) or private (true)
766 766
 		elseif (is_bool($app_data))
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		}
770 770
 		else
771 771
 		{
772
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
772
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
773 773
 		}
774 774
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
775 775
 		return $is_private;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @param array &$event
784 784
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
785 785
 	 */
786
-	function clear_private_infos(&$event,$allowed_participants = array())
786
+	function clear_private_infos(&$event, $allowed_participants = array())
787 787
 	{
788 788
 		if ($event == false) return;
789 789
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -799,19 +799,19 @@  discard block
 block discarded – undo
799 799
 			'owner'		=> $event['owner'],
800 800
 			'uid'	=> $event['uid'],
801 801
 			'etag'	=> $event['etag'],
802
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
802
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
803 803
 			'public'=> 0,
804
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
804
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
805 805
 			'non_blocking' => $event['non_blocking'],
806 806
 			'caldav_name' => $event['caldav_name'],
807 807
 		// we need full recurrence information, as they are relevant free/busy information
808
-		)+($event['recur_type'] ? array(
808
+		) + ($event['recur_type'] ? array(
809 809
 			'recur_type'     => $event['recur_type'],
810 810
 			'recur_interval' => $event['recur_interval'],
811 811
 			'recur_data'     => $event['recur_data'],
812 812
 			'recur_enddate'  => $event['recur_enddate'],
813 813
 			'recur_exception'=> $event['recur_exception'],
814
-		):array(
814
+		) : array(
815 815
 			'reference'      => $event['reference'],
816 816
 			'recurrence'     => $event['recurrence'],
817 817
 		));
@@ -825,15 +825,15 @@  discard block
 block discarded – undo
825 825
 	 */
826 826
 	function check_move_horizont($_new_horizont)
827 827
 	{
828
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
828
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
829 829
 		{
830
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
830
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
831 831
 		}
832
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
832
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
833 833
 
834 834
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
835 835
 		{
836
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
836
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']);
837 837
 			return;
838 838
 		}
839 839
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -841,15 +841,15 @@  discard block
 block discarded – undo
841 841
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
842 842
 		}
843 843
 		if (empty($maxdays)) $maxdays = 1000; // old default
844
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
844
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
845 845
 		{
846
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
847
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
846
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays);
847
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays);
848 848
 			return;
849 849
 		}
850
-		if ($new_horizont < time()+31*DAY_s)
850
+		if ($new_horizont < time() + 31 * DAY_s)
851 851
 		{
852
-			$new_horizont = time()+31*DAY_s;
852
+			$new_horizont = time() + 31 * DAY_s;
853 853
 		}
854 854
 		$old_horizont = $this->config['horizont'];
855 855
 		$this->config['horizont'] = $new_horizont;
@@ -857,21 +857,21 @@  discard block
 block discarded – undo
857 857
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
858 858
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
859 859
 		{
860
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
861
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
860
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
861
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
862 862
 			{
863 863
 				if ($this->debug == 'check_move_horizont')
864 864
 				{
865
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
865
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
866 866
 				}
867 867
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
868
-				$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
868
+				$this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
869 869
 			}
870 870
 		}
871 871
 		// update the horizont
872
-		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
872
+		Api\Config::save_value('horizont', $this->config['horizont'], 'calendar');
873 873
 
874
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
874
+		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']);
875 875
 	}
876 876
 
877 877
 	/**
@@ -882,11 +882,11 @@  discard block
 block discarded – undo
882 882
 	 * @param array $event
883 883
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
884 884
 	 */
885
-	function set_recurrences($event,$start=0)
885
+	function set_recurrences($event, $start = 0)
886 886
 	{
887
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
887
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
888 888
 		{
889
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
889
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
890 890
 		}
891 891
 		// check if the caller gave us enough information and if not read it from the DB
892 892
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -905,26 +905,26 @@  discard block
 block discarded – undo
905 905
 		if (!$start) $start = $event['start'];
906 906
 
907 907
 		$events = array();
908
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
908
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
909 909
 
910 910
 		$exceptions = array();
911
-		foreach((array)$event['recur_exception'] as $exception)
911
+		foreach ((array)$event['recur_exception'] as $exception)
912 912
 		{
913
-			$exceptions[] = Api\DateTime::to($exception, true);	// true = date
913
+			$exceptions[] = Api\DateTime::to($exception, true); // true = date
914 914
 		}
915
-		foreach($events as $event)
915
+		foreach ($events as $event)
916 916
 		{
917 917
 			$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
918
-			$start = $this->date2ts($event['start'],true);
918
+			$start = $this->date2ts($event['start'], true);
919 919
 			if ($event['whole_day'])
920 920
 			{
921 921
 				$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
922 922
 				$time->setTime(23, 59, 59);
923
-				$end = $this->date2ts($time,true);
923
+				$end = $this->date2ts($time, true);
924 924
 			}
925 925
 			else
926 926
 			{
927
-				$end = $this->date2ts($event['end'],true);
927
+				$end = $this->date2ts($event['end'], true);
928 928
 			}
929 929
 			//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
930 930
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 	 * @param array &$events array of event-arrays (reference)
941 941
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
942 942
 	 */
943
-	function db2data(&$events,$date_format='ts')
943
+	function db2data(&$events, $date_format = 'ts')
944 944
 	{
945 945
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
946 946
 		foreach ($events as &$event)
@@ -953,65 +953,65 @@  discard block
 block discarded – undo
953 953
 			// database returns timestamps as string, convert them to integer
954 954
 			// to avoid misinterpretation by Api\DateTime as Ymd string
955 955
 			// (this will fail on 32bit systems for times > 2038!)
956
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls Api\DateTime
956
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
957 957
 			$event['end'] = (int)$event['end'];
958 958
 			$event['whole_day'] = self::isWholeDay($event);
959 959
 			if ($event['whole_day'] && $date_format != 'server')
960 960
 			{
961 961
 				// Adjust dates to user TZ
962
-				$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
962
+				$stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
963 963
 				$event['start'] = Api\DateTime::to($stime, $date_format);
964
-				$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
964
+				$time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
965 965
 				$time->setTime(23, 59, 59);
966 966
 				$event['end'] = Api\DateTime::to($time, $date_format);
967 967
 				if (!empty($event['recurrence']))
968 968
 				{
969
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
969
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
970 970
 					$event['recurrence'] = Api\DateTime::to($time, $date_format);
971 971
 				}
972 972
 				if (!empty($event['recur_enddate']))
973 973
 				{
974
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
974
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
975 975
 					$time->setTime(23, 59, 59);
976 976
 					$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
977 977
 				}
978
-				$timestamps = array('modified','created');
978
+				$timestamps = array('modified', 'created');
979 979
 			}
980 980
 			else
981 981
 			{
982
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date');
982
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date');
983 983
 			}
984 984
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
985 985
 			foreach ($timestamps as $ts)
986 986
 			{
987 987
 				if (!empty($event[$ts]))
988 988
 				{
989
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
989
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
990 990
 				}
991 991
 			}
992 992
 			// same with the recur exceptions
993 993
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
994 994
 			{
995
-				foreach($event['recur_exception'] as &$date)
995
+				foreach ($event['recur_exception'] as &$date)
996 996
 				{
997 997
 					if ($event['whole_day'] && $date_format != 'server')
998 998
 					{
999 999
 						// Adjust dates to user TZ
1000
-						$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1000
+						$time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1001 1001
 						$date = Api\DateTime::to($time, $date_format);
1002 1002
 					}
1003 1003
 					else
1004 1004
 					{
1005
-						$date = $this->date2usertime((int)$date,$date_format);
1005
+						$date = $this->date2usertime((int)$date, $date_format);
1006 1006
 					}
1007 1007
 				}
1008 1008
 			}
1009 1009
 			// same with the alarms
1010 1010
 			if (isset($event['alarm']) && is_array($event['alarm']))
1011 1011
 			{
1012
-				foreach($event['alarm'] as &$alarm)
1012
+				foreach ($event['alarm'] as &$alarm)
1013 1013
 				{
1014
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
1014
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
1015 1015
 				}
1016 1016
 			}
1017 1017
 		}
@@ -1024,11 +1024,11 @@  discard block
 block discarded – undo
1024 1024
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
1025 1025
 	 * @return mixed depending of $date_format
1026 1026
 	 */
1027
-	function date2usertime($ts,$date_format='ts')
1027
+	function date2usertime($ts, $date_format = 'ts')
1028 1028
 	{
1029 1029
 		if (empty($ts) || $date_format == 'server') return $ts;
1030 1030
 
1031
-		return Api\DateTime::server2user($ts,$date_format);
1031
+		return Api\DateTime::server2user($ts, $date_format);
1032 1032
 	}
1033 1033
 
1034 1034
 	/**
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	 * 	but call clear_private_infos() with the given users
1043 1043
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
1044 1044
 	 */
1045
-	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1045
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null)
1046 1046
 	{
1047 1047
 		if (!$ids) return false;
1048 1048
 
@@ -1051,21 +1051,21 @@  discard block
 block discarded – undo
1051 1051
 		$return = null;
1052 1052
 
1053 1053
 		$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
1054
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
1054
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
1055 1055
 		{
1056 1056
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
1057 1057
 				self::$cached_event_date_format != $date_format ||
1058 1058
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
1059 1059
 			{
1060
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0);
1060
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0);
1061 1061
 
1062 1062
 				if ($events)
1063 1063
 				{
1064
-					$this->db2data($events,$date_format);
1064
+					$this->db2data($events, $date_format);
1065 1065
 
1066 1066
 					if (is_array($ids))
1067 1067
 					{
1068
-						$return =& $events;
1068
+						$return = & $events;
1069 1069
 					}
1070 1070
 					else
1071 1071
 					{
@@ -1081,13 +1081,13 @@  discard block
 block discarded – undo
1081 1081
 				$return = self::$cached_event;
1082 1082
 			}
1083 1083
 		}
1084
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
1084
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return))
1085 1085
 		{
1086 1086
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
1087 1087
 		}
1088 1088
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
1089 1089
 		{
1090
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
1090
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
1091 1091
 		}
1092 1092
 		return $return;
1093 1093
 	}
@@ -1105,17 +1105,17 @@  discard block
 block discarded – undo
1105 1105
 	 * @param array $events where the repetions get inserted
1106 1106
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
1107 1107
 	 */
1108
-	function insert_all_recurrences($event,$_start,$end,&$events)
1108
+	function insert_all_recurrences($event, $_start, $end, &$events)
1109 1109
 	{
1110
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1110
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1111 1111
 		{
1112
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
1112
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
1113 1113
 		}
1114 1114
 		$end_in = $end;
1115 1115
 
1116 1116
 		$start = $this->date2ts($_start);
1117 1117
 		$event_start_ts = $this->date2ts($event['start']);
1118
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
1118
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
1119 1119
 
1120 1120
 		// if $end is before recur_enddate, use it instead
1121 1121
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1127,27 +1127,27 @@  discard block
 block discarded – undo
1127 1127
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1128 1128
 		unset($event['recur_exception']);
1129 1129
 		// loop over all recurrences and insert them, if they are after $start
1130
-		$rrule = calendar_rrule::event2rrule($event, true);	// true = we operate in usertime, like the rest of calendar_bo
1131
-		foreach($rrule as $time)
1130
+		$rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo
1131
+		foreach ($rrule as $time)
1132 1132
 		{
1133
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1134
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1133
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1134
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1135 1135
 			{
1136 1136
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1137
-				continue;	// to early or original event (returned by interator too)
1137
+				continue; // to early or original event (returned by interator too)
1138 1138
 			}
1139 1139
 
1140 1140
 			$ts_end = $ts + $event_length;
1141 1141
 			// adjust ts_end for whole day events in case it does not fit due to
1142 1142
 			// spans over summer/wintertime adjusted days
1143
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1143
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1144 1144
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1145 1145
 			{
1146 1146
 				$arr_end['hour'] = 23;
1147 1147
 				$arr_end['minute'] = 59;
1148 1148
 				$arr_end['second'] = 59;
1149 1149
 				$ts_end_guess = $this->date2ts($arr_end);
1150
-				if($ts_end_guess - $ts_end > DAY_s/2)
1150
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1151 1151
 				{
1152 1152
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1153 1153
 				}
@@ -1161,11 +1161,11 @@  discard block
 block discarded – undo
1161 1161
 			$event['end'] = $ts_end;
1162 1162
 			$events[] = $event;
1163 1163
 		}
1164
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1164
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1165 1165
 		{
1166 1166
 			$event['start'] = $event_start_ts;
1167 1167
 			$event['end'] = $event_start_ts + $event_length;
1168
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1168
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1169 1169
 		}
1170 1170
 	}
1171 1171
 
@@ -1176,18 +1176,18 @@  discard block
 block discarded – undo
1176 1176
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1177 1177
 	 * @param int|string $date_ymd of the date of the event
1178 1178
 	 */
1179
-	function add_adjusted_event(&$events,$event,$date_ymd)
1179
+	function add_adjusted_event(&$events, $event, $date_ymd)
1180 1180
 	{
1181 1181
 		$event_in = $event;
1182 1182
 		// calculate the new start- and end-time
1183 1183
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1184 1184
 		$event_start_arr = $this->date2array($event['start']);
1185 1185
 
1186
-		$date_arr = $this->date2array((string) $date_ymd);
1186
+		$date_arr = $this->date2array((string)$date_ymd);
1187 1187
 		$date_arr['hour'] = $event_start_arr['hour'];
1188 1188
 		$date_arr['minute'] = $event_start_arr['minute'];
1189 1189
 		$date_arr['second'] = $event_start_arr['second'];
1190
-		unset($date_arr['raw']);	// else date2ts would use it
1190
+		unset($date_arr['raw']); // else date2ts would use it
1191 1191
 		$event['start'] = $this->date2ts($date_arr);
1192 1192
 		$event['end'] = $event['start'] + $length_s;
1193 1193
 
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 
1196 1196
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1197 1197
 		{
1198
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1198
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1199 1199
 		}
1200 1200
 	}
1201 1201
 
@@ -1219,22 +1219,22 @@  discard block
 block discarded – undo
1219 1219
 			{
1220 1220
 				$info = array(
1221 1221
 					'res_id'    => $uid,
1222
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1223
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1224
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1222
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1223
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1224
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1225 1225
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1226 1226
 					'app'   => 'accounts',
1227 1227
 				);
1228 1228
 			}
1229 1229
 			else
1230 1230
 			{
1231
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1231
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1232 1232
 				if ($info)
1233 1233
 				{
1234 1234
 					$info['type'] = $uid[0];
1235 1235
 					if (!$info['email'] && $info['responsible'])
1236 1236
 					{
1237
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1237
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1238 1238
 					}
1239 1239
 					$info['app'] = $this->resources[$uid[0]]['app'];
1240 1240
 				}
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 		}
1244 1244
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1245 1245
 		{
1246
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1246
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1247 1247
 		}
1248 1248
 		return $res_info_cache[$uid];
1249 1249
 	}
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 	 * @param int $user =null for which user to check, default current user
1265 1265
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1266 1266
 	 */
1267
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1267
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1268 1268
 	{
1269 1269
 		if (!$user) $user = $this->user;
1270 1270
 		if ($user == $this->user)
@@ -1273,13 +1273,13 @@  discard block
 block discarded – undo
1273 1273
 		}
1274 1274
 		else
1275 1275
 		{
1276
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1276
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1277 1277
 		}
1278 1278
 
1279 1279
 		if ($other && !is_numeric($other))
1280 1280
 		{
1281 1281
 			$resource = $this->resource_info($other);
1282
-			return $needed & $resource['rights'];
1282
+			return $needed&$resource['rights'];
1283 1283
 		}
1284 1284
 		if (is_int($event) && $event == 0)
1285 1285
 		{
@@ -1289,15 +1289,15 @@  discard block
 block discarded – undo
1289 1289
 		{
1290 1290
 			if (!is_array($event))
1291 1291
 			{
1292
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1292
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1293 1293
 			}
1294 1294
 			if (!is_array($event))
1295 1295
 			{
1296 1296
 				if ($this->xmlrpc)
1297 1297
 				{
1298
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1298
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1299 1299
 				}
1300
-				return null;	// event not found
1300
+				return null; // event not found
1301 1301
 			}
1302 1302
 			$owner = $event['owner'];
1303 1303
 			$private = !$event['public'];
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 		$grant = $grants[$owner];
1306 1306
 
1307 1307
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1308
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1308
+		if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1309 1309
 
1310 1310
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1311 1311
 		{
@@ -1314,15 +1314,15 @@  discard block
 block discarded – undo
1314 1314
 			//
1315 1315
 			if ($event['participants'] && is_array($event['participants']))
1316 1316
 			{
1317
-				foreach(array_keys($event['participants']) as $uid)
1317
+				foreach (array_keys($event['participants']) as $uid)
1318 1318
 				{
1319
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1319
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1320 1320
 					{
1321 1321
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1322
-						$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
1322
+						$grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT;
1323 1323
 						break;
1324 1324
 					}
1325
-					elseif ($grants[$uid] & Acl::READ)
1325
+					elseif ($grants[$uid]&Acl::READ)
1326 1326
 					{
1327 1327
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1328 1328
 						$grant |= Acl::READ;
@@ -1341,12 +1341,12 @@  discard block
 block discarded – undo
1341 1341
 		}
1342 1342
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
1343 1343
 		{
1344
-			$access = False;	// a group can't be the owner of an event
1344
+			$access = False; // a group can't be the owner of an event
1345 1345
 		}
1346 1346
 		else
1347 1347
 		{
1348
-			$access = $user == $owner || $grant & $needed
1349
-				&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
1348
+			$access = $user == $owner || $grant&$needed
1349
+				&& ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT);
1350 1350
 		}
1351 1351
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1352 1352
 		if ($access && $needed == Acl::DELETE && $event['deleted'] &&
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
 		}
1358 1358
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1359 1359
 		{
1360
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1360
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1361 1361
 		}
1362 1362
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1363 1363
 		return $access;
@@ -1372,9 +1372,9 @@  discard block
 block discarded – undo
1372 1372
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1373 1373
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1374 1374
 	 */
1375
-	static function date2ts($date,$user2server=False)
1375
+	static function date2ts($date, $user2server = False)
1376 1376
 	{
1377
-		return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
1377
+		return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts');
1378 1378
 	}
1379 1379
 
1380 1380
 	/**
@@ -1384,9 +1384,9 @@  discard block
 block discarded – undo
1384 1384
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1385 1385
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1386 1386
 	 */
1387
-	static function date2array($date,$server2user=False)
1387
+	static function date2array($date, $server2user = False)
1388 1388
 	{
1389
-		return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
1389
+		return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array');
1390 1390
 	}
1391 1391
 
1392 1392
 	/**
@@ -1397,9 +1397,9 @@  discard block
 block discarded – undo
1397 1397
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1398 1398
 	 * @return string date formatted according to $format
1399 1399
 	 */
1400
-	static function date2string($date,$server2user=False,$format='Ymd')
1400
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1401 1401
 	{
1402
-		return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
1402
+		return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format);
1403 1403
 	}
1404 1404
 
1405 1405
 	/**
@@ -1409,9 +1409,9 @@  discard block
 block discarded – undo
1409 1409
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1410 1410
 	 * @return string the formated date (incl. time)
1411 1411
 	 */
1412
-	static function format_date($date,$format='')
1412
+	static function format_date($date, $format = '')
1413 1413
 	{
1414
-		return Api\DateTime::to($date,$format);
1414
+		return Api\DateTime::to($date, $format);
1415 1415
 	}
1416 1416
 
1417 1417
 	/**
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1434 1434
 	 *	arrays get serialized with print_r() !
1435 1435
 	 */
1436
-	static function debug_message($msg,$backtrace=True)
1436
+	static function debug_message($msg, $backtrace = True)
1437 1437
 	{
1438 1438
 		static $acl2string = array(
1439 1439
 			0               => 'ACL-UNKNOWN',
@@ -1444,22 +1444,22 @@  discard block
 block discarded – undo
1444 1444
 			Acl::PRIVAT => 'ACL_PRIVATE',
1445 1445
 			self::ACL_FREEBUSY => 'ACL_FREEBUSY',
1446 1446
 		);
1447
-		for($i = 2; $i < func_num_args(); ++$i)
1447
+		for ($i = 2; $i < func_num_args(); ++$i)
1448 1448
 		{
1449 1449
 			$param = func_get_arg($i);
1450 1450
 
1451 1451
 			if (is_null($param))
1452 1452
 			{
1453
-				$param='NULL';
1453
+				$param = 'NULL';
1454 1454
 			}
1455 1455
 			else
1456 1456
 			{
1457
-				switch(gettype($param))
1457
+				switch (gettype($param))
1458 1458
 				{
1459 1459
 					case 'string':
1460
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1460
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1461 1461
 						{
1462
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1462
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1463 1463
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1464 1464
 						}
1465 1465
 						else
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
 						$param = $param ? 'True' : 'False';
1483 1483
 						break;
1484 1484
 					case 'integer':
1485
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1485
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1486 1486
 						break;
1487 1487
 				}
1488 1488
 			}
1489
-			$msg = str_replace('%'.($i-1),$param,$msg);
1489
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1490 1490
 		}
1491 1491
 		error_log($msg);
1492 1492
 		if ($backtrace) error_log(function_backtrace(1));
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1502 1502
 	 * @return string with formated date
1503 1503
 	 */
1504
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1504
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1505 1505
 	{
1506 1506
 		$first = $this->date2array($_first);
1507 1507
 		if ($last)
@@ -1516,27 +1516,27 @@  discard block
 block discarded – undo
1516 1516
 
1517 1517
 		if ($display_day)
1518 1518
 		{
1519
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1519
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1520 1520
 		}
1521 1521
 		for ($i = 0; $i < 5; $i += 2)
1522 1522
 		{
1523
-			switch($datefmt[$i])
1523
+			switch ($datefmt[$i])
1524 1524
 			{
1525 1525
 				case 'd':
1526
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1526
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1527 1527
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1528 1528
 					{
1529 1529
 						if (!$month_before_day)
1530 1530
 						{
1531
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1531
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1532 1532
 						}
1533 1533
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1534 1534
 						{
1535
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1535
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1536 1536
 						}
1537 1537
 						if ($display_time)
1538 1538
 						{
1539
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1539
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1540 1540
 						}
1541 1541
 						if (!$last)
1542 1542
 						{
@@ -1546,43 +1546,43 @@  discard block
 block discarded – undo
1546 1546
 
1547 1547
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1548 1548
 						{
1549
-							$range .= $last['year'] . ', ';
1549
+							$range .= $last['year'].', ';
1550 1550
 						}
1551 1551
 
1552 1552
 						if ($month_before_day)
1553 1553
 						{
1554
-							$range .= lang(strftime('%B',$last['raw']));
1554
+							$range .= lang(strftime('%B', $last['raw']));
1555 1555
 						}
1556 1556
 					}
1557 1557
 					else
1558 1558
 					{
1559 1559
 						if ($display_time)
1560 1560
 						{
1561
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1561
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1562 1562
 						}
1563 1563
 						$range .= ' - ';
1564 1564
 					}
1565
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1565
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1566 1566
 					break;
1567 1567
 				case 'm':
1568 1568
 				case 'M':
1569
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1569
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1570 1570
 					break;
1571 1571
 				case 'Y':
1572 1572
 					if ($datefmt[0] != 'm')
1573 1573
 					{
1574
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1574
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1575 1575
 					}
1576 1576
 					break;
1577 1577
 			}
1578 1578
 		}
1579 1579
 		if ($display_time && $last)
1580 1580
 		{
1581
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1581
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1582 1582
 		}
1583 1583
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1584 1584
 		{
1585
-			$range .= ', ' . $last['year'];
1585
+			$range .= ', '.$last['year'];
1586 1586
 		}
1587 1587
 		return $range;
1588 1588
 	}
@@ -1594,25 +1594,25 @@  discard block
 block discarded – undo
1594 1594
 	 * @param int $end_m end time in minutes since 0h
1595 1595
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1596 1596
 	 */
1597
-	function timespan($start_m,$end_m,$both=false)
1597
+	function timespan($start_m, $end_m, $both = false)
1598 1598
 	{
1599 1599
 		$duration = $end_m - $start_m;
1600
-		if ($end_m == 24*60-1) ++$duration;
1601
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1600
+		if ($end_m == 24 * 60 - 1) ++$duration;
1601
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1602 1602
 
1603
-		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1603
+		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false);
1604 1604
 
1605 1605
 		if ($both)	// end-time too
1606 1606
 		{
1607
-			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1607
+			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false);
1608 1608
 			// dont double am/pm if they are the same in both times
1609
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1609
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1610 1610
 			{
1611
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1611
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1612 1612
 			}
1613 1613
 			$timespan .= ':';
1614 1614
 		}
1615
-		return $timespan . ' ' . $duration;
1615
+		return $timespan.' '.$duration;
1616 1616
 	}
1617 1617
 
1618 1618
 	/**
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 	* @param boolean $append_email =false append email (Name <email>)
1624 1624
 	* @return string with name
1625 1625
 	*/
1626
-	function participant_name($id,$use_type=false, $append_email=false)
1626
+	function participant_name($id, $use_type = false, $append_email = false)
1627 1627
 	{
1628 1628
 		static $id2lid = array();
1629 1629
 		static $id2email = array();
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
 			else
1645 1645
 			{
1646 1646
 				$id2lid[$id] = Api\Accounts::username($id);
1647
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1647
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1648 1648
 			}
1649 1649
 		}
1650 1650
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1658,37 +1658,37 @@  discard block
 block discarded – undo
1658 1658
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1659 1659
 	* @return array with id / names with status pairs
1660 1660
 	*/
1661
-	function participants($event,$long_status=false,$show_group_invitation=false)
1661
+	function participants($event, $long_status = false, $show_group_invitation = false)
1662 1662
 	{
1663 1663
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1664 1664
 		$names = array();
1665
-		foreach((array)$event['participants'] as $id => $status)
1665
+		foreach ((array)$event['participants'] as $id => $status)
1666 1666
 		{
1667 1667
 			if (!is_string($status)) continue;
1668 1668
 			$quantity = $role = null;
1669
-			calendar_so::split_status($status,$quantity,$role);
1669
+			calendar_so::split_status($status, $quantity, $role);
1670 1670
 
1671
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1671
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1672 1672
 
1673 1673
 			$lang_status = lang($this->verbose_status[$status]);
1674 1674
 			if (!$long_status)
1675 1675
 			{
1676
-				switch($status[0])
1676
+				switch ($status[0])
1677 1677
 				{
1678 1678
 					case 'A':	// accepted
1679
-						$status = Api\Html::image('calendar','accepted',$lang_status);
1679
+						$status = Api\Html::image('calendar', 'accepted', $lang_status);
1680 1680
 						break;
1681 1681
 					case 'R':	// rejected
1682
-						$status = Api\Html::image('calendar','rejected',$lang_status);
1682
+						$status = Api\Html::image('calendar', 'rejected', $lang_status);
1683 1683
 						break;
1684 1684
 					case 'T':	// tentative
1685
-						$status = Api\Html::image('calendar','tentative',$lang_status);
1685
+						$status = Api\Html::image('calendar', 'tentative', $lang_status);
1686 1686
 						break;
1687 1687
 					case 'U':	// no response = unknown
1688
-						$status = Api\Html::image('calendar','needs-action',$lang_status);
1688
+						$status = Api\Html::image('calendar', 'needs-action', $lang_status);
1689 1689
 						break;
1690 1690
 					case 'D':	// delegated
1691
-						$status = Api\Html::image('calendar','forward',$lang_status);
1691
+						$status = Api\Html::image('calendar', 'forward', $lang_status);
1692 1692
 						break;
1693 1693
 					case 'G':	// group invitation
1694 1694
 						// Todo: Image, seems not to be used
@@ -1710,13 +1710,13 @@  discard block
 block discarded – undo
1710 1710
 					$role = lang($this->roles[$role]);
1711 1711
 				}
1712 1712
 				// allow to use cats as roles (beside regular iCal ones)
1713
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1713
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1714 1714
 				{
1715 1715
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1716 1716
 				}
1717 1717
 				else
1718 1718
 				{
1719
-					$role = lang(str_replace('X-','',$role));
1719
+					$role = lang(str_replace('X-', '', $role));
1720 1720
 				}
1721 1721
 				$names[$id] .= ' '.$role;
1722 1722
 			}
@@ -1733,13 +1733,13 @@  discard block
 block discarded – undo
1733 1733
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1734 1734
 	* @return array with id / names
1735 1735
 	*/
1736
-	function categories($category,&$color)
1736
+	function categories($category, &$color)
1737 1737
 	{
1738 1738
 		static $id2cat = array();
1739 1739
 		$cats = array();
1740 1740
 		$color = 0;
1741 1741
 
1742
-		foreach(explode(',',$category) as $cat_id)
1742
+		foreach (explode(',', $category) as $cat_id)
1743 1743
 		{
1744 1744
 			if (!$cat_id) continue;
1745 1745
 
@@ -1754,7 +1754,7 @@  discard block
 block discarded – undo
1754 1754
 			{
1755 1755
 				$color = $cat['data']['color'];
1756 1756
 			}
1757
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1757
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1758 1758
 			{
1759 1759
 				$color = $parts[1];
1760 1760
 			}
@@ -1766,12 +1766,12 @@  discard block
 block discarded – undo
1766 1766
 	/**
1767 1767
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1768 1768
 	 */
1769
-	private static function _list_cals_add($id,&$users,&$groups)
1769
+	private static function _list_cals_add($id, &$users, &$groups)
1770 1770
 	{
1771 1771
 		$name = Api\Accounts::username($id);
1772 1772
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1773 1773
 		{
1774
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1774
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1775 1775
 		}
1776 1776
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1777 1777
 		{
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 		}
1784 1784
 		$arr[$id] = array(
1785 1785
 			'grantor' => $id,
1786
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1786
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1787 1787
 			'name'    => $name,
1788 1788
 			'sname'	  => $egw_name
1789 1789
 		);
@@ -1805,26 +1805,26 @@  discard block
 block discarded – undo
1805 1805
 	 * @param int $user account_id of user to generate list for
1806 1806
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1807 1807
 	 */
1808
-	public static function list_calendars($user, array $grants=null)
1808
+	public static function list_calendars($user, array $grants = null)
1809 1809
 	{
1810 1810
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1811 1811
 
1812 1812
 		$users = $groups = array();
1813
-		foreach(array_keys($grants) as $id)
1813
+		foreach (array_keys($grants) as $id)
1814 1814
 		{
1815
-			self::_list_cals_add($id,$users,$groups);
1815
+			self::_list_cals_add($id, $users, $groups);
1816 1816
 		}
1817 1817
 		if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true)))
1818 1818
 		{
1819
-			foreach($memberships as $group)
1819
+			foreach ($memberships as $group)
1820 1820
 			{
1821
-				self::_list_cals_add($group,$users,$groups);
1821
+				self::_list_cals_add($group, $users, $groups);
1822 1822
 
1823
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
1823
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar')))
1824 1824
 				{
1825
-					foreach($account_perms as $id)
1825
+					foreach ($account_perms as $id)
1826 1826
 					{
1827
-						self::_list_cals_add($id,$users,$groups);
1827
+						self::_list_cals_add($id, $users, $groups);
1828 1828
 					}
1829 1829
 				}
1830 1830
 			}
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
 		usort($users, array(__CLASS__, 'name_cmp'));
1833 1833
 		usort($groups, array(__CLASS__, 'name_cmp'));
1834 1834
 
1835
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1835
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1836 1836
 	}
1837 1837
 
1838 1838
 	/**
@@ -1872,9 +1872,9 @@  discard block
 block discarded – undo
1872 1872
 	 *	month: numerical month
1873 1873
 	 *	occurence: numerical year or 0 for every year
1874 1874
 	 */
1875
-	function read_holidays($year=0)
1875
+	function read_holidays($year = 0)
1876 1876
 	{
1877
-		if (!$year) $year = (int) date('Y',$this->now_su);
1877
+		if (!$year) $year = (int)date('Y', $this->now_su);
1878 1878
 
1879 1879
 		if (!$this->cached_holidays)	// try reading the holidays from the session
1880 1880
 		{
@@ -1884,8 +1884,7 @@  discard block
 block discarded – undo
1884 1884
 		{
1885 1885
 			$this->cached_holidays[$year] = calendar_holidays::read(
1886 1886
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
1887
-				$GLOBALS['egw_info']['server']['ical_holiday_url'] :
1888
-				$GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1887
+				$GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1889 1888
 
1890 1889
 			// search for birthdays
1891 1890
 			if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
@@ -1895,36 +1894,36 @@  discard block
 block discarded – undo
1895 1894
 					'n_family' => "!''",
1896 1895
 					'bday' => "!''",
1897 1896
 				);
1898
-				$bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1899
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter);
1897
+				$bdays = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1898
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter);
1900 1899
 				// search accounts too, if not stored in contacts repository
1901 1900
 				$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
1902 1901
 					!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'];
1903
-				if ($extra_accounts_search && ($bdays2 =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1904
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter+array('owner' => 0))))
1902
+				if ($extra_accounts_search && ($bdays2 = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1903
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter + array('owner' => 0))))
1905 1904
 				{
1906
-					$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
1905
+					$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
1907 1906
 				}
1908 1907
 				if ($bdays)
1909 1908
 				{
1910 1909
 					// sort by month and day only
1911
-					usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1912
-					foreach($bdays as $pers)
1910
+					usort($bdays, create_function('$a,$b', 'return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1911
+					foreach ($bdays as $pers)
1913 1912
 					{
1914
-						if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00')
1913
+						if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00')
1915 1914
 						{
1916 1915
 							//error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
1917 1916
 							continue;
1918 1917
 						}
1919
-						list($y,$m,$d) = explode('-',$pers['bday']);
1920
-						if ($y > $year) continue; 	// not yet born
1921
-						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1918
+						list($y, $m, $d) = explode('-', $pers['bday']);
1919
+						if ($y > $year) continue; // not yet born
1920
+						$this->cached_holidays[$year][sprintf('%04d%02d%02d', $year, $m, $d)][] = array(
1922 1921
 							'day'       => $d,
1923 1922
 							'month'     => $m,
1924 1923
 							'occurence' => 0,
1925 1924
 							'name'      => lang('Birthday').' '.($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']).' '.$pers['n_middle'].' '.
1926 1925
 								$pers['n_family'].($y && !$GLOBALS['egw_info']['server']['hide_birthdays'] ? ' ('.$y.')' : ''),
1927
-							'birthyear' => $y,	// this can be used to identify birthdays from holidays
1926
+							'birthyear' => $y, // this can be used to identify birthdays from holidays
1928 1927
 						);
1929 1928
 					}
1930 1929
 				}
@@ -1932,9 +1931,9 @@  discard block
 block discarded – undo
1932 1931
 			// store holidays and birthdays in the session
1933 1932
 			Api\Cache::setSession('calendar', 'holidays', $this->cached_holidays);
1934 1933
 		}
1935
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1934
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1936 1935
 		{
1937
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$this->cached_holidays[$year]);
1936
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $this->cached_holidays[$year]);
1938 1937
 		}
1939 1938
 		return $this->cached_holidays[$year];
1940 1939
 	}
@@ -1945,10 +1944,10 @@  discard block
 block discarded – undo
1945 1944
 	 * @param type $event
1946 1945
 	 * @return array array of selected calendar fields
1947 1946
 	 */
1948
-	public static function get_link_options ($event = array())
1947
+	public static function get_link_options($event = array())
1949 1948
 	{
1950
-		unset($event);	// not used, but required by function signature
1951
-		$options = array (
1949
+		unset($event); // not used, but required by function signature
1950
+		$options = array(
1952 1951
 			'end' => lang('End date'),
1953 1952
 			'id' => lang('ID'),
1954 1953
 			'owner' => lang('Event owner'),
@@ -1975,7 +1974,7 @@  discard block
 block discarded – undo
1975 1974
 			list($id, $recur) = explode('-', $event, 2);
1976 1975
 			$event = $this->read($id, $recur);
1977 1976
 		}
1978
-		else if (!is_array($event) && (int) $event > 0)
1977
+		else if (!is_array($event) && (int)$event > 0)
1979 1978
 		{
1980 1979
 			$event = $this->read($event);
1981 1980
 		}
@@ -1983,7 +1982,7 @@  discard block
 block discarded – undo
1983 1982
 		{
1984 1983
 			return $event;
1985 1984
 		}
1986
-		$type = explode(',',$this->cal_prefs['link_title']);
1985
+		$type = explode(',', $this->cal_prefs['link_title']);
1987 1986
 		if (is_array($type))
1988 1987
 		{
1989 1988
 			foreach ($type as &$val)
@@ -2009,10 +2008,10 @@  discard block
 block discarded – undo
2009 2008
 						$extra_fields [] = $event[$val];
2010 2009
 				}
2011 2010
 			}
2012
-			$str_fields = implode(', ',$extra_fields);
2013
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2011
+			$str_fields = implode(', ', $extra_fields);
2012
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
2014 2013
 		}
2015
-		return $this->format_date($event['start']) . ': ' . $event['title'];
2014
+		return $this->format_date($event['start']).': '.$event['title'];
2016 2015
 	}
2017 2016
 
2018 2017
 	/**
@@ -2031,10 +2030,10 @@  discard block
 block discarded – undo
2031 2030
 			'offset' =>	$options['start'],
2032 2031
 			'order' => 'cal_start DESC',
2033 2032
 		);
2034
-		if($options['num_rows']) {
2033
+		if ($options['num_rows']) {
2035 2034
 			$query['num_rows'] = $options['num_rows'];
2036 2035
 		}
2037
-		foreach((array) $this->search($query) as $event)
2036
+		foreach ((array)$this->search($query) as $event)
2038 2037
 		{
2039 2038
 			$result[$event['id']] = $this->link_title($event);
2040 2039
 		}
@@ -2051,11 +2050,11 @@  discard block
 block discarded – undo
2051 2050
 	 * @param int $user =null for which user to check, default current user
2052 2051
 	 * @return boolean true if access is granted or false otherwise
2053 2052
 	 */
2054
-	function file_access($id,$check,$rel_path,$user=null)
2053
+	function file_access($id, $check, $rel_path, $user = null)
2055 2054
 	{
2056
-		unset($rel_path);	// not used, but required by function signature
2055
+		unset($rel_path); // not used, but required by function signature
2057 2056
 
2058
-		return $this->check_perms($check,$id,0,'ts',null,$user);
2057
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
2059 2058
 	}
2060 2059
 
2061 2060
 	/**
@@ -2071,36 +2070,36 @@  discard block
 block discarded – undo
2071 2070
 		}
2072 2071
 		Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
2073 2072
 
2074
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
2075
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
2073
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
2074
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
2076 2075
 
2077
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
2076
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
2078 2077
 		$values = array(
2079
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
2080
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
2081
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
2082
-			'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'),
2083
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
2084
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
2078
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
2079
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
2080
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
2081
+			'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'),
2082
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
2083
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
2085 2084
 			'interval'        => 30,
2086 2085
 		);
2087
-		foreach($values as $var => $default)
2086
+		foreach ($values as $var => $default)
2088 2087
 		{
2089
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
2088
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
2090 2089
 
2091 2090
 			// only set, if neither default nor forced pref exists
2092 2091
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2093 2092
 			{
2094
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2095
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2093
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
2094
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
2096 2095
 				$this->cal_prefs[$var] = $default;
2097 2096
 				$need_save = True;
2098 2097
 			}
2099 2098
 		}
2100 2099
 		if ($need_save)
2101 2100
 		{
2102
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
2103
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
2101
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
2102
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
2104 2103
 		}
2105 2104
 	}
2106 2105
 
@@ -2110,7 +2109,7 @@  discard block
 block discarded – undo
2110 2109
 	 * @param int|string $user account_id or account_lid
2111 2110
 	 * @param string $pw =null password
2112 2111
 	 */
2113
-	static function freebusy_url($user='',$pw=null)
2112
+	static function freebusy_url($user = '', $pw = null)
2114 2113
 	{
2115 2114
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2116 2115
 
@@ -2123,8 +2122,8 @@  discard block
 block discarded – undo
2123 2122
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
2124 2123
 		{
2125 2124
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2126
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2127
-			$credentials = '&cred=' . base64_encode($credentials);
2125
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2126
+			$credentials = '&cred='.base64_encode($credentials);
2128 2127
 		}
2129 2128
 		return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
2130 2129
 			($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
@@ -2156,11 +2155,11 @@  discard block
 block discarded – undo
2156 2155
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2157 2156
 	 * @return string|boolean string with etag or false
2158 2157
 	 */
2159
-	function get_etag($entry, &$schedule_tag=null)
2158
+	function get_etag($entry, &$schedule_tag = null)
2160 2159
 	{
2161 2160
 		if (!is_array($entry))
2162 2161
 		{
2163
-			list($id,$recur_date) = explode(':',$entry);
2162
+			list($id, $recur_date) = explode(':', $entry);
2164 2163
 			$entry = $this->read($id, $recur_date, true, 'server');
2165 2164
 		}
2166 2165
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2178,15 +2177,15 @@  discard block
 block discarded – undo
2178 2177
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2179 2178
 	 * @return integer
2180 2179
 	 */
2181
-	public function get_ctag($user, $filter='owner', $master_only=false)
2180
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2182 2181
 	{
2183 2182
 		if ($this->debug > 1) $startime = microtime(true);
2184 2183
 
2185 2184
 		// resolve users to add memberships for users and members for groups
2186 2185
 		$users = $this->resolve_users($user);
2187
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2186
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2188 2187
 
2189
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2188
+		if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs");
2190 2189
 		return $ctag;
2191 2190
 	}
2192 2191
 
@@ -2206,7 +2205,7 @@  discard block
 block discarded – undo
2206 2205
 
2207 2206
 		$content = array(
2208 2207
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
2209
-			'info_priority'  => $calendar['priority'] ,
2208
+			'info_priority'  => $calendar['priority'],
2210 2209
 			'info_public'    => $calendar['public'] != 'private',
2211 2210
 			'info_subject'   => $calendar['title'],
2212 2211
 			'info_des'       => $calendar['description'],
@@ -2221,7 +2220,7 @@  discard block
 block discarded – undo
2221 2220
 		$content['link_app'][] = $calendar['info_link']['app'];
2222 2221
 		$content['link_id'][]  = $calendar['info_link']['id'];
2223 2222
 		// Copy claendar's links
2224
-		foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2223
+		foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2225 2224
 		{
2226 2225
 			if ($link['app'] != Link::VFS_APPNAME)
2227 2226
 			{
@@ -2234,7 +2233,7 @@  discard block
 block discarded – undo
2234 2233
 			}
2235 2234
 		}
2236 2235
 		// Copy same custom fields
2237
-		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2236
+		foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2238 2237
 		{
2239 2238
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2240 2239
 		}
@@ -2252,20 +2251,20 @@  discard block
 block discarded – undo
2252 2251
 	function timesheet_set($data)
2253 2252
 	{
2254 2253
 		$set = array();
2255
-		list($id,$recurrence) = explode(':',$data['id']);
2256
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2254
+		list($id, $recurrence) = explode(':', $data['id']);
2255
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2257 2256
 		{
2258 2257
 			$set['ts_start'] = $event['start'];
2259 2258
 			$set['ts_title'] = $this->link_title($event);
2260
-			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2259
+			$set['start_time'] = Api\DateTime::to($event['start'], 'H:i');
2261 2260
 			$set['ts_description'] = $event['description'];
2262
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2261
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2263 2262
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2264 2263
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2265
-			$set['end_time'] = null;	// unset end-time
2264
+			$set['end_time'] = null; // unset end-time
2266 2265
 			$set['cat_id'] = (int)$event['category'];
2267 2266
 
2268
-			foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2267
+			foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2269 2268
 			{
2270 2269
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
2271 2270
 				{
Please login to merge, or discard this patch.