@@ -87,6 +87,7 @@ |
||
87 | 87 | * constructor |
88 | 88 | * |
89 | 89 | * @param string path of stream to read |
90 | + * @param string $path |
|
90 | 91 | * @access public |
91 | 92 | */ |
92 | 93 | function __construct($path) |
@@ -43,209 +43,209 @@ |
||
43 | 43 | */ |
44 | 44 | class _parse_lockinfo |
45 | 45 | { |
46 | - /** |
|
47 | - * success state flag |
|
48 | - * |
|
49 | - * @var bool |
|
50 | - * @access public |
|
51 | - */ |
|
52 | - var $success = false; |
|
53 | - |
|
54 | - /** |
|
55 | - * lock type, currently only "write" |
|
56 | - * |
|
57 | - * @var string |
|
58 | - * @access public |
|
59 | - */ |
|
60 | - var $locktype = ""; |
|
61 | - |
|
62 | - /** |
|
63 | - * lock scope, "shared" or "exclusive" |
|
64 | - * |
|
65 | - * @var string |
|
66 | - * @access public |
|
67 | - */ |
|
68 | - var $lockscope = ""; |
|
69 | - |
|
70 | - /** |
|
71 | - * lock owner information |
|
72 | - * |
|
73 | - * @var string |
|
74 | - * @access public |
|
75 | - */ |
|
76 | - var $owner = ""; |
|
77 | - |
|
78 | - /** |
|
79 | - * flag that is set during lock owner read |
|
80 | - * |
|
81 | - * @var bool |
|
82 | - * @access private |
|
83 | - */ |
|
84 | - var $collect_owner = false; |
|
85 | - |
|
86 | - /** |
|
87 | - * constructor |
|
88 | - * |
|
89 | - * @param string path of stream to read |
|
90 | - * @access public |
|
91 | - */ |
|
92 | - function __construct($path) |
|
93 | - { |
|
94 | - // we assume success unless problems occur |
|
95 | - $this->success = true; |
|
96 | - |
|
97 | - // remember if any input was parsed |
|
98 | - $had_input = false; |
|
99 | - |
|
100 | - // open stream |
|
101 | - $f_in = fopen($path, "r"); |
|
102 | - if (!$f_in) { |
|
103 | - $this->success = false; |
|
104 | - return; |
|
105 | - } |
|
106 | - |
|
107 | - // create namespace aware parser |
|
108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | - |
|
110 | - // set tag and data handlers |
|
111 | - xml_set_element_handler($xml_parser, |
|
112 | - array(&$this, "_startElement"), |
|
113 | - array(&$this, "_endElement")); |
|
114 | - xml_set_character_data_handler($xml_parser, |
|
115 | - array(&$this, "_data")); |
|
116 | - |
|
117 | - // we want a case sensitive parser |
|
118 | - xml_parser_set_option($xml_parser, |
|
119 | - XML_OPTION_CASE_FOLDING, false); |
|
120 | - |
|
121 | - // parse input |
|
122 | - while ($this->success && !feof($f_in)) { |
|
123 | - $line = fgets($f_in); |
|
124 | - if (is_string($line)) { |
|
125 | - $had_input = true; |
|
126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - // finish parsing |
|
131 | - if ($had_input) { |
|
132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
133 | - } |
|
134 | - |
|
135 | - // check if required tags where found |
|
136 | - $this->success &= !empty($this->locktype); |
|
137 | - $this->success &= !empty($this->lockscope); |
|
138 | - |
|
139 | - // free parser resource |
|
140 | - xml_parser_free($xml_parser); |
|
141 | - |
|
142 | - // close input stream |
|
143 | - fclose($f_in); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * tag start handler |
|
149 | - * |
|
150 | - * @param resource parser |
|
151 | - * @param string tag name |
|
152 | - * @param array tag attributes |
|
153 | - * @return void |
|
154 | - * @access private |
|
155 | - */ |
|
156 | - function _startElement($parser, $name, $attrs) |
|
157 | - { |
|
158 | - // namespace handling |
|
159 | - if (strstr($name, " ")) { |
|
160 | - list($ns, $tag) = explode(" ", $name); |
|
161 | - } else { |
|
162 | - $ns = ""; |
|
163 | - $tag = $name; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - if ($this->collect_owner) { |
|
168 | - // everything within the <owner> tag needs to be collected |
|
169 | - $ns_short = ""; |
|
170 | - $ns_attr = ""; |
|
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
173 | - $ns_short = "D:"; |
|
174 | - } else { |
|
175 | - $ns_attr = " xmlns='$ns'"; |
|
176 | - } |
|
177 | - } |
|
178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | - } else if ($ns == "DAV:") { |
|
180 | - // parse only the essential tags |
|
181 | - switch ($tag) { |
|
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * data handler |
|
198 | - * |
|
199 | - * @param resource parser |
|
200 | - * @param string data |
|
201 | - * @return void |
|
202 | - * @access private |
|
203 | - */ |
|
204 | - function _data($parser, $data) |
|
205 | - { |
|
206 | - // only the <owner> tag has data content |
|
207 | - if ($this->collect_owner) { |
|
208 | - $this->owner .= $data; |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * tag end handler |
|
214 | - * |
|
215 | - * @param resource parser |
|
216 | - * @param string tag name |
|
217 | - * @return void |
|
218 | - * @access private |
|
219 | - */ |
|
220 | - function _endElement($parser, $name) |
|
221 | - { |
|
222 | - // namespace handling |
|
223 | - if (strstr($name, " ")) { |
|
224 | - list($ns, $tag) = explode(" ", $name); |
|
225 | - } else { |
|
226 | - $ns = ""; |
|
227 | - $tag = $name; |
|
228 | - } |
|
229 | - |
|
230 | - // <owner> finished? |
|
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | - $this->collect_owner = false; |
|
233 | - } |
|
234 | - |
|
235 | - // within <owner> we have to collect everything |
|
236 | - if ($this->collect_owner) { |
|
237 | - $ns_short = ""; |
|
238 | - $ns_attr = ""; |
|
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
241 | - $ns_short = "D:"; |
|
242 | - } else { |
|
243 | - $ns_attr = " xmlns='$ns'"; |
|
244 | - } |
|
245 | - } |
|
246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | - } |
|
248 | - } |
|
46 | + /** |
|
47 | + * success state flag |
|
48 | + * |
|
49 | + * @var bool |
|
50 | + * @access public |
|
51 | + */ |
|
52 | + var $success = false; |
|
53 | + |
|
54 | + /** |
|
55 | + * lock type, currently only "write" |
|
56 | + * |
|
57 | + * @var string |
|
58 | + * @access public |
|
59 | + */ |
|
60 | + var $locktype = ""; |
|
61 | + |
|
62 | + /** |
|
63 | + * lock scope, "shared" or "exclusive" |
|
64 | + * |
|
65 | + * @var string |
|
66 | + * @access public |
|
67 | + */ |
|
68 | + var $lockscope = ""; |
|
69 | + |
|
70 | + /** |
|
71 | + * lock owner information |
|
72 | + * |
|
73 | + * @var string |
|
74 | + * @access public |
|
75 | + */ |
|
76 | + var $owner = ""; |
|
77 | + |
|
78 | + /** |
|
79 | + * flag that is set during lock owner read |
|
80 | + * |
|
81 | + * @var bool |
|
82 | + * @access private |
|
83 | + */ |
|
84 | + var $collect_owner = false; |
|
85 | + |
|
86 | + /** |
|
87 | + * constructor |
|
88 | + * |
|
89 | + * @param string path of stream to read |
|
90 | + * @access public |
|
91 | + */ |
|
92 | + function __construct($path) |
|
93 | + { |
|
94 | + // we assume success unless problems occur |
|
95 | + $this->success = true; |
|
96 | + |
|
97 | + // remember if any input was parsed |
|
98 | + $had_input = false; |
|
99 | + |
|
100 | + // open stream |
|
101 | + $f_in = fopen($path, "r"); |
|
102 | + if (!$f_in) { |
|
103 | + $this->success = false; |
|
104 | + return; |
|
105 | + } |
|
106 | + |
|
107 | + // create namespace aware parser |
|
108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | + |
|
110 | + // set tag and data handlers |
|
111 | + xml_set_element_handler($xml_parser, |
|
112 | + array(&$this, "_startElement"), |
|
113 | + array(&$this, "_endElement")); |
|
114 | + xml_set_character_data_handler($xml_parser, |
|
115 | + array(&$this, "_data")); |
|
116 | + |
|
117 | + // we want a case sensitive parser |
|
118 | + xml_parser_set_option($xml_parser, |
|
119 | + XML_OPTION_CASE_FOLDING, false); |
|
120 | + |
|
121 | + // parse input |
|
122 | + while ($this->success && !feof($f_in)) { |
|
123 | + $line = fgets($f_in); |
|
124 | + if (is_string($line)) { |
|
125 | + $had_input = true; |
|
126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + // finish parsing |
|
131 | + if ($had_input) { |
|
132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
133 | + } |
|
134 | + |
|
135 | + // check if required tags where found |
|
136 | + $this->success &= !empty($this->locktype); |
|
137 | + $this->success &= !empty($this->lockscope); |
|
138 | + |
|
139 | + // free parser resource |
|
140 | + xml_parser_free($xml_parser); |
|
141 | + |
|
142 | + // close input stream |
|
143 | + fclose($f_in); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * tag start handler |
|
149 | + * |
|
150 | + * @param resource parser |
|
151 | + * @param string tag name |
|
152 | + * @param array tag attributes |
|
153 | + * @return void |
|
154 | + * @access private |
|
155 | + */ |
|
156 | + function _startElement($parser, $name, $attrs) |
|
157 | + { |
|
158 | + // namespace handling |
|
159 | + if (strstr($name, " ")) { |
|
160 | + list($ns, $tag) = explode(" ", $name); |
|
161 | + } else { |
|
162 | + $ns = ""; |
|
163 | + $tag = $name; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + if ($this->collect_owner) { |
|
168 | + // everything within the <owner> tag needs to be collected |
|
169 | + $ns_short = ""; |
|
170 | + $ns_attr = ""; |
|
171 | + if ($ns) { |
|
172 | + if ($ns == "DAV:") { |
|
173 | + $ns_short = "D:"; |
|
174 | + } else { |
|
175 | + $ns_attr = " xmlns='$ns'"; |
|
176 | + } |
|
177 | + } |
|
178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | + } else if ($ns == "DAV:") { |
|
180 | + // parse only the essential tags |
|
181 | + switch ($tag) { |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * data handler |
|
198 | + * |
|
199 | + * @param resource parser |
|
200 | + * @param string data |
|
201 | + * @return void |
|
202 | + * @access private |
|
203 | + */ |
|
204 | + function _data($parser, $data) |
|
205 | + { |
|
206 | + // only the <owner> tag has data content |
|
207 | + if ($this->collect_owner) { |
|
208 | + $this->owner .= $data; |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * tag end handler |
|
214 | + * |
|
215 | + * @param resource parser |
|
216 | + * @param string tag name |
|
217 | + * @return void |
|
218 | + * @access private |
|
219 | + */ |
|
220 | + function _endElement($parser, $name) |
|
221 | + { |
|
222 | + // namespace handling |
|
223 | + if (strstr($name, " ")) { |
|
224 | + list($ns, $tag) = explode(" ", $name); |
|
225 | + } else { |
|
226 | + $ns = ""; |
|
227 | + $tag = $name; |
|
228 | + } |
|
229 | + |
|
230 | + // <owner> finished? |
|
231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | + $this->collect_owner = false; |
|
233 | + } |
|
234 | + |
|
235 | + // within <owner> we have to collect everything |
|
236 | + if ($this->collect_owner) { |
|
237 | + $ns_short = ""; |
|
238 | + $ns_attr = ""; |
|
239 | + if ($ns) { |
|
240 | + if ($ns == "DAV:") { |
|
241 | + $ns_short = "D:"; |
|
242 | + } else { |
|
243 | + $ns_attr = " xmlns='$ns'"; |
|
244 | + } |
|
245 | + } |
|
246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | + } |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | ?> |
@@ -179,16 +179,16 @@ |
||
179 | 179 | } else if ($ns == "DAV:") { |
180 | 180 | // parse only the essential tags |
181 | 181 | switch ($tag) { |
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -99,7 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | // open stream |
101 | 101 | $f_in = fopen($path, "r"); |
102 | - if (!$f_in) { |
|
102 | + if (!$f_in) |
|
103 | + { |
|
103 | 104 | $this->success = false; |
104 | 105 | return; |
105 | 106 | } |
@@ -119,16 +120,19 @@ discard block |
||
119 | 120 | XML_OPTION_CASE_FOLDING, false); |
120 | 121 | |
121 | 122 | // parse input |
122 | - while ($this->success && !feof($f_in)) { |
|
123 | + while ($this->success && !feof($f_in)) |
|
124 | + { |
|
123 | 125 | $line = fgets($f_in); |
124 | - if (is_string($line)) { |
|
126 | + if (is_string($line)) |
|
127 | + { |
|
125 | 128 | $had_input = true; |
126 | 129 | $this->success &= xml_parse($xml_parser, $line, false); |
127 | 130 | } |
128 | 131 | } |
129 | 132 | |
130 | 133 | // finish parsing |
131 | - if ($had_input) { |
|
134 | + if ($had_input) |
|
135 | + { |
|
132 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
133 | 137 | } |
134 | 138 | |
@@ -156,29 +160,40 @@ discard block |
||
156 | 160 | function _startElement($parser, $name, $attrs) |
157 | 161 | { |
158 | 162 | // namespace handling |
159 | - if (strstr($name, " ")) { |
|
163 | + if (strstr($name, " ")) |
|
164 | + { |
|
160 | 165 | list($ns, $tag) = explode(" ", $name); |
161 | - } else { |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
162 | 169 | $ns = ""; |
163 | 170 | $tag = $name; |
164 | 171 | } |
165 | 172 | |
166 | 173 | |
167 | - if ($this->collect_owner) { |
|
174 | + if ($this->collect_owner) |
|
175 | + { |
|
168 | 176 | // everything within the <owner> tag needs to be collected |
169 | 177 | $ns_short = ""; |
170 | 178 | $ns_attr = ""; |
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
179 | + if ($ns) |
|
180 | + { |
|
181 | + if ($ns == "DAV:") |
|
182 | + { |
|
173 | 183 | $ns_short = "D:"; |
174 | - } else { |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
175 | 187 | $ns_attr = " xmlns='$ns'"; |
176 | 188 | } |
177 | 189 | } |
178 | 190 | $this->owner .= "<$ns_short$tag$ns_attr>"; |
179 | - } else if ($ns == "DAV:") { |
|
191 | + } |
|
192 | + else if ($ns == "DAV:") |
|
193 | + { |
|
180 | 194 | // parse only the essential tags |
181 | - switch ($tag) { |
|
195 | + switch ($tag) |
|
196 | + { |
|
182 | 197 | case "write": |
183 | 198 | $this->locktype = $tag; |
184 | 199 | break; |
@@ -204,7 +219,8 @@ discard block |
||
204 | 219 | function _data($parser, $data) |
205 | 220 | { |
206 | 221 | // only the <owner> tag has data content |
207 | - if ($this->collect_owner) { |
|
222 | + if ($this->collect_owner) |
|
223 | + { |
|
208 | 224 | $this->owner .= $data; |
209 | 225 | } |
210 | 226 | } |
@@ -220,26 +236,35 @@ discard block |
||
220 | 236 | function _endElement($parser, $name) |
221 | 237 | { |
222 | 238 | // namespace handling |
223 | - if (strstr($name, " ")) { |
|
239 | + if (strstr($name, " ")) |
|
240 | + { |
|
224 | 241 | list($ns, $tag) = explode(" ", $name); |
225 | - } else { |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
226 | 245 | $ns = ""; |
227 | 246 | $tag = $name; |
228 | 247 | } |
229 | 248 | |
230 | 249 | // <owner> finished? |
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
250 | + if (($ns == "DAV:") && ($tag == "owner")) |
|
251 | + { |
|
232 | 252 | $this->collect_owner = false; |
233 | 253 | } |
234 | 254 | |
235 | 255 | // within <owner> we have to collect everything |
236 | - if ($this->collect_owner) { |
|
256 | + if ($this->collect_owner) |
|
257 | + { |
|
237 | 258 | $ns_short = ""; |
238 | 259 | $ns_attr = ""; |
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
260 | + if ($ns) |
|
261 | + { |
|
262 | + if ($ns == "DAV:") |
|
263 | + { |
|
241 | 264 | $ns_short = "D:"; |
242 | - } else { |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
243 | 268 | $ns_attr = " xmlns='$ns'"; |
244 | 269 | } |
245 | 270 | } |
@@ -95,6 +95,7 @@ |
||
95 | 95 | * |
96 | 96 | * @param string path of input stream |
97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
98 | + * @param string $path |
|
98 | 99 | * @access public |
99 | 100 | */ |
100 | 101 | function __construct($path, $store_request=false) |
@@ -43,198 +43,198 @@ |
||
43 | 43 | */ |
44 | 44 | class _parse_proppatch |
45 | 45 | { |
46 | - /** |
|
47 | - * |
|
48 | - * |
|
49 | - * @var |
|
50 | - * @access |
|
51 | - */ |
|
52 | - var $success; |
|
53 | - |
|
54 | - /** |
|
55 | - * |
|
56 | - * |
|
57 | - * @var |
|
58 | - * @access |
|
59 | - */ |
|
60 | - var $props; |
|
61 | - |
|
62 | - /** |
|
63 | - * |
|
64 | - * |
|
65 | - * @var |
|
66 | - * @access |
|
67 | - */ |
|
68 | - var $depth; |
|
69 | - |
|
70 | - /** |
|
71 | - * |
|
72 | - * |
|
73 | - * @var |
|
74 | - * @access |
|
75 | - */ |
|
76 | - var $mode; |
|
77 | - |
|
78 | - /** |
|
79 | - * |
|
80 | - * |
|
81 | - * @var |
|
82 | - * @access |
|
83 | - */ |
|
84 | - var $current; |
|
85 | - |
|
86 | - /** |
|
87 | - * On return whole request, if $store_request == true was specified in constructor |
|
88 | - * |
|
89 | - * @var string |
|
90 | - */ |
|
91 | - var $request; |
|
92 | - |
|
93 | - /** |
|
94 | - * constructor |
|
95 | - * |
|
96 | - * @param string path of input stream |
|
97 | - * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
98 | - * @access public |
|
99 | - */ |
|
100 | - function __construct($path, $store_request=false) |
|
101 | - { |
|
102 | - $this->success = true; |
|
103 | - |
|
104 | - $this->depth = 0; |
|
105 | - $this->props = array(); |
|
106 | - $had_input = false; |
|
107 | - |
|
108 | - $f_in = fopen($path, "r"); |
|
109 | - if (!$f_in) { |
|
110 | - $this->success = false; |
|
111 | - return; |
|
112 | - } |
|
113 | - |
|
114 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
115 | - |
|
116 | - xml_set_element_handler($xml_parser, |
|
117 | - array(&$this, "_startElement"), |
|
118 | - array(&$this, "_endElement")); |
|
119 | - |
|
120 | - xml_set_character_data_handler($xml_parser, |
|
121 | - array(&$this, "_data")); |
|
122 | - |
|
123 | - xml_parser_set_option($xml_parser, |
|
124 | - XML_OPTION_CASE_FOLDING, false); |
|
125 | - |
|
126 | - while($this->success && !feof($f_in)) { |
|
127 | - $line = fgets($f_in); |
|
128 | - if ($store_request) $this->request .= $line; |
|
129 | - if (is_string($line)) { |
|
130 | - $had_input = true; |
|
131 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - if($had_input) { |
|
136 | - $this->success &= xml_parse($xml_parser, "", true); |
|
137 | - } |
|
138 | - |
|
139 | - xml_parser_free($xml_parser); |
|
140 | - |
|
141 | - fclose($f_in); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * tag start handler |
|
146 | - * |
|
147 | - * @param resource parser |
|
148 | - * @param string tag name |
|
149 | - * @param array tag attributes |
|
150 | - * @return void |
|
151 | - * @access private |
|
152 | - */ |
|
153 | - function _startElement($parser, $name, $attrs) |
|
154 | - { |
|
155 | - if (strstr($name, " ")) { |
|
156 | - list($ns, $tag) = explode(" ", $name); |
|
157 | - if ($ns == "") |
|
158 | - $this->success = false; |
|
159 | - } else { |
|
160 | - $ns = ""; |
|
161 | - $tag = $name; |
|
162 | - } |
|
163 | - |
|
164 | - if ($this->depth == 1) { |
|
165 | - $this->mode = $tag; |
|
166 | - } |
|
167 | - |
|
168 | - if ($this->depth == 3) { |
|
169 | - $prop = array("name" => $tag); |
|
170 | - $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
171 | - if ($this->mode == "set") { |
|
172 | - $this->current["val"] = ""; // default set val |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - if ($this->depth >= 4) { |
|
177 | - $this->current["val"] .= "<$tag"; |
|
178 | - if (isset($attr)) { |
|
179 | - foreach ($attr as $key => $val) { |
|
180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
181 | - } |
|
182 | - } |
|
183 | - $this->current["val"] .= ">"; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - $this->depth++; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * tag end handler |
|
193 | - * |
|
194 | - * @param resource parser |
|
195 | - * @param string tag name |
|
196 | - * @return void |
|
197 | - * @access private |
|
198 | - */ |
|
199 | - function _endElement($parser, $name) |
|
200 | - { |
|
201 | - if (strstr($name, " ")) { |
|
202 | - list($ns, $tag) = explode(" ", $name); |
|
203 | - if ($ns == "") |
|
204 | - $this->success = false; |
|
205 | - } else { |
|
206 | - $ns = ""; |
|
207 | - $tag = $name; |
|
208 | - } |
|
209 | - |
|
210 | - $this->depth--; |
|
211 | - |
|
212 | - if ($this->depth >= 4) { |
|
213 | - $this->current["val"] .= "</$tag>"; |
|
214 | - } |
|
215 | - |
|
216 | - if ($this->depth == 3) { |
|
217 | - if (isset($this->current)) { |
|
218 | - $this->props[] = $this->current; |
|
219 | - unset($this->current); |
|
220 | - } |
|
221 | - } |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * input data handler |
|
226 | - * |
|
227 | - * @param resource parser |
|
228 | - * @param string data |
|
229 | - * @return void |
|
230 | - * @access private |
|
231 | - */ |
|
232 | - function _data($parser, $data) |
|
233 | - { |
|
234 | - if (isset($this->current)) { |
|
235 | - $this->current["val"] .= $data; |
|
236 | - } |
|
237 | - } |
|
46 | + /** |
|
47 | + * |
|
48 | + * |
|
49 | + * @var |
|
50 | + * @access |
|
51 | + */ |
|
52 | + var $success; |
|
53 | + |
|
54 | + /** |
|
55 | + * |
|
56 | + * |
|
57 | + * @var |
|
58 | + * @access |
|
59 | + */ |
|
60 | + var $props; |
|
61 | + |
|
62 | + /** |
|
63 | + * |
|
64 | + * |
|
65 | + * @var |
|
66 | + * @access |
|
67 | + */ |
|
68 | + var $depth; |
|
69 | + |
|
70 | + /** |
|
71 | + * |
|
72 | + * |
|
73 | + * @var |
|
74 | + * @access |
|
75 | + */ |
|
76 | + var $mode; |
|
77 | + |
|
78 | + /** |
|
79 | + * |
|
80 | + * |
|
81 | + * @var |
|
82 | + * @access |
|
83 | + */ |
|
84 | + var $current; |
|
85 | + |
|
86 | + /** |
|
87 | + * On return whole request, if $store_request == true was specified in constructor |
|
88 | + * |
|
89 | + * @var string |
|
90 | + */ |
|
91 | + var $request; |
|
92 | + |
|
93 | + /** |
|
94 | + * constructor |
|
95 | + * |
|
96 | + * @param string path of input stream |
|
97 | + * @param boolean $store_request =false if true whole request data will be made available in $this->request |
|
98 | + * @access public |
|
99 | + */ |
|
100 | + function __construct($path, $store_request=false) |
|
101 | + { |
|
102 | + $this->success = true; |
|
103 | + |
|
104 | + $this->depth = 0; |
|
105 | + $this->props = array(); |
|
106 | + $had_input = false; |
|
107 | + |
|
108 | + $f_in = fopen($path, "r"); |
|
109 | + if (!$f_in) { |
|
110 | + $this->success = false; |
|
111 | + return; |
|
112 | + } |
|
113 | + |
|
114 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
115 | + |
|
116 | + xml_set_element_handler($xml_parser, |
|
117 | + array(&$this, "_startElement"), |
|
118 | + array(&$this, "_endElement")); |
|
119 | + |
|
120 | + xml_set_character_data_handler($xml_parser, |
|
121 | + array(&$this, "_data")); |
|
122 | + |
|
123 | + xml_parser_set_option($xml_parser, |
|
124 | + XML_OPTION_CASE_FOLDING, false); |
|
125 | + |
|
126 | + while($this->success && !feof($f_in)) { |
|
127 | + $line = fgets($f_in); |
|
128 | + if ($store_request) $this->request .= $line; |
|
129 | + if (is_string($line)) { |
|
130 | + $had_input = true; |
|
131 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + if($had_input) { |
|
136 | + $this->success &= xml_parse($xml_parser, "", true); |
|
137 | + } |
|
138 | + |
|
139 | + xml_parser_free($xml_parser); |
|
140 | + |
|
141 | + fclose($f_in); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * tag start handler |
|
146 | + * |
|
147 | + * @param resource parser |
|
148 | + * @param string tag name |
|
149 | + * @param array tag attributes |
|
150 | + * @return void |
|
151 | + * @access private |
|
152 | + */ |
|
153 | + function _startElement($parser, $name, $attrs) |
|
154 | + { |
|
155 | + if (strstr($name, " ")) { |
|
156 | + list($ns, $tag) = explode(" ", $name); |
|
157 | + if ($ns == "") |
|
158 | + $this->success = false; |
|
159 | + } else { |
|
160 | + $ns = ""; |
|
161 | + $tag = $name; |
|
162 | + } |
|
163 | + |
|
164 | + if ($this->depth == 1) { |
|
165 | + $this->mode = $tag; |
|
166 | + } |
|
167 | + |
|
168 | + if ($this->depth == 3) { |
|
169 | + $prop = array("name" => $tag); |
|
170 | + $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
|
171 | + if ($this->mode == "set") { |
|
172 | + $this->current["val"] = ""; // default set val |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + if ($this->depth >= 4) { |
|
177 | + $this->current["val"] .= "<$tag"; |
|
178 | + if (isset($attr)) { |
|
179 | + foreach ($attr as $key => $val) { |
|
180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
181 | + } |
|
182 | + } |
|
183 | + $this->current["val"] .= ">"; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + $this->depth++; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * tag end handler |
|
193 | + * |
|
194 | + * @param resource parser |
|
195 | + * @param string tag name |
|
196 | + * @return void |
|
197 | + * @access private |
|
198 | + */ |
|
199 | + function _endElement($parser, $name) |
|
200 | + { |
|
201 | + if (strstr($name, " ")) { |
|
202 | + list($ns, $tag) = explode(" ", $name); |
|
203 | + if ($ns == "") |
|
204 | + $this->success = false; |
|
205 | + } else { |
|
206 | + $ns = ""; |
|
207 | + $tag = $name; |
|
208 | + } |
|
209 | + |
|
210 | + $this->depth--; |
|
211 | + |
|
212 | + if ($this->depth >= 4) { |
|
213 | + $this->current["val"] .= "</$tag>"; |
|
214 | + } |
|
215 | + |
|
216 | + if ($this->depth == 3) { |
|
217 | + if (isset($this->current)) { |
|
218 | + $this->props[] = $this->current; |
|
219 | + unset($this->current); |
|
220 | + } |
|
221 | + } |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * input data handler |
|
226 | + * |
|
227 | + * @param resource parser |
|
228 | + * @param string data |
|
229 | + * @return void |
|
230 | + * @access private |
|
231 | + */ |
|
232 | + function _data($parser, $data) |
|
233 | + { |
|
234 | + if (isset($this->current)) { |
|
235 | + $this->current["val"] .= $data; |
|
236 | + } |
|
237 | + } |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /* |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
98 | 98 | * @access public |
99 | 99 | */ |
100 | - function __construct($path, $store_request=false) |
|
100 | + function __construct($path, $store_request = false) |
|
101 | 101 | { |
102 | 102 | $this->success = true; |
103 | 103 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | xml_parser_set_option($xml_parser, |
124 | 124 | XML_OPTION_CASE_FOLDING, false); |
125 | 125 | |
126 | - while($this->success && !feof($f_in)) { |
|
126 | + while ($this->success && !feof($f_in)) { |
|
127 | 127 | $line = fgets($f_in); |
128 | 128 | if ($store_request) $this->request .= $line; |
129 | 129 | if (is_string($line)) { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - if($had_input) { |
|
135 | + if ($had_input) { |
|
136 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
137 | 137 | } |
138 | 138 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $prop = array("name" => $tag); |
170 | 170 | $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
171 | 171 | if ($this->mode == "set") { |
172 | - $this->current["val"] = ""; // default set val |
|
172 | + $this->current["val"] = ""; // default set val |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->current["val"] .= "<$tag"; |
178 | 178 | if (isset($attr)) { |
179 | 179 | foreach ($attr as $key => $val) { |
180 | - $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
|
180 | + $this->current["val"] .= ' '.$key.'="'.str_replace('"', '"', $val).'"'; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | $this->current["val"] .= ">"; |
@@ -106,7 +106,8 @@ discard block |
||
106 | 106 | $had_input = false; |
107 | 107 | |
108 | 108 | $f_in = fopen($path, "r"); |
109 | - if (!$f_in) { |
|
109 | + if (!$f_in) |
|
110 | + { |
|
110 | 111 | $this->success = false; |
111 | 112 | return; |
112 | 113 | } |
@@ -123,16 +124,22 @@ discard block |
||
123 | 124 | xml_parser_set_option($xml_parser, |
124 | 125 | XML_OPTION_CASE_FOLDING, false); |
125 | 126 | |
126 | - while($this->success && !feof($f_in)) { |
|
127 | + while($this->success && !feof($f_in)) |
|
128 | + { |
|
127 | 129 | $line = fgets($f_in); |
128 | - if ($store_request) $this->request .= $line; |
|
129 | - if (is_string($line)) { |
|
130 | + if ($store_request) |
|
131 | + { |
|
132 | + $this->request .= $line; |
|
133 | + } |
|
134 | + if (is_string($line)) |
|
135 | + { |
|
130 | 136 | $had_input = true; |
131 | 137 | $this->success &= xml_parse($xml_parser, $line, false); |
132 | 138 | } |
133 | 139 | } |
134 | 140 | |
135 | - if($had_input) { |
|
141 | + if($had_input) |
|
142 | + { |
|
136 | 143 | $this->success &= xml_parse($xml_parser, "", true); |
137 | 144 | } |
138 | 145 | |
@@ -152,31 +159,42 @@ discard block |
||
152 | 159 | */ |
153 | 160 | function _startElement($parser, $name, $attrs) |
154 | 161 | { |
155 | - if (strstr($name, " ")) { |
|
162 | + if (strstr($name, " ")) |
|
163 | + { |
|
156 | 164 | list($ns, $tag) = explode(" ", $name); |
157 | 165 | if ($ns == "") |
158 | - $this->success = false; |
|
159 | - } else { |
|
166 | + { |
|
167 | + $this->success = false; |
|
168 | + } |
|
169 | + } |
|
170 | + else |
|
171 | + { |
|
160 | 172 | $ns = ""; |
161 | 173 | $tag = $name; |
162 | 174 | } |
163 | 175 | |
164 | - if ($this->depth == 1) { |
|
176 | + if ($this->depth == 1) |
|
177 | + { |
|
165 | 178 | $this->mode = $tag; |
166 | 179 | } |
167 | 180 | |
168 | - if ($this->depth == 3) { |
|
181 | + if ($this->depth == 3) |
|
182 | + { |
|
169 | 183 | $prop = array("name" => $tag); |
170 | 184 | $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200); |
171 | - if ($this->mode == "set") { |
|
185 | + if ($this->mode == "set") |
|
186 | + { |
|
172 | 187 | $this->current["val"] = ""; // default set val |
173 | 188 | } |
174 | 189 | } |
175 | 190 | |
176 | - if ($this->depth >= 4) { |
|
191 | + if ($this->depth >= 4) |
|
192 | + { |
|
177 | 193 | $this->current["val"] .= "<$tag"; |
178 | - if (isset($attr)) { |
|
179 | - foreach ($attr as $key => $val) { |
|
194 | + if (isset($attr)) |
|
195 | + { |
|
196 | + foreach ($attr as $key => $val) |
|
197 | + { |
|
180 | 198 | $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"'; |
181 | 199 | } |
182 | 200 | } |
@@ -198,23 +216,31 @@ discard block |
||
198 | 216 | */ |
199 | 217 | function _endElement($parser, $name) |
200 | 218 | { |
201 | - if (strstr($name, " ")) { |
|
219 | + if (strstr($name, " ")) |
|
220 | + { |
|
202 | 221 | list($ns, $tag) = explode(" ", $name); |
203 | 222 | if ($ns == "") |
204 | - $this->success = false; |
|
205 | - } else { |
|
223 | + { |
|
224 | + $this->success = false; |
|
225 | + } |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
206 | 229 | $ns = ""; |
207 | 230 | $tag = $name; |
208 | 231 | } |
209 | 232 | |
210 | 233 | $this->depth--; |
211 | 234 | |
212 | - if ($this->depth >= 4) { |
|
235 | + if ($this->depth >= 4) |
|
236 | + { |
|
213 | 237 | $this->current["val"] .= "</$tag>"; |
214 | 238 | } |
215 | 239 | |
216 | - if ($this->depth == 3) { |
|
217 | - if (isset($this->current)) { |
|
240 | + if ($this->depth == 3) |
|
241 | + { |
|
242 | + if (isset($this->current)) |
|
243 | + { |
|
218 | 244 | $this->props[] = $this->current; |
219 | 245 | unset($this->current); |
220 | 246 | } |
@@ -231,7 +257,8 @@ discard block |
||
231 | 257 | */ |
232 | 258 | function _data($parser, $data) |
233 | 259 | { |
234 | - if (isset($this->current)) { |
|
260 | + if (isset($this->current)) |
|
261 | + { |
|
235 | 262 | $this->current["val"] .= $data; |
236 | 263 | } |
237 | 264 | } |
@@ -80,6 +80,7 @@ |
||
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Returns the maximum width/height of a thumbnail |
83 | + * @return integer|null |
|
83 | 84 | */ |
84 | 85 | function get_maxsize() |
85 | 86 | { |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - if (!preg_match('/^[a-z0-9_-]+$/i',$app)) |
|
73 | + if (!preg_match('/^[a-z0-9_-]+$/i', $app)) |
|
74 | 74 | { |
75 | - die('Stop'); // just to prevent someone doing nasty things |
|
75 | + die('Stop'); // just to prevent someone doing nasty things |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $app; |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function get_maxsize() |
85 | 85 | { |
86 | - $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : |
|
87 | - $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
86 | + $preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail']; |
|
88 | 87 | |
89 | 88 | // Another maximum size may be passed if thumbnails are turned on |
90 | 89 | if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize'])) |
@@ -150,7 +149,7 @@ discard block |
||
150 | 149 | } |
151 | 150 | $dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize); |
152 | 151 | $dst_dir = dirname($dst); |
153 | - if(file_exists($dst_dir)) |
|
152 | + if (file_exists($dst_dir)) |
|
154 | 153 | { |
155 | 154 | // Check whether the destination file already exists and is newer than |
156 | 155 | // the source file. Assume the file doesn't exist if thumbnailing is turned off. |
@@ -190,7 +189,7 @@ discard block |
||
190 | 189 | { |
191 | 190 | // Allow client to cache these, makes scrolling in filemanager much nicer |
192 | 191 | // setting maximum allow caching time of one year, if url contains (non-empty) moditication time |
193 | - Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
192 | + Api\Session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching |
|
194 | 193 | header('Content-Type: '.$output_mime); |
195 | 194 | readfile($dst); |
196 | 195 | return true; |
@@ -212,7 +211,7 @@ discard block |
||
212 | 211 | * @param int $minsize =null |
213 | 212 | * @return string |
214 | 213 | */ |
215 | -function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null) |
|
214 | +function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null) |
|
216 | 215 | { |
217 | 216 | // Use the egroupware file cache to store the thumbnails on a per instance basis |
218 | 217 | $cachefile = new Api\Cache\Files(array()); |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | * TODO: As this is a general purpose function, it might probably be moved |
239 | 238 | * to some other php file or an "image utils" class. |
240 | 239 | */ |
241 | -function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0) |
|
240 | +function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0) |
|
242 | 241 | { |
243 | 242 | //Scale will contain the factor by which the image has to be scaled down |
244 | 243 | $scale = 1.0; |
@@ -299,7 +298,7 @@ discard block |
||
299 | 298 | * @param int $maxh the maximum height of the thumbnail |
300 | 299 | * @returns boolean|resource false or a gd_image |
301 | 300 | */ |
302 | -function gd_image_load($file,$maxw,$maxh) |
|
301 | +function gd_image_load($file, $maxw, $maxh) |
|
303 | 302 | { |
304 | 303 | // Get mime type |
305 | 304 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
@@ -307,9 +306,9 @@ discard block |
||
307 | 306 | if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
308 | 307 | |
309 | 308 | // Call the according gd constructor depending on the file type |
310 | - if($type == 'image') |
|
309 | + if ($type == 'image') |
|
311 | 310 | { |
312 | - if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file))) |
|
311 | + if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file))) |
|
313 | 312 | { |
314 | 313 | return $image; |
315 | 314 | } |
@@ -332,12 +331,12 @@ discard block |
||
332 | 331 | else if ($type == 'application') |
333 | 332 | { |
334 | 333 | $thumb = false; |
335 | - if(strpos($image_type,'vnd.oasis.opendocument.') === 0) |
|
334 | + if (strpos($image_type, 'vnd.oasis.opendocument.') === 0) |
|
336 | 335 | { |
337 | 336 | // OpenDocuments have thumbnails inside already |
338 | 337 | $thumb = get_opendocument_thumbnail($file); |
339 | 338 | } |
340 | - else if($image_type == 'pdf') |
|
339 | + else if ($image_type == 'pdf') |
|
341 | 340 | { |
342 | 341 | $thumb = get_pdf_thumbnail($file); |
343 | 342 | } |
@@ -347,7 +346,7 @@ discard block |
||
347 | 346 | //$thumb = get_msoffice_thumbnail($file); |
348 | 347 | } |
349 | 348 | // Mark it with mime type icon |
350 | - if($thumb) |
|
349 | + if ($thumb) |
|
351 | 350 | { |
352 | 351 | // Need to scale first, or the mark will be wrong size |
353 | 352 | $scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh); |
@@ -387,8 +386,8 @@ discard block |
||
387 | 386 | |
388 | 387 | // Image is already there, but we can't access them directly through VFS |
389 | 388 | $ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods'; |
390 | - $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-'); |
|
391 | - copy($file,$archive); |
|
389 | + $archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-'); |
|
390 | + copy($file, $archive); |
|
392 | 391 | |
393 | 392 | $thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png'; |
394 | 393 | $image = imagecreatefromstring(file_get_contents($thumbnail_url)); |
@@ -442,7 +441,7 @@ discard block |
||
442 | 441 | */ |
443 | 442 | function get_pdf_thumbnail($file) |
444 | 443 | { |
445 | - if(!pdf_thumbnails_available()) return false; |
|
444 | + if (!pdf_thumbnails_available()) return false; |
|
446 | 445 | |
447 | 446 | // switch off max_excution_time, as some thumbnails take longer and |
448 | 447 | // will be startet over and over again, if they dont finish |
@@ -471,7 +470,7 @@ discard block |
||
471 | 470 | $target_height = imagesy($target_image); |
472 | 471 | |
473 | 472 | // Find mime image, if no tag image set |
474 | - if(!$tag_image && $mime) |
|
473 | + if (!$tag_image && $mime) |
|
475 | 474 | { |
476 | 475 | list($app, $icon) = explode('/', Vfs::mime_icon($mime), 2); |
477 | 476 | list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'], |
@@ -482,16 +481,16 @@ discard block |
||
482 | 481 | |
483 | 482 | // Find correct size - max 1/3 target |
484 | 483 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
485 | - if(!$tag_size) return; |
|
486 | - list($tag_width,$tag_height) = $tag_size; |
|
484 | + if (!$tag_size) return; |
|
485 | + list($tag_width, $tag_height) = $tag_size; |
|
487 | 486 | |
488 | 487 | // Put it in |
489 | - if($mime) |
|
488 | + if ($mime) |
|
490 | 489 | { |
491 | - imagecopyresampled($target_image,$tag_image, |
|
490 | + imagecopyresampled($target_image, $tag_image, |
|
492 | 491 | $target_width - $tag_width, |
493 | 492 | $target_height - $tag_height, |
494 | - 0,0, |
|
493 | + 0, 0, |
|
495 | 494 | $tag_width, |
496 | 495 | $tag_height, |
497 | 496 | imagesx($tag_image), |
@@ -545,7 +544,7 @@ discard block |
||
545 | 544 | function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh) |
546 | 545 | { |
547 | 546 | //Load the image |
548 | - if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false) |
|
547 | + if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false) |
|
549 | 548 | { |
550 | 549 | //Get the constraints of the image |
551 | 550 | $w = imagesx($img_src); |
@@ -575,14 +574,14 @@ discard block |
||
575 | 574 | */ |
576 | 575 | function gdVersion($user_ver = 0) |
577 | 576 | { |
578 | - if (! extension_loaded('gd')) { return; } |
|
577 | + if (!extension_loaded('gd')) { return; } |
|
579 | 578 | static $gd_ver = 0; |
580 | 579 | |
581 | 580 | // Just accept the specified setting if it's 1. |
582 | 581 | if ($user_ver == 1) { $gd_ver = 1; return 1; } |
583 | 582 | |
584 | 583 | // Use the static variable if function was called previously. |
585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
584 | + if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; } |
|
586 | 585 | |
587 | 586 | // Use the gd_info() function if possible. |
588 | 587 | if (function_exists('gd_info')) { |
@@ -244,10 +244,13 @@ discard block |
||
244 | 244 | $scale = 1.0; |
245 | 245 | |
246 | 246 | //Select the constraining dimension |
247 | - if ($w > $h) // landscape image: constraining factor $minh or $maxw |
|
247 | + if ($w > $h) |
|
248 | + { |
|
249 | + // landscape image: constraining factor $minh or $maxw |
|
248 | 250 | { |
249 | 251 | $scale = $minh ? $minh / $h : $maxw / $w; |
250 | 252 | } |
253 | + } |
|
251 | 254 | else // portrail image: constraining factor $minw or $maxh |
252 | 255 | { |
253 | 256 | $scale = $minw ? $minw / $w : $maxh / $h; |
@@ -304,7 +307,10 @@ discard block |
||
304 | 307 | // Get mime type |
305 | 308 | list($type, $image_type) = explode('/', $mime = Vfs::mime_content_type($file)); |
306 | 309 | // if $file is not from vfs, use Api\MimeMagic::filename2mime to get mime-type from extension |
307 | - if (!$type) list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
310 | + if (!$type) |
|
311 | + { |
|
312 | + list($type, $image_type) = explode('/', $mime = Api\MimeMagic::filename2mime($file)); |
|
313 | + } |
|
308 | 314 | |
309 | 315 | // Call the according gd constructor depending on the file type |
310 | 316 | if($type == 'image') |
@@ -442,7 +448,10 @@ discard block |
||
442 | 448 | */ |
443 | 449 | function get_pdf_thumbnail($file) |
444 | 450 | { |
445 | - if(!pdf_thumbnails_available()) return false; |
|
451 | + if(!pdf_thumbnails_available()) |
|
452 | + { |
|
453 | + return false; |
|
454 | + } |
|
446 | 455 | |
447 | 456 | // switch off max_excution_time, as some thumbnails take longer and |
448 | 457 | // will be startet over and over again, if they dont finish |
@@ -482,7 +491,10 @@ discard block |
||
482 | 491 | |
483 | 492 | // Find correct size - max 1/3 target |
484 | 493 | $tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3); |
485 | - if(!$tag_size) return; |
|
494 | + if(!$tag_size) |
|
495 | + { |
|
496 | + return; |
|
497 | + } |
|
486 | 498 | list($tag_width,$tag_height) = $tag_size; |
487 | 499 | |
488 | 500 | // Put it in |
@@ -575,17 +587,24 @@ discard block |
||
575 | 587 | */ |
576 | 588 | function gdVersion($user_ver = 0) |
577 | 589 | { |
578 | - if (! extension_loaded('gd')) { return; } |
|
590 | + if (! extension_loaded('gd')) |
|
591 | + { |
|
592 | +return; } |
|
579 | 593 | static $gd_ver = 0; |
580 | 594 | |
581 | 595 | // Just accept the specified setting if it's 1. |
582 | - if ($user_ver == 1) { $gd_ver = 1; return 1; } |
|
596 | + if ($user_ver == 1) |
|
597 | + { |
|
598 | +$gd_ver = 1; return 1; } |
|
583 | 599 | |
584 | 600 | // Use the static variable if function was called previously. |
585 | - if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; } |
|
601 | + if ($user_ver !=2 && $gd_ver > 0 ) |
|
602 | + { |
|
603 | +return $gd_ver; } |
|
586 | 604 | |
587 | 605 | // Use the gd_info() function if possible. |
588 | - if (function_exists('gd_info')) { |
|
606 | + if (function_exists('gd_info')) |
|
607 | + { |
|
589 | 608 | $ver_info = gd_info(); |
590 | 609 | $match = null; |
591 | 610 | preg_match('/\d/', $ver_info['GD Version'], $match); |
@@ -594,11 +613,15 @@ discard block |
||
594 | 613 | } |
595 | 614 | |
596 | 615 | // If phpinfo() is disabled use a specified / fail-safe choice... |
597 | - if (preg_match('/phpinfo/', ini_get('disable_functions'))) { |
|
598 | - if ($user_ver == 2) { |
|
616 | + if (preg_match('/phpinfo/', ini_get('disable_functions'))) |
|
617 | + { |
|
618 | + if ($user_ver == 2) |
|
619 | + { |
|
599 | 620 | $gd_ver = 2; |
600 | 621 | return 2; |
601 | - } else { |
|
622 | + } |
|
623 | + else |
|
624 | + { |
|
602 | 625 | $gd_ver = 1; |
603 | 626 | return 1; |
604 | 627 | } |
@@ -607,6 +630,9 @@ discard block |
||
607 | 630 | ob_start(); |
608 | 631 | phpinfo(8); |
609 | 632 | $info = stristr(ob_get_clean(), 'gd version'); |
610 | - if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0]; |
|
633 | + if (preg_match('/\d/', $info, $match)) |
|
634 | + { |
|
635 | + $gd_ver = $match[0]; |
|
636 | + } |
|
611 | 637 | return $match[0]; |
612 | 638 | } |
@@ -94,7 +94,6 @@ |
||
94 | 94 | /** |
95 | 95 | * imports entries according to given definition object. |
96 | 96 | * @param resource $_stream |
97 | - * @param string $_charset |
|
98 | 97 | * @param definition $_definition |
99 | 98 | */ |
100 | 99 | public function import( $_stream, definition $_definition ) { |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | private $user = null; |
83 | 83 | |
84 | 84 | /** |
85 | - * List of import errors |
|
86 | - */ |
|
87 | - protected $errors = array(); |
|
85 | + * List of import errors |
|
86 | + */ |
|
87 | + protected $errors = array(); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * List of actions, and how many times that action was taken |
@@ -305,26 +305,26 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Returns errors that were encountered during importing |
|
309 | - * Maximum of one error message per record, but you can append if you need to |
|
310 | - * |
|
311 | - * @return Array ( |
|
312 | - * record_# => error message |
|
313 | - * ) |
|
314 | - */ |
|
315 | - public function get_errors() { |
|
308 | + * Returns errors that were encountered during importing |
|
309 | + * Maximum of one error message per record, but you can append if you need to |
|
310 | + * |
|
311 | + * @return Array ( |
|
312 | + * record_# => error message |
|
313 | + * ) |
|
314 | + */ |
|
315 | + public function get_errors() { |
|
316 | 316 | return $this->errors; |
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Returns a list of actions taken, and the number of records for that action. |
|
321 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
322 | - * |
|
323 | - * @return Array ( |
|
324 | - * action => record count |
|
325 | - * ) |
|
326 | - */ |
|
327 | - public function get_results() { |
|
320 | + * Returns a list of actions taken, and the number of records for that action. |
|
321 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
322 | + * |
|
323 | + * @return Array ( |
|
324 | + * action => record count |
|
325 | + * ) |
|
326 | + */ |
|
327 | + public function get_results() { |
|
328 | 328 | return $this->results; |
329 | 329 | } |
330 | 330 | } // end of iface_export_plugin |
@@ -10,28 +10,28 @@ discard block |
||
10 | 10 | * @version $Id: $ |
11 | 11 | */ |
12 | 12 | |
13 | -require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php'); |
|
13 | +require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php'); |
|
14 | 14 | require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php'); |
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * class import_csv for addressbook |
19 | 19 | */ |
20 | -class import_events_csv implements iface_import_plugin { |
|
20 | +class import_events_csv implements iface_import_plugin { |
|
21 | 21 | |
22 | 22 | private static $plugin_options = array( |
23 | - 'fieldsep', // char |
|
24 | - 'charset', // string |
|
25 | - 'event_owner', // int account_id or -1 for leave untuched |
|
26 | - 'owner_joins_event', // bool |
|
27 | - 'update_cats', // string {override|add} overides record |
|
23 | + 'fieldsep', // char |
|
24 | + 'charset', // string |
|
25 | + 'event_owner', // int account_id or -1 for leave untuched |
|
26 | + 'owner_joins_event', // bool |
|
27 | + 'update_cats', // string {override|add} overides record |
|
28 | 28 | // with cat(s) from csv OR add the cat from |
29 | 29 | // csv file to exeisting cat(s) of record |
30 | - 'num_header_lines', // int number of header lines |
|
31 | - 'trash_users_records', // trashes all events of events owner before import |
|
32 | - 'field_conversion', // array( $csv_col_num => conversion) |
|
33 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
34 | - 'conditions', /* => array containing condition arrays: |
|
30 | + 'num_header_lines', // int number of header lines |
|
31 | + 'trash_users_records', // trashes all events of events owner before import |
|
32 | + 'field_conversion', // array( $csv_col_num => conversion) |
|
33 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
34 | + 'conditions', /* => array containing condition arrays: |
|
35 | 35 | 'type' => exists, // record['uid'] exists |
36 | 36 | 'true' => array( |
37 | 37 | 'action' => update, |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * actions wich could be done to data entries |
49 | 49 | */ |
50 | - private static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
50 | + private static $actions = array('none', 'update', 'insert', 'delete',); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * conditions for actions |
54 | 54 | * |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - private static $conditions = array( 'exists', 'empty', ); |
|
57 | + private static $conditions = array('exists', 'empty',); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @var definition |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param string $_charset |
98 | 98 | * @param definition $_definition |
99 | 99 | */ |
100 | - public function import( $_stream, definition $_definition ) { |
|
101 | - $import_csv = new import_csv( $_stream, array( |
|
100 | + public function import($_stream, definition $_definition) { |
|
101 | + $import_csv = new import_csv($_stream, array( |
|
102 | 102 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
103 | 103 | 'charset' => $_definition->plugin_options['charset'], |
104 | 104 | )); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $this->definition = $_definition; |
107 | 107 | |
108 | 108 | // user, is admin ? |
109 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
109 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
110 | 110 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
111 | 111 | |
112 | 112 | // dry run? |
113 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
113 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
114 | 114 | |
115 | 115 | // fetch the calendar bo |
116 | 116 | $this->bocalupdate = new calendar_boupdate(); |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
123 | 123 | |
124 | 124 | //check if file has a header lines |
125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
126 | - $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
|
125 | + if (isset($_definition->plugin_options['num_header_lines'])) { |
|
126 | + $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // set eventOwner |
130 | 130 | $plugin_options = $_definition->plugin_options; |
131 | - $plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ? |
|
131 | + $plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ? |
|
132 | 132 | $_definition->plugin_options['events_owner'] : $this->user; |
133 | 133 | $_definition->plugin_options = $plugin_options; |
134 | 134 | |
135 | 135 | // trash_users_records ? |
136 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
137 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
136 | + if ($_definition->plugin_options['trash_users_records'] === true) { |
|
137 | + if (!$_definition->plugin_options['dry_run']) { |
|
138 | 138 | $socal = new calendar_socal(); |
139 | - $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
|
140 | - unset( $socal ); |
|
139 | + $this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']); |
|
140 | + unset($socal); |
|
141 | 141 | } else { |
142 | - $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
|
142 | + $lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']); |
|
143 | 143 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
144 | 144 | } |
145 | 145 | } |
@@ -147,44 +147,44 @@ discard block |
||
147 | 147 | $this->errors = array(); |
148 | 148 | $this->results = array(); |
149 | 149 | |
150 | - while ( $record = $import_csv->get_record() ) { |
|
150 | + while ($record = $import_csv->get_record()) { |
|
151 | 151 | |
152 | 152 | // don't import empty events |
153 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
153 | + if (count(array_unique($record)) < 2) continue; |
|
154 | 154 | |
155 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
155 | + if ($_definition->plugin_options['events_owner'] != -1) { |
|
156 | 156 | $record['owner'] = $_definition->plugin_options['events_owner']; |
157 | - } else unset( $record['owner'] ); |
|
157 | + } else unset($record['owner']); |
|
158 | 158 | |
159 | - if ( $_definition->plugin_options['conditions'] ) { |
|
160 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
161 | - switch ( $condition['type'] ) { |
|
159 | + if ($_definition->plugin_options['conditions']) { |
|
160 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
161 | + switch ($condition['type']) { |
|
162 | 162 | // exists |
163 | 163 | case 'exists' : |
164 | 164 | |
165 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
165 | + if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) { |
|
166 | 166 | // apply action to event matching this exists condition |
167 | 167 | $record['id'] = $event['id']; |
168 | 168 | |
169 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
170 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
171 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
172 | - $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
|
169 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
170 | + if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']); |
|
171 | + if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']); |
|
172 | + $record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id']))); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // check if entry is modiefied |
176 | - $event = array_intersect_key( $event, $record ); |
|
177 | - $diff = array_diff( $event, $record ); |
|
178 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
176 | + $event = array_intersect_key($event, $record); |
|
177 | + $diff = array_diff($event, $record); |
|
178 | + if (!empty($diff)) $record['modified'] = time(); |
|
179 | 179 | |
180 | 180 | $action = $condition['true']; |
181 | 181 | } else $action = $condition['false']; |
182 | 182 | |
183 | - $this->action( $action['action'], $record ); |
|
183 | + $this->action($action['action'], $record); |
|
184 | 184 | break; |
185 | 185 | case 'empty' : |
186 | - $action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false']; |
|
187 | - $this->action( $action['action'], $record ); |
|
186 | + $action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false']; |
|
187 | + $this->action($action['action'], $record); |
|
188 | 188 | break; |
189 | 189 | |
190 | 190 | // not supported action |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | } else { |
198 | 198 | // unconditional insert |
199 | - $this->action( 'insert', $record ); |
|
199 | + $this->action('insert', $record); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param array $_data event data for the action |
209 | 209 | * @return bool success or not |
210 | 210 | */ |
211 | - private function action ( $_action, $_data ) { |
|
212 | - switch ( $_action ) { |
|
211 | + private function action($_action, $_data) { |
|
212 | + switch ($_action) { |
|
213 | 213 | case 'none' : |
214 | 214 | return true; |
215 | 215 | |
@@ -217,32 +217,32 @@ discard block |
||
217 | 217 | case 'insert' : |
218 | 218 | |
219 | 219 | // paticipants handling |
220 | - $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
|
220 | + $participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array(); |
|
221 | 221 | $_data['participants'] = array(); |
222 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
222 | + if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) { |
|
223 | 223 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
224 | 224 | } |
225 | - foreach( $participants as $participant ) { |
|
226 | - list( $participant, $status ) = explode( '=', $participant ); |
|
227 | - $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
|
228 | - $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
|
229 | - if ( $participant && is_numeric($participant ) ) { |
|
225 | + foreach ($participants as $participant) { |
|
226 | + list($participant, $status) = explode('=', $participant); |
|
227 | + $valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T'); |
|
228 | + $status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U'; |
|
229 | + if ($participant && is_numeric($participant)) { |
|
230 | 230 | $_data['participants'][$participant] = $status; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | // no valid participants so far --> add the importing user/owner |
234 | - if ( empty( $_data['participants'] ) ) { |
|
234 | + if (empty($_data['participants'])) { |
|
235 | 235 | $_data['participants'][$this->user] = 'A'; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // are we serious? |
239 | - if ( $this->dry_run ) { |
|
239 | + if ($this->dry_run) { |
|
240 | 240 | print_r($_data); |
241 | 241 | $this->results[$_action]++; |
242 | 242 | } else { |
243 | 243 | $messages = array(); |
244 | - $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
245 | - if(!$result) { |
|
244 | + $result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
245 | + if (!$result) { |
|
246 | 246 | $this->errors = implode(',', $messages); |
247 | 247 | } else { |
248 | 248 | $this->results[$_action]++; |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for addressbook |
19 | 19 | */ |
20 | -class import_events_csv implements iface_import_plugin { |
|
20 | +class import_events_csv implements iface_import_plugin |
|
21 | +{ |
|
21 | 22 | |
22 | 23 | private static $plugin_options = array( |
23 | 24 | 'fieldsep', // char |
@@ -97,7 +98,8 @@ discard block |
||
97 | 98 | * @param string $_charset |
98 | 99 | * @param definition $_definition |
99 | 100 | */ |
100 | - public function import( $_stream, definition $_definition ) { |
|
101 | + public function import( $_stream, definition $_definition ) |
|
102 | + { |
|
101 | 103 | $import_csv = new import_csv( $_stream, array( |
102 | 104 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
103 | 105 | 'charset' => $_definition->plugin_options['charset'], |
@@ -122,7 +124,8 @@ discard block |
||
122 | 124 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
123 | 125 | |
124 | 126 | //check if file has a header lines |
125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
127 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) ) |
|
128 | + { |
|
126 | 129 | $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
127 | 130 | } |
128 | 131 | |
@@ -133,12 +136,16 @@ discard block |
||
133 | 136 | $_definition->plugin_options = $plugin_options; |
134 | 137 | |
135 | 138 | // trash_users_records ? |
136 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
137 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
139 | + if ( $_definition->plugin_options['trash_users_records'] === true ) |
|
140 | + { |
|
141 | + if ( !$_definition->plugin_options['dry_run'] ) |
|
142 | + { |
|
138 | 143 | $socal = new calendar_socal(); |
139 | 144 | $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
140 | 145 | unset( $socal ); |
141 | - } else { |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
142 | 149 | $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
143 | 150 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
144 | 151 | } |
@@ -147,38 +154,63 @@ discard block |
||
147 | 154 | $this->errors = array(); |
148 | 155 | $this->results = array(); |
149 | 156 | |
150 | - while ( $record = $import_csv->get_record() ) { |
|
157 | + while ( $record = $import_csv->get_record() ) |
|
158 | + { |
|
151 | 159 | |
152 | 160 | // don't import empty events |
153 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
161 | + if( count( array_unique( $record ) ) < 2 ) |
|
162 | + { |
|
163 | + continue; |
|
164 | + } |
|
154 | 165 | |
155 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
166 | + if ( $_definition->plugin_options['events_owner'] != -1 ) |
|
167 | + { |
|
156 | 168 | $record['owner'] = $_definition->plugin_options['events_owner']; |
157 | - } else unset( $record['owner'] ); |
|
169 | + } |
|
170 | + else { |
|
171 | + unset( $record['owner'] ); |
|
172 | + } |
|
158 | 173 | |
159 | - if ( $_definition->plugin_options['conditions'] ) { |
|
160 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
161 | - switch ( $condition['type'] ) { |
|
174 | + if ( $_definition->plugin_options['conditions'] ) |
|
175 | + { |
|
176 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
177 | + { |
|
178 | + switch ( $condition['type'] ) |
|
179 | + { |
|
162 | 180 | // exists |
163 | 181 | case 'exists' : |
164 | 182 | |
165 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
183 | + if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) |
|
184 | + { |
|
166 | 185 | // apply action to event matching this exists condition |
167 | 186 | $record['id'] = $event['id']; |
168 | 187 | |
169 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
170 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
171 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
188 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
189 | + { |
|
190 | + if ( !is_array( $event['cat_id'] ) ) |
|
191 | + { |
|
192 | + $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
193 | + } |
|
194 | + if ( !is_array( $record['cat_id'] ) ) |
|
195 | + { |
|
196 | + $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
197 | + } |
|
172 | 198 | $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
173 | 199 | } |
174 | 200 | |
175 | 201 | // check if entry is modiefied |
176 | 202 | $event = array_intersect_key( $event, $record ); |
177 | 203 | $diff = array_diff( $event, $record ); |
178 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
204 | + if( !empty( $diff ) ) |
|
205 | + { |
|
206 | + $record['modified'] = time(); |
|
207 | + } |
|
179 | 208 | |
180 | 209 | $action = $condition['true']; |
181 | - } else $action = $condition['false']; |
|
210 | + } |
|
211 | + else { |
|
212 | + $action = $condition['false']; |
|
213 | + } |
|
182 | 214 | |
183 | 215 | $this->action( $action['action'], $record ); |
184 | 216 | break; |
@@ -192,9 +224,14 @@ discard block |
||
192 | 224 | throw new Exception('condition not supported!!!'); |
193 | 225 | break; |
194 | 226 | } |
195 | - if ($action['last']) break; |
|
227 | + if ($action['last']) |
|
228 | + { |
|
229 | + break; |
|
230 | + } |
|
196 | 231 | } |
197 | - } else { |
|
232 | + } |
|
233 | + else |
|
234 | + { |
|
198 | 235 | // unconditional insert |
199 | 236 | $this->action( 'insert', $record ); |
200 | 237 | } |
@@ -208,8 +245,10 @@ discard block |
||
208 | 245 | * @param array $_data event data for the action |
209 | 246 | * @return bool success or not |
210 | 247 | */ |
211 | - private function action ( $_action, $_data ) { |
|
212 | - switch ( $_action ) { |
|
248 | + private function action ( $_action, $_data ) |
|
249 | + { |
|
250 | + switch ( $_action ) |
|
251 | + { |
|
213 | 252 | case 'none' : |
214 | 253 | return true; |
215 | 254 | |
@@ -219,32 +258,42 @@ discard block |
||
219 | 258 | // paticipants handling |
220 | 259 | $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
221 | 260 | $_data['participants'] = array(); |
222 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
261 | + if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) |
|
262 | + { |
|
223 | 263 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
224 | 264 | } |
225 | - foreach( $participants as $participant ) { |
|
265 | + foreach( $participants as $participant ) |
|
266 | + { |
|
226 | 267 | list( $participant, $status ) = explode( '=', $participant ); |
227 | 268 | $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
228 | 269 | $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
229 | - if ( $participant && is_numeric($participant ) ) { |
|
270 | + if ( $participant && is_numeric($participant ) ) |
|
271 | + { |
|
230 | 272 | $_data['participants'][$participant] = $status; |
231 | 273 | } |
232 | 274 | } |
233 | 275 | // no valid participants so far --> add the importing user/owner |
234 | - if ( empty( $_data['participants'] ) ) { |
|
276 | + if ( empty( $_data['participants'] ) ) |
|
277 | + { |
|
235 | 278 | $_data['participants'][$this->user] = 'A'; |
236 | 279 | } |
237 | 280 | |
238 | 281 | // are we serious? |
239 | - if ( $this->dry_run ) { |
|
282 | + if ( $this->dry_run ) |
|
283 | + { |
|
240 | 284 | print_r($_data); |
241 | 285 | $this->results[$_action]++; |
242 | - } else { |
|
286 | + } |
|
287 | + else |
|
288 | + { |
|
243 | 289 | $messages = array(); |
244 | 290 | $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
245 | - if(!$result) { |
|
291 | + if(!$result) |
|
292 | + { |
|
246 | 293 | $this->errors = implode(',', $messages); |
247 | - } else { |
|
294 | + } |
|
295 | + else |
|
296 | + { |
|
248 | 297 | $this->results[$_action]++; |
249 | 298 | } |
250 | 299 | return $result; |
@@ -259,7 +308,8 @@ discard block |
||
259 | 308 | * |
260 | 309 | * @return string name |
261 | 310 | */ |
262 | - public static function get_name() { |
|
311 | + public static function get_name() |
|
312 | + { |
|
263 | 313 | return lang('Calendar CSV export'); |
264 | 314 | } |
265 | 315 | |
@@ -268,7 +318,8 @@ discard block |
||
268 | 318 | * |
269 | 319 | * @return string descriprion |
270 | 320 | */ |
271 | - public static function get_description() { |
|
321 | + public static function get_description() |
|
322 | + { |
|
272 | 323 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators."); |
273 | 324 | } |
274 | 325 | |
@@ -277,7 +328,8 @@ discard block |
||
277 | 328 | * |
278 | 329 | * @return string suffix (comma seperated) |
279 | 330 | */ |
280 | - public static function get_filesuffix() { |
|
331 | + public static function get_filesuffix() |
|
332 | + { |
|
281 | 333 | return 'csv'; |
282 | 334 | } |
283 | 335 | |
@@ -293,7 +345,8 @@ discard block |
||
293 | 345 | * preserv => array, |
294 | 346 | * ) |
295 | 347 | */ |
296 | - public function get_options_etpl() { |
|
348 | + public function get_options_etpl() |
|
349 | + { |
|
297 | 350 | // lets do it! |
298 | 351 | } |
299 | 352 | |
@@ -302,7 +355,8 @@ discard block |
||
302 | 355 | * |
303 | 356 | * @return string etemplate name |
304 | 357 | */ |
305 | - public function get_selectors_etpl() { |
|
358 | + public function get_selectors_etpl() |
|
359 | + { |
|
306 | 360 | // lets do it! |
307 | 361 | } |
308 | 362 | |
@@ -314,7 +368,8 @@ discard block |
||
314 | 368 | * record_# => error message |
315 | 369 | * ) |
316 | 370 | */ |
317 | - public function get_errors() { |
|
371 | + public function get_errors() |
|
372 | + { |
|
318 | 373 | return $this->errors; |
319 | 374 | } |
320 | 375 | |
@@ -326,7 +381,8 @@ discard block |
||
326 | 381 | * action => record count |
327 | 382 | * ) |
328 | 383 | */ |
329 | - public function get_results() { |
|
384 | + public function get_results() |
|
385 | + { |
|
330 | 386 | return $this->results; |
331 | 387 | } |
332 | 388 | } // end of iface_export_plugin |
@@ -519,6 +519,7 @@ discard block |
||
519 | 519 | * @param array $new_event Event after the change |
520 | 520 | * @param string $role we treat CHAIR like event owners |
521 | 521 | * @param string $status of current user |
522 | + * @param integer $msg_type |
|
522 | 523 | * @return boolean true = update requested, false otherwise |
523 | 524 | */ |
524 | 525 | public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
@@ -594,7 +595,7 @@ discard block |
||
594 | 595 | /** |
595 | 596 | * Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified |
596 | 597 | * |
597 | - * @param int|string $user_or_email |
|
598 | + * @param string $user_or_email |
|
598 | 599 | * @param string $ical_method ='REQUEST' |
599 | 600 | * @param string $role ='REQ-PARTICIPANT' |
600 | 601 | * @return boolean true if user requested to be notified, false if not |
@@ -645,8 +646,7 @@ discard block |
||
645 | 646 | * Get iCal/iMip method from internal nummeric msg-type plus optional notification message and verbose name |
646 | 647 | * |
647 | 648 | * @param int $msg_type see MSG_* defines |
648 | - * @param string& $action=null on return verbose name |
|
649 | - * @param string& $msg=null on return notification message |
|
649 | + * @param string& $action on return verbose name |
|
650 | 650 | */ |
651 | 651 | function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
652 | 652 | { |
@@ -1011,6 +1011,9 @@ discard block |
||
1011 | 1011 | return true; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | + /** |
|
1015 | + * @param integer $added |
|
1016 | + */ |
|
1014 | 1017 | function get_update_message($event,$added) |
1015 | 1018 | { |
1016 | 1019 | $nul = null; |
@@ -1300,8 +1303,8 @@ discard block |
||
1300 | 1303 | * |
1301 | 1304 | * @param int $right self::CAT_ACL_{ADD|STATUS} |
1302 | 1305 | * @param int|array $event |
1303 | - * @return boolean true if use has the right, false if not |
|
1304 | - * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
1306 | + * @return null|boolean true if use has the right, false if not |
|
1307 | + * @return null|boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
1305 | 1308 | * null = cat has no acl |
1306 | 1309 | */ |
1307 | 1310 | function check_cat_acl($right,$event) |
@@ -1386,6 +1389,8 @@ discard block |
||
1386 | 1389 | * Check if current user has a given right on a category (if it's restricted!) |
1387 | 1390 | * |
1388 | 1391 | * @param int $cat_id |
1392 | + * @param integer $right |
|
1393 | + * @param integer $user |
|
1389 | 1394 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1390 | 1395 | * null = cat has no acl |
1391 | 1396 | */ |
@@ -1647,7 +1652,7 @@ discard block |
||
1647 | 1652 | * @param string $action |
1648 | 1653 | * @param array $event_arr |
1649 | 1654 | * @param array $disinvited |
1650 | - * @return array |
|
1655 | + * @return string |
|
1651 | 1656 | */ |
1652 | 1657 | function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
1653 | 1658 | { |
@@ -1504,22 +1504,22 @@ discard block |
||
1504 | 1504 | // check the old list against the new list |
1505 | 1505 | foreach ($old_event['participants'] as $userid => $status) |
1506 | 1506 | { |
1507 | - if (!isset($new_event['participants'][$userid])){ |
|
1508 | - // Attendee will be deleted this way |
|
1509 | - $new_event['participants'][$userid] = 'G'; |
|
1510 | - } |
|
1511 | - elseif ($new_event['participants'][$userid] == $status) |
|
1512 | - { |
|
1513 | - // Same status -- nothing to do. |
|
1514 | - unset($new_event['participants'][$userid]); |
|
1515 | - } |
|
1507 | + if (!isset($new_event['participants'][$userid])){ |
|
1508 | + // Attendee will be deleted this way |
|
1509 | + $new_event['participants'][$userid] = 'G'; |
|
1510 | + } |
|
1511 | + elseif ($new_event['participants'][$userid] == $status) |
|
1512 | + { |
|
1513 | + // Same status -- nothing to do. |
|
1514 | + unset($new_event['participants'][$userid]); |
|
1515 | + } |
|
1516 | 1516 | } |
1517 | 1517 | // write the changes |
1518 | 1518 | foreach ($new_event['participants'] as $userid => $status) |
1519 | 1519 | { |
1520 | 1520 | $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
1521 | 1521 | } |
1522 | - } |
|
1522 | + } |
|
1523 | 1523 | |
1524 | 1524 | /** |
1525 | 1525 | * deletes an event |
@@ -2493,24 +2493,24 @@ discard block |
||
2493 | 2493 | /** |
2494 | 2494 | * classifies an incoming event from the eGW point-of-view |
2495 | 2495 | * |
2496 | - * exceptions: unlike other calendar apps eGW does not create an event exception |
|
2497 | - * if just the participant state changes - therefore we have to distinguish between |
|
2498 | - * real exceptions and status only exceptions |
|
2499 | - * |
|
2500 | - * @param array $event the event to check |
|
2501 | - * |
|
2502 | - * @return array |
|
2503 | - * type => |
|
2504 | - * SINGLE a single event |
|
2505 | - * SERIES-MASTER the series master |
|
2506 | - * SERIES-EXCEPTION event is a real exception |
|
2507 | - * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
2508 | - * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
2509 | - * stored_event => if event already exists in the database array with event data or false |
|
2510 | - * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
2511 | - * the corresponding series master event array |
|
2512 | - * NOTE: this param is false if event is of type SERIES-MASTER |
|
2513 | - */ |
|
2496 | + * exceptions: unlike other calendar apps eGW does not create an event exception |
|
2497 | + * if just the participant state changes - therefore we have to distinguish between |
|
2498 | + * real exceptions and status only exceptions |
|
2499 | + * |
|
2500 | + * @param array $event the event to check |
|
2501 | + * |
|
2502 | + * @return array |
|
2503 | + * type => |
|
2504 | + * SINGLE a single event |
|
2505 | + * SERIES-MASTER the series master |
|
2506 | + * SERIES-EXCEPTION event is a real exception |
|
2507 | + * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
2508 | + * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
2509 | + * stored_event => if event already exists in the database array with event data or false |
|
2510 | + * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
2511 | + * the corresponding series master event array |
|
2512 | + * NOTE: this param is false if event is of type SERIES-MASTER |
|
2513 | + */ |
|
2514 | 2514 | function get_event_info($event) |
2515 | 2515 | { |
2516 | 2516 | $type = 'SINGLE'; // default |
@@ -2681,16 +2681,16 @@ discard block |
||
2681 | 2681 | 'stored_event' => $stored_event, |
2682 | 2682 | 'master_event' => $master_event, |
2683 | 2683 | ); |
2684 | - } |
|
2685 | - |
|
2686 | - /** |
|
2687 | - * Translates all timestamps for a given event from server-time to user-time. |
|
2688 | - * The update() and save() methods expect timestamps in user-time. |
|
2689 | - * @param &$event the event we are working on |
|
2690 | - * |
|
2691 | - */ |
|
2692 | - function server2usertime (&$event) |
|
2693 | - { |
|
2684 | + } |
|
2685 | + |
|
2686 | + /** |
|
2687 | + * Translates all timestamps for a given event from server-time to user-time. |
|
2688 | + * The update() and save() methods expect timestamps in user-time. |
|
2689 | + * @param &$event the event we are working on |
|
2690 | + * |
|
2691 | + */ |
|
2692 | + function server2usertime (&$event) |
|
2693 | + { |
|
2694 | 2694 | // we run all dates through date2usertime, to adjust to user-time |
2695 | 2695 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
2696 | 2696 | { |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
2714 | 2714 | } |
2715 | 2715 | } |
2716 | - } |
|
2716 | + } |
|
2717 | 2717 | /** |
2718 | 2718 | * Delete events that are more than $age years old |
2719 | 2719 | * |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | use EGroupware\Api\Acl; |
17 | 17 | |
18 | 18 | // types of messsages send by calendar_boupdate::send_update |
19 | -define('MSG_DELETED',0); |
|
20 | -define('MSG_MODIFIED',1); |
|
21 | -define('MSG_ADDED',2); |
|
22 | -define('MSG_REJECTED',3); |
|
23 | -define('MSG_TENTATIVE',4); |
|
24 | -define('MSG_ACCEPTED',5); |
|
25 | -define('MSG_ALARM',6); |
|
26 | -define('MSG_DISINVITE',7); |
|
27 | -define('MSG_DELEGATED',8); |
|
19 | +define('MSG_DELETED', 0); |
|
20 | +define('MSG_MODIFIED', 1); |
|
21 | +define('MSG_ADDED', 2); |
|
22 | +define('MSG_REJECTED', 3); |
|
23 | +define('MSG_TENTATIVE', 4); |
|
24 | +define('MSG_ACCEPTED', 5); |
|
25 | +define('MSG_ALARM', 6); |
|
26 | +define('MSG_DISINVITE', 7); |
|
27 | +define('MSG_DELEGATED', 8); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Class to access AND manipulate all calendar data (business object) |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function __construct() |
93 | 93 | { |
94 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
94 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
95 | 95 | |
96 | - parent::__construct(); // calling the parent constructor |
|
96 | + parent::__construct(); // calling the parent constructor |
|
97 | 97 | |
98 | 98 | $this->resources_so = new resources_so(); |
99 | 99 | |
100 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
100 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -124,16 +124,16 @@ discard block |
||
124 | 124 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
125 | 125 | * ++++++++ ++++++++ |
126 | 126 | */ |
127 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
127 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
128 | 128 | { |
129 | - unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
129 | + unset($updateTS); // ignored, as updating timestamps is required for sync! |
|
130 | 130 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
131 | 131 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
132 | 132 | |
133 | 133 | if ($this->debug > 1 || $this->debug == 'update') |
134 | 134 | { |
135 | 135 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
136 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
136 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
137 | 137 | } |
138 | 138 | // check some minimum requirements: |
139 | 139 | // - new events need start, end and title |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | // check if user has the permission to update / create the event |
164 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
165 | - $new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) && |
|
166 | - !$this->check_perms(Acl::ADD,0,$event['owner'])) |
|
164 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
165 | + $new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) && |
|
166 | + !$this->check_perms(Acl::ADD, 0, $event['owner'])) |
|
167 | 167 | { |
168 | - $messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner'])); |
|
168 | + $messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner'])); |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | if ($new_event) |
@@ -174,24 +174,24 @@ discard block |
||
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
177 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | // do we need to check, if user is allowed to invite the invited participants |
181 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
181 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
182 | 182 | { |
183 | 183 | // report removed participants back to user |
184 | - foreach($removed as $key => $account_id) |
|
184 | + foreach ($removed as $key => $account_id) |
|
185 | 185 | { |
186 | 186 | $removed[$key] = $this->participant_name($account_id); |
187 | 187 | } |
188 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
189 | - ': '.implode(', ',$removed); |
|
188 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
189 | + ': '.implode(', ', $removed); |
|
190 | 190 | } |
191 | 191 | // check category based ACL |
192 | 192 | if ($event['category']) |
193 | 193 | { |
194 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
194 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
195 | 195 | if (!$old_event || !isset($old_event['category'])) |
196 | 196 | { |
197 | 197 | $old_event['category'] = array(); |
@@ -200,38 +200,38 @@ discard block |
||
200 | 200 | { |
201 | 201 | $old_event['category'] = explode(',', $old_event['category']); |
202 | 202 | } |
203 | - foreach($event['category'] as $key => $cat_id) |
|
203 | + foreach ($event['category'] as $key => $cat_id) |
|
204 | 204 | { |
205 | 205 | // check if user is allowed to update event categories |
206 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
207 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
206 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
207 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
208 | 208 | { |
209 | 209 | unset($event['category'][$key]); |
210 | 210 | // report removed category to user |
211 | 211 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
212 | - continue; // no further check, as cat was removed |
|
212 | + continue; // no further check, as cat was removed |
|
213 | 213 | } |
214 | 214 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
215 | 215 | if (!$status_reset_to_unknown && |
216 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
216 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
217 | 217 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
218 | 218 | { |
219 | - foreach((array)$event['participants'] as $uid => $status) |
|
219 | + foreach ((array)$event['participants'] as $uid => $status) |
|
220 | 220 | { |
221 | 221 | $q = $r = null; |
222 | - calendar_so::split_status($status,$q,$r); |
|
222 | + calendar_so::split_status($status, $q, $r); |
|
223 | 223 | if ($status != 'U') |
224 | 224 | { |
225 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
225 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
226 | 226 | // todo: report reset status to user |
227 | 227 | } |
228 | 228 | } |
229 | - $status_reset_to_unknown = true; // once is enough |
|
229 | + $status_reset_to_unknown = true; // once is enough |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | if ($removed_cats) |
233 | 233 | { |
234 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
234 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
235 | 235 | } |
236 | 236 | if ($status_reset_to_unknown) |
237 | 237 | { |
@@ -267,30 +267,30 @@ discard block |
||
267 | 267 | $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); |
268 | 268 | //error_log("new $cal_id=". array2string($event)); |
269 | 269 | |
270 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
270 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
271 | 271 | { |
272 | 272 | // Restored, bring back links |
273 | 273 | Link::restore('calendar', $cal_id); |
274 | 274 | } |
275 | 275 | if ($this->log_file) |
276 | 276 | { |
277 | - $this->log2file($event2save,$event,$old_event); |
|
277 | + $this->log2file($event2save, $event, $old_event); |
|
278 | 278 | } |
279 | 279 | // send notifications |
280 | - if(!$skip_notification) |
|
280 | + if (!$skip_notification) |
|
281 | 281 | { |
282 | 282 | if ($new_event) |
283 | 283 | { |
284 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
284 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
285 | 285 | } |
286 | 286 | else // update existing event |
287 | 287 | { |
288 | - $this->check4update($event,$old_event); |
|
288 | + $this->check4update($event, $old_event); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | 292 | // notify the link-class about the update, as other apps may be subscribt to it |
293 | - Link::notify_update('calendar',$cal_id,$event); |
|
293 | + Link::notify_update('calendar', $cal_id, $event); |
|
294 | 294 | |
295 | 295 | return $cal_id; |
296 | 296 | } |
@@ -308,27 +308,27 @@ discard block |
||
308 | 308 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
309 | 309 | * @return array or events |
310 | 310 | */ |
311 | - function conflicts(array $event, &$checked_excluding=null) |
|
311 | + function conflicts(array $event, &$checked_excluding = null) |
|
312 | 312 | { |
313 | 313 | $types_with_quantity = array(); |
314 | - foreach($this->resources as $type => $data) |
|
314 | + foreach ($this->resources as $type => $data) |
|
315 | 315 | { |
316 | 316 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
317 | 317 | } |
318 | 318 | // get all NOT rejected participants and evtl. their quantity |
319 | 319 | $quantity = $users = array(); |
320 | - foreach($event['participants'] as $uid => $status) |
|
320 | + foreach ($event['participants'] as $uid => $status) |
|
321 | 321 | { |
322 | 322 | $q = $role = null; |
323 | 323 | calendar_so::split_status($status, $q, $role); |
324 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
324 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
325 | 325 | |
326 | 326 | if ($uid < 0) // group, check it's members too |
327 | 327 | { |
328 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
328 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
329 | 329 | } |
330 | 330 | $users[] = $uid; |
331 | - if (in_array($uid[0],$types_with_quantity)) |
|
331 | + if (in_array($uid[0], $types_with_quantity)) |
|
332 | 332 | { |
333 | 333 | $quantity[$uid] = $q; |
334 | 334 | } |
@@ -351,58 +351,58 @@ discard block |
||
351 | 351 | } |
352 | 352 | $checked = 0; |
353 | 353 | $start = microtime(true); |
354 | - $duration = $event['end']-$event['start']; |
|
355 | - foreach($recurences as $date) |
|
354 | + $duration = $event['end'] - $event['start']; |
|
355 | + foreach ($recurences as $date) |
|
356 | 356 | { |
357 | 357 | $startts = $date->format('ts'); |
358 | 358 | |
359 | 359 | // skip past events or recurrences |
360 | - if ($startts+$duration < $this->now_su) continue; |
|
360 | + if ($startts + $duration < $this->now_su) continue; |
|
361 | 361 | |
362 | 362 | // abort check if configured limits are exceeded |
363 | 363 | if ($event['recur_type'] && |
364 | 364 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
365 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
365 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
366 | 366 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
367 | 367 | { |
368 | 368 | if ($this->debug > 2 || $this->debug == 'conflicts') |
369 | 369 | { |
370 | 370 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
371 | - $checked, microtime(true)-$start, $date); |
|
371 | + $checked, microtime(true) - $start, $date); |
|
372 | 372 | } |
373 | 373 | $checked_excluding = $date; |
374 | 374 | break; |
375 | 375 | } |
376 | - $overlapping_events =& $this->search(array( |
|
376 | + $overlapping_events = & $this->search(array( |
|
377 | 377 | 'start' => $startts, |
378 | - 'end' => $startts+$duration, |
|
378 | + 'end' => $startts + $duration, |
|
379 | 379 | 'users' => $users, |
380 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
381 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
380 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
381 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
382 | 382 | 'query' => array( |
383 | 383 | 'cal_non_blocking' => 0, |
384 | 384 | ), |
385 | - 'no_integration' => true, // do NOT use integration of other apps |
|
385 | + 'no_integration' => true, // do NOT use integration of other apps |
|
386 | 386 | )); |
387 | 387 | if ($this->debug > 2 || $this->debug == 'conflicts') |
388 | 388 | { |
389 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
389 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
390 | 390 | } |
391 | - foreach((array) $overlapping_events as $k => $overlap) |
|
391 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
392 | 392 | { |
393 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
394 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
393 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
394 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
395 | 395 | $overlap['non_blocking']) // that's a non_blocking event |
396 | 396 | { |
397 | 397 | continue; |
398 | 398 | } |
399 | 399 | if ($this->debug > 3 || $this->debug == 'conflicts') |
400 | 400 | { |
401 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
401 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
402 | 402 | } |
403 | 403 | // check if the overlap is with a rejected participant or within the allowed quantity |
404 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
405 | - foreach($common_parts as $n => $uid) |
|
404 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
405 | + foreach ($common_parts as $n => $uid) |
|
406 | 406 | { |
407 | 407 | $status = $overlap['participants'][$uid]; |
408 | 408 | calendar_so::split_status($status, $q, $role); |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | unset($common_parts[$n]); |
412 | 412 | continue; |
413 | 413 | } |
414 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
414 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
415 | 415 | { |
416 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
416 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
417 | 417 | } |
418 | 418 | if (!isset($max_quantity[$uid])) |
419 | 419 | { |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $quantity[$uid] += $q; |
424 | 424 | if ($quantity[$uid] <= $max_quantity[$uid]) |
425 | 425 | { |
426 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
426 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
427 | 427 | unset($common_parts[$n]); |
428 | 428 | continue; |
429 | 429 | } |
@@ -433,22 +433,22 @@ discard block |
||
433 | 433 | { |
434 | 434 | if ($this->debug > 3 || $this->debug == 'conflicts') |
435 | 435 | { |
436 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
436 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
437 | 437 | } |
438 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
438 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
442 | 442 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
443 | 443 | // check if we are withing the allowed quantity and if not add all events using that resource |
444 | 444 | // seems this function is doing very strange things, it gives empty conflicts |
445 | - foreach($max_quantity as $uid => $max) |
|
445 | + foreach ($max_quantity as $uid => $max) |
|
446 | 446 | { |
447 | 447 | if ($quantity[$uid] > $max) |
448 | 448 | { |
449 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
449 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
450 | 450 | { |
451 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
451 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | } |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | |
457 | 457 | if (count($conflicts)) |
458 | 458 | { |
459 | - foreach($conflicts as $key => $conflict) |
|
459 | + foreach ($conflicts as $key => $conflict) |
|
460 | 460 | { |
461 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
462 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
461 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
462 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
463 | 463 | { |
464 | 464 | $conflicts[$key] = array( |
465 | 465 | 'id' => $conflict['id'], |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | if ($this->debug > 2 || $this->debug == 'conflicts') |
474 | 474 | { |
475 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
475 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | return $conflicts; |
@@ -484,22 +484,22 @@ discard block |
||
484 | 484 | * @param array $old_event =null old event with already invited participants |
485 | 485 | * @return array removed participants because of missing invite grants |
486 | 486 | */ |
487 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
487 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
488 | 488 | { |
489 | 489 | if (!$this->require_acl_invite) |
490 | 490 | { |
491 | - return array(); // nothing to check, everyone can invite everyone else |
|
491 | + return array(); // nothing to check, everyone can invite everyone else |
|
492 | 492 | } |
493 | 493 | if ($event['id'] && is_null($old_event)) |
494 | 494 | { |
495 | 495 | $old_event = $this->read($event['id']); |
496 | 496 | } |
497 | 497 | $removed = array(); |
498 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
498 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
499 | 499 | { |
500 | 500 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
501 | 501 | { |
502 | - unset($event['participants'][$uid]); // remove participant |
|
502 | + unset($event['participants'][$uid]); // remove participant |
|
503 | 503 | $removed[] = $uid; |
504 | 504 | } |
505 | 505 | } |
@@ -529,15 +529,15 @@ discard block |
||
529 | 529 | } |
530 | 530 | elseif (!$this->require_acl_invite) |
531 | 531 | { |
532 | - $ret = true; // no grant required |
|
532 | + $ret = true; // no grant required |
|
533 | 533 | } |
534 | 534 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
535 | 535 | { |
536 | - $ret = true; // grant only required for groups |
|
536 | + $ret = true; // grant only required for groups |
|
537 | 537 | } |
538 | 538 | else |
539 | 539 | { |
540 | - $ret = $this->check_perms(self::ACL_INVITE,0,$uid); |
|
540 | + $ret = $this->check_perms(self::ACL_INVITE, 0, $uid); |
|
541 | 541 | } |
542 | 542 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
543 | 543 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * @param array $old_event the event before the update |
552 | 552 | * @todo check if there is a real change, not assume every save is a change |
553 | 553 | */ |
554 | - function check4update($new_event,$old_event) |
|
554 | + function check4update($new_event, $old_event) |
|
555 | 555 | { |
556 | 556 | //error_log(__METHOD__."($new_event[title])"); |
557 | 557 | $modified = $added = $deleted = array(); |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
560 | 560 | |
561 | 561 | // Find modified and deleted participants ... |
562 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
562 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
563 | 563 | { |
564 | - if(isset($new_event['participants'][$old_userid])) |
|
564 | + if (isset($new_event['participants'][$old_userid])) |
|
565 | 565 | { |
566 | 566 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
567 | 567 | } |
@@ -571,27 +571,27 @@ discard block |
||
571 | 571 | } |
572 | 572 | } |
573 | 573 | // Find new participants ... |
574 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
574 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
575 | 575 | { |
576 | - if(!isset($old_event['participants'][$new_userid])) |
|
576 | + if (!isset($old_event['participants'][$new_userid])) |
|
577 | 577 | { |
578 | 578 | $added[$new_userid] = 'U'; |
579 | 579 | } |
580 | 580 | } |
581 | 581 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
582 | - if(count($added) || count($modified) || count($deleted)) |
|
582 | + if (count($added) || count($modified) || count($deleted)) |
|
583 | 583 | { |
584 | - if(count($added)) |
|
584 | + if (count($added)) |
|
585 | 585 | { |
586 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
586 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
587 | 587 | } |
588 | - if(count($modified)) |
|
588 | + if (count($modified)) |
|
589 | 589 | { |
590 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
590 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
591 | 591 | } |
592 | - if(count($deleted)) |
|
592 | + if (count($deleted)) |
|
593 | 593 | { |
594 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
594 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | } |
@@ -608,11 +608,11 @@ discard block |
||
608 | 608 | * @param string $status of current user |
609 | 609 | * @return boolean true = update requested, false otherwise |
610 | 610 | */ |
611 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
611 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
612 | 612 | { |
613 | 613 | if ($msg_type == MSG_ALARM) |
614 | 614 | { |
615 | - return True; // always True for now |
|
615 | + return True; // always True for now |
|
616 | 616 | } |
617 | 617 | $want_update = 0; |
618 | 618 | |
@@ -625,13 +625,13 @@ discard block |
||
625 | 625 | if (!is_numeric($userid) && $role == 'CHAIR' && |
626 | 626 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
627 | 627 | { |
628 | - switch($msg_type) |
|
628 | + switch ($msg_type) |
|
629 | 629 | { |
630 | 630 | case MSG_DELETED: // treat deleting event as rejection to organizer |
631 | 631 | $msg_type = MSG_REJECTED; |
632 | 632 | break; |
633 | 633 | case MSG_ADDED: // new events use added, but organizer needs status |
634 | - switch($status[0]) |
|
634 | + switch ($status[0]) |
|
635 | 635 | { |
636 | 636 | case 'A': $msg_type = MSG_ACCEPTED; break; |
637 | 637 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | } |
645 | 645 | else |
646 | 646 | { |
647 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
647 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
648 | 648 | { |
649 | 649 | case 'responses': |
650 | 650 | ++$want_update; |
@@ -658,8 +658,8 @@ discard block |
||
658 | 658 | default: |
659 | 659 | if (is_array($new_event) && is_array($old_event)) |
660 | 660 | { |
661 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
662 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
661 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
662 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
663 | 663 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
664 | 664 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
665 | 665 | { |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @param string $role ='REQ-PARTICIPANT' |
688 | 688 | * @return boolean true if user requested to be notified, false if not |
689 | 689 | */ |
690 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
690 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
691 | 691 | { |
692 | 692 | // check if email is from a user |
693 | 693 | if (is_numeric($user_or_email)) |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | ) |
712 | 712 | ); |
713 | 713 | } |
714 | - switch($ical_method) |
|
714 | + switch ($ical_method) |
|
715 | 715 | { |
716 | 716 | default: |
717 | 717 | case 'REQUEST': |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | * @param string& $action=null on return verbose name |
737 | 737 | * @param string& $msg=null on return notification message |
738 | 738 | */ |
739 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
739 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
740 | 740 | { |
741 | - switch($msg_type) |
|
741 | + switch ($msg_type) |
|
742 | 742 | { |
743 | 743 | case MSG_DELETED: |
744 | 744 | $action = 'Canceled'; |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | $msg = $this->cal_prefs['notify'.$pref]; |
791 | 791 | if (empty($msg)) |
792 | 792 | { |
793 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
793 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
794 | 794 | } |
795 | 795 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
796 | 796 | return $method; |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @param int $user =0 User who started the notify, default current user |
807 | 807 | * @return bool true/false |
808 | 808 | */ |
809 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
809 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
810 | 810 | { |
811 | 811 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
812 | 812 | if (!is_array($to_notify)) |
@@ -818,11 +818,11 @@ discard block |
||
818 | 818 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
819 | 819 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
820 | 820 | { |
821 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
821 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
825 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
825 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
826 | 826 | { |
827 | 827 | return False; |
828 | 828 | } |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | $restore_tz = $tz; |
833 | 833 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
834 | 834 | } |
835 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
835 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
836 | 836 | |
837 | 837 | if (!$user) |
838 | 838 | { |
@@ -848,16 +848,16 @@ discard block |
||
848 | 848 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
849 | 849 | |
850 | 850 | // add all group-members to the notification, unless they are already participants |
851 | - foreach($to_notify as $userid => $statusid) |
|
851 | + foreach ($to_notify as $userid => $statusid) |
|
852 | 852 | { |
853 | 853 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
854 | 854 | ($members = $GLOBALS['egw']->accounts->members($userid, true))) |
855 | 855 | { |
856 | - foreach($members as $member) |
|
856 | + foreach ($members as $member) |
|
857 | 857 | { |
858 | 858 | if (!isset($to_notify[$member])) |
859 | 859 | { |
860 | - $to_notify[$member] = 'G'; // Group-invitation |
|
860 | + $to_notify[$member] = 'G'; // Group-invitation |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | } |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | { |
869 | 869 | // check if we have *only* an external chair |
870 | 870 | $chair = null; |
871 | - foreach($to_notify as $userid => $statusid) |
|
871 | + foreach ($to_notify as $userid => $statusid) |
|
872 | 872 | { |
873 | 873 | $res_info = $quantity = $role = null; |
874 | 874 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | // *only* an external chair --> do not notify anyone, but the external chair and the current user |
881 | 881 | if (!empty($chair) && !is_numeric($chair)) |
882 | 882 | { |
883 | - $to_notify = array($chair => $to_notify[$chair])+ |
|
883 | + $to_notify = array($chair => $to_notify[$chair]) + |
|
884 | 884 | (isset($to_notify[$user]) ? array($user => $to_notify[$user]) : array()); |
885 | 885 | } |
886 | 886 | } |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
892 | 892 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
893 | 893 | $owner_prefs = $ics = null; |
894 | - foreach($to_notify as $userid => $statusid) |
|
894 | + foreach ($to_notify as $userid => $statusid) |
|
895 | 895 | { |
896 | 896 | $res_info = $quantity = $role = null; |
897 | 897 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -914,14 +914,14 @@ discard block |
||
914 | 914 | |
915 | 915 | if (!isset($userid)) |
916 | 916 | { |
917 | - if (empty($res_info['email'])) continue; // no way to notify |
|
917 | + if (empty($res_info['email'])) continue; // no way to notify |
|
918 | 918 | // check if event-owner wants non-EGroupware users notified |
919 | 919 | if (is_null($owner_prefs)) |
920 | 920 | { |
921 | 921 | $preferences = new Api\Preferences($owner); |
922 | 922 | $owner_prefs = $preferences->read_repository(); |
923 | 923 | } |
924 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
924 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
925 | 925 | (empty($owner_prefs['calendar']['notify_externals']) || |
926 | 926 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
927 | 927 | { |
@@ -933,12 +933,12 @@ discard block |
||
933 | 933 | |
934 | 934 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
935 | 935 | { |
936 | - continue; // dont notify rejected participants or groups |
|
936 | + continue; // dont notify rejected participants or groups |
|
937 | 937 | } |
938 | 938 | |
939 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
939 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
940 | 940 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
941 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
941 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
942 | 942 | $msg_type == MSG_ALARM) |
943 | 943 | { |
944 | 944 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -947,8 +947,8 @@ discard block |
||
947 | 947 | $preferences = new Api\Preferences($userid); |
948 | 948 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
949 | 949 | $fullname = Api\Accounts::username($userid); |
950 | - $tfn = Api\Accounts::id2name($userid,'account_firstname'); |
|
951 | - $tln = Api\Accounts::id2name($userid,'account_lastname'); |
|
950 | + $tfn = Api\Accounts::id2name($userid, 'account_firstname'); |
|
951 | + $tln = Api\Accounts::id2name($userid, 'account_lastname'); |
|
952 | 952 | } |
953 | 953 | else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
954 | 954 | { |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | } |
960 | 960 | $part_prefs = $owner_prefs; |
961 | 961 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
962 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
962 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
963 | 963 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
964 | 964 | } |
965 | 965 | $m_type = $msg_type; |
@@ -984,14 +984,14 @@ discard block |
||
984 | 984 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
985 | 985 | $action, $event_arr, $disinvited); |
986 | 986 | $details['to-fullname'] = $fullname; |
987 | - $details['to-firstname'] = isset($tfn)? $tfn: ''; |
|
988 | - $details['to-lastname'] = isset($tln)? $tln: ''; |
|
987 | + $details['to-firstname'] = isset($tfn) ? $tfn : ''; |
|
988 | + $details['to-lastname'] = isset($tln) ? $tln : ''; |
|
989 | 989 | |
990 | 990 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
991 | 991 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
992 | 992 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
993 | 993 | $timeformat = $part_prefs['common']['timeformat']; |
994 | - switch($timeformat) |
|
994 | + switch ($timeformat) |
|
995 | 995 | { |
996 | 996 | case '24': |
997 | 997 | $timeformat = 'H:i'; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | $timeformat = 'h:i a'; |
1001 | 1001 | break; |
1002 | 1002 | } |
1003 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
1003 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
1004 | 1004 | |
1005 | 1005 | $startdate->setTimezone($timezone); |
1006 | 1006 | $details['startdate'] = $startdate->format($timeformat); |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | $details['enddate'] = $enddate->format($timeformat); |
1010 | 1010 | |
1011 | 1011 | $modified->setTimezone($timezone); |
1012 | - $details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']); |
|
1012 | + $details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']); |
|
1013 | 1013 | |
1014 | 1014 | if ($old_event != False) |
1015 | 1015 | { |
@@ -1018,15 +1018,14 @@ discard block |
||
1018 | 1018 | } |
1019 | 1019 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
1020 | 1020 | |
1021 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
1021 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
1022 | 1022 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
1023 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
1023 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
1024 | 1024 | { |
1025 | - case 'ical': |
|
1026 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1025 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1027 | 1026 | { |
1028 | 1027 | $calendar_ical = new calendar_ical(); |
1029 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
1028 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
1030 | 1029 | // we need to pass $event[id] so iCal class reads event again, |
1031 | 1030 | // as event is in user TZ, but iCal class expects server TZ! |
1032 | 1031 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1047,11 +1046,11 @@ discard block |
||
1047 | 1046 | case 'extended': |
1048 | 1047 | |
1049 | 1048 | $details_body = lang('Event Details follow').":\n"; |
1050 | - foreach($event_arr as $key => $val) |
|
1049 | + foreach ($event_arr as $key => $val) |
|
1051 | 1050 | { |
1052 | - if(!empty($details[$key])) |
|
1051 | + if (!empty($details[$key])) |
|
1053 | 1052 | { |
1054 | - switch($key) |
|
1053 | + switch ($key) |
|
1055 | 1054 | { |
1056 | 1055 | case 'access': |
1057 | 1056 | case 'priority': |
@@ -1060,7 +1059,7 @@ discard block |
||
1060 | 1059 | case 'title': |
1061 | 1060 | break; |
1062 | 1061 | default: |
1063 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
1062 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
1064 | 1063 | break; |
1065 | 1064 | } |
1066 | 1065 | } |
@@ -1068,7 +1067,7 @@ discard block |
||
1068 | 1067 | break; |
1069 | 1068 | } |
1070 | 1069 | // send via notification_app |
1071 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
1070 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
1072 | 1071 | { |
1073 | 1072 | try { |
1074 | 1073 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1090,7 +1089,7 @@ discard block |
||
1090 | 1089 | // popup notifiactions: set subject, different message (without separator) and (always) links |
1091 | 1090 | $notification->set_popupsubject($subject); |
1092 | 1091 | |
1093 | - if ($method =='REQUEST') |
|
1092 | + if ($method == 'REQUEST') |
|
1094 | 1093 | { |
1095 | 1094 | // Add ACCEPT|REHECT|TENTATIVE actions |
1096 | 1095 | $notification->set_popupdata('calendar', array( |
@@ -1101,11 +1100,11 @@ discard block |
||
1101 | 1100 | } |
1102 | 1101 | if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
1103 | 1102 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
1104 | - $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
|
1103 | + $notification->set_popuplinks(array($details['link_arr'] + array('app'=>'calendar'))); |
|
1105 | 1104 | |
1106 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1105 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1107 | 1106 | $notification->send(); |
1108 | - foreach(notifications::errors(true) as $error) |
|
1107 | + foreach (notifications::errors(true) as $error) |
|
1109 | 1108 | { |
1110 | 1109 | error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error"); |
1111 | 1110 | } |
@@ -1144,14 +1143,14 @@ discard block |
||
1144 | 1143 | return true; |
1145 | 1144 | } |
1146 | 1145 | |
1147 | - function get_update_message($event,$added) |
|
1146 | + function get_update_message($event, $added) |
|
1148 | 1147 | { |
1149 | 1148 | $nul = null; |
1150 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
1149 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
1151 | 1150 | |
1152 | 1151 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
1153 | 1152 | |
1154 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
1153 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
1155 | 1154 | } |
1156 | 1155 | |
1157 | 1156 | /** |
@@ -1165,37 +1164,37 @@ discard block |
||
1165 | 1164 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
1166 | 1165 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
1167 | 1166 | |
1168 | - $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1169 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
1167 | + $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1168 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
1170 | 1169 | { |
1171 | - return False; // event not found |
|
1170 | + return False; // event not found |
|
1172 | 1171 | } |
1173 | 1172 | if ($alarm['all']) |
1174 | 1173 | { |
1175 | 1174 | $to_notify = $event['participants']; |
1176 | 1175 | } |
1177 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1176 | + elseif ($this->check_perms(Acl::READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
1178 | 1177 | { |
1179 | 1178 | $to_notify[$alarm['owner']] = 'A'; |
1180 | 1179 | } |
1181 | 1180 | else |
1182 | 1181 | { |
1183 | - return False; // no rights |
|
1182 | + return False; // no rights |
|
1184 | 1183 | } |
1185 | 1184 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
1186 | 1185 | Api\Translation::add_app('calendar'); |
1187 | 1186 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
1188 | 1187 | |
1189 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
1188 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
1190 | 1189 | |
1191 | 1190 | // create a new alarm for recuring events for the next event, if one exists |
1192 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
1191 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
1193 | 1192 | { |
1194 | 1193 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
1195 | 1194 | unset($alarm['times']); |
1196 | 1195 | unset($alarm['next']); |
1197 | 1196 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
1198 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1197 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1199 | 1198 | } |
1200 | 1199 | return $ret; |
1201 | 1200 | } |
@@ -1211,14 +1210,14 @@ discard block |
||
1211 | 1210 | * Please note: you should ALLWAYS update timestamps, as they are required for sync! |
1212 | 1211 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
1213 | 1212 | */ |
1214 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
1213 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
1215 | 1214 | { |
1216 | 1215 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
1217 | 1216 | |
1218 | 1217 | // check if user has the permission to update / create the event |
1219 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
1220 | - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && |
|
1221 | - !$this->check_perms(Acl::ADD,0,$event['owner']))) |
|
1218 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
1219 | + !$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) && |
|
1220 | + !$this->check_perms(Acl::ADD, 0, $event['owner']))) |
|
1222 | 1221 | { |
1223 | 1222 | return false; |
1224 | 1223 | } |
@@ -1239,7 +1238,7 @@ discard block |
||
1239 | 1238 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
1240 | 1239 | { |
1241 | 1240 | $event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
1242 | - $event['recur_enddate']->setTime(23,59,59); |
|
1241 | + $event['recur_enddate']->setTime(23, 59, 59); |
|
1243 | 1242 | $rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName()); |
1244 | 1243 | $rrule->rewind(); |
1245 | 1244 | $enddate = $rrule->current(); |
@@ -1298,19 +1297,19 @@ discard block |
||
1298 | 1297 | |
1299 | 1298 | $event['recur_enddate'] = $save_event['recur_enddate'] = $time; |
1300 | 1299 | } |
1301 | - $timestamps = array('modified','created'); |
|
1300 | + $timestamps = array('modified', 'created'); |
|
1302 | 1301 | // all-day events are handled in server time |
1303 | 1302 | // $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName(); |
1304 | 1303 | } |
1305 | 1304 | else |
1306 | 1305 | { |
1307 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
1306 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
1308 | 1307 | } |
1309 | 1308 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
1310 | - foreach($timestamps as $ts) |
|
1309 | + foreach ($timestamps as $ts) |
|
1311 | 1310 | { |
1312 | 1311 | // we convert here from user-time to timestamps in server-time! |
1313 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1312 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
1314 | 1313 | } |
1315 | 1314 | // convert tzid name to integer tz_id, of set user default |
1316 | 1315 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1320,7 +1319,7 @@ discard block |
||
1320 | 1319 | // same with the recur exceptions |
1321 | 1320 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
1322 | 1321 | { |
1323 | - foreach($event['recur_exception'] as &$date) |
|
1322 | + foreach ($event['recur_exception'] as &$date) |
|
1324 | 1323 | { |
1325 | 1324 | if ($event['whole_day']) |
1326 | 1325 | { |
@@ -1329,7 +1328,7 @@ discard block |
||
1329 | 1328 | } |
1330 | 1329 | else |
1331 | 1330 | { |
1332 | - $date = $this->date2ts($date,true); |
|
1331 | + $date = $this->date2ts($date, true); |
|
1333 | 1332 | } |
1334 | 1333 | } |
1335 | 1334 | unset($date); |
@@ -1337,7 +1336,7 @@ discard block |
||
1337 | 1336 | // same with the alarms |
1338 | 1337 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
1339 | 1338 | { |
1340 | - foreach($event['alarm'] as $id => &$alarm) |
|
1339 | + foreach ($event['alarm'] as $id => &$alarm) |
|
1341 | 1340 | { |
1342 | 1341 | // remove alarms belonging to not longer existing or rejected participants |
1343 | 1342 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1350,21 +1349,20 @@ discard block |
||
1350 | 1349 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
1351 | 1350 | } |
1352 | 1351 | } |
1353 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
1352 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
1354 | 1353 | } |
1355 | 1354 | } |
1356 | 1355 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
1357 | 1356 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
1358 | 1357 | { |
1359 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
1358 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
1360 | 1359 | { |
1361 | 1360 | if (!isset($event['alarm'][$id])) |
1362 | 1361 | { |
1363 | 1362 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1364 | 1363 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
1365 | 1364 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1366 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
1367 | - $old_event['participants'][$alarm['owner']]; |
|
1365 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
1368 | 1366 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
1369 | 1367 | { |
1370 | 1368 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1393,7 +1391,7 @@ discard block |
||
1393 | 1391 | } |
1394 | 1392 | $set_recurrences = $old_event ? abs($event['recur_enddate'] - $old_event['recur_enddate']) > 1 : false; |
1395 | 1393 | $set_recurrences_start = 0; |
1396 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1394 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1397 | 1395 | { |
1398 | 1396 | $save_event['id'] = $cal_id; |
1399 | 1397 | // unset participants to enforce the default stati for all added recurrences |
@@ -1404,7 +1402,7 @@ discard block |
||
1404 | 1402 | // create links for new participants from addressbook, if configured |
1405 | 1403 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
1406 | 1404 | { |
1407 | - foreach($event['participants'] as $uid => $status) |
|
1405 | + foreach ($event['participants'] as $uid => $status) |
|
1408 | 1406 | { |
1409 | 1407 | $user_type = $user_id = null; |
1410 | 1408 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1417,7 +1415,7 @@ discard block |
||
1417 | 1415 | |
1418 | 1416 | // Update history |
1419 | 1417 | $tracking = new calendar_tracking($this); |
1420 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1418 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
1421 | 1419 | $tracking->track($event, $old_event); |
1422 | 1420 | |
1423 | 1421 | return $cal_id; |
@@ -1432,16 +1430,16 @@ discard block |
||
1432 | 1430 | * @param array|int $event event array or id of the event |
1433 | 1431 | * @return boolean |
1434 | 1432 | */ |
1435 | - function check_status_perms($uid,$event) |
|
1433 | + function check_status_perms($uid, $event) |
|
1436 | 1434 | { |
1437 | 1435 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
1438 | 1436 | { |
1439 | 1437 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1440 | 1438 | |
1441 | - return $this->check_perms(Acl::EDIT,0,$event['owner']); |
|
1439 | + return $this->check_perms(Acl::EDIT, 0, $event['owner']); |
|
1442 | 1440 | } |
1443 | 1441 | // check if we have a category Acl for the event or not (null) |
1444 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
1442 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
1445 | 1443 | if (!is_null($access)) |
1446 | 1444 | { |
1447 | 1445 | return $access; |
@@ -1458,10 +1456,10 @@ discard block |
||
1458 | 1456 | // regular user and groups (need to check memberships too) |
1459 | 1457 | if (!isset($event['participants'][$uid])) |
1460 | 1458 | { |
1461 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
1459 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
1462 | 1460 | } |
1463 | 1461 | $memberships[] = $uid; |
1464 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid); |
|
1462 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid); |
|
1465 | 1463 | } |
1466 | 1464 | |
1467 | 1465 | /** |
@@ -1475,16 +1473,16 @@ discard block |
||
1475 | 1473 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1476 | 1474 | * null = cat has no acl |
1477 | 1475 | */ |
1478 | - function check_cat_acl($right,$event) |
|
1476 | + function check_cat_acl($right, $event) |
|
1479 | 1477 | { |
1480 | 1478 | if (!is_array($event)) $event = $this->read($event); |
1481 | 1479 | |
1482 | 1480 | $ret = null; |
1483 | 1481 | if ($event['category']) |
1484 | 1482 | { |
1485 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
1483 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
1486 | 1484 | { |
1487 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
1485 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
1488 | 1486 | if ($access === true) |
1489 | 1487 | { |
1490 | 1488 | $ret = true; |
@@ -1492,7 +1490,7 @@ discard block |
||
1492 | 1490 | } |
1493 | 1491 | if ($access === false) |
1494 | 1492 | { |
1495 | - $ret = false; // cat denies access --> check further cats |
|
1493 | + $ret = false; // cat denies access --> check further cats |
|
1496 | 1494 | } |
1497 | 1495 | } |
1498 | 1496 | } |
@@ -1513,12 +1511,12 @@ discard block |
||
1513 | 1511 | * @param int $cat_id =null null to return array with all cats |
1514 | 1512 | * @return array with account_id => right pairs |
1515 | 1513 | */ |
1516 | - public static function get_cat_rights($cat_id=null) |
|
1514 | + public static function get_cat_rights($cat_id = null) |
|
1517 | 1515 | { |
1518 | 1516 | if (!isset(self::$cat_rights_cache)) |
1519 | 1517 | { |
1520 | - self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights', |
|
1521 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
1518 | + self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights', |
|
1519 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
1522 | 1520 | } |
1523 | 1521 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
1524 | 1522 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1531,7 +1529,7 @@ discard block |
||
1531 | 1529 | * @param int $user |
1532 | 1530 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
1533 | 1531 | */ |
1534 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
1532 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
1535 | 1533 | { |
1536 | 1534 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1537 | 1535 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1541,15 +1539,15 @@ discard block |
||
1541 | 1539 | if ($rights) |
1542 | 1540 | { |
1543 | 1541 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
1544 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
1542 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
1545 | 1543 | } |
1546 | 1544 | else |
1547 | 1545 | { |
1548 | 1546 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1549 | 1547 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
1550 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
1548 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
1551 | 1549 | } |
1552 | - Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
1550 | + Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
1553 | 1551 | } |
1554 | 1552 | } |
1555 | 1553 | |
@@ -1560,9 +1558,9 @@ discard block |
||
1560 | 1558 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1561 | 1559 | * null = cat has no acl |
1562 | 1560 | */ |
1563 | - public static function has_cat_right($right,$cat_id,$user) |
|
1561 | + public static function has_cat_right($right, $cat_id, $user) |
|
1564 | 1562 | { |
1565 | - static $cache=null; |
|
1563 | + static $cache = null; |
|
1566 | 1564 | |
1567 | 1565 | if (!isset($cache[$cat_id])) |
1568 | 1566 | { |
@@ -1570,21 +1568,21 @@ discard block |
||
1570 | 1568 | $cat_rights = self::get_cat_rights($cat_id); |
1571 | 1569 | if (!is_null($cat_rights)) |
1572 | 1570 | { |
1573 | - static $memberships=null; |
|
1571 | + static $memberships = null; |
|
1574 | 1572 | if (is_null($memberships)) |
1575 | 1573 | { |
1576 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
1574 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
1577 | 1575 | $memberships[] = $user; |
1578 | 1576 | } |
1579 | - foreach($cat_rights as $uid => $value) |
|
1577 | + foreach ($cat_rights as $uid => $value) |
|
1580 | 1578 | { |
1581 | 1579 | $all |= $value; |
1582 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1580 | + if (in_array($uid, $memberships)) $own |= $value; |
|
1583 | 1581 | } |
1584 | 1582 | } |
1585 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
1583 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
1586 | 1584 | { |
1587 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
1585 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
1588 | 1586 | } |
1589 | 1587 | } |
1590 | 1588 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1604,13 +1602,13 @@ discard block |
||
1604 | 1602 | * @param boolean $skip_notification =false true: do not send notification messages |
1605 | 1603 | * @return int number of changed recurrences |
1606 | 1604 | */ |
1607 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
1605 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
1608 | 1606 | { |
1609 | 1607 | unset($updateTS); |
1610 | 1608 | |
1611 | 1609 | $cal_id = is_array($event) ? $event['id'] : $event; |
1612 | 1610 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
1613 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
1611 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
1614 | 1612 | { |
1615 | 1613 | return false; |
1616 | 1614 | } |
@@ -1619,16 +1617,16 @@ discard block |
||
1619 | 1617 | if ($this->log) |
1620 | 1618 | { |
1621 | 1619 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1622 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
1620 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
1623 | 1621 | } |
1624 | 1622 | $old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server'); |
1625 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
1626 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
1627 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
1623 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
1624 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
1625 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
1628 | 1626 | { |
1629 | 1627 | if ($status == 'R') // remove alarms belonging to rejected participants |
1630 | 1628 | { |
1631 | - foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1629 | + foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1632 | 1630 | { |
1633 | 1631 | if ((string)$alarm['owner'] === (string)$uid) |
1634 | 1632 | { |
@@ -1650,8 +1648,8 @@ discard block |
||
1650 | 1648 | if (isset($status2msg[$status]) && !$skip_notification) |
1651 | 1649 | { |
1652 | 1650 | if (!is_array($event)) $event = $this->read($cal_id); |
1653 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1654 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
1651 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
1652 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
1655 | 1653 | } |
1656 | 1654 | |
1657 | 1655 | // Update history |
@@ -1671,14 +1669,14 @@ discard block |
||
1671 | 1669 | * @param int $recur_date =0 date to change, or 0 = all since now |
1672 | 1670 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
1673 | 1671 | */ |
1674 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
1672 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
1675 | 1673 | { |
1676 | 1674 | if (!isset($new_event['participants'])) return; |
1677 | 1675 | |
1678 | 1676 | // check the old list against the new list |
1679 | 1677 | foreach ($old_event['participants'] as $userid => $status) |
1680 | 1678 | { |
1681 | - if (!isset($new_event['participants'][$userid])){ |
|
1679 | + if (!isset($new_event['participants'][$userid])) { |
|
1682 | 1680 | // Attendee will be deleted this way |
1683 | 1681 | $new_event['participants'][$userid] = 'G'; |
1684 | 1682 | } |
@@ -1691,7 +1689,7 @@ discard block |
||
1691 | 1689 | // write the changes |
1692 | 1690 | foreach ($new_event['participants'] as $userid => $status) |
1693 | 1691 | { |
1694 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
1692 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
1695 | 1693 | } |
1696 | 1694 | } |
1697 | 1695 | |
@@ -1706,43 +1704,43 @@ discard block |
||
1706 | 1704 | * @param int &$exceptions_kept=null on return number of kept exceptions |
1707 | 1705 | * @return boolean true on success, false on error (usually permission denied) |
1708 | 1706 | */ |
1709 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
1710 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
1707 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
1708 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
1711 | 1709 | { |
1712 | 1710 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
1713 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
1714 | - !$ignore_acl && !$this->check_perms(Acl::DELETE,$event)) |
|
1711 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
1712 | + !$ignore_acl && !$this->check_perms(Acl::DELETE, $event)) |
|
1715 | 1713 | { |
1716 | 1714 | return false; |
1717 | 1715 | } |
1718 | 1716 | |
1719 | 1717 | // Don't send notification if the event has already been deleted |
1720 | - if(!$event['deleted'] && !$skip_notification) |
|
1718 | + if (!$event['deleted'] && !$skip_notification) |
|
1721 | 1719 | { |
1722 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
1720 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
1723 | 1721 | } |
1724 | 1722 | |
1725 | 1723 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
1726 | 1724 | { |
1727 | 1725 | $config = Api\Config::read('phpgwapi'); |
1728 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
1726 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
1729 | 1727 | { |
1730 | 1728 | $this->so->delete($cal_id); |
1731 | 1729 | |
1732 | 1730 | // delete all links to the event |
1733 | - Link::unlink(0,'calendar',$cal_id); |
|
1731 | + Link::unlink(0, 'calendar', $cal_id); |
|
1734 | 1732 | } |
1735 | 1733 | elseif ($config['calendar_delete_history']) |
1736 | 1734 | { |
1737 | 1735 | // mark all links to the event as deleted, but keep them |
1738 | - Link::unlink(0,'calendar',$cal_id,'','','',true); |
|
1736 | + Link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
1739 | 1737 | |
1740 | 1738 | $event['deleted'] = $this->now; |
1741 | 1739 | $this->save($event, $ignore_acl); |
1742 | 1740 | // Actually delete alarms |
1743 | 1741 | if (isset($event['alarm']) && is_array($event['alarm'])) |
1744 | 1742 | { |
1745 | - foreach($event['alarm'] as $id => $alarm) |
|
1743 | + foreach ($event['alarm'] as $id => $alarm) |
|
1746 | 1744 | { |
1747 | 1745 | $this->delete_alarm($id); |
1748 | 1746 | } |
@@ -1764,7 +1762,7 @@ discard block |
||
1764 | 1762 | if (!($exception = $this->read($id))) continue; |
1765 | 1763 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
1766 | 1764 | $exception['reference'] = $exception['recurrence'] = 0; |
1767 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
1765 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
1768 | 1766 | ++$exceptions_kept; |
1769 | 1767 | } |
1770 | 1768 | } |
@@ -1776,9 +1774,9 @@ discard block |
||
1776 | 1774 | if ($event['alarm']) |
1777 | 1775 | { |
1778 | 1776 | $next_recurrance = null; |
1779 | - foreach($event['alarm'] as &$alarm) |
|
1777 | + foreach ($event['alarm'] as &$alarm) |
|
1780 | 1778 | { |
1781 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
1779 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
1782 | 1780 | { |
1783 | 1781 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
1784 | 1782 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1786,12 +1784,12 @@ discard block |
||
1786 | 1784 | { |
1787 | 1785 | $checkdate = $recur_date; |
1788 | 1786 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
1789 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
1787 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
1790 | 1788 | { |
1791 | 1789 | $next_recurrance = $this->date2ts($e['start']); |
1792 | 1790 | } |
1793 | 1791 | } |
1794 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1792 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1795 | 1793 | $alarm['cal_id'] = $cal_id; |
1796 | 1794 | unset($alarm['times']); |
1797 | 1795 | unset($alarm['next']); |
@@ -1805,7 +1803,7 @@ discard block |
||
1805 | 1803 | $event = $this->read($cal_id); |
1806 | 1804 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
1807 | 1805 | $event['recur_exception'][] = $recur_date; |
1808 | - $this->save($event);// updates the content-history |
|
1806 | + $this->save($event); // updates the content-history |
|
1809 | 1807 | } |
1810 | 1808 | if ($event['reference']) |
1811 | 1809 | { |
@@ -1823,19 +1821,19 @@ discard block |
||
1823 | 1821 | * @param array $disinvited |
1824 | 1822 | * @return array |
1825 | 1823 | */ |
1826 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
1824 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
1827 | 1825 | { |
1828 | 1826 | $details = array( // event-details for the notify-msg |
1829 | 1827 | 'id' => $event['id'], |
1830 | 1828 | 'action' => lang($action), |
1831 | 1829 | ); |
1832 | 1830 | $event_arr = $this->event2array($event); |
1833 | - foreach($event_arr as $key => $val) |
|
1831 | + foreach ($event_arr as $key => $val) |
|
1834 | 1832 | { |
1835 | 1833 | if ($key == 'recur_type') $key = 'repetition'; |
1836 | 1834 | $details[$key] = $val['data']; |
1837 | 1835 | } |
1838 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
1836 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
1839 | 1837 | |
1840 | 1838 | $event_arr['link']['field'] = lang('URL'); |
1841 | 1839 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1851,7 +1849,7 @@ discard block |
||
1851 | 1849 | */ |
1852 | 1850 | $link_arr = array(); |
1853 | 1851 | $link_arr['text'] = $event['title']; |
1854 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
1852 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
1855 | 1853 | 'cal_id' => $event['id'], |
1856 | 1854 | 'date' => $eventStart_arr['full'], |
1857 | 1855 | 'ajax' => true |
@@ -1860,11 +1858,11 @@ discard block |
||
1860 | 1858 | $details['link_arr'] = $link_arr; |
1861 | 1859 | |
1862 | 1860 | $dis = array(); |
1863 | - foreach($disinvited as $uid) |
|
1861 | + foreach ($disinvited as $uid) |
|
1864 | 1862 | { |
1865 | 1863 | $dis[] = $this->participant_name($uid); |
1866 | 1864 | } |
1867 | - $details['disinvited'] = implode(', ',$dis); |
|
1865 | + $details['disinvited'] = implode(', ', $dis); |
|
1868 | 1866 | return $details; |
1869 | 1867 | } |
1870 | 1868 | |
@@ -1888,13 +1886,13 @@ discard block |
||
1888 | 1886 | 'data' => $event['description'] |
1889 | 1887 | ); |
1890 | 1888 | |
1891 | - foreach(explode(',',$event['category']) as $cat_id) |
|
1889 | + foreach (explode(',', $event['category']) as $cat_id) |
|
1892 | 1890 | { |
1893 | 1891 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
1894 | 1892 | } |
1895 | 1893 | $var['category'] = Array( |
1896 | 1894 | 'field' => lang('Category'), |
1897 | - 'data' => implode(', ',$cat_string) |
|
1895 | + 'data' => implode(', ', $cat_string) |
|
1898 | 1896 | ); |
1899 | 1897 | |
1900 | 1898 | $var['location'] = Array( |
@@ -1940,10 +1938,10 @@ discard block |
||
1940 | 1938 | |
1941 | 1939 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
1942 | 1940 | { |
1943 | - $participants = $this->participants($event,true); |
|
1941 | + $participants = $this->participants($event, true); |
|
1944 | 1942 | |
1945 | 1943 | // fix external organiser to not be included as participant and shown as organiser |
1946 | - foreach($event['participants'] as $uid => $status) |
|
1944 | + foreach ($event['participants'] as $uid => $status) |
|
1947 | 1945 | { |
1948 | 1946 | $role = $quantity = null; |
1949 | 1947 | calendar_so::split_status($status, $quantity, $role); |
@@ -1977,26 +1975,26 @@ discard block |
||
1977 | 1975 | * @param array $old_event =null event-data in the DB before calling save |
1978 | 1976 | * @param string $type ='update' |
1979 | 1977 | */ |
1980 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
1978 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
1981 | 1979 | { |
1982 | - if (!($f = fopen($this->log_file,'a'))) |
|
1980 | + if (!($f = fopen($this->log_file, 'a'))) |
|
1983 | 1981 | { |
1984 | 1982 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
1985 | 1983 | return false; |
1986 | 1984 | } |
1987 | - fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
1988 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
1989 | - foreach(array('start','end') as $name) |
|
1985 | + fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
1986 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
1987 | + foreach (array('start', 'end') as $name) |
|
1990 | 1988 | { |
1991 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1992 | - $this->format_date($event_saved[$name]) .' / '. |
|
1989 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1990 | + $this->format_date($event_saved[$name]).' / '. |
|
1993 | 1991 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
1994 | 1992 | } |
1995 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
1993 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
1996 | 1994 | { |
1997 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
1995 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
1998 | 1996 | } |
1999 | - fwrite($f,"\n"); |
|
1997 | + fwrite($f, "\n"); |
|
2000 | 1998 | fclose($f); |
2001 | 1999 | |
2002 | 2000 | return true; |
@@ -2017,7 +2015,7 @@ discard block |
||
2017 | 2015 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
2018 | 2016 | |
2019 | 2017 | $time = new Api\DateTime($event['start']); |
2020 | - if(!is_array($event['alarm'])) |
|
2018 | + if (!is_array($event['alarm'])) |
|
2021 | 2019 | { |
2022 | 2020 | $event['alarm'] = $this->so->read_alarms($event['id']); |
2023 | 2021 | } |
@@ -2031,9 +2029,9 @@ discard block |
||
2031 | 2029 | $instance_date = $instance_date->format('ts'); |
2032 | 2030 | } |
2033 | 2031 | |
2034 | - foreach($event['alarm'] as &$alarm) |
|
2032 | + foreach ($event['alarm'] as &$alarm) |
|
2035 | 2033 | { |
2036 | - if($event['recur_type'] != MCAL_RECUR_NONE && $instance_date) |
|
2034 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $instance_date) |
|
2037 | 2035 | { |
2038 | 2036 | calendar_so::shift_alarm($event, $alarm, $instance_date); |
2039 | 2037 | } |
@@ -2053,14 +2051,14 @@ discard block |
||
2053 | 2051 | * @param boolean $update_modified =true call update modified, default true |
2054 | 2052 | * @return string id of the alarm, or false on error (eg. no perms) |
2055 | 2053 | */ |
2056 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
2054 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
2057 | 2055 | { |
2058 | - if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
2056 | + if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
2059 | 2057 | { |
2060 | 2058 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
2061 | - return false; // no rights to add the alarm |
|
2059 | + return false; // no rights to add the alarm |
|
2062 | 2060 | } |
2063 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
2061 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
2064 | 2062 | |
2065 | 2063 | return $this->so->save_alarm($cal_id, $alarm, $update_modified); |
2066 | 2064 | } |
@@ -2073,11 +2071,11 @@ discard block |
||
2073 | 2071 | */ |
2074 | 2072 | function delete_alarm($id) |
2075 | 2073 | { |
2076 | - list(,$cal_id) = explode(':',$id); |
|
2074 | + list(,$cal_id) = explode(':', $id); |
|
2077 | 2075 | |
2078 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
2076 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
2079 | 2077 | { |
2080 | - return false; // no rights to delete the alarm |
|
2078 | + return false; // no rights to delete the alarm |
|
2081 | 2079 | } |
2082 | 2080 | |
2083 | 2081 | return $this->so->delete_alarm($id); |
@@ -2092,13 +2090,13 @@ discard block |
||
2092 | 2090 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
2093 | 2091 | * @return array category ids (found, added and preserved categories) |
2094 | 2092 | */ |
2095 | - function find_or_add_categories($catname_list, $old_event=null) |
|
2093 | + function find_or_add_categories($catname_list, $old_event = null) |
|
2096 | 2094 | { |
2097 | 2095 | if (is_array($old_event) || $old_event > 0) |
2098 | 2096 | { |
2099 | 2097 | // preserve categories without users read access |
2100 | 2098 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
2101 | - $old_categories = explode(',',$old_event['category']); |
|
2099 | + $old_categories = explode(',', $old_event['category']); |
|
2102 | 2100 | $old_cats_preserve = array(); |
2103 | 2101 | if (is_array($old_categories) && count($old_categories) > 0) |
2104 | 2102 | { |
@@ -2152,7 +2150,7 @@ discard block |
||
2152 | 2150 | { |
2153 | 2151 | if (!is_array($cat_id_list)) |
2154 | 2152 | { |
2155 | - $cat_id_list = explode(',',$cat_id_list); |
|
2153 | + $cat_id_list = explode(',', $cat_id_list); |
|
2156 | 2154 | } |
2157 | 2155 | $cat_list = array(); |
2158 | 2156 | foreach ($cat_id_list as $cat_id) |
@@ -2177,7 +2175,7 @@ discard block |
||
2177 | 2175 | * master -> try to find a releated series master |
2178 | 2176 | * @return array calendar_ids of matching entries |
2179 | 2177 | */ |
2180 | - function find_event($event, $filter='exact') |
|
2178 | + function find_event($event, $filter = 'exact') |
|
2181 | 2179 | { |
2182 | 2180 | $matchingEvents = array(); |
2183 | 2181 | $query = array(); |
@@ -2185,14 +2183,14 @@ discard block |
||
2185 | 2183 | if ($this->log) |
2186 | 2184 | { |
2187 | 2185 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2188 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
2186 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
2189 | 2187 | } |
2190 | 2188 | |
2191 | 2189 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
2192 | 2190 | |
2193 | 2191 | if ($filter == 'master') |
2194 | 2192 | { |
2195 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
2193 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
2196 | 2194 | $query['cal_recurrence'] = 0; |
2197 | 2195 | } |
2198 | 2196 | elseif ($filter == 'exact') |
@@ -2213,14 +2211,14 @@ discard block |
||
2213 | 2211 | if ($this->log) |
2214 | 2212 | { |
2215 | 2213 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2216 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
2214 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
2217 | 2215 | } |
2218 | 2216 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
2219 | 2217 | { |
2220 | 2218 | if ($this->log) |
2221 | 2219 | { |
2222 | 2220 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2223 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2221 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2224 | 2222 | } |
2225 | 2223 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
2226 | 2224 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2239,7 +2237,7 @@ discard block |
||
2239 | 2237 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
2240 | 2238 | if (in_array($event['recurrence'], $exceptions)) |
2241 | 2239 | { |
2242 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
2240 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
2243 | 2241 | } |
2244 | 2242 | } |
2245 | 2243 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2258,19 +2256,19 @@ discard block |
||
2258 | 2256 | |
2259 | 2257 | // only query calendars of users, we have READ-grants from |
2260 | 2258 | $users = array(); |
2261 | - foreach(array_keys($this->grants) as $user) |
|
2259 | + foreach (array_keys($this->grants) as $user) |
|
2262 | 2260 | { |
2263 | 2261 | $user = trim($user); |
2264 | - if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
|
2262 | + if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user)) |
|
2265 | 2263 | { |
2266 | - if ($user && !in_array($user,$users)) // already added? |
|
2264 | + if ($user && !in_array($user, $users)) // already added? |
|
2267 | 2265 | { |
2268 | 2266 | $users[] = $user; |
2269 | 2267 | } |
2270 | 2268 | } |
2271 | 2269 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2272 | 2270 | { |
2273 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2271 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2274 | 2272 | } |
2275 | 2273 | // the further code is only for real users |
2276 | 2274 | if (!is_numeric($user)) continue; |
@@ -2281,7 +2279,7 @@ discard block |
||
2281 | 2279 | $members = $GLOBALS['egw']->accounts->members($user, true); |
2282 | 2280 | if (is_array($members)) |
2283 | 2281 | { |
2284 | - foreach($members as $member) |
|
2282 | + foreach ($members as $member) |
|
2285 | 2283 | { |
2286 | 2284 | // use only members which gave the user a read-grant |
2287 | 2285 | if (!in_array($member, $users) && |
@@ -2297,7 +2295,7 @@ discard block |
||
2297 | 2295 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
2298 | 2296 | if (is_array($memberships)) |
2299 | 2297 | { |
2300 | - foreach($memberships as $group) |
|
2298 | + foreach ($memberships as $group) |
|
2301 | 2299 | { |
2302 | 2300 | if (!in_array($group, $users)) |
2303 | 2301 | { |
@@ -2323,24 +2321,24 @@ discard block |
||
2323 | 2321 | |
2324 | 2322 | // check length with some tolerance |
2325 | 2323 | $length = $event['end'] - $event['start'] - $delta; |
2326 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
2324 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
2327 | 2325 | $length += 2 * $delta; |
2328 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
2329 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
2330 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
2326 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
2327 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
2328 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
2331 | 2329 | } |
2332 | 2330 | elseif (isset($event['start'])) |
2333 | 2331 | { |
2334 | 2332 | if ($filter == 'relax') |
2335 | 2333 | { |
2336 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
2337 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
2334 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
2335 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
2338 | 2336 | } |
2339 | 2337 | else |
2340 | 2338 | { |
2341 | 2339 | // we accept a tiny tolerance |
2342 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
2343 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
2340 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
2341 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
2344 | 2342 | } |
2345 | 2343 | } |
2346 | 2344 | if ($filter == 'relax') |
@@ -2363,14 +2361,14 @@ discard block |
||
2363 | 2361 | if ($this->log) |
2364 | 2362 | { |
2365 | 2363 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2366 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
2364 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
2367 | 2365 | } |
2368 | 2366 | } |
2369 | 2367 | |
2370 | 2368 | if ($this->log) |
2371 | 2369 | { |
2372 | 2370 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2373 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
2371 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
2374 | 2372 | } |
2375 | 2373 | if (!count($users) || !($foundEvents = |
2376 | 2374 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2378,19 +2376,19 @@ discard block |
||
2378 | 2376 | if ($this->log) |
2379 | 2377 | { |
2380 | 2378 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2381 | - "[NO MATCH]\n",3,$this->logfile); |
|
2379 | + "[NO MATCH]\n", 3, $this->logfile); |
|
2382 | 2380 | } |
2383 | 2381 | return $matchingEvents; |
2384 | 2382 | } |
2385 | 2383 | |
2386 | 2384 | $pseudos = array(); |
2387 | 2385 | |
2388 | - foreach($foundEvents as $egwEvent) |
|
2386 | + foreach ($foundEvents as $egwEvent) |
|
2389 | 2387 | { |
2390 | 2388 | if ($this->log) |
2391 | 2389 | { |
2392 | 2390 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2393 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2391 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2394 | 2392 | } |
2395 | 2393 | |
2396 | 2394 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2464,7 +2462,7 @@ discard block |
||
2464 | 2462 | if (in_array($event['recurrence'], $exceptions)) |
2465 | 2463 | { |
2466 | 2464 | // We found a pseudo exception |
2467 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
2465 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
2468 | 2466 | break; |
2469 | 2467 | } |
2470 | 2468 | } |
@@ -2482,7 +2480,7 @@ discard block |
||
2482 | 2480 | if ($this->log) |
2483 | 2481 | { |
2484 | 2482 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2485 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
2483 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
2486 | 2484 | } |
2487 | 2485 | continue; |
2488 | 2486 | } |
@@ -2494,7 +2492,7 @@ discard block |
||
2494 | 2492 | if ($this->log) |
2495 | 2493 | { |
2496 | 2494 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2497 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
2495 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
2498 | 2496 | } |
2499 | 2497 | continue; |
2500 | 2498 | } |
@@ -2515,8 +2513,8 @@ discard block |
||
2515 | 2513 | if ($this->log) |
2516 | 2514 | { |
2517 | 2515 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2518 | - "() event[$key] differ: '" . $event[$key] . |
|
2519 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
2516 | + "() event[$key] differ: '".$event[$key]. |
|
2517 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
2520 | 2518 | } |
2521 | 2519 | continue 2; // next foundEvent |
2522 | 2520 | } |
@@ -2534,7 +2532,7 @@ discard block |
||
2534 | 2532 | if ($this->log) |
2535 | 2533 | { |
2536 | 2534 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2537 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
2535 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
2538 | 2536 | } |
2539 | 2537 | continue 2; |
2540 | 2538 | } |
@@ -2546,7 +2544,7 @@ discard block |
||
2546 | 2544 | { |
2547 | 2545 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2548 | 2546 | '() event has additional categories:' |
2549 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
2547 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
2550 | 2548 | } |
2551 | 2549 | continue; |
2552 | 2550 | } |
@@ -2566,7 +2564,7 @@ discard block |
||
2566 | 2564 | if ($this->log) |
2567 | 2565 | { |
2568 | 2566 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2569 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
2567 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
2570 | 2568 | } |
2571 | 2569 | continue 2; |
2572 | 2570 | } |
@@ -2589,8 +2587,8 @@ discard block |
||
2589 | 2587 | if ($this->log) |
2590 | 2588 | { |
2591 | 2589 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2592 | - '() missing event[participants]: ' . |
|
2593 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
2590 | + '() missing event[participants]: '. |
|
2591 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
2594 | 2592 | } |
2595 | 2593 | continue; |
2596 | 2594 | } |
@@ -2602,7 +2600,7 @@ discard block |
||
2602 | 2600 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
2603 | 2601 | { |
2604 | 2602 | // We found a pseudo Exception |
2605 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
2603 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
2606 | 2604 | continue; |
2607 | 2605 | } |
2608 | 2606 | } |
@@ -2624,7 +2622,7 @@ discard block |
||
2624 | 2622 | if ($this->log) |
2625 | 2623 | { |
2626 | 2624 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2627 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
2625 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
2628 | 2626 | } |
2629 | 2627 | continue 2; |
2630 | 2628 | } |
@@ -2634,8 +2632,8 @@ discard block |
||
2634 | 2632 | if ($this->log) |
2635 | 2633 | { |
2636 | 2634 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2637 | - '() missing event[recur_exception]: ' . |
|
2638 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
2635 | + '() missing event[recur_exception]: '. |
|
2636 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
2639 | 2637 | } |
2640 | 2638 | continue; |
2641 | 2639 | } |
@@ -2650,8 +2648,8 @@ discard block |
||
2650 | 2648 | if ($this->log) |
2651 | 2649 | { |
2652 | 2650 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2653 | - "() events[$key] differ: " . $event[$key] . |
|
2654 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
2651 | + "() events[$key] differ: ".$event[$key]. |
|
2652 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
2655 | 2653 | } |
2656 | 2654 | continue 2; |
2657 | 2655 | } |
@@ -2667,7 +2665,7 @@ discard block |
||
2667 | 2665 | if ($this->log) |
2668 | 2666 | { |
2669 | 2667 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2670 | - "() new exception for series found.\n",3,$this->logfile); |
|
2668 | + "() new exception for series found.\n", 3, $this->logfile); |
|
2671 | 2669 | } |
2672 | 2670 | $matchingEvents = array(); |
2673 | 2671 | } |
@@ -2678,7 +2676,7 @@ discard block |
||
2678 | 2676 | if ($this->log) |
2679 | 2677 | { |
2680 | 2678 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2681 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
2679 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
2682 | 2680 | } |
2683 | 2681 | return $matches; |
2684 | 2682 | } |
@@ -2751,7 +2749,7 @@ discard block |
||
2751 | 2749 | if ($this->log) |
2752 | 2750 | { |
2753 | 2751 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2754 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
2752 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
2755 | 2753 | } |
2756 | 2754 | $type = 'SERIES-EXCEPTION'; |
2757 | 2755 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2772,7 +2770,7 @@ discard block |
||
2772 | 2770 | } |
2773 | 2771 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
2774 | 2772 | { |
2775 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2773 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2776 | 2774 | $recurrence_event = $master_event; |
2777 | 2775 | $recurrence_event['start'] = $event['start']; |
2778 | 2776 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2789,8 +2787,8 @@ discard block |
||
2789 | 2787 | if ($this->log) |
2790 | 2788 | { |
2791 | 2789 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2792 | - '() try occurrence ' . $egw_rrule->current() |
|
2793 | - . " ($occurrence)\n",3,$this->logfile); |
|
2790 | + '() try occurrence '.$egw_rrule->current() |
|
2791 | + . " ($occurrence)\n", 3, $this->logfile); |
|
2794 | 2792 | } |
2795 | 2793 | if ($event['start'] == $occurrence) |
2796 | 2794 | { |
@@ -2823,8 +2821,8 @@ discard block |
||
2823 | 2821 | // default if we cannot find a proof for a fundamental change |
2824 | 2822 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
2825 | 2823 | // check for changed data |
2826 | - foreach (array('start','end','uid','title','location','description', |
|
2827 | - 'priority','public','special','non_blocking') as $key) |
|
2824 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
2825 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
2828 | 2826 | { |
2829 | 2827 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
2830 | 2828 | { |
@@ -2882,10 +2880,10 @@ discard block |
||
2882 | 2880 | * @param &$event the event we are working on |
2883 | 2881 | * |
2884 | 2882 | */ |
2885 | - function server2usertime (&$event) |
|
2883 | + function server2usertime(&$event) |
|
2886 | 2884 | { |
2887 | 2885 | // we run all dates through date2usertime, to adjust to user-time |
2888 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
2886 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
2889 | 2887 | { |
2890 | 2888 | // we convert here from server-time to timestamps in user-time! |
2891 | 2889 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2893,7 +2891,7 @@ discard block |
||
2893 | 2891 | // same with the recur exceptions |
2894 | 2892 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
2895 | 2893 | { |
2896 | - foreach($event['recur_exception'] as $n => $date) |
|
2894 | + foreach ($event['recur_exception'] as $n => $date) |
|
2897 | 2895 | { |
2898 | 2896 | $event['recur_exception'][$n] = $this->date2usertime($date); |
2899 | 2897 | } |
@@ -2901,7 +2899,7 @@ discard block |
||
2901 | 2899 | // same with the alarms |
2902 | 2900 | if (isset($event['alarm']) && is_array($event['alarm'])) |
2903 | 2901 | { |
2904 | - foreach($event['alarm'] as $id => $alarm) |
|
2902 | + foreach ($event['alarm'] as $id => $alarm) |
|
2905 | 2903 | { |
2906 | 2904 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
2907 | 2905 | } |
@@ -2918,7 +2916,7 @@ discard block |
||
2918 | 2916 | { |
2919 | 2917 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
2920 | 2918 | { |
2921 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
2919 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
2922 | 2920 | } |
2923 | 2921 | } |
2924 | 2922 | } |
@@ -1878,12 +1878,12 @@ discard block |
||
1878 | 1878 | */ |
1879 | 1879 | function event2array($event) |
1880 | 1880 | { |
1881 | - $var['title'] = Array( |
|
1881 | + $var['title'] = array( |
|
1882 | 1882 | 'field' => lang('Title'), |
1883 | 1883 | 'data' => $event['title'] |
1884 | 1884 | ); |
1885 | 1885 | |
1886 | - $var['description'] = Array( |
|
1886 | + $var['description'] = array( |
|
1887 | 1887 | 'field' => lang('Description'), |
1888 | 1888 | 'data' => $event['description'] |
1889 | 1889 | ); |
@@ -1892,48 +1892,48 @@ discard block |
||
1892 | 1892 | { |
1893 | 1893 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
1894 | 1894 | } |
1895 | - $var['category'] = Array( |
|
1895 | + $var['category'] = array( |
|
1896 | 1896 | 'field' => lang('Category'), |
1897 | 1897 | 'data' => implode(', ',$cat_string) |
1898 | 1898 | ); |
1899 | 1899 | |
1900 | - $var['location'] = Array( |
|
1900 | + $var['location'] = array( |
|
1901 | 1901 | 'field' => lang('Location'), |
1902 | 1902 | 'data' => $event['location'] |
1903 | 1903 | ); |
1904 | 1904 | |
1905 | - $var['startdate'] = Array( |
|
1905 | + $var['startdate'] = array( |
|
1906 | 1906 | 'field' => lang('Start Date/Time'), |
1907 | 1907 | 'data' => $this->format_date($event['start']), |
1908 | 1908 | ); |
1909 | 1909 | |
1910 | - $var['enddate'] = Array( |
|
1910 | + $var['enddate'] = array( |
|
1911 | 1911 | 'field' => lang('End Date/Time'), |
1912 | 1912 | 'data' => $this->format_date($event['end']), |
1913 | 1913 | ); |
1914 | 1914 | |
1915 | - $pri = Array( |
|
1915 | + $pri = array( |
|
1916 | 1916 | 0 => lang('None'), |
1917 | 1917 | 1 => lang('Low'), |
1918 | 1918 | 2 => lang('Normal'), |
1919 | 1919 | 3 => lang('High') |
1920 | 1920 | ); |
1921 | - $var['priority'] = Array( |
|
1921 | + $var['priority'] = array( |
|
1922 | 1922 | 'field' => lang('Priority'), |
1923 | 1923 | 'data' => $pri[$event['priority']] |
1924 | 1924 | ); |
1925 | 1925 | |
1926 | - $var['owner'] = Array( |
|
1926 | + $var['owner'] = array( |
|
1927 | 1927 | 'field' => lang('Owner'), |
1928 | 1928 | 'data' => Api\Accounts::username($event['owner']) |
1929 | 1929 | ); |
1930 | 1930 | |
1931 | - $var['updated'] = Array( |
|
1931 | + $var['updated'] = array( |
|
1932 | 1932 | 'field' => lang('Updated'), |
1933 | 1933 | 'data' => $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier']) |
1934 | 1934 | ); |
1935 | 1935 | |
1936 | - $var['access'] = Array( |
|
1936 | + $var['access'] = array( |
|
1937 | 1937 | 'field' => lang('Access'), |
1938 | 1938 | 'data' => $event['public'] ? lang('Public') : lang('Private') |
1939 | 1939 | ); |
@@ -1956,13 +1956,13 @@ discard block |
||
1956 | 1956 | } |
1957 | 1957 | } |
1958 | 1958 | |
1959 | - $var['participants'] = Array( |
|
1959 | + $var['participants'] = array( |
|
1960 | 1960 | 'field' => lang('Participants'), |
1961 | 1961 | 'data' => $participants |
1962 | 1962 | ); |
1963 | 1963 | |
1964 | 1964 | // Repeated Events |
1965 | - $var['recur_type'] = Array( |
|
1965 | + $var['recur_type'] = array( |
|
1966 | 1966 | 'field' => lang('Repetition'), |
1967 | 1967 | 'data' => ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '', |
1968 | 1968 | ); |
@@ -2012,7 +2012,7 @@ discard block |
||
2012 | 2012 | * @param Api\DateTime|int|null $instance_date For recurring events, this is the date we |
2013 | 2013 | * are dealing with |
2014 | 2014 | */ |
2015 | - function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
|
2015 | + function check_move_alarms(array &$event, array $old_event = null, $instance_date = null) |
|
2016 | 2016 | { |
2017 | 2017 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
2018 | 2018 |
@@ -91,13 +91,19 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function __construct() |
93 | 93 | { |
94 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
94 | + if ($this->debug > 0) |
|
95 | + { |
|
96 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
97 | + } |
|
95 | 98 | |
96 | 99 | parent::__construct(); // calling the parent constructor |
97 | 100 | |
98 | 101 | $this->resources_so = new resources_so(); |
99 | 102 | |
100 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
103 | + if ($this->debug > 0) |
|
104 | + { |
|
105 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
106 | + } |
|
101 | 107 | } |
102 | 108 | |
103 | 109 | /** |
@@ -128,7 +134,10 @@ discard block |
||
128 | 134 | { |
129 | 135 | unset($updateTS); // ignored, as updating timestamps is required for sync! |
130 | 136 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
131 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
137 | + if (!is_array($messages)) |
|
138 | + { |
|
139 | + $messages = $messages ? (array)$messages : array(); |
|
140 | + } |
|
132 | 141 | |
133 | 142 | if ($this->debug > 1 || $this->debug == 'update') |
134 | 143 | { |
@@ -148,10 +157,13 @@ discard block |
||
148 | 157 | |
149 | 158 | $status_reset_to_unknown = false; |
150 | 159 | |
151 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
160 | + if (($new_event = !$event['id'])) |
|
161 | + { |
|
162 | + // some defaults for new entries |
|
152 | 163 | { |
153 | 164 | // if no owner given, set user to owner |
154 | 165 | if (!$event['owner']) $event['owner'] = $this->user; |
166 | + } |
|
155 | 167 | // set owner as participant if none is given |
156 | 168 | if (!is_array($event['participants']) || !count($event['participants'])) |
157 | 169 | { |
@@ -191,7 +203,10 @@ discard block |
||
191 | 203 | // check category based ACL |
192 | 204 | if ($event['category']) |
193 | 205 | { |
194 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
206 | + if (!is_array($event['category'])) |
|
207 | + { |
|
208 | + $event['category'] = explode(',',$event['category']); |
|
209 | + } |
|
195 | 210 | if (!$old_event || !isset($old_event['category'])) |
196 | 211 | { |
197 | 212 | $old_event['category'] = array(); |
@@ -243,13 +258,16 @@ discard block |
||
243 | 258 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) && |
244 | 259 | (($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding)) |
245 | 260 | { |
246 | - if ($checked_excluding) // warn user if not all recurrences have been checked |
|
261 | + if ($checked_excluding) |
|
262 | + { |
|
263 | + // warn user if not all recurrences have been checked |
|
247 | 264 | { |
248 | 265 | $conflicts['warning'] = array( |
249 | 266 | 'start' => $checked_excluding, |
250 | 267 | 'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)), |
251 | 268 | ); |
252 | 269 | } |
270 | + } |
|
253 | 271 | return $conflicts; |
254 | 272 | } |
255 | 273 | |
@@ -313,7 +331,10 @@ discard block |
||
313 | 331 | $types_with_quantity = array(); |
314 | 332 | foreach($this->resources as $type => $data) |
315 | 333 | { |
316 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
334 | + if ($data['max_quantity']) |
|
335 | + { |
|
336 | + $types_with_quantity[] = $type; |
|
337 | + } |
|
317 | 338 | } |
318 | 339 | // get all NOT rejected participants and evtl. their quantity |
319 | 340 | $quantity = $users = array(); |
@@ -321,12 +342,19 @@ discard block |
||
321 | 342 | { |
322 | 343 | $q = $role = null; |
323 | 344 | calendar_so::split_status($status, $q, $role); |
324 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants |
|
345 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
346 | + { |
|
347 | + continue; |
|
348 | + } |
|
349 | + // ignore rejected or non-participants |
|
325 | 350 | |
326 | - if ($uid < 0) // group, check it's members too |
|
351 | + if ($uid < 0) |
|
352 | + { |
|
353 | + // group, check it's members too |
|
327 | 354 | { |
328 | 355 | $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
329 | 356 | } |
357 | + } |
|
330 | 358 | $users[] = $uid; |
331 | 359 | if (in_array($uid[0],$types_with_quantity)) |
332 | 360 | { |
@@ -357,18 +385,24 @@ discard block |
||
357 | 385 | $startts = $date->format('ts'); |
358 | 386 | |
359 | 387 | // skip past events or recurrences |
360 | - if ($startts+$duration < $this->now_su) continue; |
|
388 | + if ($startts+$duration < $this->now_su) |
|
389 | + { |
|
390 | + continue; |
|
391 | + } |
|
361 | 392 | |
362 | 393 | // abort check if configured limits are exceeded |
363 | 394 | if ($event['recur_type'] && |
364 | 395 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
365 | 396 | microtime(true) > $start+$max_check_time || // max check time exceeded |
366 | - $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
|
397 | + $startts > $this->config['horizont'])) |
|
398 | + { |
|
399 | + // we are behind horizon for which recurrences are rendered |
|
367 | 400 | { |
368 | 401 | if ($this->debug > 2 || $this->debug == 'conflicts') |
369 | 402 | { |
370 | 403 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
371 | 404 | $checked, microtime(true)-$start, $date); |
405 | + } |
|
372 | 406 | } |
373 | 407 | $checked_excluding = $date; |
374 | 408 | break; |
@@ -392,10 +426,13 @@ discard block |
||
392 | 426 | { |
393 | 427 | if ($overlap['id'] == $event['id'] || // that's the event itself |
394 | 428 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
395 | - $overlap['non_blocking']) // that's a non_blocking event |
|
429 | + $overlap['non_blocking']) |
|
430 | + { |
|
431 | + // that's a non_blocking event |
|
396 | 432 | { |
397 | 433 | continue; |
398 | 434 | } |
435 | + } |
|
399 | 436 | if ($this->debug > 3 || $this->debug == 'conflicts') |
400 | 437 | { |
401 | 438 | $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
@@ -518,7 +555,8 @@ discard block |
||
518 | 555 | if (!is_numeric($uid)) |
519 | 556 | { |
520 | 557 | $resources_config = Api\Config::read('resources'); |
521 | - if ($resources_config['bookingrequests'] === 'disabled') { |
|
558 | + if ($resources_config['bookingrequests'] === 'disabled') |
|
559 | + { |
|
522 | 560 | $cat_id = $this->resources_so->get_value('cat_id', intval(substr($uid, 1))); |
523 | 561 | return resources_acl_bo::is_permitted($cat_id, resources_acl_bo::DIRECT_BOOKING); |
524 | 562 | } |
@@ -890,14 +928,20 @@ discard block |
||
890 | 928 | $startdate = new Api\DateTime($event['start']); |
891 | 929 | $enddate = new Api\DateTime($event['end']); |
892 | 930 | $modified = new Api\DateTime($event['modified']); |
893 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
931 | + if ($old_event) |
|
932 | + { |
|
933 | + $olddate = new Api\DateTime($old_event['start']); |
|
934 | + } |
|
894 | 935 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
895 | 936 | $owner_prefs = $ics = null; |
896 | 937 | foreach($to_notify as $userid => $statusid) |
897 | 938 | { |
898 | 939 | $res_info = $quantity = $role = null; |
899 | 940 | calendar_so::split_status($statusid, $quantity, $role); |
900 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
941 | + if ($this->debug > 0) |
|
942 | + { |
|
943 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
944 | + } |
|
901 | 945 | |
902 | 946 | if (!is_numeric($userid)) |
903 | 947 | { |
@@ -916,7 +960,11 @@ discard block |
||
916 | 960 | |
917 | 961 | if (!isset($userid)) |
918 | 962 | { |
919 | - if (empty($res_info['email'])) continue; // no way to notify |
|
963 | + if (empty($res_info['email'])) |
|
964 | + { |
|
965 | + continue; |
|
966 | + } |
|
967 | + // no way to notify |
|
920 | 968 | // check if event-owner wants non-EGroupware users notified |
921 | 969 | if (is_null($owner_prefs)) |
922 | 970 | { |
@@ -990,7 +1038,10 @@ discard block |
||
990 | 1038 | $details['to-lastname'] = isset($tln)? $tln: ''; |
991 | 1039 | |
992 | 1040 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
993 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
1041 | + if (!isset($part_prefs['common']['tz'])) |
|
1042 | + { |
|
1043 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
1044 | + } |
|
994 | 1045 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
995 | 1046 | $timeformat = $part_prefs['common']['timeformat']; |
996 | 1047 | switch($timeformat) |
@@ -1025,9 +1076,12 @@ discard block |
||
1025 | 1076 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
1026 | 1077 | { |
1027 | 1078 | case 'ical': |
1028 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
1079 | + if (is_null($ics) || $m_type != $msg_type) |
|
1080 | + { |
|
1081 | + // need different ical for organizer notification |
|
1029 | 1082 | { |
1030 | 1083 | $calendar_ical = new calendar_ical(); |
1084 | + } |
|
1031 | 1085 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
1032 | 1086 | // we need to pass $event[id] so iCal class reads event again, |
1033 | 1087 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -1043,7 +1097,10 @@ discard block |
||
1043 | 1097 | 'encoding' => '8bit', |
1044 | 1098 | 'type' => 'text/calendar; method='.$method, |
1045 | 1099 | ); |
1046 | - if ($m_type != $msg_type) unset($ics); |
|
1100 | + if ($m_type != $msg_type) |
|
1101 | + { |
|
1102 | + unset($ics); |
|
1103 | + } |
|
1047 | 1104 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
1048 | 1105 | // fall through |
1049 | 1106 | case 'extended': |
@@ -1103,11 +1160,16 @@ discard block |
||
1103 | 1160 | 'app' => 'calendar' |
1104 | 1161 | )); |
1105 | 1162 | } |
1106 | - if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
1163 | + if ($m_type === MSG_ALARM) |
|
1164 | + { |
|
1165 | + $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); |
|
1166 | + } |
|
1107 | 1167 | $notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n"); |
1108 | 1168 | $notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar'))); |
1109 | 1169 | |
1110 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1170 | + if(is_array($attachment)) |
|
1171 | + { |
|
1172 | +$notification->set_attachments(array($attachment)); } |
|
1111 | 1173 | $notification->send(); |
1112 | 1174 | foreach(notifications::errors(true) as $error) |
1113 | 1175 | { |
@@ -1143,7 +1205,10 @@ discard block |
||
1143 | 1205 | Api\Translation::init(); |
1144 | 1206 | } |
1145 | 1207 | // restore timezone, in case we had to reset it to server-timezone |
1146 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
1208 | + if ($restore_tz) |
|
1209 | + { |
|
1210 | + date_default_timezone_set($restore_tz); |
|
1211 | + } |
|
1147 | 1212 | |
1148 | 1213 | return true; |
1149 | 1214 | } |
@@ -1178,10 +1243,13 @@ discard block |
||
1178 | 1243 | { |
1179 | 1244 | $to_notify = $event['participants']; |
1180 | 1245 | } |
1181 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1246 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
1247 | + { |
|
1248 | + // checks agains $this->owner set to $alarm[owner] |
|
1182 | 1249 | { |
1183 | 1250 | $to_notify[$alarm['owner']] = 'A'; |
1184 | 1251 | } |
1252 | + } |
|
1185 | 1253 | else |
1186 | 1254 | { |
1187 | 1255 | return False; // no rights |
@@ -1230,14 +1298,20 @@ discard block |
||
1230 | 1298 | if ($event['id']) |
1231 | 1299 | { |
1232 | 1300 | // invalidate the read-cache if it contains the event we store now |
1233 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
1301 | + if ($event['id'] == self::$cached_event['id']) |
|
1302 | + { |
|
1303 | + self::$cached_event = array(); |
|
1304 | + } |
|
1234 | 1305 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
1235 | 1306 | } |
1236 | 1307 | else |
1237 | 1308 | { |
1238 | 1309 | $old_event = null; |
1239 | 1310 | } |
1240 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
1311 | + if (!isset($event['whole_day'])) |
|
1312 | + { |
|
1313 | + $event['whole_day'] = $this->isWholeDay($event); |
|
1314 | + } |
|
1241 | 1315 | |
1242 | 1316 | // set recur-enddate/range-end to real end-date of last recurrence |
1243 | 1317 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
@@ -1314,7 +1388,10 @@ discard block |
||
1314 | 1388 | foreach($timestamps as $ts) |
1315 | 1389 | { |
1316 | 1390 | // we convert here from user-time to timestamps in server-time! |
1317 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1391 | + if (isset($event[$ts])) |
|
1392 | + { |
|
1393 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1394 | + } |
|
1318 | 1395 | } |
1319 | 1396 | // convert tzid name to integer tz_id, of set user default |
1320 | 1397 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1365,7 +1442,10 @@ discard block |
||
1365 | 1442 | if (!isset($event['alarm'][$id])) |
1366 | 1443 | { |
1367 | 1444 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1368 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
1445 | + if ($alarm['time'] < time()) |
|
1446 | + { |
|
1447 | + calendar_so::shift_alarm($event, $alarm); |
|
1448 | + } |
|
1369 | 1449 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1370 | 1450 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
1371 | 1451 | $old_event['participants'][$alarm['owner']]; |
@@ -1421,7 +1501,10 @@ discard block |
||
1421 | 1501 | |
1422 | 1502 | // Update history |
1423 | 1503 | $tracking = new calendar_tracking($this); |
1424 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1504 | + if (empty($event['id']) && !empty($cal_id)) |
|
1505 | + { |
|
1506 | + $event['id']=$cal_id; |
|
1507 | + } |
|
1425 | 1508 | $tracking->track($event, $old_event); |
1426 | 1509 | |
1427 | 1510 | return $cal_id; |
@@ -1438,9 +1521,12 @@ discard block |
||
1438 | 1521 | */ |
1439 | 1522 | function check_status_perms($uid,$event) |
1440 | 1523 | { |
1441 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
1524 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
1525 | + { |
|
1526 | + // for contact we use the owner of the event |
|
1442 | 1527 | { |
1443 | 1528 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1529 | + } |
|
1444 | 1530 | |
1445 | 1531 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
1446 | 1532 | } |
@@ -1451,13 +1537,19 @@ discard block |
||
1451 | 1537 | return $access; |
1452 | 1538 | } |
1453 | 1539 | // no access or denied access because of category acl --> regular check |
1454 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
1540 | + if (!is_numeric($uid)) |
|
1541 | + { |
|
1542 | + // this is eg. for resources (r123) |
|
1455 | 1543 | { |
1456 | 1544 | $resource = $this->resource_info($uid); |
1545 | + } |
|
1457 | 1546 | |
1458 | 1547 | return Acl::EDIT & $resource['rights']; |
1459 | 1548 | } |
1460 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
1549 | + if (!is_array($event) && !($event = $this->read($event))) |
|
1550 | + { |
|
1551 | + return false; |
|
1552 | + } |
|
1461 | 1553 | |
1462 | 1554 | // regular user and groups (need to check memberships too) |
1463 | 1555 | if (!isset($event['participants'][$uid])) |
@@ -1481,7 +1573,10 @@ discard block |
||
1481 | 1573 | */ |
1482 | 1574 | function check_cat_acl($right,$event) |
1483 | 1575 | { |
1484 | - if (!is_array($event)) $event = $this->read($event); |
|
1576 | + if (!is_array($event)) |
|
1577 | + { |
|
1578 | + $event = $this->read($event); |
|
1579 | + } |
|
1485 | 1580 | |
1486 | 1581 | $ret = null; |
1487 | 1582 | if ($event['category']) |
@@ -1538,7 +1633,10 @@ discard block |
||
1538 | 1633 | public static function set_cat_rights($cat_id,$user,$rights) |
1539 | 1634 | { |
1540 | 1635 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1541 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
1636 | + if (!isset(self::$cat_rights_cache)) |
|
1637 | + { |
|
1638 | + self::get_cat_rights($cat_id); |
|
1639 | + } |
|
1542 | 1640 | |
1543 | 1641 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
1544 | 1642 | { |
@@ -1550,7 +1648,10 @@ discard block |
||
1550 | 1648 | else |
1551 | 1649 | { |
1552 | 1650 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1553 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1651 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
1652 | + { |
|
1653 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1654 | + } |
|
1554 | 1655 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
1555 | 1656 | } |
1556 | 1657 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1583,7 +1684,10 @@ discard block |
||
1583 | 1684 | foreach($cat_rights as $uid => $value) |
1584 | 1685 | { |
1585 | 1686 | $all |= $value; |
1586 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1687 | + if (in_array($uid,$memberships)) |
|
1688 | + { |
|
1689 | + $own |= $value; |
|
1690 | + } |
|
1587 | 1691 | } |
1588 | 1692 | } |
1589 | 1693 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1630,13 +1734,16 @@ discard block |
||
1630 | 1734 | is_numeric($uid)?$uid:substr($uid,1),$status, |
1631 | 1735 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
1632 | 1736 | { |
1633 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
1737 | + if ($status == 'R') |
|
1738 | + { |
|
1739 | + // remove alarms belonging to rejected participants |
|
1634 | 1740 | { |
1635 | 1741 | foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
1636 | 1742 | { |
1637 | 1743 | if ((string)$alarm['owner'] === (string)$uid) |
1638 | 1744 | { |
1639 | 1745 | $this->so->delete_alarm($id); |
1746 | + } |
|
1640 | 1747 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
1641 | 1748 | } |
1642 | 1749 | } |
@@ -1653,8 +1760,15 @@ discard block |
||
1653 | 1760 | |
1654 | 1761 | if (isset($status2msg[$status]) && !$skip_notification) |
1655 | 1762 | { |
1656 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
1657 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1763 | + if (!is_array($event)) |
|
1764 | + { |
|
1765 | + $event = $this->read($cal_id); |
|
1766 | + } |
|
1767 | + if (isset($recur_date)) |
|
1768 | + { |
|
1769 | + $event = $this->read($event['id'],$recur_date); |
|
1770 | + } |
|
1771 | + //re-read the actually edited recurring event |
|
1658 | 1772 | $this->send_update($status2msg[$status],$event['participants'],$event); |
1659 | 1773 | } |
1660 | 1774 | |
@@ -1677,12 +1791,16 @@ discard block |
||
1677 | 1791 | */ |
1678 | 1792 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
1679 | 1793 | { |
1680 | - if (!isset($new_event['participants'])) return; |
|
1794 | + if (!isset($new_event['participants'])) |
|
1795 | + { |
|
1796 | + return; |
|
1797 | + } |
|
1681 | 1798 | |
1682 | 1799 | // check the old list against the new list |
1683 | 1800 | foreach ($old_event['participants'] as $userid => $status) |
1684 | - { |
|
1685 | - if (!isset($new_event['participants'][$userid])){ |
|
1801 | + { |
|
1802 | + if (!isset($new_event['participants'][$userid])) |
|
1803 | + { |
|
1686 | 1804 | // Attendee will be deleted this way |
1687 | 1805 | $new_event['participants'][$userid] = 'G'; |
1688 | 1806 | } |
@@ -1765,7 +1883,10 @@ discard block |
||
1765 | 1883 | } |
1766 | 1884 | else |
1767 | 1885 | { |
1768 | - if (!($exception = $this->read($id))) continue; |
|
1886 | + if (!($exception = $this->read($id))) |
|
1887 | + { |
|
1888 | + continue; |
|
1889 | + } |
|
1769 | 1890 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
1770 | 1891 | $exception['reference'] = $exception['recurrence'] = 0; |
1771 | 1892 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1836,7 +1957,10 @@ discard block |
||
1836 | 1957 | $event_arr = $this->event2array($event); |
1837 | 1958 | foreach($event_arr as $key => $val) |
1838 | 1959 | { |
1839 | - if ($key == 'recur_type') $key = 'repetition'; |
|
1960 | + if ($key == 'recur_type') |
|
1961 | + { |
|
1962 | + $key = 'repetition'; |
|
1963 | + } |
|
1840 | 1964 | $details[$key] = $val['data']; |
1841 | 1965 | } |
1842 | 1966 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1845,7 +1969,10 @@ discard block |
||
1845 | 1969 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
1846 | 1970 | $link = $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit&cal_id='.$event['id'].'&date='.$eventStart_arr['full'].'&no_popup=1&ajax=true'; |
1847 | 1971 | // if url is only a path, try guessing the rest ;-) |
1848 | - if ($link[0] == '/') $link = Api\Framework::getUrl($link); |
|
1972 | + if ($link[0] == '/') |
|
1973 | + { |
|
1974 | + $link = Api\Framework::getUrl($link); |
|
1975 | + } |
|
1849 | 1976 | $event_arr['link']['data'] = $details['link'] = $link; |
1850 | 1977 | |
1851 | 1978 | /* this is needed for notification-app |
@@ -2018,7 +2145,10 @@ discard block |
||
2018 | 2145 | */ |
2019 | 2146 | function check_move_alarms(Array &$event, Array $old_event = null, $instance_date = null) |
2020 | 2147 | { |
2021 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
2148 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
2149 | + { |
|
2150 | + return; |
|
2151 | + } |
|
2022 | 2152 | |
2023 | 2153 | $time = new Api\DateTime($event['start']); |
2024 | 2154 | if(!is_array($event['alarm'])) |
@@ -2101,7 +2231,10 @@ discard block |
||
2101 | 2231 | if (is_array($old_event) || $old_event > 0) |
2102 | 2232 | { |
2103 | 2233 | // preserve categories without users read access |
2104 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
2234 | + if (!is_array($old_event)) |
|
2235 | + { |
|
2236 | + $old_event = $this->read($old_event); |
|
2237 | + } |
|
2105 | 2238 | $old_categories = explode(',',$old_event['category']); |
2106 | 2239 | $old_cats_preserve = array(); |
2107 | 2240 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -2192,7 +2325,10 @@ discard block |
||
2192 | 2325 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
2193 | 2326 | } |
2194 | 2327 | |
2195 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
2328 | + if (!isset($event['recurrence'])) |
|
2329 | + { |
|
2330 | + $event['recurrence'] = 0; |
|
2331 | + } |
|
2196 | 2332 | |
2197 | 2333 | if ($filter == 'master') |
2198 | 2334 | { |
@@ -2246,19 +2382,26 @@ discard block |
||
2246 | 2382 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
2247 | 2383 | } |
2248 | 2384 | } |
2249 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
2385 | + } |
|
2386 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
2250 | 2387 | $event['recur_type'] == $egwEvent['recur_type'] && |
2251 | 2388 | strpos($egwEvent['title'], $event['title']) === 0)) |
2252 | 2389 | { |
2253 | 2390 | $matchingEvents[] = $egwEvent['id']; // we found the event |
2254 | 2391 | } |
2255 | 2392 | } |
2256 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
2393 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
2394 | + { |
|
2395 | + return $matchingEvents; |
|
2396 | + } |
|
2257 | 2397 | } |
2258 | 2398 | unset($event['id']); |
2259 | 2399 | |
2260 | 2400 | // No chance to find a master without [U]ID |
2261 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
2401 | + if ($filter == 'master' && empty($event['uid'])) |
|
2402 | + { |
|
2403 | + return $matchingEvents; |
|
2404 | + } |
|
2262 | 2405 | |
2263 | 2406 | // only query calendars of users, we have READ-grants from |
2264 | 2407 | $users = array(); |
@@ -2267,17 +2410,23 @@ discard block |
||
2267 | 2410 | $user = trim($user); |
2268 | 2411 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
2269 | 2412 | { |
2270 | - if ($user && !in_array($user,$users)) // already added? |
|
2413 | + if ($user && !in_array($user,$users)) |
|
2414 | + { |
|
2415 | + // already added? |
|
2271 | 2416 | { |
2272 | 2417 | $users[] = $user; |
2273 | 2418 | } |
2419 | + } |
|
2274 | 2420 | } |
2275 | 2421 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2276 | 2422 | { |
2277 | 2423 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
2278 | 2424 | } |
2279 | 2425 | // the further code is only for real users |
2280 | - if (!is_numeric($user)) continue; |
|
2426 | + if (!is_numeric($user)) |
|
2427 | + { |
|
2428 | + continue; |
|
2429 | + } |
|
2281 | 2430 | |
2282 | 2431 | // for groups we have to include the members |
2283 | 2432 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2357,7 +2506,10 @@ discard block |
||
2357 | 2506 | } |
2358 | 2507 | foreach ($matchFields as $key) |
2359 | 2508 | { |
2360 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
2509 | + if (isset($event[$key])) |
|
2510 | + { |
|
2511 | + $query['cal_'.$key] = $event[$key]; |
|
2512 | + } |
|
2361 | 2513 | } |
2362 | 2514 | } |
2363 | 2515 | |
@@ -2397,7 +2549,10 @@ discard block |
||
2397 | 2549 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
2398 | 2550 | } |
2399 | 2551 | |
2400 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
2552 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
2553 | + { |
|
2554 | + continue; |
|
2555 | + } |
|
2401 | 2556 | |
2402 | 2557 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
2403 | 2558 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2564,13 +2719,16 @@ discard block |
||
2564 | 2719 | foreach ($event['participants'] as $attendee => $status) |
2565 | 2720 | { |
2566 | 2721 | if (!isset($egwEvent['participants'][$attendee]) && |
2567 | - $attendee != $egwEvent['owner']) // || |
|
2722 | + $attendee != $egwEvent['owner']) |
|
2723 | + { |
|
2724 | + // || |
|
2568 | 2725 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
2569 | 2726 | { |
2570 | 2727 | if ($this->log) |
2571 | 2728 | { |
2572 | 2729 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2573 | 2730 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
2731 | + } |
|
2574 | 2732 | } |
2575 | 2733 | continue 2; |
2576 | 2734 | } |
@@ -2892,7 +3050,10 @@ discard block |
||
2892 | 3050 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
2893 | 3051 | { |
2894 | 3052 | // we convert here from server-time to timestamps in user-time! |
2895 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
3053 | + if (isset($event[$ts])) |
|
3054 | + { |
|
3055 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
3056 | + } |
|
2896 | 3057 | } |
2897 | 3058 | // same with the recur exceptions |
2898 | 3059 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2920,9 +3081,12 @@ discard block |
||
2920 | 3081 | */ |
2921 | 3082 | function purge($age) |
2922 | 3083 | { |
2923 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
3084 | + if (is_numeric($age) && $age > 0) |
|
3085 | + { |
|
3086 | + // just make sure bogus values dont delete everything |
|
2924 | 3087 | { |
2925 | 3088 | $this->so->purge(time() - 365*24*3600*(float)$age); |
2926 | 3089 | } |
3090 | + } |
|
2927 | 3091 | } |
2928 | 3092 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * Exports records as defined in $_definition |
29 | 29 | * |
30 | - * @param egw_record $_definition |
|
30 | + * @param importexport_definition $_definition |
|
31 | 31 | */ |
32 | 32 | public function export( $_stream, importexport_definition $_definition) { |
33 | 33 | $options = $_definition->plugin_options; |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | protected function get_selects() |
368 | 368 | { |
369 | - $this->selects['priority'] = Array( |
|
369 | + $this->selects['priority'] = array( |
|
370 | 370 | 0 => lang('None'), |
371 | 371 | 1 => lang('Low'), |
372 | 372 | 2 => lang('Normal'), |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | /** |
395 | 395 | * Adjust automatically generated field filters |
396 | 396 | */ |
397 | - public function get_filter_fields(Array &$filters) |
|
397 | + public function get_filter_fields(array &$filters) |
|
398 | 398 | { |
399 | 399 | |
400 | 400 | // Calendar SO doesn't support filtering by column, so we have to remove pretty much everything |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param egw_record $_definition |
31 | 31 | */ |
32 | - public function export( $_stream, importexport_definition $_definition) { |
|
32 | + public function export($_stream, importexport_definition $_definition) { |
|
33 | 33 | $options = $_definition->plugin_options; |
34 | 34 | |
35 | 35 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
36 | 36 | if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
37 | 37 | // Custom fields need to be specifically requested |
38 | 38 | $cfs = array(); |
39 | - foreach($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
40 | - if($key[0] == '#') $cfs[] = substr($key,1); |
|
39 | + foreach ($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
40 | + if ($key[0] == '#') $cfs[] = substr($key, 1); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $query = array( |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'num_rows' => -1, |
46 | 46 | 'csv_export' => true |
47 | 47 | ); |
48 | - switch($options['selection']) |
|
48 | + switch ($options['selection']) |
|
49 | 49 | { |
50 | 50 | case 'criteria': |
51 | 51 | $query = array( |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | 'users' => $options['criteria']['owner'], |
56 | 56 | 'cfs' => $cfs // Otherwise we shouldn't get any custom fields |
57 | 57 | ); |
58 | - if($options['criteria']['start']) |
|
58 | + if ($options['criteria']['start']) |
|
59 | 59 | { |
60 | 60 | $query['start'] = $options['criteria']['start']; |
61 | 61 | } |
62 | - if($options['criteria']['end']) |
|
62 | + if ($options['criteria']['end']) |
|
63 | 63 | { |
64 | - $query['end'] = strtotime('+1 day',$options['criteria']['end'])-1; |
|
64 | + $query['end'] = strtotime('+1 day', $options['criteria']['end']) - 1; |
|
65 | 65 | } |
66 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
66 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
67 | 67 | $query['offset'] = 0; |
68 | 68 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
69 | 69 | } |
70 | - $events =& $this->bo->search($query); |
|
70 | + $events = & $this->bo->search($query); |
|
71 | 71 | break; |
72 | 72 | case 'search_results': |
73 | 73 | $states = $this->bo->cal_prefs['saved_states']; |
74 | 74 | $query = Api\Cache::getSession('calendar', 'calendar_list'); |
75 | - $query['num_rows'] = -1; // all |
|
76 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
75 | + $query['num_rows'] = -1; // all |
|
76 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
77 | 77 | $query['start'] = 0; |
78 | 78 | $query['cfs'] = $cfs; |
79 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
79 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
80 | 80 | { |
81 | 81 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
82 | 82 | } |
83 | 83 | $ui = new calendar_uilist(); |
84 | - if($states['view'] == 'listview') |
|
84 | + if ($states['view'] == 'listview') |
|
85 | 85 | { |
86 | 86 | $ui->get_rows($query, $events, $unused); |
87 | 87 | } |
@@ -98,35 +98,35 @@ discard block |
||
98 | 98 | $filter = $_definition->filter; |
99 | 99 | |
100 | 100 | // Handle ranges |
101 | - foreach($filter as $field => $value) |
|
101 | + foreach ($filter as $field => $value) |
|
102 | 102 | { |
103 | - if($field == 'filter' && $value) |
|
103 | + if ($field == 'filter' && $value) |
|
104 | 104 | { |
105 | 105 | $query['filter'] = $value; |
106 | 106 | continue; |
107 | 107 | } |
108 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
108 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) |
|
109 | 109 | { |
110 | 110 | $query['query']["cal_$field"] = $value; |
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
115 | - if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
116 | - if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
115 | + if ($value['from']) $query['sql_filter'][] = "cal_$field >= ".(int)$value['from']; |
|
116 | + if ($value['to']) $query['sql_filter'][] = "cal_$field <= ".(int)$value['to']; |
|
117 | 117 | |
118 | 118 | } |
119 | - if($query['sql_filter'] && is_array($query['sql_filter'])) |
|
119 | + if ($query['sql_filter'] && is_array($query['sql_filter'])) |
|
120 | 120 | { |
121 | 121 | // Set as an extra parameter |
122 | - $sql_filter = implode(' AND ',$query['sql_filter']); |
|
122 | + $sql_filter = implode(' AND ', $query['sql_filter']); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | case 'all': |
126 | 126 | $events = $this->bo->search($query + array( |
127 | 127 | 'offset' => 0, |
128 | 128 | 'order' => 'cal_start', |
129 | - ),$sql_filter); |
|
129 | + ), $sql_filter); |
|
130 | 130 | break; |
131 | 131 | } |
132 | 132 | |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | // Get rid of yearly recurring events that don't belong |
146 | 146 | //if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue; |
147 | 147 | // Add in participants |
148 | - if($options['mapping']['participants']) |
|
148 | + if ($options['mapping']['participants']) |
|
149 | 149 | { |
150 | - if(is_array($event['participants'])) |
|
150 | + if (is_array($event['participants'])) |
|
151 | 151 | { |
152 | - $event['participants'] = implode(", ",$this->bo->participants($event,true)); |
|
152 | + $event['participants'] = implode(", ", $this->bo->participants($event, true)); |
|
153 | 153 | } |
154 | 154 | else |
155 | 155 | { |
@@ -160,23 +160,23 @@ discard block |
||
160 | 160 | if (is_array($event)) |
161 | 161 | { |
162 | 162 | $record->set_record($event); |
163 | - if($options['mapping']['recurrence']) |
|
163 | + if ($options['mapping']['recurrence']) |
|
164 | 164 | { |
165 | 165 | $rrule = calendar_rrule::event2rrule($event); |
166 | 166 | $record->recurrence = $rrule->__toString(); |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Standard stuff |
170 | - if($options['convert']) |
|
170 | + if ($options['convert']) |
|
171 | 171 | { |
172 | 172 | importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects); |
173 | 173 | } |
174 | 174 | else |
175 | 175 | { |
176 | 176 | // Implode arrays, so they don't say 'Array' |
177 | - foreach($record->get_record_array() as $key => $value) |
|
177 | + foreach ($record->get_record_array() as $key => $value) |
|
178 | 178 | { |
179 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
179 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | $export_object->export_record($record); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $states = $this->bo->cal_prefs['saved_states']; |
239 | 239 | $list = Api\Cache::getSession('calendar', 'calendar_list'); |
240 | 240 | |
241 | - $start= new Api\DateTime($list['startdate']); |
|
241 | + $start = new Api\DateTime($list['startdate']); |
|
242 | 242 | $end = new Api\DateTime($list['enddate']); |
243 | 243 | |
244 | 244 | if ($states['view'] == 'listview') |
@@ -247,24 +247,24 @@ discard block |
||
247 | 247 | |
248 | 248 | // Use UI to get dates |
249 | 249 | $ui = new calendar_uilist(); |
250 | - $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
251 | - $ui->get_rows($list,$rows,$readonlys); |
|
250 | + $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
251 | + $ui->get_rows($list, $rows, $readonlys); |
|
252 | 252 | $start = $ui->first ? $ui->first : new Api\DateTime($ui->date); |
253 | 253 | $end = $ui->last; |
254 | 254 | |
255 | 255 | // Special handling |
256 | - if($list['filter'] == 'all') $start = $end = null; |
|
257 | - if($list['filter'] == 'before') |
|
256 | + if ($list['filter'] == 'all') $start = $end = null; |
|
257 | + if ($list['filter'] == 'before') |
|
258 | 258 | { |
259 | 259 | $end = $start; |
260 | 260 | $start = null; |
261 | 261 | } |
262 | 262 | $ui = null; |
263 | 263 | } |
264 | - else if(!$end) |
|
264 | + else if (!$end) |
|
265 | 265 | { |
266 | - $end = '+1 ' . $states['view']; |
|
267 | - $end = strtotime($end, $start->format('ts'))-1; |
|
266 | + $end = '+1 '.$states['view']; |
|
267 | + $end = strtotime($end, $start->format('ts')) - 1; |
|
268 | 268 | } |
269 | 269 | $prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]); |
270 | 270 | $data = array( |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | ); |
331 | 331 | $filters = array_reverse($filters, true); |
332 | 332 | |
333 | - foreach($filters as $field_name => &$settings) |
|
333 | + foreach ($filters as $field_name => &$settings) |
|
334 | 334 | { |
335 | 335 | // Can't filter on a custom field |
336 | - if(strpos($field_name, '#') === 0) |
|
336 | + if (strpos($field_name, '#') === 0) |
|
337 | 337 | { |
338 | 338 | unset($filters[$field_name]); |
339 | 339 | continue; |
340 | 340 | } |
341 | 341 | |
342 | 342 | // Pass on select options |
343 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
343 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | } |
@@ -16,9 +16,11 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * export CSV plugin of calendar |
18 | 18 | */ |
19 | -class calendar_export_csv implements importexport_iface_export_plugin { |
|
19 | +class calendar_export_csv implements importexport_iface_export_plugin |
|
20 | +{ |
|
20 | 21 | |
21 | - public function __construct() { |
|
22 | + public function __construct() |
|
23 | + { |
|
22 | 24 | Api\Translation::add_app('calendar'); |
23 | 25 | $this->bo = new calendar_bo(); |
24 | 26 | $this->get_selects(); |
@@ -29,15 +31,23 @@ discard block |
||
29 | 31 | * |
30 | 32 | * @param egw_record $_definition |
31 | 33 | */ |
32 | - public function export( $_stream, importexport_definition $_definition) { |
|
34 | + public function export( $_stream, importexport_definition $_definition) |
|
35 | + { |
|
33 | 36 | $options = $_definition->plugin_options; |
34 | 37 | |
35 | 38 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
36 | - if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
|
39 | + if (!$limit_exception) |
|
40 | + { |
|
41 | + $export_limit = Api\Storage\Merge::getExportLimit('calendar'); |
|
42 | + } |
|
37 | 43 | // Custom fields need to be specifically requested |
38 | 44 | $cfs = array(); |
39 | - foreach($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
40 | - if($key[0] == '#') $cfs[] = substr($key,1); |
|
45 | + foreach($options['mapping'] + (array)$_definition->filter as $key => $label) |
|
46 | + { |
|
47 | + if($key[0] == '#') |
|
48 | + { |
|
49 | + $cfs[] = substr($key,1); |
|
50 | + } |
|
41 | 51 | } |
42 | 52 | |
43 | 53 | $query = array( |
@@ -63,7 +73,8 @@ discard block |
||
63 | 73 | { |
64 | 74 | $query['end'] = strtotime('+1 day',$options['criteria']['end'])-1; |
65 | 75 | } |
66 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
76 | + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
77 | + { |
|
67 | 78 | $query['offset'] = 0; |
68 | 79 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
69 | 80 | } |
@@ -112,8 +123,14 @@ discard block |
||
112 | 123 | } |
113 | 124 | |
114 | 125 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
115 | - if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
116 | - if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
126 | + if($value['from']) |
|
127 | + { |
|
128 | + $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
129 | + } |
|
130 | + if($value['to']) |
|
131 | + { |
|
132 | + $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
133 | + } |
|
117 | 134 | |
118 | 135 | } |
119 | 136 | if($query['sql_filter'] && is_array($query['sql_filter'])) |
@@ -176,7 +193,10 @@ discard block |
||
176 | 193 | // Implode arrays, so they don't say 'Array' |
177 | 194 | foreach($record->get_record_array() as $key => $value) |
178 | 195 | { |
179 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
196 | + if(is_array($value)) |
|
197 | + { |
|
198 | + $record->$key = implode(',', $value); |
|
199 | + } |
|
180 | 200 | } |
181 | 201 | } |
182 | 202 | $export_object->export_record($record); |
@@ -253,7 +273,10 @@ discard block |
||
253 | 273 | $end = $ui->last; |
254 | 274 | |
255 | 275 | // Special handling |
256 | - if($list['filter'] == 'all') $start = $end = null; |
|
276 | + if($list['filter'] == 'all') |
|
277 | + { |
|
278 | + $start = $end = null; |
|
279 | + } |
|
257 | 280 | if($list['filter'] == 'before') |
258 | 281 | { |
259 | 282 | $end = $start; |
@@ -340,7 +363,10 @@ discard block |
||
340 | 363 | } |
341 | 364 | |
342 | 365 | // Pass on select options |
343 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
366 | + if($this->selects[$field_name]) |
|
367 | + { |
|
368 | + $settings['values'] = $this->selects[$field_name]; |
|
369 | + } |
|
344 | 370 | } |
345 | 371 | |
346 | 372 | } |
@@ -135,6 +135,9 @@ |
||
135 | 135 | return $until_year ? $years : $years[$year]; |
136 | 136 | } |
137 | 137 | |
138 | + /** |
|
139 | + * @param string $url |
|
140 | + */ |
|
138 | 141 | protected static function is_url($url) |
139 | 142 | { |
140 | 143 | return $url[0] == '/' || strpos($url, '://') !== false; |
@@ -41,7 +41,10 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function read($country, $year=null) |
43 | 43 | { |
44 | - if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
|
44 | + if (!$year) |
|
45 | + { |
|
46 | + $year = (int)Api\DateTime::to('now', 'Y'); |
|
47 | + } |
|
45 | 48 | $level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE; |
46 | 49 | |
47 | 50 | $holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year); |
@@ -68,7 +71,10 @@ discard block |
||
68 | 71 | */ |
69 | 72 | public static function render($country, $year=null, $until_year=null) |
70 | 73 | { |
71 | - if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
|
74 | + if (!$year) |
|
75 | + { |
|
76 | + $year = (int)Api\DateTime::to('now', 'Y'); |
|
77 | + } |
|
72 | 78 | $end_year = $until_year && $year < $until_year ? $until_year : $year; |
73 | 79 | |
74 | 80 | $starttime = microtime(true); |
@@ -81,22 +87,40 @@ discard block |
||
81 | 87 | { |
82 | 88 | $start = new Api\DateTime($event['start']); |
83 | 89 | $end = new Api\DateTime($event['end']); |
84 | - if ($start->format('Y') > $end_year) continue; |
|
85 | - if ($end->format('Y') < $year && !$event['recur_type']) continue; |
|
90 | + if ($start->format('Y') > $end_year) |
|
91 | + { |
|
92 | + continue; |
|
93 | + } |
|
94 | + if ($end->format('Y') < $year && !$event['recur_type']) |
|
95 | + { |
|
96 | + continue; |
|
97 | + } |
|
86 | 98 | |
87 | 99 | // recuring events |
88 | 100 | if ($event['recur_type']) |
89 | 101 | { |
90 | 102 | // calendar_rrule limits no enddate, to 5 years |
91 | - if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101'; |
|
103 | + if (!$event['recur_enddate']) |
|
104 | + { |
|
105 | + $event['recur_enddate'] = (1+$end_year).'0101'; |
|
106 | + } |
|
92 | 107 | |
93 | 108 | $rrule = calendar_rrule::event2rrule($event); |
94 | - if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue; |
|
109 | + if ($rrule->enddate && $rrule->enddate->format('Y') < $year) |
|
110 | + { |
|
111 | + continue; |
|
112 | + } |
|
95 | 113 | |
96 | 114 | foreach($rrule as $rtime) |
97 | 115 | { |
98 | - if (($y = (int)$rtime->format('Y')) < $year) continue; |
|
99 | - if ($y > $end_year) break; |
|
116 | + if (($y = (int)$rtime->format('Y')) < $year) |
|
117 | + { |
|
118 | + continue; |
|
119 | + } |
|
120 | + if ($y > $end_year) |
|
121 | + { |
|
122 | + break; |
|
123 | + } |
|
100 | 124 | |
101 | 125 | $ymd = (int)$rtime->format('Ymd'); |
102 | 126 | $years[$y][(string)$ymd][] = array( |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param int $year =null default current year |
45 | 45 | * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title' |
46 | 46 | */ |
47 | - public static function read($country, $year=null) |
|
47 | + public static function read($country, $year = null) |
|
48 | 48 | { |
49 | 49 | if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
50 | 50 | $level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | $holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year); |
53 | 53 | |
54 | 54 | // if we dont find holidays in cache, we render from previous year until next 5 years |
55 | - if (!isset($holidays) && ($years = self::render($country, $year-1, $year+5))) |
|
55 | + if (!isset($holidays) && ($years = self::render($country, $year - 1, $year + 5))) |
|
56 | 56 | { |
57 | - foreach($years as $y => $data) |
|
57 | + foreach ($years as $y => $data) |
|
58 | 58 | { |
59 | 59 | Api\Cache::setCache($level, __CLASS__, $country.':'.$y, $data, self::HOLIDAY_CACHE_TIME); |
60 | 60 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param int $until_year =null default, fetch only one year, if given result is indexed additional by year |
72 | 72 | * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title' |
73 | 73 | */ |
74 | - public static function render($country, $year=null, $until_year=null) |
|
74 | + public static function render($country, $year = null, $until_year = null) |
|
75 | 75 | { |
76 | 76 | if (!$year) $year = (int)Api\DateTime::to('now', 'Y'); |
77 | 77 | $end_year = $until_year && $year < $until_year ? $until_year : $year; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | return array(); |
83 | 83 | } |
84 | 84 | $years = array(); |
85 | - foreach($holidays as $event) |
|
85 | + foreach ($holidays as $event) |
|
86 | 86 | { |
87 | 87 | $start = new Api\DateTime($event['start']); |
88 | 88 | $end = new Api\DateTime($event['end']); |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | if ($event['recur_type']) |
94 | 94 | { |
95 | 95 | // calendar_rrule limits no enddate, to 5 years |
96 | - if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101'; |
|
96 | + if (!$event['recur_enddate']) $event['recur_enddate'] = (1 + $end_year).'0101'; |
|
97 | 97 | |
98 | 98 | $rrule = calendar_rrule::event2rrule($event); |
99 | 99 | if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue; |
100 | 100 | |
101 | - foreach($rrule as $rtime) |
|
101 | + foreach ($rrule as $rtime) |
|
102 | 102 | { |
103 | 103 | if (($y = (int)$rtime->format('Y')) < $year) continue; |
104 | 104 | if ($y > $end_year) break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | else |
117 | 117 | { |
118 | 118 | $end_ymd = (int)$end->format('Ymd'); |
119 | - while(($ymd = (int)$start->format('Ymd')) <= $end_ymd) |
|
119 | + while (($ymd = (int)$start->format('Ymd')) <= $end_ymd) |
|
120 | 120 | { |
121 | 121 | $y = (int)$start->format('Y'); |
122 | 122 | $years[$y][(string)$ymd][] = array( |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
133 | - foreach($years as $y => &$data) |
|
133 | + foreach ($years as $y => &$data) |
|
134 | 134 | { |
135 | 135 | ksort($data); |
136 | 136 | } |
137 | - error_log(__METHOD__."('$country', $year, $end_year) took ". number_format(microtime(true)-$starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events'); |
|
137 | + error_log(__METHOD__."('$country', $year, $end_year) took ".number_format(microtime(true) - $starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events'); |
|
138 | 138 | unset($starttime); |
139 | 139 | |
140 | 140 | return $until_year ? $years : $years[$year]; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | // php does not automatic gzip decode, but it does not accept that in request headers |
167 | 167 | // iCloud eg. always gzip compresses: https://p16-calendars.icloud.com/holidays/au_en-au.ics |
168 | - foreach($http_response_header as $h) |
|
168 | + foreach ($http_response_header as $h) |
|
169 | 169 | { |
170 | 170 | if (preg_match('/^content-encoding:.*gzip/i', $h)) |
171 | 171 | { |
@@ -204,6 +204,7 @@ |
||
204 | 204 | * |
205 | 205 | * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date |
206 | 206 | * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT |
207 | + * @param boolean $updated |
|
207 | 208 | * @return string message about update |
208 | 209 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
209 | 210 | * @throws Api\Exception\WrongUserinput if no PDO sqlite support |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function DateTimeZone($tzid) |
73 | 73 | { |
74 | - if (($id = self::tz2id($tzid,'alias'))) |
|
74 | + if (($id = self::tz2id($tzid, 'alias'))) |
|
75 | 75 | { |
76 | 76 | $tzid = self::id2tz($id); |
77 | 77 | } |
@@ -89,34 +89,34 @@ discard block |
||
89 | 89 | * @param string $what ='id' what to return, default id, null for whole array |
90 | 90 | * @return int tz_id or null if not found |
91 | 91 | */ |
92 | - public static function tz2id($tzid,$what='id') |
|
92 | + public static function tz2id($tzid, $what = 'id') |
|
93 | 93 | { |
94 | - $id =& self::$tz2id[$tzid]; |
|
94 | + $id = & self::$tz2id[$tzid]; |
|
95 | 95 | |
96 | 96 | if (!isset($id)) |
97 | 97 | { |
98 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
98 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
99 | 99 | 'tz_tzid' => $tzid, |
100 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
100 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
101 | 101 | { |
102 | 102 | $id = $data['tz_id']; |
103 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
103 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | // check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires' |
107 | 107 | if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2) |
108 | 108 | { |
109 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
109 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
110 | 110 | 'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]), |
111 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
111 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
112 | 112 | { |
113 | 113 | $id = $data['tz_id']; |
114 | - self::$tz_cache[$id] = Api\Db::strip_array_keys($data,'tz_'); |
|
114 | + self::$tz_cache[$id] = Api\Db::strip_array_keys($data, 'tz_'); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | if (isset($id) && $what != 'id') |
118 | 118 | { |
119 | - return self::id2tz($id,$what); |
|
119 | + return self::id2tz($id, $what); |
|
120 | 120 | } |
121 | 121 | return $id; |
122 | 122 | } |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude' |
135 | 135 | * @return mixed false: if not found |
136 | 136 | */ |
137 | - public static function id2tz($id,$what='tzid') |
|
137 | + public static function id2tz($id, $what = 'tzid') |
|
138 | 138 | { |
139 | - $data =& self::$tz_cache[$id]; |
|
139 | + $data = & self::$tz_cache[$id]; |
|
140 | 140 | |
141 | 141 | if (!isset($data)) |
142 | 142 | { |
143 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
143 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
144 | 144 | 'tz_id' => $id, |
145 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
145 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
146 | 146 | { |
147 | - $data = Api\Db::strip_array_keys($data,'tz_'); |
|
147 | + $data = Api\Db::strip_array_keys($data, 'tz_'); |
|
148 | 148 | self::$tz2id[$data['tzid']] = $id; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | // if not tzid queried, resolve aliases automatically |
152 | 152 | if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') |
153 | 153 | { |
154 | - $data = self::id2tz($data['alias'],null); |
|
154 | + $data = self::id2tz($data['alias'], null); |
|
155 | 155 | } |
156 | 156 | return !$data ? $data : ($what ? $data[$what] : $data); |
157 | 157 | } |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public static function init_static() |
172 | 172 | { |
173 | - self::$tz_cache =& Api\Cache::getSession(__CLASS__,'tz_cache'); |
|
174 | - self::$tz2id =& Api\Cache::getSession(__CLASS__,'tz2id'); |
|
173 | + self::$tz_cache = & Api\Cache::getSession(__CLASS__, 'tz_cache'); |
|
174 | + self::$tz2id = & Api\Cache::getSession(__CLASS__, 'tz2id'); |
|
175 | 175 | |
176 | 176 | // init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar |
177 | 177 | if (!is_array(self::$tz2id)) |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | { |
189 | 189 | $updated = false; |
190 | 190 | $msg = self::import_zones($updated); |
191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
191 | + if ($updated) error_log($msg); // log that timezones have been updated |
|
192 | 192 | |
193 | 193 | $alias_msg = self::import_tz_aliases($updated); |
194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
194 | + if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
195 | 195 | |
196 | 196 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
197 | 197 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @throws Api\Exception\WrongUserinput for broken sqlite extension |
211 | 211 | * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json |
212 | 212 | */ |
213 | - public static function import_zones(&$updated=null, $file='calendar/setup/zones.json') |
|
213 | + public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json') |
|
214 | 214 | { |
215 | 215 | $path = EGW_SERVER_ROOT.'/'.$file; |
216 | 216 | |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | { |
233 | 233 | $updated = false; |
234 | 234 | fclose($fp); |
235 | - return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right |
|
235 | + return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right |
|
236 | 236 | } |
237 | - $json .= fread($fp, 1024*1024); |
|
237 | + $json .= fread($fp, 1024 * 1024); |
|
238 | 238 | fclose($fp); |
239 | 239 | if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones'])) |
240 | 240 | { |
@@ -242,38 +242,38 @@ discard block |
||
242 | 242 | } |
243 | 243 | // import zones first and then aliases |
244 | 244 | $tz2id = array(); |
245 | - foreach(array('zones', 'aliases') as $type) |
|
245 | + foreach (array('zones', 'aliases') as $type) |
|
246 | 246 | { |
247 | - foreach($zones[$type] as $tzid => $data) |
|
247 | + foreach ($zones[$type] as $tzid => $data) |
|
248 | 248 | { |
249 | 249 | if ($type == 'aliases') |
250 | 250 | { |
251 | 251 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
252 | - if (!$data['alias']) continue; // there's no such tzid |
|
252 | + if (!$data['alias']) continue; // there's no such tzid |
|
253 | 253 | } |
254 | 254 | // check if already in database |
255 | - $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
|
255 | + $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array( |
|
256 | 256 | 'tz_tzid' => $tzid, |
257 | - ),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
257 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
258 | 258 | |
259 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
259 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
260 | 260 | 'tz_alias' => $data['alias'], |
261 | 261 | 'tz_latitude' => $data['latitude'], |
262 | 262 | 'tz_longitude' => $data['longitude'], |
263 | 263 | 'tz_component' => $data['ics'], |
264 | - ),array( |
|
264 | + ), array( |
|
265 | 265 | 'tz_tzid' => $tzid, |
266 | - ),__LINE__,__FILE__,'calendar'); |
|
266 | + ), __LINE__, __FILE__, 'calendar'); |
|
267 | 267 | |
268 | 268 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
269 | + if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id'); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
273 | 273 | |
274 | 274 | //_debug_array($tz2id); |
275 | 275 | $updated = true; |
276 | - return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id)); |
|
276 | + return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id)); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @return string message about update |
285 | 285 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
286 | 286 | */ |
287 | - public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php') |
|
287 | + public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php') |
|
288 | 288 | { |
289 | 289 | $path = EGW_SERVER_ROOT.'/'.$file; |
290 | 290 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | if ($tz_aliases_mtime === $config['tz_aliases_mtime']) |
298 | 298 | { |
299 | 299 | $updated = false; |
300 | - return lang('Nothing to update, version is already %1.',$tz_aliases_mtime); |
|
300 | + return lang('Nothing to update, version is already %1.', $tz_aliases_mtime); |
|
301 | 301 | } |
302 | 302 | $tz_aliases = array(); |
303 | - include($path); // sets $tz_aliases |
|
303 | + include($path); // sets $tz_aliases |
|
304 | 304 | |
305 | 305 | $updates = 0; |
306 | - foreach($tz_aliases as $alias => $tzid) |
|
306 | + foreach ($tz_aliases as $alias => $tzid) |
|
307 | 307 | { |
308 | - if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
308 | + if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
309 | 309 | ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
310 | 310 | { |
311 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
311 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
312 | 312 | 'tz_alias' => $tz_id, |
313 | - ),array( |
|
313 | + ), array( |
|
314 | 314 | 'tz_tzid' => $alias, |
315 | - ),__LINE__,__FILE__,'calendar'); |
|
315 | + ), __LINE__, __FILE__, 'calendar'); |
|
316 | 316 | ++$updates; |
317 | 317 | } |
318 | 318 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
319 | 319 | } |
320 | - Api\Config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi'); |
|
320 | + Api\Config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi'); |
|
321 | 321 | |
322 | 322 | //_debug_array($tz2id); |
323 | 323 | $updated = true; |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | } |
359 | 359 | // $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly |
360 | 360 | // --> we have to parse it and let Horde_Icalendar add it again |
361 | - $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false); |
|
362 | - $horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE'); |
|
361 | + $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false); |
|
362 | + $horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE'); |
|
363 | 363 | // DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing |
364 | 364 | $standard = $horde_vtimezone->findComponent('STANDARD'); |
365 | 365 | if (is_a($standard, 'Horde_Icalendar')) |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component |
391 | 391 | * @return string |
392 | 392 | */ |
393 | - public static function user_timezone($user=null, $type='vcalendar') |
|
393 | + public static function user_timezone($user = null, $type = 'vcalendar') |
|
394 | 394 | { |
395 | 395 | if (!$user || $user == $GLOBALS['egw_info']['user']['account_id']) |
396 | 396 | { |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | case 'vcalendar': |
410 | 410 | // checking type of $val, now we included the object definition (no need to always include it!) |
411 | 411 | $vcal = new Horde_Icalendar; |
412 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
412 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
413 | 413 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
414 | 414 | self::add_vtimezone($vcal, $tzid); |
415 | 415 | $tzid = $vcal->exportvCalendar('utf-8'); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | case 'tzid': |
418 | 418 | break; |
419 | 419 | default: |
420 | - $tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type); |
|
420 | + $tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type); |
|
421 | 421 | break; |
422 | 422 | } |
423 | 423 | return $tzid; |
@@ -188,10 +188,18 @@ discard block |
||
188 | 188 | { |
189 | 189 | $updated = false; |
190 | 190 | $msg = self::import_zones($updated); |
191 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
191 | + if ($updated) |
|
192 | + { |
|
193 | + error_log($msg); |
|
194 | + } |
|
195 | + // log that timezones have been updated |
|
192 | 196 | |
193 | 197 | $alias_msg = self::import_tz_aliases($updated); |
194 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
198 | + if ($updated) |
|
199 | + { |
|
200 | + error_log($alias_msg); |
|
201 | + } |
|
202 | + // log that timezone aliases have been updated |
|
195 | 203 | |
196 | 204 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
197 | 205 | |
@@ -249,7 +257,11 @@ discard block |
||
249 | 257 | if ($type == 'aliases') |
250 | 258 | { |
251 | 259 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
252 | - if (!$data['alias']) continue; // there's no such tzid |
|
260 | + if (!$data['alias']) |
|
261 | + { |
|
262 | + continue; |
|
263 | + } |
|
264 | + // there's no such tzid |
|
253 | 265 | } |
254 | 266 | // check if already in database |
255 | 267 | $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
@@ -266,7 +278,10 @@ discard block |
||
266 | 278 | ),__LINE__,__FILE__,'calendar'); |
267 | 279 | |
268 | 280 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
269 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
281 | + if (!$tz2id[$tzid]) |
|
282 | + { |
|
283 | + $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | } |
272 | 287 | Api\Config::save_value('tz_version', $tz_version, 'phpgwapi'); |
@@ -306,13 +321,16 @@ discard block |
||
306 | 321 | foreach($tz_aliases as $alias => $tzid) |
307 | 322 | { |
308 | 323 | if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
309 | - ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
|
324 | + ($tz_id = self::tz2id($tzid))) |
|
325 | + { |
|
326 | + // given tzid for alias exists in DB |
|
310 | 327 | { |
311 | 328 | $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
312 | 329 | 'tz_alias' => $tz_id, |
313 | 330 | ),array( |
314 | 331 | 'tz_tzid' => $alias, |
315 | 332 | ),__LINE__,__FILE__,'calendar'); |
333 | + } |
|
316 | 334 | ++$updates; |
317 | 335 | } |
318 | 336 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
@@ -402,7 +420,10 @@ discard block |
||
402 | 420 | $prefs = $prefs_obj->read(); |
403 | 421 | $tzid = $prefs['common']['tz']; |
404 | 422 | } |
405 | - if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName(); |
|
423 | + if (!$tzid) |
|
424 | + { |
|
425 | + $tzid = Api\DateTime::$server_timezone->getName(); |
|
426 | + } |
|
406 | 427 | |
407 | 428 | switch ($type) |
408 | 429 | { |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | * date instead of today |
1078 | 1078 | * @param boolean $no_notifications Toggle notifications to participants |
1079 | 1079 | * |
1080 | - * @return false or error message |
|
1080 | + * @return string|false or error message |
|
1081 | 1081 | */ |
1082 | 1082 | function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true) |
1083 | 1083 | { |
@@ -2173,7 +2173,7 @@ discard block |
||
2173 | 2173 | * Freetime search |
2174 | 2174 | * |
2175 | 2175 | * As the function is called in a popup via javascript, parametes get initialy transfered via the url |
2176 | - * @param array $content=null array with parameters or false (default) to use the get-params |
|
2176 | + * @param array $content array with parameters or false (default) to use the get-params |
|
2177 | 2177 | * @param string start[str] start-date |
2178 | 2178 | * @param string start[hour] start-hour |
2179 | 2179 | * @param string start[min] start-minutes |
@@ -2417,7 +2417,7 @@ discard block |
||
2417 | 2417 | /** |
2418 | 2418 | * Export events as vCalendar version 2.0 files (iCal) |
2419 | 2419 | * |
2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
2420 | + * @param integer $content numeric cal_id or submitted content from etempalte::exec |
|
2421 | 2421 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
2422 | 2422 | * @return string error-msg if $return_error |
2423 | 2423 | */ |
@@ -2415,14 +2415,14 @@ discard block |
||
2415 | 2415 | } |
2416 | 2416 | |
2417 | 2417 | /** |
2418 | - * Export events as vCalendar version 2.0 files (iCal) |
|
2419 | - * |
|
2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
2421 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
2422 | - * @return string error-msg if $return_error |
|
2423 | - */ |
|
2424 | - function export($content=0,$return_error=false) |
|
2425 | - { |
|
2418 | + * Export events as vCalendar version 2.0 files (iCal) |
|
2419 | + * |
|
2420 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
2421 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
2422 | + * @return string error-msg if $return_error |
|
2423 | + */ |
|
2424 | + function export($content=0,$return_error=false) |
|
2425 | + { |
|
2426 | 2426 | $boical = new calendar_ical(); |
2427 | 2427 | #error_log(__METHOD__.print_r($content,true)); |
2428 | 2428 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2476,7 +2476,7 @@ discard block |
||
2476 | 2476 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
2477 | 2477 | $etpl = new etemplate_new('calendar.export'); |
2478 | 2478 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
2479 | - } |
|
2479 | + } |
|
2480 | 2480 | |
2481 | 2481 | /** |
2482 | 2482 | * Edit category ACL (admin only) |
@@ -2548,8 +2548,8 @@ discard block |
||
2548 | 2548 | } |
2549 | 2549 | |
2550 | 2550 | /** |
2551 | - * Set up the required fields to get the history tab |
|
2552 | - */ |
|
2551 | + * Set up the required fields to get the history tab |
|
2552 | + */ |
|
2553 | 2553 | public function setup_history(&$content, &$sel_options) |
2554 | 2554 | { |
2555 | 2555 | $status = 'history_status'; |
@@ -2890,11 +2890,11 @@ |
||
2890 | 2890 | { |
2891 | 2891 | $msg = lang('Event deleted'); |
2892 | 2892 | } |
2893 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
2893 | + $response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete')); |
|
2894 | 2894 | } |
2895 | 2895 | else |
2896 | 2896 | { |
2897 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
2897 | + $response->apply('egw.message', array(lang('Error')),'error'); |
|
2898 | 2898 | } |
2899 | 2899 | } |
2900 | 2900 |
@@ -598,220 +598,220 @@ discard block |
||
598 | 598 | |
599 | 599 | switch((string)$button) |
600 | 600 | { |
601 | - case 'exception': // create an exception in a recuring event |
|
602 | - $msg = $this->_create_exception($event,$preserv); |
|
603 | - break; |
|
601 | + case 'exception': // create an exception in a recuring event |
|
602 | + $msg = $this->_create_exception($event,$preserv); |
|
603 | + break; |
|
604 | 604 | |
605 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
606 | - unset($event['id']); |
|
607 | - unset($event['uid']); |
|
608 | - unset($event['reference']); |
|
609 | - unset($preserv['reference']); |
|
610 | - unset($event['recurrence']); |
|
611 | - unset($preserv['recurrence']); |
|
612 | - unset($event['recur_exception']); |
|
613 | - unset($event['edit_single']); // in case it has been set |
|
614 | - unset($event['modified']); |
|
615 | - unset($event['modifier']); |
|
616 | - unset($event['caldav_name']); |
|
617 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
605 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
606 | + unset($event['id']); |
|
607 | + unset($event['uid']); |
|
608 | + unset($event['reference']); |
|
609 | + unset($preserv['reference']); |
|
610 | + unset($event['recurrence']); |
|
611 | + unset($preserv['recurrence']); |
|
612 | + unset($event['recur_exception']); |
|
613 | + unset($event['edit_single']); // in case it has been set |
|
614 | + unset($event['modified']); |
|
615 | + unset($event['modifier']); |
|
616 | + unset($event['caldav_name']); |
|
617 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
618 | + |
|
619 | + // Clear participant stati |
|
620 | + foreach($event['participant_types'] as $type => &$participants) |
|
621 | + { |
|
622 | + foreach($participants as $id => &$p_response) |
|
623 | + { |
|
624 | + if($type == 'u' && $id == $event['owner']) continue; |
|
625 | + calendar_so::split_status($p_response, $quantity, $role); |
|
626 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
627 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
628 | + $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
629 | + } |
|
630 | + } |
|
618 | 631 | |
619 | - // Clear participant stati |
|
620 | - foreach($event['participant_types'] as $type => &$participants) |
|
621 | - { |
|
622 | - foreach($participants as $id => &$p_response) |
|
632 | + // Copy alarms |
|
633 | + if (is_array($event['alarm'])) |
|
623 | 634 | { |
624 | - if($type == 'u' && $id == $event['owner']) continue; |
|
625 | - calendar_so::split_status($p_response, $quantity, $role); |
|
626 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
627 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
628 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
635 | + foreach($event['alarm'] as $n => &$alarm) |
|
636 | + { |
|
637 | + unset($alarm['id']); |
|
638 | + unset($alarm['cal_id']); |
|
639 | + } |
|
629 | 640 | } |
630 | - } |
|
631 | 641 | |
632 | - // Copy alarms |
|
633 | - if (is_array($event['alarm'])) |
|
634 | - { |
|
635 | - foreach($event['alarm'] as $n => &$alarm) |
|
642 | + // Get links to be copied |
|
643 | + // With no ID, $content['link_to']['to_id'] is used |
|
644 | + $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
645 | + foreach(Link::get_links('calendar', $content['id']) as $link) |
|
636 | 646 | { |
637 | - unset($alarm['id']); |
|
638 | - unset($alarm['cal_id']); |
|
647 | + if ($link['app'] != Link::VFS_APPNAME) |
|
648 | + { |
|
649 | + Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
650 | + } |
|
651 | + elseif ($link['app'] == Link::VFS_APPNAME) |
|
652 | + { |
|
653 | + Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
654 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
655 | + 'name' => $link['id'], |
|
656 | + ), $link['remark']); |
|
657 | + } |
|
639 | 658 | } |
640 | - } |
|
659 | + unset($link); |
|
660 | + $preserv['view'] = $preserv['edit_single'] = false; |
|
661 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
662 | + $event['title'] = lang('Copy of:').' '.$event['title']; |
|
663 | + break; |
|
641 | 664 | |
642 | - // Get links to be copied |
|
643 | - // With no ID, $content['link_to']['to_id'] is used |
|
644 | - $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
645 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
646 | - { |
|
647 | - if ($link['app'] != Link::VFS_APPNAME) |
|
665 | + case 'mail': |
|
666 | + case 'sendrequest': |
|
667 | + case 'save': |
|
668 | + case 'print': |
|
669 | + case 'apply': |
|
670 | + case 'infolog': |
|
671 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
648 | 672 | { |
649 | - Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
673 | + $msg = lang('Permission denied'); |
|
674 | + $button = ''; |
|
675 | + break; |
|
650 | 676 | } |
651 | - elseif ($link['app'] == Link::VFS_APPNAME) |
|
677 | + if ($event['start'] > $event['end']) |
|
652 | 678 | { |
653 | - Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
654 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
655 | - 'name' => $link['id'], |
|
656 | - ), $link['remark']); |
|
679 | + $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
680 | + $button = ''; |
|
681 | + break; |
|
657 | 682 | } |
658 | - } |
|
659 | - unset($link); |
|
660 | - $preserv['view'] = $preserv['edit_single'] = false; |
|
661 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
662 | - $event['title'] = lang('Copy of:').' '.$event['title']; |
|
663 | - break; |
|
664 | - |
|
665 | - case 'mail': |
|
666 | - case 'sendrequest': |
|
667 | - case 'save': |
|
668 | - case 'print': |
|
669 | - case 'apply': |
|
670 | - case 'infolog': |
|
671 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
672 | - { |
|
673 | - $msg = lang('Permission denied'); |
|
674 | - $button = ''; |
|
675 | - break; |
|
676 | - } |
|
677 | - if ($event['start'] > $event['end']) |
|
678 | - { |
|
679 | - $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
680 | - $button = ''; |
|
681 | - break; |
|
682 | - } |
|
683 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
684 | - { |
|
685 | - $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
686 | - $button = ''; |
|
687 | - break; |
|
688 | - } |
|
689 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
690 | - { |
|
691 | - $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
692 | - $button = ''; |
|
693 | - break; |
|
694 | - } |
|
695 | - if (!$event['participants']) |
|
696 | - { |
|
697 | - $msg = lang('Error: no participants selected !!!'); |
|
698 | - $button = ''; |
|
699 | - break; |
|
700 | - } |
|
701 | - // if private event with ressource reservation is forbidden |
|
702 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
703 | - { |
|
704 | - foreach (array_keys($event['participants']) as $uid) |
|
683 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
684 | + { |
|
685 | + $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
686 | + $button = ''; |
|
687 | + break; |
|
688 | + } |
|
689 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
690 | + { |
|
691 | + $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
692 | + $button = ''; |
|
693 | + break; |
|
694 | + } |
|
695 | + if (!$event['participants']) |
|
705 | 696 | { |
706 | - if ($uid[0] == 'r') //ressource detection |
|
697 | + $msg = lang('Error: no participants selected !!!'); |
|
698 | + $button = ''; |
|
699 | + break; |
|
700 | + } |
|
701 | + // if private event with ressource reservation is forbidden |
|
702 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
703 | + { |
|
704 | + foreach (array_keys($event['participants']) as $uid) |
|
707 | 705 | { |
708 | - $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
709 | - $button = ''; |
|
710 | - break 2; //break foreach and case |
|
706 | + if ($uid[0] == 'r') //ressource detection |
|
707 | + { |
|
708 | + $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
709 | + $button = ''; |
|
710 | + break 2; //break foreach and case |
|
711 | + } |
|
711 | 712 | } |
712 | 713 | } |
713 | - } |
|
714 | - if ($content['edit_single']) // we edited a single event from a series |
|
715 | - { |
|
716 | - $event['reference'] = $event['id']; |
|
717 | - $event['recurrence'] = $content['edit_single']; |
|
718 | - unset($event['id']); |
|
719 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
720 | - if (!is_array($conflicts) && $conflicts) |
|
714 | + if ($content['edit_single']) // we edited a single event from a series |
|
721 | 715 | { |
722 | - // now we need to add the original start as recur-execption to the series |
|
723 | - $recur_event = $this->bo->read($event['reference']); |
|
724 | - $recur_event['recur_exception'][] = $content['edit_single']; |
|
725 | - // check if we need to move the alarms, because they are next on that exception |
|
726 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
716 | + $event['reference'] = $event['id']; |
|
717 | + $event['recurrence'] = $content['edit_single']; |
|
718 | + unset($event['id']); |
|
719 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
720 | + if (!is_array($conflicts) && $conflicts) |
|
727 | 721 | { |
728 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
722 | + // now we need to add the original start as recur-execption to the series |
|
723 | + $recur_event = $this->bo->read($event['reference']); |
|
724 | + $recur_event['recur_exception'][] = $content['edit_single']; |
|
725 | + // check if we need to move the alarms, because they are next on that exception |
|
726 | + foreach($recur_event['alarm'] as $id => $alarm) |
|
729 | 727 | { |
730 | - $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
731 | - foreach ($rrule as $time) |
|
728 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
732 | 729 | { |
733 | - if ($content['edit_single'] < $time->format('ts')) |
|
730 | + $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
731 | + foreach ($rrule as $time) |
|
734 | 732 | { |
735 | - $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
736 | - $this->bo->save_alarm($event['reference'], $alarm); |
|
737 | - break; |
|
733 | + if ($content['edit_single'] < $time->format('ts')) |
|
734 | + { |
|
735 | + $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
736 | + $this->bo->save_alarm($event['reference'], $alarm); |
|
737 | + break; |
|
738 | + } |
|
738 | 739 | } |
739 | 740 | } |
740 | 741 | } |
741 | - } |
|
742 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
743 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
744 | - $this->bo->update($recur_event,true); // no conflict check here |
|
742 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
743 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
744 | + $this->bo->update($recur_event,true); // no conflict check here |
|
745 | 745 | |
746 | - // Save links |
|
747 | - if($content['links']) |
|
748 | - { |
|
749 | - Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
750 | - } |
|
746 | + // Save links |
|
747 | + if($content['links']) |
|
748 | + { |
|
749 | + Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
750 | + } |
|
751 | 751 | |
752 | - if(Api\Json\Response::isJSONResponse()) |
|
752 | + if(Api\Json\Response::isJSONResponse()) |
|
753 | + { |
|
754 | + // Sending null will trigger a removal of the original |
|
755 | + // for that date |
|
756 | + Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
757 | + } |
|
758 | + |
|
759 | + unset($recur_event); |
|
760 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
761 | + unset($preserv['edit_single']); |
|
762 | + } |
|
763 | + else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
753 | 764 | { |
754 | - // Sending null will trigger a removal of the original |
|
755 | - // for that date |
|
756 | - Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
765 | + $event['id'] = $event['reference']; |
|
766 | + $event['reference'] = $event['recurrence'] = 0; |
|
767 | + $event['uid'] = $content['uid']; |
|
757 | 768 | } |
758 | - |
|
759 | - unset($recur_event); |
|
760 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
761 | - unset($preserv['edit_single']); |
|
769 | + $update_type = 'edit'; |
|
762 | 770 | } |
763 | - else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
771 | + else // we edited a non-reccuring event or the whole series |
|
764 | 772 | { |
765 | - $event['id'] = $event['reference']; |
|
766 | - $event['reference'] = $event['recurrence'] = 0; |
|
767 | - $event['uid'] = $content['uid']; |
|
768 | - } |
|
769 | - $update_type = 'edit'; |
|
770 | - } |
|
771 | - else // we edited a non-reccuring event or the whole series |
|
772 | - { |
|
773 | - if (($old_event = $this->bo->read($event['id']))) |
|
774 | - { |
|
775 | - if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
773 | + if (($old_event = $this->bo->read($event['id']))) |
|
776 | 774 | { |
777 | - $update_type = 'edit'; |
|
778 | - |
|
779 | - // we edit a existing series event |
|
780 | - if ($event['start'] != $old_event['start'] || |
|
781 | - $event['whole_day'] != $old_event['whole_day'] || |
|
782 | - $event['end'] != $old_event['end']) |
|
775 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
783 | 776 | { |
784 | - // calculate offset against old series start or clicked recurrance, |
|
785 | - // depending on which is smaller |
|
786 | - $offset = $event['start'] - $old_event['start']; |
|
787 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
788 | - { |
|
789 | - $offset = $off2; |
|
790 | - } |
|
791 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
792 | - if($msg) |
|
777 | + $update_type = 'edit'; |
|
778 | + |
|
779 | + // we edit a existing series event |
|
780 | + if ($event['start'] != $old_event['start'] || |
|
781 | + $event['whole_day'] != $old_event['whole_day'] || |
|
782 | + $event['end'] != $old_event['end']) |
|
793 | 783 | { |
794 | - $noerror = false; |
|
784 | + // calculate offset against old series start or clicked recurrance, |
|
785 | + // depending on which is smaller |
|
786 | + $offset = $event['start'] - $old_event['start']; |
|
787 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
788 | + { |
|
789 | + $offset = $off2; |
|
790 | + } |
|
791 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
792 | + if($msg) |
|
793 | + { |
|
794 | + $noerror = false; |
|
795 | + } |
|
795 | 796 | } |
796 | 797 | } |
797 | - } |
|
798 | - else |
|
799 | - { |
|
800 | - if ($old_event['start'] != $event['start'] || |
|
801 | - $old_event['end'] != $event['end'] || |
|
802 | - $event['whole_day'] != $old_event['whole_day']) |
|
798 | + else |
|
803 | 799 | { |
804 | - $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
805 | - foreach((array)$event['participants'] as $uid => $status) |
|
800 | + if ($old_event['start'] != $event['start'] || |
|
801 | + $old_event['end'] != $event['end'] || |
|
802 | + $event['whole_day'] != $old_event['whole_day']) |
|
806 | 803 | { |
807 | - $q = $r = null; |
|
808 | - calendar_so::split_status($status,$q,$r); |
|
809 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
804 | + $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
805 | + foreach((array)$event['participants'] as $uid => $status) |
|
810 | 806 | { |
811 | - $preferences = new Api\Preferences($uid); |
|
812 | - $part_prefs = $preferences->read_repository(); |
|
813 | - switch ($part_prefs['calendar']['reset_stati']) |
|
807 | + $q = $r = null; |
|
808 | + calendar_so::split_status($status,$q,$r); |
|
809 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
814 | 810 | { |
811 | + $preferences = new Api\Preferences($uid); |
|
812 | + $part_prefs = $preferences->read_repository(); |
|
813 | + switch ($part_prefs['calendar']['reset_stati']) |
|
814 | + { |
|
815 | 815 | case 'no': |
816 | 816 | break; |
817 | 817 | case 'startday': |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $status_reset_to_unknown = true; |
821 | 821 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
822 | 822 | // todo: report reset status to user |
823 | - } |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | // check if we need to move the alarms, because they are relative |
@@ -962,83 +962,83 @@ discard block |
||
962 | 962 | } |
963 | 963 | break; |
964 | 964 | |
965 | - case 'cancel': |
|
966 | - if($content['cancel_needs_refresh']) |
|
967 | - { |
|
968 | - Framework::refresh_opener($msg, 'calendar'); |
|
969 | - } |
|
970 | - break; |
|
971 | - |
|
972 | - case 'delete': // delete of event (regular or series) |
|
973 | - $exceptions_kept = null; |
|
974 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
975 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
976 | - { |
|
977 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
965 | + case 'cancel': |
|
966 | + if($content['cancel_needs_refresh']) |
|
978 | 967 | { |
979 | - $msg = lang('Series deleted'); |
|
980 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
968 | + Framework::refresh_opener($msg, 'calendar'); |
|
981 | 969 | } |
982 | - else |
|
970 | + break; |
|
971 | + |
|
972 | + case 'delete': // delete of event (regular or series) |
|
973 | + $exceptions_kept = null; |
|
974 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
975 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
983 | 976 | { |
984 | - $msg = lang('Event deleted'); |
|
985 | - } |
|
977 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
978 | + { |
|
979 | + $msg = lang('Series deleted'); |
|
980 | + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
981 | + } |
|
982 | + else |
|
983 | + { |
|
984 | + $msg = lang('Event deleted'); |
|
985 | + } |
|
986 | 986 | |
987 | - } |
|
988 | - break; |
|
987 | + } |
|
988 | + break; |
|
989 | 989 | |
990 | - case 'freetime': |
|
991 | - // the "click" has to be in onload, to make sure the button is already created |
|
992 | - $event['button_was'] = $button; |
|
993 | - break; |
|
990 | + case 'freetime': |
|
991 | + // the "click" has to be in onload, to make sure the button is already created |
|
992 | + $event['button_was'] = $button; |
|
993 | + break; |
|
994 | 994 | |
995 | - case 'add_alarm': |
|
996 | - $time = $content['start']; |
|
997 | - $offset = $time - $content['new_alarm']['date']; |
|
998 | - if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
999 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
1000 | - $time < $next_occurrence['start']) |
|
1001 | - { |
|
1002 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
1003 | - } |
|
1004 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1005 | - { |
|
1006 | - $alarm = array( |
|
1007 | - 'offset' => $offset, |
|
1008 | - 'time' => $content['new_alarm']['date'], |
|
1009 | - 'all' => !$content['new_alarm']['owner'], |
|
1010 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
1011 | - ); |
|
1012 | - if ($alarm['time'] < $this->bo->now_su) |
|
995 | + case 'add_alarm': |
|
996 | + $time = $content['start']; |
|
997 | + $offset = $time - $content['new_alarm']['date']; |
|
998 | + if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
999 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
1000 | + $time < $next_occurrence['start']) |
|
1013 | 1001 | { |
1014 | - $msg = lang("Can't add alarms in the past !!!"); |
|
1002 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
1015 | 1003 | } |
1016 | - elseif ($event['id']) // save the alarm immediatly |
|
1004 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1017 | 1005 | { |
1018 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1006 | + $alarm = array( |
|
1007 | + 'offset' => $offset, |
|
1008 | + 'time' => $content['new_alarm']['date'], |
|
1009 | + 'all' => !$content['new_alarm']['owner'], |
|
1010 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
1011 | + ); |
|
1012 | + if ($alarm['time'] < $this->bo->now_su) |
|
1013 | + { |
|
1014 | + $msg = lang("Can't add alarms in the past !!!"); |
|
1015 | + } |
|
1016 | + elseif ($event['id']) // save the alarm immediatly |
|
1019 | 1017 | { |
1020 | - $alarm['id'] = $alarm_id; |
|
1021 | - $event['alarm'][$alarm_id] = $alarm; |
|
1018 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1019 | + { |
|
1020 | + $alarm['id'] = $alarm_id; |
|
1021 | + $event['alarm'][$alarm_id] = $alarm; |
|
1022 | 1022 | |
1023 | - $msg = lang('Alarm added'); |
|
1024 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1023 | + $msg = lang('Alarm added'); |
|
1024 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1025 | + } |
|
1026 | + else |
|
1027 | + { |
|
1028 | + $msg = lang('Error adding the alarm'); |
|
1029 | + } |
|
1025 | 1030 | } |
1026 | 1031 | else |
1027 | 1032 | { |
1028 | - $msg = lang('Error adding the alarm'); |
|
1033 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1034 | + $event['alarm'][$alarm['id']] = $alarm; |
|
1029 | 1035 | } |
1030 | 1036 | } |
1031 | 1037 | else |
1032 | 1038 | { |
1033 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1034 | - $event['alarm'][$alarm['id']] = $alarm; |
|
1039 | + $msg = lang('Permission denied'); |
|
1035 | 1040 | } |
1036 | - } |
|
1037 | - else |
|
1038 | - { |
|
1039 | - $msg = lang('Permission denied'); |
|
1040 | - } |
|
1041 | - break; |
|
1041 | + break; |
|
1042 | 1042 | } |
1043 | 1043 | // add notification-errors, if we have some |
1044 | 1044 | if (($notification_errors = notifications::errors(true))) |
@@ -120,11 +120,14 @@ discard block |
||
120 | 120 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
121 | 121 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
122 | 122 | { |
123 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
123 | + if ($owner) |
|
124 | + { |
|
125 | + // make an owner who is no user or we have no add-rights a participant |
|
124 | 126 | { |
125 | 127 | if(!is_array($owner)) |
126 | 128 | { |
127 | 129 | $owner = explode(',',$owner); |
130 | + } |
|
128 | 131 | } |
129 | 132 | // if we come from ressources we don't need any users selected in calendar |
130 | 133 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -156,9 +159,17 @@ discard block |
||
156 | 159 | $participant_types['u'] = $participant_types = $participants = array(); |
157 | 160 | foreach($extra_participants as $uid) |
158 | 161 | { |
159 | - if (isset($participants[$uid])) continue; // already included |
|
162 | + if (isset($participants[$uid])) |
|
163 | + { |
|
164 | + continue; |
|
165 | + } |
|
166 | + // already included |
|
160 | 167 | |
161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
168 | + if (!$this->bo->check_acl_invite($uid)) |
|
169 | + { |
|
170 | + continue; |
|
171 | + } |
|
172 | + // no right to invite --> ignored |
|
162 | 173 | |
163 | 174 | if (is_numeric($uid)) |
164 | 175 | { |
@@ -196,10 +207,13 @@ discard block |
||
196 | 207 | } |
197 | 208 | } |
198 | 209 | } |
199 | - if (!$participants) // if all participants got removed, include current user |
|
210 | + if (!$participants) |
|
211 | + { |
|
212 | + // if all participants got removed, include current user |
|
200 | 213 | { |
201 | 214 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
202 | 215 | } |
216 | + } |
|
203 | 217 | if(isset($_GET['cat_id'])) |
204 | 218 | { |
205 | 219 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -261,10 +275,13 @@ discard block |
||
261 | 275 | */ |
262 | 276 | function process_edit($content) |
263 | 277 | { |
264 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
278 | + if (!is_array($content)) |
|
279 | + { |
|
280 | + // redirect from etemplate, if POST empty |
|
265 | 281 | { |
266 | 282 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
267 | 283 | } |
284 | + } |
|
268 | 285 | // clear notification errors |
269 | 286 | notifications::errors(true); |
270 | 287 | $messages = null; |
@@ -277,7 +294,11 @@ discard block |
||
277 | 294 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
278 | 295 | |
279 | 296 | list($button) = @each($content['button']); |
280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
297 | + if (!$button && $content['action']) |
|
298 | + { |
|
299 | + $button = $content['action']; |
|
300 | + } |
|
301 | + // action selectbox |
|
281 | 302 | unset($content['button']); unset($content['action']); |
282 | 303 | |
283 | 304 | $view = $content['view']; |
@@ -290,7 +311,10 @@ discard block |
||
290 | 311 | { |
291 | 312 | list($date) = each($content['recur_exception']['delete_exception']); |
292 | 313 | // eT2 converts time to |
293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
314 | + if (!is_numeric($date)) |
|
315 | + { |
|
316 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
317 | + } |
|
294 | 318 | unset($content['recur_exception']['delete_exception']); |
295 | 319 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
296 | 320 | { |
@@ -299,7 +323,10 @@ discard block |
||
299 | 323 | foreach ($recur_exceptions as $id) |
300 | 324 | { |
301 | 325 | if (!($exception = $this->bo->read($id)) || |
302 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
326 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
327 | + { |
|
328 | + continue; |
|
329 | + } |
|
303 | 330 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
304 | 331 | $exception['reference'] = $exception['recurrence'] = 0; |
305 | 332 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -357,8 +384,7 @@ discard block |
||
357 | 384 | // Existing event, check for change from/to whole day |
358 | 385 | ($old = $this->bo->read($content['cal_id'])) && $old['whole_day'] !== $content['whole_day'] && |
359 | 386 | ($def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]) |
360 | - ) |
|
361 | - { |
|
387 | + ) { |
|
362 | 388 | // Reset default alarm |
363 | 389 | $old_default = array_shift($content['alarm']); |
364 | 390 | $this->bo->delete_alarm($old_default['id']); |
@@ -395,7 +421,10 @@ discard block |
||
395 | 421 | $event['end'] = $this->bo->date2ts($event['end']); |
396 | 422 | } |
397 | 423 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
398 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
424 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
425 | + { |
|
426 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
427 | + } |
|
399 | 428 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
400 | 429 | { |
401 | 430 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -522,7 +551,11 @@ discard block |
||
522 | 551 | break; |
523 | 552 | |
524 | 553 | default: // existing participant row |
525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
554 | + if (!is_array($data)) |
|
555 | + { |
|
556 | + continue; |
|
557 | + } |
|
558 | + // widgets in participant tab, above participant list |
|
526 | 559 | $quantity = $status = $role = null; |
527 | 560 | foreach(array('uid','status','quantity','role') as $name) |
528 | 561 | { |
@@ -655,7 +688,10 @@ discard block |
||
655 | 688 | { |
656 | 689 | foreach($participants as $id => &$p_response) |
657 | 690 | { |
658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
691 | + if($type == 'u' && $id == $event['owner']) |
|
692 | + { |
|
693 | + continue; |
|
694 | + } |
|
659 | 695 | calendar_so::split_status($p_response, $quantity, $role); |
660 | 696 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
661 | 697 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -737,17 +773,23 @@ discard block |
||
737 | 773 | { |
738 | 774 | foreach (array_keys($event['participants']) as $uid) |
739 | 775 | { |
740 | - if ($uid[0] == 'r') //ressource detection |
|
776 | + if ($uid[0] == 'r') |
|
777 | + { |
|
778 | + //ressource detection |
|
741 | 779 | { |
742 | 780 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
781 | + } |
|
743 | 782 | $button = ''; |
744 | 783 | break 2; //break foreach and case |
745 | 784 | } |
746 | 785 | } |
747 | 786 | } |
748 | - if ($content['edit_single']) // we edited a single event from a series |
|
787 | + if ($content['edit_single']) |
|
788 | + { |
|
789 | + // we edited a single event from a series |
|
749 | 790 | { |
750 | 791 | $event['reference'] = $event['id']; |
792 | + } |
|
751 | 793 | $event['recurrence'] = $content['edit_single']; |
752 | 794 | unset($event['id']); |
753 | 795 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -849,7 +891,10 @@ discard block |
||
849 | 891 | case 'no': |
850 | 892 | break; |
851 | 893 | case 'startday': |
852 | - if ($sameday) break; |
|
894 | + if ($sameday) |
|
895 | + { |
|
896 | + break; |
|
897 | + } |
|
853 | 898 | default: |
854 | 899 | $status_reset_to_unknown = true; |
855 | 900 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -1017,7 +1062,10 @@ discard block |
||
1017 | 1062 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
1018 | 1063 | { |
1019 | 1064 | $msg = lang('Series deleted'); |
1020 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
1065 | + if ($exceptions_kept) |
|
1066 | + { |
|
1067 | + $msg .= lang(', exceptions preserved'); |
|
1068 | + } |
|
1021 | 1069 | } |
1022 | 1070 | else |
1023 | 1071 | { |
@@ -1053,11 +1101,14 @@ discard block |
||
1053 | 1101 | { |
1054 | 1102 | $msg = lang("Can't add alarms in the past !!!"); |
1055 | 1103 | } |
1056 | - elseif ($event['id']) // save the alarm immediatly |
|
1104 | + elseif ($event['id']) |
|
1105 | + { |
|
1106 | + // save the alarm immediatly |
|
1057 | 1107 | { |
1058 | 1108 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
1059 | 1109 | { |
1060 | 1110 | $alarm['id'] = $alarm_id; |
1111 | + } |
|
1061 | 1112 | $event['alarm'][$alarm_id] = $alarm; |
1062 | 1113 | |
1063 | 1114 | $msg = lang('Alarm added'); |
@@ -1070,7 +1121,9 @@ discard block |
||
1070 | 1121 | } |
1071 | 1122 | else |
1072 | 1123 | { |
1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1124 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
1125 | + { |
|
1126 | +} // get a temporary non-conflicting, numeric id |
|
1074 | 1127 | $event['alarm'][$alarm['id']] = $alarm; |
1075 | 1128 | } |
1076 | 1129 | } |
@@ -1093,10 +1146,13 @@ discard block |
||
1093 | 1146 | } |
1094 | 1147 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
1095 | 1148 | { |
1096 | - if ($content['lock_token']) // remove an existing lock |
|
1149 | + if ($content['lock_token']) |
|
1150 | + { |
|
1151 | + // remove an existing lock |
|
1097 | 1152 | { |
1098 | 1153 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
1099 | 1154 | } |
1155 | + } |
|
1100 | 1156 | if ($content['no_popup']) |
1101 | 1157 | { |
1102 | 1158 | Egw::redirect_link('/index.php',array( |
@@ -1154,13 +1210,19 @@ discard block |
||
1154 | 1210 | } |
1155 | 1211 | |
1156 | 1212 | // Copy links |
1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1213 | + if(!is_array($event['link_to'])) |
|
1214 | + { |
|
1215 | + $event['link_to'] = array(); |
|
1216 | + } |
|
1158 | 1217 | $event['link_to']['to_app'] = 'calendar'; |
1159 | 1218 | $event['link_to']['to_id'] = 0; |
1160 | 1219 | |
1161 | 1220 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
1162 | 1221 | { |
1163 | - if(!$link['id']) continue; |
|
1222 | + if(!$link['id']) |
|
1223 | + { |
|
1224 | + continue; |
|
1225 | + } |
|
1164 | 1226 | if ($link['app'] != Link::VFS_APPNAME) |
1165 | 1227 | { |
1166 | 1228 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1228,8 +1290,7 @@ discard block |
||
1228 | 1290 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
1229 | 1291 | // Adjust for requested date in the past |
1230 | 1292 | Api\DateTime::to($as_of_date,'ts') < time() |
1231 | - ) |
|
1232 | - { |
|
1293 | + ) { |
|
1233 | 1294 | |
1234 | 1295 | unset($orig_event); |
1235 | 1296 | // copy event by unsetting the id(s) |
@@ -1317,7 +1378,10 @@ discard block |
||
1317 | 1378 | foreach($event['participants'] as $uid => $status) |
1318 | 1379 | { |
1319 | 1380 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1320 | - if (empty($status)) continue; |
|
1381 | + if (empty($status)) |
|
1382 | + { |
|
1383 | + continue; |
|
1384 | + } |
|
1321 | 1385 | if(!is_array($status)) |
1322 | 1386 | { |
1323 | 1387 | $quantity = $role = null; |
@@ -1328,28 +1392,43 @@ discard block |
||
1328 | 1392 | ); |
1329 | 1393 | } |
1330 | 1394 | $toadd = ''; |
1331 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
1395 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
1396 | + { |
|
1397 | + continue; |
|
1398 | + } |
|
1332 | 1399 | |
1333 | 1400 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1334 | 1401 | { |
1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1402 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
1403 | + { |
|
1404 | + continue; |
|
1405 | + } |
|
1336 | 1406 | |
1337 | 1407 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
1338 | 1408 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
1339 | 1409 | |
1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1410 | + if (!in_array($toadd,$to)) |
|
1411 | + { |
|
1412 | + $to[] = $toadd; |
|
1413 | + } |
|
1341 | 1414 | } |
1342 | 1415 | elseif ($uid < 0) |
1343 | 1416 | { |
1344 | 1417 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
1345 | 1418 | { |
1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1419 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
1420 | + { |
|
1421 | + continue; |
|
1422 | + } |
|
1347 | 1423 | |
1348 | 1424 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
1349 | 1425 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
1350 | 1426 | |
1351 | 1427 | // dont add groupmembers if they already rejected the event, or are the current user |
1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1428 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
1429 | + { |
|
1430 | + $to[] = $toadd; |
|
1431 | + } |
|
1353 | 1432 | } |
1354 | 1433 | } |
1355 | 1434 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1401,7 +1480,10 @@ discard block |
||
1401 | 1480 | 'preset[size]' => filesize($ics_file), |
1402 | 1481 | ); |
1403 | 1482 | $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
1404 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
1483 | + if ($asrequest) |
|
1484 | + { |
|
1485 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
1486 | + } |
|
1405 | 1487 | $response = Api\Json\Response::get(); |
1406 | 1488 | $response->call('app.calendar.custom_mail', $vars); |
1407 | 1489 | } |
@@ -1587,9 +1669,15 @@ discard block |
||
1587 | 1669 | } |
1588 | 1670 | } |
1589 | 1671 | // set new start and end if given by $_GET |
1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1672 | + if(isset($_GET['start'])) |
|
1673 | + { |
|
1674 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1675 | + if(isset($_GET['end'])) |
|
1676 | + { |
|
1677 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1678 | + if(isset($_GET['non_blocking'])) |
|
1679 | + { |
|
1680 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1593 | 1681 | // check if the event is the whole day |
1594 | 1682 | $start = $this->bo->date2array($event['start']); |
1595 | 1683 | $end = $this->bo->date2array($event['end']); |
@@ -1602,10 +1690,13 @@ discard block |
||
1602 | 1690 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
1603 | 1691 | { |
1604 | 1692 | $link_id = $link_ids[$n]; |
1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1693 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
1694 | + { |
|
1695 | + // guard against XSS |
|
1606 | 1696 | { |
1607 | 1697 | continue; |
1608 | 1698 | } |
1699 | + } |
|
1609 | 1700 | if(!$n) |
1610 | 1701 | { |
1611 | 1702 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1614,7 +1705,10 @@ discard block |
||
1614 | 1705 | { |
1615 | 1706 | foreach((array)$set['link_app'] as $i => $l_app) |
1616 | 1707 | { |
1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1708 | + if (($l_id=$set['link_id'][$i])) |
|
1709 | + { |
|
1710 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1711 | + } |
|
1618 | 1712 | } |
1619 | 1713 | unset($set['link_app']); |
1620 | 1714 | unset($set['link_id']); |
@@ -1640,10 +1734,13 @@ discard block |
||
1640 | 1734 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
1641 | 1735 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1642 | 1736 | |
1643 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
1737 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
1738 | + { |
|
1739 | + // already locked --> refresh the lock |
|
1644 | 1740 | { |
1645 | 1741 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
1646 | 1742 | } |
1743 | + } |
|
1647 | 1744 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1648 | 1745 | { |
1649 | 1746 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1677,14 +1774,20 @@ discard block |
||
1677 | 1774 | )); |
1678 | 1775 | Framework::message($msg, $msg_type); |
1679 | 1776 | $content['duration'] = $content['end'] - $content['start']; |
1680 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
1777 | + if (isset($this->durations[$content['duration']])) |
|
1778 | + { |
|
1779 | + $content['end'] = ''; |
|
1780 | + } |
|
1681 | 1781 | |
1682 | 1782 | $row = 3; |
1683 | 1783 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1684 | 1784 | // preserve some ui elements, if set eg. under error-conditions |
1685 | 1785 | foreach(array('quantity','resource','role') as $n) |
1686 | 1786 | { |
1687 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
1787 | + if (isset($event['participants'][$n])) |
|
1788 | + { |
|
1789 | + $content['participants'][$n] = $event['participants'][$n]; |
|
1790 | + } |
|
1688 | 1791 | } |
1689 | 1792 | foreach($event['participant_types'] as $type => $participants) |
1690 | 1793 | { |
@@ -1726,9 +1829,13 @@ discard block |
||
1726 | 1829 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1727 | 1830 | |
1728 | 1831 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
1729 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
1832 | + { |
|
1833 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
1834 | + } |
|
1730 | 1835 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
1731 | - $readonlys['participants']['delete'][$uid] = true; |
|
1836 | + { |
|
1837 | + $readonlys['participants']['delete'][$uid] = true; |
|
1838 | + } |
|
1732 | 1839 | // todo: make the participants available as links with email as title |
1733 | 1840 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1734 | 1841 | // enumerate group-invitations, so people can accept/reject them |
@@ -1759,7 +1866,11 @@ discard block |
||
1759 | 1866 | $content['participants']['cal_resources'] = ''; |
1760 | 1867 | foreach($this->bo->resources as $data) |
1761 | 1868 | { |
1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1869 | + if ($data['app'] == 'email') |
|
1870 | + { |
|
1871 | + continue; |
|
1872 | + } |
|
1873 | + // make no sense, as we cant search for email |
|
1763 | 1874 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1764 | 1875 | } |
1765 | 1876 | } |
@@ -1787,9 +1898,18 @@ discard block |
||
1787 | 1898 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
1788 | 1899 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
1789 | 1900 | $label = array(); |
1790 | - if ($days) $label[] = $days.' '.lang('days'); |
|
1791 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
1792 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
1901 | + if ($days) |
|
1902 | + { |
|
1903 | + $label[] = $days.' '.lang('days'); |
|
1904 | + } |
|
1905 | + if ($hours) |
|
1906 | + { |
|
1907 | + $label[] = $hours.' '.lang('hours'); |
|
1908 | + } |
|
1909 | + if ($minutes) |
|
1910 | + { |
|
1911 | + $label[] = $minutes.' '.lang('Minutes'); |
|
1912 | + } |
|
1793 | 1913 | if (!$label) |
1794 | 1914 | { |
1795 | 1915 | $alarm['offset'] = lang('at start of the event'); |
@@ -1861,25 +1981,34 @@ discard block |
||
1861 | 1981 | 'participants' => $this->accountsel->account_selection == 'none', |
1862 | 1982 | 'history' => !$event['id'], |
1863 | 1983 | ); |
1864 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
1984 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
1985 | + { |
|
1986 | + // no mail without mail-app |
|
1865 | 1987 | { |
1866 | 1988 | unset($sel_options['action']['mail']); |
1989 | + } |
|
1867 | 1990 | unset($sel_options['action']['sendmeetingrequest']); |
1868 | 1991 | } |
1869 | - if (!$event['id']) // no ical export for new (not saved) events |
|
1992 | + if (!$event['id']) |
|
1993 | + { |
|
1994 | + // no ical export for new (not saved) events |
|
1870 | 1995 | { |
1871 | 1996 | $readonlys['action'] = true; |
1872 | 1997 | } |
1998 | + } |
|
1873 | 1999 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
1874 | 2000 | { |
1875 | 2001 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1876 | 2002 | } |
1877 | 2003 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
1878 | 2004 | |
1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
2005 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
2006 | + { |
|
2007 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
1880 | 2008 | { |
1881 | 2009 | $sel_options['owner'][0] = lang('All participants'); |
1882 | 2010 | } |
2011 | + } |
|
1883 | 2012 | if (isset($event['participant_types']['u'][$this->user])) |
1884 | 2013 | { |
1885 | 2014 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1922,7 +2051,10 @@ discard block |
||
1922 | 2051 | |
1923 | 2052 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
1924 | 2053 | |
1925 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
2054 | + if (!empty($preserved['lock_token'])) |
|
2055 | + { |
|
2056 | + $content['lock_token'] = $preserved['lock_token']; |
|
2057 | + } |
|
1926 | 2058 | |
1927 | 2059 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1928 | 2060 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2275,13 +2407,16 @@ discard block |
||
2275 | 2407 | |
2276 | 2408 | foreach (array_keys($allConflicts) as $pId) |
2277 | 2409 | { |
2278 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2410 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
2411 | + { |
|
2412 | + // resources Allow ignore conflicts |
|
2279 | 2413 | { |
2280 | 2414 | |
2281 | 2415 | switch ($resources_config['ignoreconflicts']) |
2282 | 2416 | { |
2283 | 2417 | case 'no': |
2284 | 2418 | $readonlys['button[ignore]'] = true; |
2419 | + } |
|
2285 | 2420 | break; |
2286 | 2421 | case 'allusers': |
2287 | 2422 | $readonlys['button[ignore]'] = false; |
@@ -2425,7 +2560,10 @@ discard block |
||
2425 | 2560 | } |
2426 | 2561 | else |
2427 | 2562 | { |
2428 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
2563 | + if (!$content['duration']) |
|
2564 | + { |
|
2565 | + $content['duration'] = $content['end'] - $content['start']; |
|
2566 | + } |
|
2429 | 2567 | $weekds = 0; |
2430 | 2568 | foreach ($content['weekdays'] as &$wdays) |
2431 | 2569 | { |
@@ -2447,7 +2585,10 @@ discard block |
||
2447 | 2585 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
2448 | 2586 | |
2449 | 2587 | $sel_options['duration'] = $this->durations; |
2450 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
2588 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
2589 | + { |
|
2590 | + $content['end'] = ''; |
|
2591 | + } |
|
2451 | 2592 | |
2452 | 2593 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
2453 | 2594 | 'participants' => $content['participants'], |
@@ -2468,7 +2609,10 @@ discard block |
||
2468 | 2609 | */ |
2469 | 2610 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
2470 | 2611 | { |
2471 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2612 | + if ($this->debug > 2) |
|
2613 | + { |
|
2614 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2615 | + } |
|
2472 | 2616 | |
2473 | 2617 | $busy = $this->bo->search(array( |
2474 | 2618 | 'start' => $start, |
@@ -2485,9 +2629,17 @@ discard block |
||
2485 | 2629 | $n = 0; |
2486 | 2630 | foreach($busy as $event) |
2487 | 2631 | { |
2488 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2632 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
2633 | + { |
|
2634 | + continue; |
|
2635 | + } |
|
2636 | + // ignore our own event |
|
2489 | 2637 | |
2490 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
2638 | + if ($event['non_blocking']) |
|
2639 | + { |
|
2640 | + continue; |
|
2641 | + } |
|
2642 | + // ignore non_blocking events |
|
2491 | 2643 | |
2492 | 2644 | // check if from all wanted participants at least one has a not rejected status in found event |
2493 | 2645 | $non_rejected_found = false; |
@@ -2496,7 +2648,10 @@ discard block |
||
2496 | 2648 | $status = $event['participants'][$uid]; |
2497 | 2649 | $quantity = $role = null; |
2498 | 2650 | calendar_so::split_status($status, $quantity, $role); |
2499 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
2651 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
2652 | + { |
|
2653 | + continue; |
|
2654 | + } |
|
2500 | 2655 | |
2501 | 2656 | if (isset($event['participants'][$uid]) || |
2502 | 2657 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2506,7 +2661,10 @@ discard block |
||
2506 | 2661 | break; |
2507 | 2662 | } |
2508 | 2663 | } |
2509 | - if (!$non_rejected_found) continue; |
|
2664 | + if (!$non_rejected_found) |
|
2665 | + { |
|
2666 | + continue; |
|
2667 | + } |
|
2510 | 2668 | |
2511 | 2669 | if ($this->debug) |
2512 | 2670 | { |
@@ -2537,11 +2695,17 @@ discard block |
||
2537 | 2695 | 'start' => $ft_start, |
2538 | 2696 | 'end' => $ft_end, |
2539 | 2697 | ); |
2540 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2698 | + if ($this->debug > 1) |
|
2699 | + { |
|
2700 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2701 | + } |
|
2541 | 2702 | } |
2542 | 2703 | $ft_start = $event['end']; |
2543 | 2704 | } |
2544 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2705 | + if ($this->debug > 0) |
|
2706 | + { |
|
2707 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2708 | + } |
|
2545 | 2709 | |
2546 | 2710 | return $freetime; |
2547 | 2711 | } |
@@ -2561,10 +2725,16 @@ discard block |
||
2561 | 2725 | */ |
2562 | 2726 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2563 | 2727 | { |
2564 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2728 | + if ($this->debug > 1) |
|
2729 | + { |
|
2730 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2731 | + } |
|
2565 | 2732 | |
2566 | 2733 | $freetime_daywise = array(); |
2567 | - if (!is_array($sel_options)) $sel_options = array(); |
|
2734 | + if (!is_array($sel_options)) |
|
2735 | + { |
|
2736 | + $sel_options = array(); |
|
2737 | + } |
|
2568 | 2738 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2569 | 2739 | |
2570 | 2740 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2574,7 +2744,10 @@ discard block |
||
2574 | 2744 | if (($end_time - $start_time)*HOUR_s < $duration) |
2575 | 2745 | { |
2576 | 2746 | $end_time = 0; |
2577 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2747 | + if ($this->debug > 1) |
|
2748 | + { |
|
2749 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2750 | + } |
|
2578 | 2751 | } |
2579 | 2752 | $n = 0; |
2580 | 2753 | foreach($freetime as $ft) |
@@ -2595,13 +2768,19 @@ discard block |
||
2595 | 2768 | } |
2596 | 2769 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2597 | 2770 | |
2598 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2771 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
2772 | + { |
|
2773 | + // start earlier then start_time |
|
2599 | 2774 | { |
2600 | 2775 | $start = $daybegin + $start_time*HOUR_s; |
2601 | 2776 | } |
2777 | + } |
|
2602 | 2778 | // if end_time given use it, else the original slot's end |
2603 | 2779 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
2604 | - if ($end > $ft['end']) $end = $ft['end']; |
|
2780 | + if ($end > $ft['end']) |
|
2781 | + { |
|
2782 | + $end = $ft['end']; |
|
2783 | + } |
|
2605 | 2784 | |
2606 | 2785 | // slot to small for duration |
2607 | 2786 | if ($end - $start < $duration) |
@@ -2643,7 +2822,10 @@ discard block |
||
2643 | 2822 | { |
2644 | 2823 | $msg = lang('Permission denied'); |
2645 | 2824 | |
2646 | - if ($return_error) return $msg; |
|
2825 | + if ($return_error) |
|
2826 | + { |
|
2827 | + return $msg; |
|
2828 | + } |
|
2647 | 2829 | } |
2648 | 2830 | else |
2649 | 2831 | { |
@@ -2705,27 +2887,42 @@ discard block |
||
2705 | 2887 | { |
2706 | 2888 | list($button) = each($_content['button']); |
2707 | 2889 | unset($_content['button']); |
2708 | - if ($button != 'cancel') // store changed Acl |
|
2890 | + if ($button != 'cancel') |
|
2891 | + { |
|
2892 | + // store changed Acl |
|
2709 | 2893 | { |
2710 | 2894 | foreach($_content as $data) |
2711 | 2895 | { |
2712 | 2896 | if (!($cat_id = $data['cat_id'])) continue; |
2897 | + } |
|
2713 | 2898 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
2714 | 2899 | { |
2715 | 2900 | $rights = 0; |
2716 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2717 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2718 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2901 | + if (in_array($account_id,(array)$data['add'])) |
|
2902 | + { |
|
2903 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2904 | + } |
|
2905 | + if (in_array($account_id,(array)$data['status'])) |
|
2906 | + { |
|
2907 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2908 | + } |
|
2909 | + if ($account_id) |
|
2910 | + { |
|
2911 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2912 | + } |
|
2719 | 2913 | } |
2720 | 2914 | } |
2721 | 2915 | } |
2722 | - if ($button != 'apply') // end dialog |
|
2916 | + if ($button != 'apply') |
|
2917 | + { |
|
2918 | + // end dialog |
|
2723 | 2919 | { |
2724 | 2920 | Egw::redirect_link('/index.php', array( |
2725 | 2921 | 'menuaction' => 'admin.admin_ui.index', |
2726 | 2922 | 'ajax' => 'true' |
2727 | 2923 | ), 'admin'); |
2728 | 2924 | } |
2925 | + } |
|
2729 | 2926 | } |
2730 | 2927 | $content= $preserv = array(); |
2731 | 2928 | $n = 1; |
@@ -2739,8 +2936,14 @@ discard block |
||
2739 | 2936 | ); |
2740 | 2937 | foreach($data as $account_id => $rights) |
2741 | 2938 | { |
2742 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2743 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2939 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
2940 | + { |
|
2941 | + $row['add'][] = $account_id; |
|
2942 | + } |
|
2943 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
2944 | + { |
|
2945 | + $row['status'][] = $account_id; |
|
2946 | + } |
|
2744 | 2947 | } |
2745 | 2948 | $content[$n] = $row; |
2746 | 2949 | $preserv[$n] = array( |
@@ -2868,7 +3071,10 @@ discard block |
||
2868 | 3071 | break; |
2869 | 3072 | } |
2870 | 3073 | } |
2871 | - if($return) return; |
|
3074 | + if($return) |
|
3075 | + { |
|
3076 | + return; |
|
3077 | + } |
|
2872 | 3078 | } |
2873 | 3079 | $old_event=$event=$this->bo->read($eventId); |
2874 | 3080 | if (!$durationT) |
@@ -2962,7 +3168,10 @@ discard block |
||
2962 | 3168 | $this->bo->update($event,true, true, false, true, $message,true); |
2963 | 3169 | |
2964 | 3170 | // Whole day non blocking with DAY_s would add a day |
2965 | - if($duration==DAY_s) $duration=0; |
|
3171 | + if($duration==DAY_s) |
|
3172 | + { |
|
3173 | + $duration=0; |
|
3174 | + } |
|
2966 | 3175 | } |
2967 | 3176 | |
2968 | 3177 | $status_reset_to_unknown = false; |
@@ -2980,7 +3189,10 @@ discard block |
||
2980 | 3189 | case 'no': |
2981 | 3190 | break; |
2982 | 3191 | case 'startday': |
2983 | - if ($sameday) break; |
|
3192 | + if ($sameday) |
|
3193 | + { |
|
3194 | + break; |
|
3195 | + } |
|
2984 | 3196 | default: |
2985 | 3197 | $status_reset_to_unknown = true; |
2986 | 3198 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -3024,7 +3236,10 @@ discard block |
||
3024 | 3236 | { |
3025 | 3237 | $response->call('egw.message', implode('<br />', $message)); |
3026 | 3238 | } |
3027 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
3239 | + if($event['id'] != $eventId ) |
|
3240 | + { |
|
3241 | + $this->update_client($_eventId); |
|
3242 | + } |
|
3028 | 3243 | if ($status_reset_to_unknown) |
3029 | 3244 | { |
3030 | 3245 | foreach((array)$event['participants'] as $uid => $status) |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var locktime in seconds |
56 | 56 | */ |
57 | - var $locktime_default=1; |
|
57 | + var $locktime_default = 1; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Constructor |
61 | 61 | */ |
62 | 62 | function __construct() |
63 | 63 | { |
64 | - parent::__construct(true); // call the parent's constructor |
|
64 | + parent::__construct(true); // call the parent's constructor |
|
65 | 65 | |
66 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
66 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
67 | 67 | { |
68 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
68 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -77,11 +77,10 @@ discard block |
||
77 | 77 | function &default_add_event() |
78 | 78 | { |
79 | 79 | $extra_participants = $_GET['participants'] ? |
80 | - (!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) : |
|
81 | - array(); |
|
80 | + (!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array(); |
|
82 | 81 | |
83 | 82 | // if participant is a contact, add its link title as title |
84 | - foreach($extra_participants as $uid) |
|
83 | + foreach ($extra_participants as $uid) |
|
85 | 84 | { |
86 | 85 | if ($uid[0] == 'c') |
87 | 86 | { |
@@ -93,14 +92,14 @@ discard block |
||
93 | 92 | if (isset($_GET['owner'])) |
94 | 93 | { |
95 | 94 | $owner = $_GET['owner']; |
96 | - if(!is_array($owner) && strpos($owner, ',')) |
|
95 | + if (!is_array($owner) && strpos($owner, ',')) |
|
97 | 96 | { |
98 | - $owner = explode(',',$owner); |
|
97 | + $owner = explode(',', $owner); |
|
99 | 98 | } |
100 | - if(is_array($owner)) |
|
99 | + if (is_array($owner)) |
|
101 | 100 | { |
102 | 101 | // old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0' |
103 | - if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
102 | + if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
104 | 103 | { |
105 | 104 | $extra_participants += $owner; |
106 | 105 | } |
@@ -118,18 +117,18 @@ discard block |
||
118 | 117 | } |
119 | 118 | |
120 | 119 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
121 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
120 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
122 | 121 | { |
123 | 122 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
124 | 123 | { |
125 | - if(!is_array($owner)) |
|
124 | + if (!is_array($owner)) |
|
126 | 125 | { |
127 | - $owner = explode(',',$owner); |
|
126 | + $owner = explode(',', $owner); |
|
128 | 127 | } |
129 | 128 | // if we come from ressources we don't need any users selected in calendar |
130 | 129 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
131 | 130 | { |
132 | - foreach($owner as $uid) |
|
131 | + foreach ($owner as $uid) |
|
133 | 132 | { |
134 | 133 | $extra_participants[] = $uid; |
135 | 134 | } |
@@ -139,77 +138,77 @@ discard block |
||
139 | 138 | } |
140 | 139 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
141 | 140 | |
142 | - if(isset($_GET['start'])) |
|
141 | + if (isset($_GET['start'])) |
|
143 | 142 | { |
144 | 143 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
145 | 144 | } |
146 | 145 | else |
147 | 146 | { |
148 | 147 | $start = $this->bo->date2ts(array( |
149 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
150 | - 'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
151 | - 'minute' => (int) $_GET['minute'], |
|
148 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
149 | + 'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
150 | + 'minute' => (int)$_GET['minute'], |
|
152 | 151 | )); |
153 | 152 | } |
154 | 153 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
155 | 154 | |
156 | 155 | $participant_types['u'] = $participant_types = $participants = array(); |
157 | - foreach($extra_participants as $uid) |
|
156 | + foreach ($extra_participants as $uid) |
|
158 | 157 | { |
159 | - if (isset($participants[$uid])) continue; // already included |
|
158 | + if (isset($participants[$uid])) continue; // already included |
|
160 | 159 | |
161 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
160 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
162 | 161 | |
163 | 162 | if (is_numeric($uid)) |
164 | 163 | { |
165 | 164 | $participants[$uid] = $participant_types['u'][$uid] = |
166 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
167 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
165 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
166 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
168 | 167 | } |
169 | 168 | elseif (is_array($this->bo->resources[$uid[0]])) |
170 | 169 | { |
171 | 170 | // Expand mailing lists |
172 | - if($uid[0] == 'l') |
|
171 | + if ($uid[0] == 'l') |
|
173 | 172 | { |
174 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
173 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
175 | 174 | { |
176 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
177 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
175 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
176 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
178 | 177 | } |
179 | 178 | continue; |
180 | 179 | } |
181 | 180 | // if contact is a user, use the user instead (as the GUI) |
182 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
181 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
183 | 182 | { |
184 | 183 | $uid = $account_id; |
185 | 184 | $participants[$uid] = $participant_types['u'][$uid] = |
186 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
187 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
185 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
186 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
188 | 187 | continue; |
189 | 188 | } |
190 | 189 | $res_data = $this->bo->resources[$uid[0]]; |
191 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
192 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
190 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
191 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
193 | 192 | { |
194 | 193 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
195 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
194 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
196 | 195 | } |
197 | 196 | } |
198 | 197 | } |
199 | 198 | if (!$participants) // if all participants got removed, include current user |
200 | 199 | { |
201 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
200 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
202 | 201 | } |
203 | - if(isset($_GET['cat_id'])) |
|
202 | + if (isset($_GET['cat_id'])) |
|
204 | 203 | { |
205 | - $cat_id = explode(',',$_GET['cat_id']); |
|
206 | - foreach($cat_id as &$cat) |
|
204 | + $cat_id = explode(',', $_GET['cat_id']); |
|
205 | + foreach ($cat_id as &$cat) |
|
207 | 206 | { |
208 | 207 | $cat = (int)$cat; |
209 | 208 | } |
210 | 209 | } |
211 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
212 | - if(isset($_GET['end'])) |
|
210 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
211 | + if (isset($_GET['end'])) |
|
213 | 212 | { |
214 | 213 | $end = Api\DateTime::to($_GET['end'], 'ts'); |
215 | 214 | $duration = $end - $start; |
@@ -227,9 +226,9 @@ discard block |
||
227 | 226 | if ((string)$this->cal_prefs[$alarm_pref] !== '') |
228 | 227 | { |
229 | 228 | $offset = 60 * $this->cal_prefs[$alarm_pref]; |
230 | - $alarms[1] = array( |
|
229 | + $alarms[1] = array( |
|
231 | 230 | 'default' => 1, |
232 | - 'offset' => $offset , |
|
231 | + 'offset' => $offset, |
|
233 | 232 | 'time' => $start - $offset, |
234 | 233 | 'all' => false, |
235 | 234 | 'owner' => $owner, |
@@ -244,7 +243,7 @@ discard block |
||
244 | 243 | 'start' => $start, |
245 | 244 | 'end' => $end, |
246 | 245 | 'tzid' => $this->bo->common_prefs['tz'], |
247 | - 'priority' => 2, // normal |
|
246 | + 'priority' => 2, // normal |
|
248 | 247 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
249 | 248 | 'alarm' => $alarms, |
250 | 249 | 'recur_exception' => array(), |
@@ -263,7 +262,7 @@ discard block |
||
263 | 262 | { |
264 | 263 | if (!is_array($content)) // redirect from etemplate, if POST empty |
265 | 264 | { |
266 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
265 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
267 | 266 | } |
268 | 267 | // clear notification errors |
269 | 268 | notifications::errors(true); |
@@ -277,22 +276,22 @@ discard block |
||
277 | 276 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
278 | 277 | |
279 | 278 | list($button) = @each($content['button']); |
280 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
279 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
281 | 280 | unset($content['button']); unset($content['action']); |
282 | 281 | |
283 | 282 | $view = $content['view']; |
284 | 283 | if ($button == 'ical') |
285 | 284 | { |
286 | - $msg = $this->export($content['id'],true); |
|
285 | + $msg = $this->export($content['id'], true); |
|
287 | 286 | } |
288 | 287 | // delete a recur-exception |
289 | 288 | if ($content['recur_exception']['delete_exception']) |
290 | 289 | { |
291 | 290 | list($date) = each($content['recur_exception']['delete_exception']); |
292 | 291 | // eT2 converts time to |
293 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
292 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
294 | 293 | unset($content['recur_exception']['delete_exception']); |
295 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
294 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
296 | 295 | { |
297 | 296 | // propagate the exception to a single event |
298 | 297 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -302,7 +301,7 @@ discard block |
||
302 | 301 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
303 | 302 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
304 | 303 | $exception['reference'] = $exception['recurrence'] = 0; |
305 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
304 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
306 | 305 | break; |
307 | 306 | } |
308 | 307 | unset($content['recur_exception'][$key]); |
@@ -343,7 +342,7 @@ discard block |
||
343 | 342 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
344 | 343 | if ((string)$def_alarm === '') |
345 | 344 | { |
346 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
345 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
347 | 346 | } |
348 | 347 | else |
349 | 348 | { |
@@ -365,7 +364,7 @@ discard block |
||
365 | 364 | $offset = 60 * $def_alarm; |
366 | 365 | array_unshift($content['alarm'], array( |
367 | 366 | 'default' => 1, |
368 | - 'offset' => $offset , |
|
367 | + 'offset' => $offset, |
|
369 | 368 | 'time' => $content['start'] - $offset, |
370 | 369 | 'all' => false, |
371 | 370 | 'owner' => 0, |
@@ -378,7 +377,7 @@ discard block |
||
378 | 377 | unset($event['alarm']['delete_alarm']); |
379 | 378 | unset($event['duration']); |
380 | 379 | |
381 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
380 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
382 | 381 | { |
383 | 382 | // no conversation necessary, event is already in the right format |
384 | 383 | } |
@@ -398,7 +397,7 @@ discard block |
||
398 | 397 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
399 | 398 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
400 | 399 | { |
401 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
400 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
402 | 401 | } |
403 | 402 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
404 | 403 | { |
@@ -410,9 +409,9 @@ discard block |
||
410 | 409 | |
411 | 410 | $event['participants'] = $event['participant_types'] = array(); |
412 | 411 | |
413 | - foreach($content['participants'] as $key => $data) |
|
412 | + foreach ($content['participants'] as $key => $data) |
|
414 | 413 | { |
415 | - switch($key) |
|
414 | + switch ($key) |
|
416 | 415 | { |
417 | 416 | case 'delete': // handled in default |
418 | 417 | case 'quantity': // handled in new_resource |
@@ -421,7 +420,7 @@ discard block |
||
421 | 420 | case 'status_date': |
422 | 421 | break; |
423 | 422 | case 'participant': |
424 | - foreach($data as $participant) |
|
423 | + foreach ($data as $participant) |
|
425 | 424 | { |
426 | 425 | if (is_null($participant)) |
427 | 426 | { |
@@ -430,17 +429,17 @@ discard block |
||
430 | 429 | |
431 | 430 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
432 | 431 | $email = array(); |
433 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
432 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
434 | 433 | { |
435 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
436 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
434 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
435 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
437 | 436 | { |
438 | 437 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
439 | 438 | } |
440 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
439 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
441 | 440 | 'email' => $email[2], |
442 | 441 | 'email_home' => $email[2], |
443 | - ),true,'','','',false,'OR'))) |
|
442 | + ), true, '', '', '', false, 'OR'))) |
|
444 | 443 | { |
445 | 444 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
446 | 445 | } |
@@ -451,7 +450,7 @@ discard block |
||
451 | 450 | } |
452 | 451 | else |
453 | 452 | { |
454 | - if(is_numeric($participant)) |
|
453 | + if (is_numeric($participant)) |
|
455 | 454 | { |
456 | 455 | $uid = $participant; |
457 | 456 | $id = $participant; |
@@ -460,12 +459,12 @@ discard block |
||
460 | 459 | else |
461 | 460 | { |
462 | 461 | $uid = $participant; |
463 | - $id = substr($participant,1); |
|
462 | + $id = substr($participant, 1); |
|
464 | 463 | $resource = $this->bo->resources[$participant[0]]; |
465 | 464 | } |
466 | - if(!$this->bo->check_acl_invite($uid)) |
|
465 | + if (!$this->bo->check_acl_invite($uid)) |
|
467 | 466 | { |
468 | - if(!$msg_permission_denied_added) |
|
467 | + if (!$msg_permission_denied_added) |
|
469 | 468 | { |
470 | 469 | $msg .= lang('Permission denied!'); |
471 | 470 | $msg_permission_denied_added = true; |
@@ -475,20 +474,19 @@ discard block |
||
475 | 474 | |
476 | 475 | $type = $resource['type']; |
477 | 476 | $status = isset($this->bo->resources[$type]['new_status']) ? |
478 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
479 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
477 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
480 | 478 | |
481 | 479 | // Expand mailing lists |
482 | - if($type == 'l') |
|
480 | + if ($type == 'l') |
|
483 | 481 | { |
484 | 482 | // Ignore ACL here, allow inviting anyone in the list |
485 | - foreach($this->bo->enum_mailing_list($participant, true) as $contact) |
|
483 | + foreach ($this->bo->enum_mailing_list($participant, true) as $contact) |
|
486 | 484 | { |
487 | 485 | // Mailing lists can contain users, so allow for that possibility |
488 | 486 | $_type = is_numeric($contact) ? '' : $contact[0]; |
489 | - $_uid = is_numeric($contact) ? $contact : substr($contact,1); |
|
487 | + $_uid = is_numeric($contact) ? $contact : substr($contact, 1); |
|
490 | 488 | $event['participants'][$contact] = $event['participant_types'][$_type][$_uid] = |
491 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
489 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
492 | 490 | } |
493 | 491 | continue; |
494 | 492 | } |
@@ -498,8 +496,8 @@ discard block |
||
498 | 496 | // todo check real availability = maximum - already booked quantity |
499 | 497 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
500 | 498 | { |
501 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
502 | - foreach(array('quantity','resource','role') as $n) |
|
499 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
500 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
503 | 501 | { |
504 | 502 | $event['participants'][$n] = $content['participants'][$n]; |
505 | 503 | } |
@@ -508,7 +506,7 @@ discard block |
||
508 | 506 | else |
509 | 507 | { |
510 | 508 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
511 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
509 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
512 | 510 | } |
513 | 511 | } |
514 | 512 | } |
@@ -522,15 +520,15 @@ discard block |
||
522 | 520 | break; |
523 | 521 | |
524 | 522 | default: // existing participant row |
525 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
523 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
526 | 524 | $quantity = $status = $role = null; |
527 | - foreach(array('uid','status','quantity','role') as $name) |
|
525 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
528 | 526 | { |
529 | 527 | $$name = $data[$name]; |
530 | 528 | } |
531 | 529 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
532 | 530 | { |
533 | - $uid = false; // entry has been deleted |
|
531 | + $uid = false; // entry has been deleted |
|
534 | 532 | } |
535 | 533 | elseif ($uid) |
536 | 534 | { |
@@ -541,27 +539,27 @@ discard block |
||
541 | 539 | } |
542 | 540 | else |
543 | 541 | { |
544 | - $id = substr($uid,1); |
|
542 | + $id = substr($uid, 1); |
|
545 | 543 | $type = $uid[0]; |
546 | 544 | } |
547 | 545 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
548 | 546 | { |
549 | 547 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
550 | 548 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
551 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
549 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
552 | 550 | { |
553 | 551 | // Update main window |
554 | 552 | $d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone); |
555 | 553 | $client_updated = $this->update_client($event['id'], $d); |
556 | 554 | |
557 | 555 | // refreshing the calendar-view with the changed participant-status |
558 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
556 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
559 | 557 | { |
560 | 558 | $msg = lang('Status for all future scheduled days changed'); |
561 | 559 | } |
562 | 560 | else |
563 | 561 | { |
564 | - if(isset($content['edit_single'])) |
|
562 | + if (isset($content['edit_single'])) |
|
565 | 563 | { |
566 | 564 | $msg = lang('Status for this particular day changed'); |
567 | 565 | // prevent accidentally creating a real exception afterwards |
@@ -582,7 +580,7 @@ discard block |
||
582 | 580 | if ($status == 'R' && $event['alarm']) |
583 | 581 | { |
584 | 582 | // remove from bo->set_status deleted alarms of rejected users from UI too |
585 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
583 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
586 | 584 | { |
587 | 585 | if ((string)$alarm['owner'] === (string)$uid) |
588 | 586 | { |
@@ -595,7 +593,7 @@ discard block |
||
595 | 593 | if ($uid && $status != 'G') |
596 | 594 | { |
597 | 595 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
598 | - calendar_so::combine_status($status,$quantity,$role); |
|
596 | + calendar_so::combine_status($status, $quantity, $role); |
|
599 | 597 | } |
600 | 598 | } |
601 | 599 | break; |
@@ -614,26 +612,26 @@ discard block |
||
614 | 612 | 'tabs' => $content['tabs'], |
615 | 613 | 'template' => $content['template'], |
616 | 614 | ); |
617 | - $noerror=true; |
|
615 | + $noerror = true; |
|
618 | 616 | |
619 | 617 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
620 | 618 | |
621 | 619 | $ignore_conflicts = $status_reset_to_unknown = false; |
622 | 620 | |
623 | - switch((string)$button) |
|
621 | + switch ((string)$button) |
|
624 | 622 | { |
625 | 623 | case 'ignore': |
626 | 624 | $ignore_conflicts = true; |
627 | - $button = $event['button_was']; // save or apply |
|
625 | + $button = $event['button_was']; // save or apply |
|
628 | 626 | unset($event['button_was']); |
629 | 627 | break; |
630 | 628 | |
631 | 629 | } |
632 | 630 | |
633 | - switch((string)$button) |
|
631 | + switch ((string)$button) |
|
634 | 632 | { |
635 | 633 | case 'exception': // create an exception in a recuring event |
636 | - $msg = $this->_create_exception($event,$preserv); |
|
634 | + $msg = $this->_create_exception($event, $preserv); |
|
637 | 635 | break; |
638 | 636 | |
639 | 637 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -644,29 +642,29 @@ discard block |
||
644 | 642 | unset($event['recurrence']); |
645 | 643 | unset($preserv['recurrence']); |
646 | 644 | unset($event['recur_exception']); |
647 | - unset($event['edit_single']); // in case it has been set |
|
645 | + unset($event['edit_single']); // in case it has been set |
|
648 | 646 | unset($event['modified']); |
649 | 647 | unset($event['modifier']); |
650 | 648 | unset($event['caldav_name']); |
651 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
649 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner']; |
|
652 | 650 | |
653 | 651 | // Clear participant stati |
654 | - foreach($event['participant_types'] as $type => &$participants) |
|
652 | + foreach ($event['participant_types'] as $type => &$participants) |
|
655 | 653 | { |
656 | - foreach($participants as $id => &$p_response) |
|
654 | + foreach ($participants as $id => &$p_response) |
|
657 | 655 | { |
658 | - if($type == 'u' && $id == $event['owner']) continue; |
|
656 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
659 | 657 | calendar_so::split_status($p_response, $quantity, $role); |
660 | 658 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
661 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
662 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
659 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
660 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
663 | 661 | } |
664 | 662 | } |
665 | 663 | |
666 | 664 | // Copy alarms |
667 | 665 | if (is_array($event['alarm'])) |
668 | 666 | { |
669 | - foreach($event['alarm'] as $n => &$alarm) |
|
667 | + foreach ($event['alarm'] as $n => &$alarm) |
|
670 | 668 | { |
671 | 669 | unset($alarm['id']); |
672 | 670 | unset($alarm['cal_id']); |
@@ -676,7 +674,7 @@ discard block |
||
676 | 674 | // Get links to be copied |
677 | 675 | // With no ID, $content['link_to']['to_id'] is used |
678 | 676 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
679 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
677 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
680 | 678 | { |
681 | 679 | if ($link['app'] != Link::VFS_APPNAME) |
682 | 680 | { |
@@ -692,7 +690,7 @@ discard block |
||
692 | 690 | } |
693 | 691 | unset($link); |
694 | 692 | $preserv['view'] = $preserv['edit_single'] = false; |
695 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
693 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry'))); |
|
696 | 694 | $event['title'] = lang('Copy of:').' '.$event['title']; |
697 | 695 | break; |
698 | 696 | |
@@ -702,7 +700,7 @@ discard block |
||
702 | 700 | case 'print': |
703 | 701 | case 'apply': |
704 | 702 | case 'infolog': |
705 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
703 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
706 | 704 | { |
707 | 705 | $msg = lang('Permission denied'); |
708 | 706 | $button = ''; |
@@ -720,7 +718,7 @@ discard block |
||
720 | 718 | $button = ''; |
721 | 719 | break; |
722 | 720 | } |
723 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
721 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
724 | 722 | { |
725 | 723 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
726 | 724 | $button = ''; |
@@ -750,14 +748,14 @@ discard block |
||
750 | 748 | $event['reference'] = $event['id']; |
751 | 749 | $event['recurrence'] = $content['edit_single']; |
752 | 750 | unset($event['id']); |
753 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
751 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
754 | 752 | if (!is_array($conflicts) && $conflicts) |
755 | 753 | { |
756 | 754 | // now we need to add the original start as recur-execption to the series |
757 | 755 | $recur_event = $this->bo->read($event['reference']); |
758 | 756 | $recur_event['recur_exception'][] = $content['edit_single']; |
759 | 757 | // check if we need to move the alarms, because they are next on that exception |
760 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
758 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
761 | 759 | { |
762 | 760 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
763 | 761 | { |
@@ -773,17 +771,17 @@ discard block |
||
773 | 771 | } |
774 | 772 | } |
775 | 773 | } |
776 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
777 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
778 | - $this->bo->update($recur_event,true); // no conflict check here |
|
774 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
775 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
776 | + $this->bo->update($recur_event, true); // no conflict check here |
|
779 | 777 | |
780 | 778 | // Save links |
781 | - if($content['links']) |
|
779 | + if ($content['links']) |
|
782 | 780 | { |
783 | 781 | Link::link('calendar', $event['id'], $content['links']['to_id']); |
784 | 782 | } |
785 | 783 | |
786 | - if(Api\Json\Response::isJSONResponse()) |
|
784 | + if (Api\Json\Response::isJSONResponse()) |
|
787 | 785 | { |
788 | 786 | // Sending null will trigger a removal of the original |
789 | 787 | // for that date |
@@ -791,7 +789,7 @@ discard block |
||
791 | 789 | } |
792 | 790 | |
793 | 791 | unset($recur_event); |
794 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
792 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
795 | 793 | unset($preserv['edit_single']); |
796 | 794 | } |
797 | 795 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -822,8 +820,8 @@ discard block |
||
822 | 820 | { |
823 | 821 | $offset = $off2; |
824 | 822 | } |
825 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
826 | - if($msg) |
|
823 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
824 | + if ($msg) |
|
827 | 825 | { |
828 | 826 | $noerror = false; |
829 | 827 | } |
@@ -836,10 +834,10 @@ discard block |
||
836 | 834 | $event['whole_day'] != $old_event['whole_day']) |
837 | 835 | { |
838 | 836 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
839 | - foreach((array)$event['participants'] as $uid => $status) |
|
837 | + foreach ((array)$event['participants'] as $uid => $status) |
|
840 | 838 | { |
841 | 839 | $q = $r = null; |
842 | - calendar_so::split_status($status,$q,$r); |
|
840 | + calendar_so::split_status($status, $q, $r); |
|
843 | 841 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
844 | 842 | { |
845 | 843 | $preferences = new Api\Preferences($uid); |
@@ -852,7 +850,7 @@ discard block |
||
852 | 850 | if ($sameday) break; |
853 | 851 | default: |
854 | 852 | $status_reset_to_unknown = true; |
855 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
853 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
856 | 854 | // todo: report reset status to user |
857 | 855 | } |
858 | 856 | } |
@@ -870,43 +868,43 @@ discard block |
||
870 | 868 | } |
871 | 869 | // Adding participants needs to be done as an edit, in case we |
872 | 870 | // have participants visible in seperate calendars |
873 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
871 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
874 | 872 | { |
875 | 873 | $update_type = 'edit'; |
876 | 874 | } |
877 | 875 | // Changing category may affect event filtering |
878 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
876 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
879 | 877 | { |
880 | 878 | $update_type = 'edit'; |
881 | 879 | } |
882 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
880 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
883 | 881 | unset($event['ignore']); |
884 | 882 | } |
885 | 883 | if (is_array($conflicts)) |
886 | 884 | { |
887 | - $event['button_was'] = $button; // remember for ignore |
|
888 | - return $this->conflicts($event,$conflicts,$preserv); |
|
885 | + $event['button_was'] = $button; // remember for ignore |
|
886 | + return $this->conflicts($event, $conflicts, $preserv); |
|
889 | 887 | } |
890 | 888 | |
891 | 889 | // Event spans multiple days, need an edit to make sure they all get updated |
892 | 890 | // We could check old date, as removing from days could still be an update |
893 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
891 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
894 | 892 | { |
895 | 893 | $update_type = 'edit'; |
896 | 894 | } |
897 | 895 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
898 | 896 | if ($messages) |
899 | 897 | { |
900 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
898 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
901 | 899 | } |
902 | 900 | if ($conflicts === 0) |
903 | 901 | { |
904 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
905 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
906 | - htmlspecialchars(Egw::link('/index.php',array( |
|
902 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
903 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
904 | + htmlspecialchars(Egw::link('/index.php', array( |
|
907 | 905 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
908 | 906 | 'cal_id' => $content['id'], |
909 | - ))).'">','</a>'); |
|
907 | + ))).'">', '</a>'); |
|
910 | 908 | $noerror = false; |
911 | 909 | } |
912 | 910 | elseif ($conflicts > 0) |
@@ -928,19 +926,19 @@ discard block |
||
928 | 926 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
929 | 927 | if ($alarm['time'] < $this->bo->now_su) |
930 | 928 | { |
931 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
929 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
932 | 930 | { |
933 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
931 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
934 | 932 | } |
935 | 933 | else |
936 | 934 | { |
937 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
935 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
938 | 936 | } |
939 | 937 | } |
940 | 938 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
941 | 939 | elseif ($event_time < $event['start']) |
942 | 940 | { |
943 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
941 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
944 | 942 | } |
945 | 943 | if ($alarm) |
946 | 944 | { |
@@ -949,9 +947,9 @@ discard block |
||
949 | 947 | } |
950 | 948 | } |
951 | 949 | // attach all future exceptions to the new series |
952 | - $events =& $this->bo->search(array( |
|
950 | + $events = & $this->bo->search(array( |
|
953 | 951 | 'query' => array('cal_uid' => $old_event['uid']), |
954 | - 'filter' => 'owner', // return all possible entries |
|
952 | + 'filter' => 'owner', // return all possible entries |
|
955 | 953 | 'daywise' => false, |
956 | 954 | 'date_format' => 'ts', |
957 | 955 | )); |
@@ -962,7 +960,7 @@ discard block |
||
962 | 960 | $exception['recurrence'] += $offset; |
963 | 961 | $exception['reference'] = $event['id']; |
964 | 962 | $exception['uid'] = $event['uid']; |
965 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
963 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
966 | 964 | } |
967 | 965 | } |
968 | 966 | } |
@@ -970,12 +968,12 @@ discard block |
||
970 | 968 | $message = lang('Event saved'); |
971 | 969 | if ($status_reset_to_unknown) |
972 | 970 | { |
973 | - foreach((array)$event['participants'] as $uid => $status) |
|
971 | + foreach ((array)$event['participants'] as $uid => $status) |
|
974 | 972 | { |
975 | 973 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
976 | 974 | { |
977 | - calendar_so::split_status($status,$q,$r); |
|
978 | - $status = calendar_so::combine_status('U',$q,$r); |
|
975 | + calendar_so::split_status($status, $q, $r); |
|
976 | + $status = calendar_so::combine_status('U', $q, $r); |
|
979 | 977 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
980 | 978 | } |
981 | 979 | } |
@@ -983,17 +981,17 @@ discard block |
||
983 | 981 | } |
984 | 982 | |
985 | 983 | $response = Api\Json\Response::get(); |
986 | - if($response && $update_type != 'delete') |
|
984 | + if ($response && $update_type != 'delete') |
|
987 | 985 | { |
988 | 986 | $client_updated = $this->update_client($event['id']); |
989 | 987 | } |
990 | 988 | |
991 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
989 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
992 | 990 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
993 | 991 | // writing links for new entry, existing ones are handled by the widget itself |
994 | 992 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
995 | 993 | { |
996 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
994 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
997 | 995 | } |
998 | 996 | } |
999 | 997 | else |
@@ -1003,7 +1001,7 @@ discard block |
||
1003 | 1001 | break; |
1004 | 1002 | |
1005 | 1003 | case 'cancel': |
1006 | - if($content['cancel_needs_refresh']) |
|
1004 | + if ($content['cancel_needs_refresh']) |
|
1007 | 1005 | { |
1008 | 1006 | Framework::refresh_opener($msg, 'calendar'); |
1009 | 1007 | } |
@@ -1041,7 +1039,7 @@ discard block |
||
1041 | 1039 | { |
1042 | 1040 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
1043 | 1041 | } |
1044 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1042 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
1045 | 1043 | { |
1046 | 1044 | $alarm = array( |
1047 | 1045 | 'offset' => $offset, |
@@ -1055,13 +1053,13 @@ discard block |
||
1055 | 1053 | } |
1056 | 1054 | elseif ($event['id']) // save the alarm immediatly |
1057 | 1055 | { |
1058 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1056 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
1059 | 1057 | { |
1060 | 1058 | $alarm['id'] = $alarm_id; |
1061 | 1059 | $event['alarm'][$alarm_id] = $alarm; |
1062 | 1060 | |
1063 | 1061 | $msg = lang('Alarm added'); |
1064 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1062 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
1065 | 1063 | } |
1066 | 1064 | else |
1067 | 1065 | { |
@@ -1070,7 +1068,7 @@ discard block |
||
1070 | 1068 | } |
1071 | 1069 | else |
1072 | 1070 | { |
1073 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1071 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1074 | 1072 | $event['alarm'][$alarm['id']] = $alarm; |
1075 | 1073 | } |
1076 | 1074 | } |
@@ -1087,32 +1085,32 @@ discard block |
||
1087 | 1085 | } |
1088 | 1086 | // New event, send data before updating so it's there |
1089 | 1087 | $response = Api\Json\Response::get(); |
1090 | - if($response && !$content['id'] && $event['id']) |
|
1088 | + if ($response && !$content['id'] && $event['id']) |
|
1091 | 1089 | { |
1092 | 1090 | $client_updated = $this->update_client($event['id']); |
1093 | 1091 | } |
1094 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
1092 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
1095 | 1093 | { |
1096 | 1094 | if ($content['lock_token']) // remove an existing lock |
1097 | 1095 | { |
1098 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
1096 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
1099 | 1097 | } |
1100 | 1098 | if ($content['no_popup']) |
1101 | 1099 | { |
1102 | - Egw::redirect_link('/index.php',array( |
|
1100 | + Egw::redirect_link('/index.php', array( |
|
1103 | 1101 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1104 | 1102 | 'msg' => $msg, |
1105 | 1103 | 'ajax' => 'true' |
1106 | 1104 | )); |
1107 | 1105 | } |
1108 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1106 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1109 | 1107 | { |
1110 | - Framework::refresh_opener($msg,'calendar'); |
|
1108 | + Framework::refresh_opener($msg, 'calendar'); |
|
1111 | 1109 | } |
1112 | 1110 | else |
1113 | 1111 | { |
1114 | 1112 | Framework::refresh_opener($msg, 'calendar', |
1115 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
1113 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
1116 | 1114 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
1117 | 1115 | ); |
1118 | 1116 | } |
@@ -1120,7 +1118,7 @@ discard block |
||
1120 | 1118 | exit(); |
1121 | 1119 | } |
1122 | 1120 | unset($event['no_notifications']); |
1123 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1121 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1124 | 1122 | } |
1125 | 1123 | |
1126 | 1124 | /** |
@@ -1132,7 +1130,7 @@ discard block |
||
1132 | 1130 | * @param array &$preserv |
1133 | 1131 | * @return string message that exception was created |
1134 | 1132 | */ |
1135 | - function _create_exception(&$event,&$preserv) |
|
1133 | + function _create_exception(&$event, &$preserv) |
|
1136 | 1134 | { |
1137 | 1135 | // In some cases where the user makes the first day an exception, actual_date may be missing |
1138 | 1136 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1142,25 +1140,25 @@ discard block |
||
1142 | 1140 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
1143 | 1141 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
1144 | 1142 | $event['recur_type'] = MCAL_RECUR_NONE; |
1145 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
1143 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
1146 | 1144 | { |
1147 | 1145 | unset($event[$name]); |
1148 | 1146 | } |
1149 | 1147 | // add all alarms as new alarms to execption |
1150 | 1148 | $event['alarm'] = array_values((array)$event['alarm']); |
1151 | - foreach($event['alarm'] as &$alarm) |
|
1149 | + foreach ($event['alarm'] as &$alarm) |
|
1152 | 1150 | { |
1153 | 1151 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
1154 | 1152 | } |
1155 | 1153 | |
1156 | 1154 | // Copy links |
1157 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1155 | + if (!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1158 | 1156 | $event['link_to']['to_app'] = 'calendar'; |
1159 | 1157 | $event['link_to']['to_id'] = 0; |
1160 | 1158 | |
1161 | - foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1159 | + foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1162 | 1160 | { |
1163 | - if(!$link['id']) continue; |
|
1161 | + if (!$link['id']) continue; |
|
1164 | 1162 | if ($link['app'] != Link::VFS_APPNAME) |
1165 | 1163 | { |
1166 | 1164 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1176,7 +1174,7 @@ discard block |
||
1176 | 1174 | |
1177 | 1175 | $event['links'] = $event['link_to']; |
1178 | 1176 | |
1179 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
1177 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
1180 | 1178 | { |
1181 | 1179 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
1182 | 1180 | } |
@@ -1203,14 +1201,14 @@ discard block |
||
1203 | 1201 | { |
1204 | 1202 | $msg = false; |
1205 | 1203 | |
1206 | - if(!$as_of_date ) |
|
1204 | + if (!$as_of_date) |
|
1207 | 1205 | { |
1208 | 1206 | $as_of_date = time(); |
1209 | 1207 | } |
1210 | 1208 | |
1211 | 1209 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
1212 | 1210 | |
1213 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1211 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1214 | 1212 | { |
1215 | 1213 | $msg = lang("Error: You can't shift a series from the past!"); |
1216 | 1214 | return $msg; |
@@ -1223,11 +1221,11 @@ discard block |
||
1223 | 1221 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
1224 | 1222 | |
1225 | 1223 | // base start-date of new series on actual / clicked date |
1226 | - $event['start'] = $as_of_date ; |
|
1224 | + $event['start'] = $as_of_date; |
|
1227 | 1225 | |
1228 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
1226 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
1229 | 1227 | // Adjust for requested date in the past |
1230 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
1228 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
1231 | 1229 | ) |
1232 | 1230 | { |
1233 | 1231 | |
@@ -1247,17 +1245,17 @@ discard block |
||
1247 | 1245 | $rriter->next_no_exception(); |
1248 | 1246 | $occurrence = $rriter->current(); |
1249 | 1247 | } |
1250 | - while ($rriter->valid() && ( |
|
1248 | + while ($rriter->valid() && ( |
|
1251 | 1249 | Api\DateTime::to($occurrence, 'ts') <= time() || |
1252 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
1250 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
1253 | 1251 | ) && ($last = $occurrence)); |
1254 | 1252 | |
1255 | 1253 | |
1256 | 1254 | // Make sure as_of_date is still valid, may have to move forward |
1257 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
1255 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
1258 | 1256 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
1259 | 1257 | { |
1260 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
1258 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
1261 | 1259 | } |
1262 | 1260 | |
1263 | 1261 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1265,7 +1263,7 @@ discard block |
||
1265 | 1263 | { |
1266 | 1264 | $event['end'] = $event['start'] + $duration; |
1267 | 1265 | } |
1268 | - elseif($event['end'] < $event['start']) |
|
1266 | + elseif ($event['end'] < $event['start']) |
|
1269 | 1267 | { |
1270 | 1268 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
1271 | 1269 | } |
@@ -1274,7 +1272,7 @@ discard block |
||
1274 | 1272 | $event['participants'] = $old_event['participants']; |
1275 | 1273 | foreach ($old_event['recur_exception'] as $key => $exdate) |
1276 | 1274 | { |
1277 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
1275 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
1278 | 1276 | { |
1279 | 1277 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
1280 | 1278 | unset($old_event['recur_exception'][$key]); |
@@ -1288,18 +1286,18 @@ discard block |
||
1288 | 1286 | } |
1289 | 1287 | $last->setTime(0, 0, 0); |
1290 | 1288 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
1291 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
1289 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
1292 | 1290 | { |
1293 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1294 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
1295 | - htmlspecialchars(Egw::link('/index.php',array( |
|
1291 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1292 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
1293 | + htmlspecialchars(Egw::link('/index.php', array( |
|
1296 | 1294 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1297 | 1295 | 'cal_id' => $event['id'], |
1298 | - ))).'">','</a>'); |
|
1296 | + ))).'">', '</a>'); |
|
1299 | 1297 | $event = $orig_event; |
1300 | 1298 | } |
1301 | 1299 | } |
1302 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
1300 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
1303 | 1301 | return $msg; |
1304 | 1302 | } |
1305 | 1303 | |
@@ -1310,18 +1308,18 @@ discard block |
||
1310 | 1308 | * @param boolean $added |
1311 | 1309 | * @return string javascript window.open command |
1312 | 1310 | */ |
1313 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
1311 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
1314 | 1312 | { |
1315 | 1313 | $to = array(); |
1316 | 1314 | |
1317 | - foreach($event['participants'] as $uid => $status) |
|
1315 | + foreach ($event['participants'] as $uid => $status) |
|
1318 | 1316 | { |
1319 | 1317 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1320 | 1318 | if (empty($status)) continue; |
1321 | - if(!is_array($status)) |
|
1319 | + if (!is_array($status)) |
|
1322 | 1320 | { |
1323 | 1321 | $quantity = $role = null; |
1324 | - calendar_so::split_status($status,$quantity,$role); |
|
1322 | + calendar_so::split_status($status, $quantity, $role); |
|
1325 | 1323 | $status = array( |
1326 | 1324 | 'status' => $status, |
1327 | 1325 | 'uid' => $uid, |
@@ -1332,32 +1330,32 @@ discard block |
||
1332 | 1330 | |
1333 | 1331 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1334 | 1332 | { |
1335 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1333 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
1336 | 1334 | |
1337 | 1335 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
1338 | 1336 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
1339 | 1337 | |
1340 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1338 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
1341 | 1339 | } |
1342 | 1340 | elseif ($uid < 0) |
1343 | 1341 | { |
1344 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
1342 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
1345 | 1343 | { |
1346 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1344 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
1347 | 1345 | |
1348 | 1346 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
1349 | 1347 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
1350 | 1348 | |
1351 | 1349 | // dont add groupmembers if they already rejected the event, or are the current user |
1352 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1350 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1353 | 1351 | } |
1354 | 1352 | } |
1355 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1353 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1356 | 1354 | { |
1357 | 1355 | $to[] = $info['email']; |
1358 | 1356 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1359 | 1357 | } |
1360 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
1358 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
1361 | 1359 | { |
1362 | 1360 | $to[] = $info['email']; |
1363 | 1361 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1366,7 +1364,7 @@ discard block |
||
1366 | 1364 | // prefer event description over standard notification text |
1367 | 1365 | if (empty($event['description'])) |
1368 | 1366 | { |
1369 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1367 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1370 | 1368 | } |
1371 | 1369 | else |
1372 | 1370 | { |
@@ -1381,12 +1379,12 @@ discard block |
||
1381 | 1379 | $boical = new calendar_ical(); |
1382 | 1380 | // we need to pass $event[id] so iCal class reads event again, |
1383 | 1381 | // as event is in user TZ, but iCal class expects server TZ! |
1384 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
1382 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
1385 | 1383 | |
1386 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
1387 | - if(($f = fopen($ics_file,'w'))) |
|
1384 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
1385 | + if (($f = fopen($ics_file, 'w'))) |
|
1388 | 1386 | { |
1389 | - fwrite($f,$ics); |
|
1387 | + fwrite($f, $ics); |
|
1390 | 1388 | fclose($f); |
1391 | 1389 | } |
1392 | 1390 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1397,10 +1395,10 @@ discard block |
||
1397 | 1395 | 'preset[body]' => $body, |
1398 | 1396 | 'preset[name]' => 'event.ics', |
1399 | 1397 | 'preset[file]' => $ics_file, |
1400 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
1398 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
1401 | 1399 | 'preset[size]' => filesize($ics_file), |
1402 | 1400 | ); |
1403 | - $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
|
1401 | + $vars[$asrequest ? 'preset[to]' : 'preset[bcc]'] = $to; |
|
1404 | 1402 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
1405 | 1403 | $response = Api\Json\Response::get(); |
1406 | 1404 | $response->call('app.calendar.custom_mail', $vars); |
@@ -1454,7 +1452,7 @@ discard block |
||
1454 | 1452 | * @param mixed $link_to_id ='' from or for the link-widget |
1455 | 1453 | * @param string $msg_type =null default automatic detect, if it contains "error" |
1456 | 1454 | */ |
1457 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
1455 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
1458 | 1456 | { |
1459 | 1457 | $sel_options = array( |
1460 | 1458 | 'recur_type' => &$this->bo->recur_types, |
@@ -1478,8 +1476,8 @@ discard block |
||
1478 | 1476 | 'no_popup' => isset($_GET['no_popup']), |
1479 | 1477 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
1480 | 1478 | ); |
1481 | - $cal_id = (int) $_GET['cal_id']; |
|
1482 | - if($_GET['action']) |
|
1479 | + $cal_id = (int)$_GET['cal_id']; |
|
1480 | + if ($_GET['action']) |
|
1483 | 1481 | { |
1484 | 1482 | $event = $this->bo->read($cal_id); |
1485 | 1483 | $event['action'] = $_GET['action']; |
@@ -1497,14 +1495,14 @@ discard block |
||
1497 | 1495 | { |
1498 | 1496 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
1499 | 1497 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
1500 | - $event =& $this->default_add_event(); |
|
1498 | + $event = & $this->default_add_event(); |
|
1501 | 1499 | } |
1502 | 1500 | if (!empty($_GET['ical_data']) && |
1503 | 1501 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
1504 | 1502 | { |
1505 | 1503 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
1506 | 1504 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
1507 | - $event =& $this->default_add_event(); |
|
1505 | + $event = & $this->default_add_event(); |
|
1508 | 1506 | } |
1509 | 1507 | if (!empty($_GET['ical'])) |
1510 | 1508 | { |
@@ -1513,14 +1511,14 @@ discard block |
||
1513 | 1511 | { |
1514 | 1512 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
1515 | 1513 | $msg = lang('Error: importing the iCal'); |
1516 | - $event =& $this->default_add_event(); |
|
1514 | + $event = & $this->default_add_event(); |
|
1517 | 1515 | } |
1518 | 1516 | else |
1519 | 1517 | { |
1520 | 1518 | if (count($events) > 1) |
1521 | 1519 | { |
1522 | 1520 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
1523 | - $msg_type = 'notice'; // no not hide automatic |
|
1521 | + $msg_type = 'notice'; // no not hide automatic |
|
1524 | 1522 | } |
1525 | 1523 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
1526 | 1524 | $this->bo->db2data($events, 'ts'); |
@@ -1533,7 +1531,7 @@ discard block |
||
1533 | 1531 | else |
1534 | 1532 | { |
1535 | 1533 | $event['participant_types'] = array(); |
1536 | - foreach($event['participants'] as $uid => $status) |
|
1534 | + foreach ($event['participants'] as $uid => $status) |
|
1537 | 1535 | { |
1538 | 1536 | $user_type = $user_id = null; |
1539 | 1537 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1554,15 +1552,15 @@ discard block |
||
1554 | 1552 | } |
1555 | 1553 | else |
1556 | 1554 | { |
1557 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
1555 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
1558 | 1556 | exit(); |
1559 | 1557 | } |
1560 | 1558 | } |
1561 | - $event =& $this->default_add_event(); |
|
1559 | + $event = & $this->default_add_event(); |
|
1562 | 1560 | } |
1563 | 1561 | else |
1564 | 1562 | { |
1565 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1563 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1566 | 1564 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1567 | 1565 | { |
1568 | 1566 | if (empty($event['whole_day'])) |
@@ -1575,10 +1573,10 @@ discard block |
||
1575 | 1573 | $date->setUser(); |
1576 | 1574 | } |
1577 | 1575 | $event = $this->bo->read($cal_id, $date, true); |
1578 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1576 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1579 | 1577 | if ($_GET['exception']) |
1580 | 1578 | { |
1581 | - $msg = $this->_create_exception($event,$preserv); |
|
1579 | + $msg = $this->_create_exception($event, $preserv); |
|
1582 | 1580 | } |
1583 | 1581 | else |
1584 | 1582 | { |
@@ -1587,9 +1585,9 @@ discard block |
||
1587 | 1585 | } |
1588 | 1586 | } |
1589 | 1587 | // set new start and end if given by $_GET |
1590 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1591 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1592 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1588 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
1589 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
1590 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1593 | 1591 | // check if the event is the whole day |
1594 | 1592 | $start = $this->bo->date2array($event['start']); |
1595 | 1593 | $end = $this->bo->date2array($event['end']); |
@@ -1599,30 +1597,30 @@ discard block |
||
1599 | 1597 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
1600 | 1598 | { |
1601 | 1599 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
1602 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1600 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1603 | 1601 | { |
1604 | 1602 | $link_id = $link_ids[$n]; |
1605 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1603 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
1606 | 1604 | { |
1607 | 1605 | continue; |
1608 | 1606 | } |
1609 | - if(!$n) |
|
1607 | + if (!$n) |
|
1610 | 1608 | { |
1611 | - $event['title'] = Link::title($link_app,$link_id); |
|
1609 | + $event['title'] = Link::title($link_app, $link_id); |
|
1612 | 1610 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
1613 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
1611 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
1614 | 1612 | { |
1615 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
1613 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
1616 | 1614 | { |
1617 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1615 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
1618 | 1616 | } |
1619 | 1617 | unset($set['link_app']); |
1620 | 1618 | unset($set['link_id']); |
1621 | 1619 | |
1622 | - $event = array_merge($event,$set); |
|
1620 | + $event = array_merge($event, $set); |
|
1623 | 1621 | } |
1624 | 1622 | } |
1625 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
1623 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
1626 | 1624 | } |
1627 | 1625 | } |
1628 | 1626 | } |
@@ -1632,45 +1630,45 @@ discard block |
||
1632 | 1630 | { |
1633 | 1631 | $etpl->read($preserv['template'] = 'calendar.edit'); |
1634 | 1632 | } |
1635 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
1633 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
1636 | 1634 | //echo "view=$view, event="; _debug_array($event); |
1637 | 1635 | // shared locking of entries to edit |
1638 | 1636 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
1639 | 1637 | { |
1640 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
1638 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
1641 | 1639 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1642 | 1640 | |
1643 | 1641 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
1644 | 1642 | { |
1645 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
1643 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
1646 | 1644 | } |
1647 | 1645 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1648 | 1646 | { |
1649 | 1647 | $msg .= ' '.lang('This entry is currently opened by %1!', |
1650 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
1648 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
1651 | 1649 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
1652 | 1650 | } |
1653 | - elseif($lock) |
|
1651 | + elseif ($lock) |
|
1654 | 1652 | { |
1655 | 1653 | $preserv['lock_token'] = $lock['token']; |
1656 | 1654 | } |
1657 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
1655 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
1658 | 1656 | { |
1659 | 1657 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
1660 | 1658 | } |
1661 | 1659 | else |
1662 | 1660 | { |
1663 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1661 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1664 | 1662 | $view = true; |
1665 | 1663 | } |
1666 | 1664 | } |
1667 | - $content = array_merge($event,array( |
|
1665 | + $content = array_merge($event, array( |
|
1668 | 1666 | 'cal_id' => $event['id'], |
1669 | 1667 | 'link_to' => array( |
1670 | 1668 | 'to_id' => $link_to_id, |
1671 | 1669 | 'to_app' => 'calendar', |
1672 | 1670 | ), |
1673 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1671 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1674 | 1672 | 'tabs' => $preserv['tabs'], |
1675 | 1673 | 'view' => $view, |
1676 | 1674 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1682,11 +1680,11 @@ discard block |
||
1682 | 1680 | $row = 3; |
1683 | 1681 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1684 | 1682 | // preserve some ui elements, if set eg. under error-conditions |
1685 | - foreach(array('quantity','resource','role') as $n) |
|
1683 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
1686 | 1684 | { |
1687 | 1685 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
1688 | 1686 | } |
1689 | - foreach($event['participant_types'] as $type => $participants) |
|
1687 | + foreach ($event['participant_types'] as $type => $participants) |
|
1690 | 1688 | { |
1691 | 1689 | $name = 'accounts'; |
1692 | 1690 | if (isset($this->bo->resources[$type])) |
@@ -1695,17 +1693,17 @@ discard block |
||
1695 | 1693 | } |
1696 | 1694 | // sort participants (in there group/app) by title |
1697 | 1695 | uksort($participants, array($this, 'uid_title_cmp')); |
1698 | - foreach($participants as $id => $status) |
|
1696 | + foreach ($participants as $id => $status) |
|
1699 | 1697 | { |
1700 | 1698 | $uid = $type == 'u' ? $id : $type.$id; |
1701 | 1699 | $quantity = $role = null; |
1702 | - calendar_so::split_status($status,$quantity,$role); |
|
1700 | + calendar_so::split_status($status, $quantity, $role); |
|
1703 | 1701 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1704 | 1702 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
1705 | 1703 | 'uid' => $uid, |
1706 | 1704 | 'status' => $status, |
1707 | 1705 | 'old_status' => $status, |
1708 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1706 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1709 | 1707 | 'role' => $role, |
1710 | 1708 | ); |
1711 | 1709 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1714,33 +1712,33 @@ discard block |
||
1714 | 1712 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
1715 | 1713 | } |
1716 | 1714 | // allow third party apps to use categories for roles |
1717 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
1715 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
1718 | 1716 | { |
1719 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
1717 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
1720 | 1718 | } |
1721 | 1719 | else |
1722 | 1720 | { |
1723 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
1721 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
1724 | 1722 | } |
1725 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
1723 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
1726 | 1724 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1727 | 1725 | |
1728 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
1726 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
1729 | 1727 | $readonlys['participants'][$row]['status'] = $no_status; |
1730 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
1728 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
1731 | 1729 | $readonlys['participants']['delete'][$uid] = true; |
1732 | 1730 | // todo: make the participants available as links with email as title |
1733 | 1731 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1734 | 1732 | // enumerate group-invitations, so people can accept/reject them |
1735 | 1733 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
1736 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
1734 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
1737 | 1735 | { |
1738 | 1736 | $sel_options['status']['G'] = lang('Select one'); |
1739 | 1737 | // sort members by title |
1740 | 1738 | usort($members, array($this, 'uid_title_cmp')); |
1741 | - foreach($members as $member) |
|
1739 | + foreach ($members as $member) |
|
1742 | 1740 | { |
1743 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
1741 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
1744 | 1742 | { |
1745 | 1743 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1746 | 1744 | 'app' => 'Group invitation', |
@@ -1749,7 +1747,7 @@ discard block |
||
1749 | 1747 | ); |
1750 | 1748 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
1751 | 1749 | // read access is enough to invite participants, but you need edit rights to change status |
1752 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
1750 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
1753 | 1751 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
1754 | 1752 | } |
1755 | 1753 | } |
@@ -1757,37 +1755,37 @@ discard block |
||
1757 | 1755 | } |
1758 | 1756 | // resouces / apps we shedule, atm. resources and addressbook |
1759 | 1757 | $content['participants']['cal_resources'] = ''; |
1760 | - foreach($this->bo->resources as $data) |
|
1758 | + foreach ($this->bo->resources as $data) |
|
1761 | 1759 | { |
1762 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1760 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1763 | 1761 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1764 | 1762 | } |
1765 | 1763 | } |
1766 | 1764 | $content['participants']['status_date'] = $preserv['actual_date']; |
1767 | - $preserved = array_merge($preserv,$content); |
|
1765 | + $preserved = array_merge($preserv, $content); |
|
1768 | 1766 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
1769 | 1767 | if ($event['alarm']) |
1770 | 1768 | { |
1771 | 1769 | // makes keys of the alarm-array starting with 1 |
1772 | 1770 | $content['alarm'] = array(false); |
1773 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
1771 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
1774 | 1772 | { |
1775 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
1773 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
1776 | 1774 | { |
1777 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1775 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1778 | 1776 | } |
1779 | - $alarm['all'] = (int) $alarm['all']; |
|
1777 | + $alarm['all'] = (int)$alarm['all']; |
|
1780 | 1778 | // fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise |
1781 | 1779 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1782 | 1780 | $after = false; |
1783 | - if($alarm['offset'] < 0) |
|
1781 | + if ($alarm['offset'] < 0) |
|
1784 | 1782 | { |
1785 | 1783 | $after = true; |
1786 | 1784 | $alarm['offset'] = -1 * $alarm['offset']; |
1787 | 1785 | } |
1788 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
1789 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
1790 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
1786 | + $days = (int)($alarm['offset'] / DAY_s); |
|
1787 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
1788 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
1791 | 1789 | $label = array(); |
1792 | 1790 | if ($days) $label[] = $days.' '.lang('days'); |
1793 | 1791 | if ($hours) $label[] = $hours.' '.lang('hours'); |
@@ -1798,11 +1796,11 @@ discard block |
||
1798 | 1796 | } |
1799 | 1797 | else |
1800 | 1798 | { |
1801 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
1799 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
1802 | 1800 | } |
1803 | 1801 | $content['alarm'][] = $alarm; |
1804 | 1802 | |
1805 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
1803 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
1806 | 1804 | } |
1807 | 1805 | if (count($content['alarm']) == 1) |
1808 | 1806 | { |
@@ -1817,20 +1815,20 @@ discard block |
||
1817 | 1815 | |
1818 | 1816 | if ($view) |
1819 | 1817 | { |
1820 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1818 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1821 | 1819 | $readonlys['button[cancel]'] = $readonlys['action'] = |
1822 | 1820 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
1823 | 1821 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
1824 | 1822 | |
1825 | 1823 | $content['participants']['no_add'] = true; |
1826 | 1824 | |
1827 | - if(!$event['whole_day']) |
|
1825 | + if (!$event['whole_day']) |
|
1828 | 1826 | { |
1829 | 1827 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
1830 | 1828 | } |
1831 | 1829 | |
1832 | 1830 | // respect category permissions |
1833 | - if(!empty($event['category'])) |
|
1831 | + if (!empty($event['category'])) |
|
1834 | 1832 | { |
1835 | 1833 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
1836 | 1834 | } |
@@ -1841,7 +1839,7 @@ discard block |
||
1841 | 1839 | |
1842 | 1840 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1843 | 1841 | { |
1844 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1842 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1845 | 1843 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
1846 | 1844 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
1847 | 1845 | } |
@@ -1851,9 +1849,9 @@ discard block |
||
1851 | 1849 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
1852 | 1850 | } |
1853 | 1851 | } |
1854 | - if($content['category'] && !is_array($content['category'])) |
|
1852 | + if ($content['category'] && !is_array($content['category'])) |
|
1855 | 1853 | { |
1856 | - $content['category'] = explode(',',$event['category']); |
|
1854 | + $content['category'] = explode(',', $event['category']); |
|
1857 | 1855 | } |
1858 | 1856 | // disabling the custom fields tab, if there are none |
1859 | 1857 | $readonlys['tabs'] = array( |
@@ -1870,13 +1868,13 @@ discard block |
||
1870 | 1868 | { |
1871 | 1869 | $readonlys['action'] = true; |
1872 | 1870 | } |
1873 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
1871 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
1874 | 1872 | { |
1875 | 1873 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1876 | 1874 | } |
1877 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
1875 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
1878 | 1876 | |
1879 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1877 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1880 | 1878 | { |
1881 | 1879 | $sel_options['owner'][0] = lang('All participants'); |
1882 | 1880 | } |
@@ -1884,26 +1882,26 @@ discard block |
||
1884 | 1882 | { |
1885 | 1883 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
1886 | 1884 | } |
1887 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
1885 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
1888 | 1886 | { |
1889 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
1887 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
1890 | 1888 | { |
1891 | 1889 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
1892 | 1890 | } |
1893 | 1891 | } |
1894 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1892 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1895 | 1893 | if (!$event['id']) |
1896 | 1894 | { |
1897 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
1895 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
1898 | 1896 | } |
1899 | 1897 | if ($preserved['no_popup']) |
1900 | 1898 | { |
1901 | 1899 | // If not a popup, load the normal calendar interface on cancel |
1902 | - $etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1900 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1903 | 1901 | } |
1904 | 1902 | |
1905 | 1903 | // Allow admins to restore deleted events |
1906 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
1904 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
1907 | 1905 | { |
1908 | 1906 | $content['deleted'] = $preserved['deleted'] = null; |
1909 | 1907 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1915,7 +1913,7 @@ discard block |
||
1915 | 1913 | // Setup history tab |
1916 | 1914 | $this->setup_history($content, $sel_options); |
1917 | 1915 | |
1918 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
1916 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
1919 | 1917 | . (!$event['id'] ? lang('Add') |
1920 | 1918 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
1921 | 1919 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1925,15 +1923,15 @@ discard block |
||
1925 | 1923 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
1926 | 1924 | |
1927 | 1925 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1928 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1926 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1929 | 1927 | { |
1930 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1928 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1931 | 1929 | $content['button']['save'] = true; |
1932 | - $this->process_edit(array_merge($content,$preserved)); |
|
1930 | + $this->process_edit(array_merge($content, $preserved)); |
|
1933 | 1931 | } |
1934 | 1932 | else |
1935 | 1933 | { |
1936 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
1934 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
1937 | 1935 | } |
1938 | 1936 | } |
1939 | 1937 | |
@@ -1943,14 +1941,14 @@ discard block |
||
1943 | 1941 | * @param int $id |
1944 | 1942 | * @param string $token |
1945 | 1943 | */ |
1946 | - function ajax_unlock($id,$token) |
|
1944 | + function ajax_unlock($id, $token) |
|
1947 | 1945 | { |
1948 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
1946 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
1949 | 1947 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1950 | 1948 | |
1951 | 1949 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
1952 | 1950 | { |
1953 | - Vfs::unlock($lock_path,$token,false); |
|
1951 | + Vfs::unlock($lock_path, $token, false); |
|
1954 | 1952 | } |
1955 | 1953 | } |
1956 | 1954 | |
@@ -1962,17 +1960,17 @@ discard block |
||
1962 | 1960 | * are called by new mail-app; and we intend to use the stuff passed on by session |
1963 | 1961 | * @param string $msg = null |
1964 | 1962 | */ |
1965 | - function meeting(array $event=null, $msg=null) |
|
1963 | + function meeting(array $event = null, $msg = null) |
|
1966 | 1964 | { |
1967 | 1965 | $user = $GLOBALS['egw_info']['user']['account_id']; |
1968 | 1966 | $readonlys['button[apply]'] = true; |
1969 | - $_usesession=!is_array($event); |
|
1967 | + $_usesession = !is_array($event); |
|
1970 | 1968 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
1971 | 1969 | //are called by new mail-app; and we intend to use the stuff passed on by session |
1972 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
1970 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
1973 | 1971 | { |
1974 | - $event=null; // set to null |
|
1975 | - $_usesession=true; // trigger session read |
|
1972 | + $event = null; // set to null |
|
1973 | + $_usesession = true; // trigger session read |
|
1976 | 1974 | } |
1977 | 1975 | if (!is_array($event)) |
1978 | 1976 | { |
@@ -2002,7 +2000,7 @@ discard block |
||
2002 | 2000 | if (($existing_event = $this->bo->read($event['uid'], $event['recurrence'], false, 'ts', null, true)) && // true = read the exception |
2003 | 2001 | !$existing_event['deleted']) |
2004 | 2002 | { |
2005 | - switch(strtolower($ical_method)) |
|
2003 | + switch (strtolower($ical_method)) |
|
2006 | 2004 | { |
2007 | 2005 | case 'reply': |
2008 | 2006 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -2056,19 +2054,19 @@ discard block |
||
2056 | 2054 | } |
2057 | 2055 | else // event not in calendar |
2058 | 2056 | { |
2059 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2057 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2060 | 2058 | } |
2061 | 2059 | $event['participant_types'] = array(); |
2062 | - foreach($event['participants'] as $uid => $status) |
|
2060 | + foreach ($event['participants'] as $uid => $status) |
|
2063 | 2061 | { |
2064 | 2062 | $user_type = $user_id = null; |
2065 | 2063 | calendar_so::split_user($uid, $user_type, $user_id); |
2066 | 2064 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
2067 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2065 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2068 | 2066 | } |
2069 | 2067 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
2070 | 2068 | $event['recure'] = $this->bo->recure2string($event); |
2071 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
2069 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
2072 | 2070 | |
2073 | 2071 | // ignore events in the past (for recurring events check enddate!) |
2074 | 2072 | if ($this->bo->date2ts($event['start']) < $this->bo->now_su && |
@@ -2088,23 +2086,23 @@ discard block |
||
2088 | 2086 | // clear notification errors |
2089 | 2087 | notifications::errors(true); |
2090 | 2088 | |
2091 | - switch($button) |
|
2089 | + switch ($button) |
|
2092 | 2090 | { |
2093 | 2091 | case 'reject': |
2094 | 2092 | if (!$event['id']) |
2095 | 2093 | { |
2096 | 2094 | // send reply to organizer |
2097 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
2098 | - break; // no need to store rejected event |
|
2095 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
2096 | + break; // no need to store rejected event |
|
2099 | 2097 | } |
2100 | 2098 | // fall-through |
2101 | 2099 | case 'accept': |
2102 | 2100 | case 'tentativ': |
2103 | - $status = strtoupper($button[0]); // A, R or T |
|
2101 | + $status = strtoupper($button[0]); // A, R or T |
|
2104 | 2102 | if (!$event['id']) |
2105 | 2103 | { |
2106 | 2104 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
2107 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
2105 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
2108 | 2106 | { |
2109 | 2107 | // --> make organize a participant with role chair and current user the owner |
2110 | 2108 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2112,7 +2110,7 @@ discard block |
||
2112 | 2110 | $event['owner'] = $this->user; |
2113 | 2111 | } |
2114 | 2112 | // store event without notifications! |
2115 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2113 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2116 | 2114 | { |
2117 | 2115 | $msg[] = lang('Event saved'); |
2118 | 2116 | } |
@@ -2126,7 +2124,7 @@ discard block |
||
2126 | 2124 | elseif (self::event_changed($event, $event['old'])) |
2127 | 2125 | { |
2128 | 2126 | // check if we are allowed to update the event |
2129 | - if($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2127 | + if ($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2130 | 2128 | { |
2131 | 2129 | if ($event['recurrence'] && !$event['old']['reference'] && ($recur_event = $this->bo->read($event['id']))) |
2132 | 2130 | { |
@@ -2134,9 +2132,9 @@ discard block |
||
2134 | 2132 | $recur_event['recur_exception'][] = $event['recurrence']; |
2135 | 2133 | // check if we need to move the alarms, because they are next on that exception |
2136 | 2134 | $this->bo->check_move_alarms($recur_event, null, $event['recurrence']); |
2137 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2138 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2139 | - $this->bo->update($recur_event, $ignore_conflicts=true, true, false, true, $msg, true); |
|
2135 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2136 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2137 | + $this->bo->update($recur_event, $ignore_conflicts = true, true, false, true, $msg, true); |
|
2140 | 2138 | |
2141 | 2139 | // then we need to create the exception as new event |
2142 | 2140 | unset($event['id']); |
@@ -2151,7 +2149,7 @@ discard block |
||
2151 | 2149 | } |
2152 | 2150 | unset($event['old']); |
2153 | 2151 | |
2154 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2152 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2155 | 2153 | { |
2156 | 2154 | $msg[] = lang('Event saved'); |
2157 | 2155 | } |
@@ -2199,7 +2197,7 @@ discard block |
||
2199 | 2197 | Framework::message(implode("\n", (array)$msg)); |
2200 | 2198 | $readonlys['button[edit]'] = !$event['id']; |
2201 | 2199 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
2202 | - switch(strtolower($ical_method)) |
|
2200 | + switch (strtolower($ical_method)) |
|
2203 | 2201 | { |
2204 | 2202 | case 'reply': |
2205 | 2203 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2213,7 +2211,7 @@ discard block |
||
2213 | 2211 | break; |
2214 | 2212 | } |
2215 | 2213 | $tpl = new Etemplate('calendar.meeting'); |
2216 | - $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event+array( |
|
2214 | + $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event + array( |
|
2217 | 2215 | 'old' => $existing_event, |
2218 | 2216 | ), 2); |
2219 | 2217 | } |
@@ -2245,37 +2243,37 @@ discard block |
||
2245 | 2243 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
2246 | 2244 | * @param array $preserv data to preserv |
2247 | 2245 | */ |
2248 | - function conflicts($event,$conflicts,$preserv) |
|
2246 | + function conflicts($event, $conflicts, $preserv) |
|
2249 | 2247 | { |
2250 | 2248 | $etpl = new Etemplate('calendar.conflicts'); |
2251 | 2249 | $allConflicts = array(); |
2252 | 2250 | |
2253 | - foreach($conflicts as $k => $conflict) |
|
2251 | + foreach ($conflicts as $k => $conflict) |
|
2254 | 2252 | { |
2255 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
2253 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
2256 | 2254 | |
2257 | 2255 | $conflicts[$k] += array( |
2258 | 2256 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
2259 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
2260 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
2261 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
2262 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
2263 | - ),true,true)), // show group invitations too |
|
2257 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
2258 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
2259 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
2260 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
2261 | + ), true, true)), // show group invitations too |
|
2264 | 2262 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
2265 | 2263 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
2266 | 2264 | ); |
2267 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
2265 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
2268 | 2266 | } |
2269 | 2267 | $content = $event + array( |
2270 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2268 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2271 | 2269 | ); |
2272 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
2270 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
2273 | 2271 | $resources_config = Api\Config::read('resources'); |
2274 | 2272 | $readonlys = array(); |
2275 | 2273 | |
2276 | 2274 | foreach (array_keys($allConflicts) as $pId) |
2277 | 2275 | { |
2278 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2276 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
2279 | 2277 | { |
2280 | 2278 | |
2281 | 2279 | switch ($resources_config['ignoreconflicts']) |
@@ -2295,7 +2293,7 @@ discard block |
||
2295 | 2293 | } |
2296 | 2294 | } |
2297 | 2295 | } |
2298 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
2296 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
2299 | 2297 | } |
2300 | 2298 | |
2301 | 2299 | /** |
@@ -2313,7 +2311,7 @@ discard block |
||
2313 | 2311 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
2314 | 2312 | |
2315 | 2313 | // convert start/end date-time values to timestamps |
2316 | - foreach(array('start', 'end') as $name) |
|
2314 | + foreach (array('start', 'end') as $name) |
|
2317 | 2315 | { |
2318 | 2316 | if (!empty($edit_content[$name])) |
2319 | 2317 | { |
@@ -2343,7 +2341,7 @@ discard block |
||
2343 | 2341 | 'recur_type' => $edit_content['recur_type'], |
2344 | 2342 | 'participants' => array(), |
2345 | 2343 | ); |
2346 | - foreach($edit_content['participants'] as $key => $data) |
|
2344 | + foreach ($edit_content['participants'] as $key => $data) |
|
2347 | 2345 | { |
2348 | 2346 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
2349 | 2347 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2358,21 +2356,21 @@ discard block |
||
2358 | 2356 | // default search parameters |
2359 | 2357 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
2360 | 2358 | $content['end_time'] = $this->cal_prefs['workdayends']; |
2361 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
2359 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
2362 | 2360 | { |
2363 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2361 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2364 | 2362 | } |
2365 | 2363 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
2366 | 2364 | |
2367 | 2365 | $content['search_window'] = 7 * DAY_s; |
2368 | 2366 | |
2369 | 2367 | // store content in session |
2370 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
2368 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
2371 | 2369 | |
2372 | 2370 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
2373 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
2371 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
2374 | 2372 | |
2375 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
2373 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
2376 | 2374 | |
2377 | 2375 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
2378 | 2376 | |
@@ -2395,26 +2393,26 @@ discard block |
||
2395 | 2393 | { |
2396 | 2394 | $etpl = new Etemplate('calendar.freetimesearch'); |
2397 | 2395 | $sel_options['search_window'] = array( |
2398 | - 7*DAY_s => lang('one week'), |
|
2399 | - 14*DAY_s => lang('two weeks'), |
|
2400 | - 31*DAY_s => lang('one month'), |
|
2401 | - 92*DAY_s => lang('three month'), |
|
2402 | - 365*DAY_s => lang('one year'), |
|
2396 | + 7 * DAY_s => lang('one week'), |
|
2397 | + 14 * DAY_s => lang('two weeks'), |
|
2398 | + 31 * DAY_s => lang('one month'), |
|
2399 | + 92 * DAY_s => lang('three month'), |
|
2400 | + 365 * DAY_s => lang('one year'), |
|
2403 | 2401 | ); |
2404 | 2402 | if (!is_array($content)) |
2405 | 2403 | { |
2406 | 2404 | // get content from session (and delete it immediatly) |
2407 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2408 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2405 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2406 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2409 | 2407 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
2410 | 2408 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
2411 | 2409 | $sTime = $content['start_time']; |
2412 | 2410 | $eTime = $content['end_time']; |
2413 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
2414 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
2411 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
2412 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
2415 | 2413 | |
2416 | 2414 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
2417 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
2415 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
2418 | 2416 | { |
2419 | 2417 | if ($window > $content['duration']) |
2420 | 2418 | { |
@@ -2441,19 +2439,19 @@ discard block |
||
2441 | 2439 | { |
2442 | 2440 | $content['msg'] .= lang('Only the initial date of that recurring event is checked!'); |
2443 | 2441 | } |
2444 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
2445 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
2442 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
2443 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
2446 | 2444 | |
2447 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
2445 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
2448 | 2446 | |
2449 | 2447 | $sel_options['duration'] = $this->durations; |
2450 | 2448 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
2451 | 2449 | |
2452 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
2450 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
2453 | 2451 | 'participants' => $content['participants'], |
2454 | 2452 | 'cal_id' => $content['cal_id'], |
2455 | 2453 | 'recur_type' => $content['recur_type'], |
2456 | - ),2); |
|
2454 | + ), 2); |
|
2457 | 2455 | } |
2458 | 2456 | |
2459 | 2457 | /** |
@@ -2466,15 +2464,15 @@ discard block |
||
2466 | 2464 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
2467 | 2465 | * @return array of free time-slots: array with start and end values |
2468 | 2466 | */ |
2469 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
2467 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
2470 | 2468 | { |
2471 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2469 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
2472 | 2470 | |
2473 | 2471 | $busy = $this->bo->search(array( |
2474 | 2472 | 'start' => $start, |
2475 | 2473 | 'end' => $end, |
2476 | 2474 | 'users' => $participants, |
2477 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2475 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2478 | 2476 | )); |
2479 | 2477 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
2480 | 2478 | 'start' => $end, |
@@ -2483,15 +2481,15 @@ discard block |
||
2483 | 2481 | $ft_start = $start; |
2484 | 2482 | $freetime = array(); |
2485 | 2483 | $n = 0; |
2486 | - foreach($busy as $event) |
|
2484 | + foreach ($busy as $event) |
|
2487 | 2485 | { |
2488 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2486 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2489 | 2487 | |
2490 | 2488 | if ($event['non_blocking']) continue; // ignore non_blocking events |
2491 | 2489 | |
2492 | 2490 | // check if from all wanted participants at least one has a not rejected status in found event |
2493 | 2491 | $non_rejected_found = false; |
2494 | - foreach($participants as $uid) |
|
2492 | + foreach ($participants as $uid) |
|
2495 | 2493 | { |
2496 | 2494 | $status = $event['participants'][$uid]; |
2497 | 2495 | $quantity = $role = null; |
@@ -2510,10 +2508,10 @@ discard block |
||
2510 | 2508 | |
2511 | 2509 | if ($this->debug) |
2512 | 2510 | { |
2513 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
2511 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
2514 | 2512 | echo "event[title]=$event[title]<br>\n"; |
2515 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
2516 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
2513 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
2514 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
2517 | 2515 | } |
2518 | 2516 | // $events ends before our actual position ==> ignore it |
2519 | 2517 | if ($event['end'] < $ft_start) |
@@ -2537,11 +2535,11 @@ discard block |
||
2537 | 2535 | 'start' => $ft_start, |
2538 | 2536 | 'end' => $ft_end, |
2539 | 2537 | ); |
2540 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2538 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
2541 | 2539 | } |
2542 | 2540 | $ft_start = $event['end']; |
2543 | 2541 | } |
2544 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2542 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
2545 | 2543 | |
2546 | 2544 | return $freetime; |
2547 | 2545 | } |
@@ -2561,46 +2559,46 @@ discard block |
||
2561 | 2559 | */ |
2562 | 2560 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2563 | 2561 | { |
2564 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2562 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
2565 | 2563 | |
2566 | 2564 | $freetime_daywise = array(); |
2567 | 2565 | if (!is_array($sel_options)) $sel_options = array(); |
2568 | 2566 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2569 | 2567 | |
2570 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
2571 | - $end_time = (int) $_end_time; |
|
2568 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
2569 | + $end_time = (int)$_end_time; |
|
2572 | 2570 | |
2573 | 2571 | // ignore the end_time, if duration would never fit |
2574 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
2572 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
2575 | 2573 | { |
2576 | 2574 | $end_time = 0; |
2577 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2575 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
2578 | 2576 | } |
2579 | 2577 | $n = 0; |
2580 | - foreach($freetime as $ft) |
|
2578 | + foreach ($freetime as $ft) |
|
2581 | 2579 | { |
2582 | 2580 | $adaybegin = $this->bo->date2array($ft['start']); |
2583 | 2581 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
2584 | 2582 | unset($adaybegin['raw']); |
2585 | 2583 | $daybegin = $this->bo->date2ts($adaybegin); |
2586 | 2584 | |
2587 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
2585 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
2588 | 2586 | { |
2589 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
2590 | - $mcal_dow = pow(2,$dow); |
|
2591 | - if (!($weekdays & $mcal_dow)) |
|
2587 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
2588 | + $mcal_dow = pow(2, $dow); |
|
2589 | + if (!($weekdays&$mcal_dow)) |
|
2592 | 2590 | { |
2593 | 2591 | //echo "wrong day of week $dow<br>\n"; |
2594 | - continue; // wrong day of week |
|
2592 | + continue; // wrong day of week |
|
2595 | 2593 | } |
2596 | 2594 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2597 | 2595 | |
2598 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2596 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
2599 | 2597 | { |
2600 | - $start = $daybegin + $start_time*HOUR_s; |
|
2598 | + $start = $daybegin + $start_time * HOUR_s; |
|
2601 | 2599 | } |
2602 | 2600 | // if end_time given use it, else the original slot's end |
2603 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
2601 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
2604 | 2602 | if ($end > $ft['end']) $end = $ft['end']; |
2605 | 2603 | |
2606 | 2604 | // slot to small for duration |
@@ -2614,11 +2612,11 @@ discard block |
||
2614 | 2612 | 'end' => $end, |
2615 | 2613 | ); |
2616 | 2614 | $times = array(); |
2617 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
2615 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
2618 | 2616 | { |
2619 | 2617 | $e = $s + $duration; |
2620 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
2621 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
2618 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
2619 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
2622 | 2620 | } |
2623 | 2621 | $sel_options[$n.'start'] = $times; |
2624 | 2622 | } |
@@ -2633,13 +2631,13 @@ discard block |
||
2633 | 2631 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
2634 | 2632 | * @return string error-msg if $return_error |
2635 | 2633 | */ |
2636 | - function export($content=0,$return_error=false) |
|
2634 | + function export($content = 0, $return_error = false) |
|
2637 | 2635 | { |
2638 | 2636 | $boical = new calendar_ical(); |
2639 | 2637 | #error_log(__METHOD__.print_r($content,true)); |
2640 | 2638 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
2641 | 2639 | { |
2642 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
2640 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
2643 | 2641 | { |
2644 | 2642 | $msg = lang('Permission denied'); |
2645 | 2643 | |
@@ -2647,20 +2645,20 @@ discard block |
||
2647 | 2645 | } |
2648 | 2646 | else |
2649 | 2647 | { |
2650 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
2648 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
2651 | 2649 | echo $ical; |
2652 | 2650 | common::egw_exit(); |
2653 | 2651 | } |
2654 | 2652 | } |
2655 | 2653 | if (is_array($content)) |
2656 | 2654 | { |
2657 | - $events =& $this->bo->search(array( |
|
2655 | + $events = & $this->bo->search(array( |
|
2658 | 2656 | 'start' => $content['start'], |
2659 | 2657 | 'end' => $content['end'], |
2660 | 2658 | 'enum_recuring' => false, |
2661 | 2659 | 'daywise' => false, |
2662 | 2660 | 'owner' => $this->owner, |
2663 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
2661 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
2664 | 2662 | )); |
2665 | 2663 | if (!$events) |
2666 | 2664 | { |
@@ -2668,8 +2666,8 @@ discard block |
||
2668 | 2666 | } |
2669 | 2667 | else |
2670 | 2668 | { |
2671 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
2672 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
2669 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
2670 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
2673 | 2671 | echo $ical; |
2674 | 2672 | common::egw_exit(); |
2675 | 2673 | } |
@@ -2685,9 +2683,9 @@ discard block |
||
2685 | 2683 | } |
2686 | 2684 | $content['msg'] = $msg; |
2687 | 2685 | |
2688 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
2686 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
2689 | 2687 | $etpl = new etemplate_new('calendar.export'); |
2690 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
2688 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
2691 | 2689 | } |
2692 | 2690 | |
2693 | 2691 | /** |
@@ -2695,7 +2693,7 @@ discard block |
||
2695 | 2693 | * |
2696 | 2694 | * @param array $_content |
2697 | 2695 | */ |
2698 | - function cat_acl(array $_content=null) |
|
2696 | + function cat_acl(array $_content = null) |
|
2699 | 2697 | { |
2700 | 2698 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
2701 | 2699 | { |
@@ -2707,15 +2705,15 @@ discard block |
||
2707 | 2705 | unset($_content['button']); |
2708 | 2706 | if ($button != 'cancel') // store changed Acl |
2709 | 2707 | { |
2710 | - foreach($_content as $data) |
|
2708 | + foreach ($_content as $data) |
|
2711 | 2709 | { |
2712 | 2710 | if (!($cat_id = $data['cat_id'])) continue; |
2713 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
2711 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
2714 | 2712 | { |
2715 | 2713 | $rights = 0; |
2716 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2717 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2718 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2714 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2715 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2716 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
2719 | 2717 | } |
2720 | 2718 | } |
2721 | 2719 | } |
@@ -2727,20 +2725,20 @@ discard block |
||
2727 | 2725 | ), 'admin'); |
2728 | 2726 | } |
2729 | 2727 | } |
2730 | - $content= $preserv = array(); |
|
2728 | + $content = $preserv = array(); |
|
2731 | 2729 | $n = 1; |
2732 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2730 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2733 | 2731 | { |
2734 | - $cat_id = substr($Lcat_id,1); |
|
2732 | + $cat_id = substr($Lcat_id, 1); |
|
2735 | 2733 | $row = array( |
2736 | 2734 | 'cat_id' => $cat_id, |
2737 | 2735 | 'add' => array(), |
2738 | 2736 | 'status' => array(), |
2739 | 2737 | ); |
2740 | - foreach($data as $account_id => $rights) |
|
2738 | + foreach ($data as $account_id => $rights) |
|
2741 | 2739 | { |
2742 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2743 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2740 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2741 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2744 | 2742 | } |
2745 | 2743 | $content[$n] = $row; |
2746 | 2744 | $preserv[$n] = array( |
@@ -2756,7 +2754,7 @@ discard block |
||
2756 | 2754 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
2757 | 2755 | $tmp = new Etemplate('calendar.cat_acl'); |
2758 | 2756 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
2759 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
2757 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
2760 | 2758 | } |
2761 | 2759 | |
2762 | 2760 | /** |
@@ -2806,18 +2804,18 @@ discard block |
||
2806 | 2804 | |
2807 | 2805 | |
2808 | 2806 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
2809 | - if($content['recur_type'] || $content['recurrence']) |
|
2807 | + if ($content['recur_type'] || $content['recurrence']) |
|
2810 | 2808 | { |
2811 | 2809 | $content['history']['filter'] = array( |
2812 | 2810 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
2813 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
2814 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
2811 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
2812 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
2815 | 2813 | ); |
2816 | 2814 | } |
2817 | 2815 | |
2818 | 2816 | // Translate labels |
2819 | 2817 | $tracking = new calendar_tracking(); |
2820 | - foreach($tracking->field2label as $field => $label) |
|
2818 | + foreach ($tracking->field2label as $field => $label) |
|
2821 | 2819 | { |
2822 | 2820 | $sel_options[$status][$field] = lang($label); |
2823 | 2821 | } |
@@ -2836,44 +2834,44 @@ discard block |
||
2836 | 2834 | * which particular instance was dragged |
2837 | 2835 | * @return string XML response if no error occurs |
2838 | 2836 | */ |
2839 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
2837 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
2840 | 2838 | { |
2841 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
2839 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
2842 | 2840 | $ignore_conflicts = false; |
2843 | 2841 | |
2844 | 2842 | // we do not allow dragging into another users calendar ATM |
2845 | - if($targetOwner < 0) |
|
2843 | + if ($targetOwner < 0) |
|
2846 | 2844 | { |
2847 | 2845 | $targetOwner = array($targetOwner); |
2848 | 2846 | } |
2849 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2847 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2850 | 2848 | { |
2851 | 2849 | $targetOwner = $calendarOwner; |
2852 | 2850 | } |
2853 | 2851 | // But you may be viewing multiple users, or a group calendar and |
2854 | 2852 | // dragging your event - dragging across calendars does not change owner |
2855 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2853 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2856 | 2854 | { |
2857 | 2855 | $return = true; |
2858 | - foreach($targetOwner as $owner) |
|
2856 | + foreach ($targetOwner as $owner) |
|
2859 | 2857 | { |
2860 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
2858 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
2861 | 2859 | { |
2862 | 2860 | $return = false; |
2863 | 2861 | break; |
2864 | 2862 | } |
2865 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
2863 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
2866 | 2864 | { |
2867 | 2865 | $return = false; |
2868 | 2866 | break; |
2869 | 2867 | } |
2870 | 2868 | } |
2871 | - if($return) return; |
|
2869 | + if ($return) return; |
|
2872 | 2870 | } |
2873 | - $old_event=$event=$this->bo->read($eventId); |
|
2871 | + $old_event = $event = $this->bo->read($eventId); |
|
2874 | 2872 | if (!$durationT) |
2875 | 2873 | { |
2876 | - $duration=$event['end']-$event['start']; |
|
2874 | + $duration = $event['end'] - $event['start']; |
|
2877 | 2875 | } |
2878 | 2876 | // Drag a normal event to whole day non-blocking |
2879 | 2877 | else if ($durationT == 'whole_day') |
@@ -2881,7 +2879,7 @@ discard block |
||
2881 | 2879 | $event['whole_day'] = true; |
2882 | 2880 | $event['non_blocking'] = true; |
2883 | 2881 | // Make duration whole days, less 1 second |
2884 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
2882 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
2885 | 2883 | } |
2886 | 2884 | else |
2887 | 2885 | { |
@@ -2894,19 +2892,19 @@ discard block |
||
2894 | 2892 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
2895 | 2893 | if (!empty($event['whole_day'])) |
2896 | 2894 | { |
2897 | - $d =& $this->bo->so->startOfDay($d); |
|
2895 | + $d = & $this->bo->so->startOfDay($d); |
|
2898 | 2896 | $d->setUser(); |
2899 | 2897 | } |
2900 | 2898 | $event = $this->bo->read($eventId, $d, true); |
2901 | 2899 | |
2902 | 2900 | // For DnD, create an exception if they gave the date |
2903 | 2901 | $preserv = null; |
2904 | - $this->_create_exception($event,$preserv); |
|
2902 | + $this->_create_exception($event, $preserv); |
|
2905 | 2903 | unset($event['id']); |
2906 | 2904 | $links = $event['link_to']['to_id']; |
2907 | 2905 | |
2908 | 2906 | $messages = null; |
2909 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
2907 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
2910 | 2908 | if (!is_array($conflicts) && $conflicts) |
2911 | 2909 | { |
2912 | 2910 | // now we need to add the original start as recur-execption to the series |
@@ -2914,28 +2912,28 @@ discard block |
||
2914 | 2912 | $recur_event['recur_exception'][] = $d->format('ts'); |
2915 | 2913 | // check if we need to move the alarms, because they are next on that exception |
2916 | 2914 | $this->bo->check_move_alarms($recur_event, null, $d); |
2917 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2918 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2919 | - $this->bo->update($recur_event,true); // no conflict check here |
|
2915 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2916 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2917 | + $this->bo->update($recur_event, true); // no conflict check here |
|
2920 | 2918 | |
2921 | 2919 | // Sending null will trigger a removal of the original for that date |
2922 | 2920 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
2923 | 2921 | |
2924 | 2922 | unset($recur_event); |
2925 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
2923 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
2926 | 2924 | unset($preserv['edit_single']); |
2927 | 2925 | } |
2928 | 2926 | } |
2929 | 2927 | |
2930 | 2928 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
2931 | 2929 | $event['start'] = $d->format('ts'); |
2932 | - $event['end'] = $event['start']+$duration; |
|
2930 | + $event['end'] = $event['start'] + $duration; |
|
2933 | 2931 | |
2934 | 2932 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
2935 | 2933 | { |
2936 | 2934 | // calculate offset against clicked recurrance, |
2937 | 2935 | // depending on which is smaller |
2938 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
2936 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
2939 | 2937 | $event['start'] = $old_event['start'] + $offset; |
2940 | 2938 | $event['duration'] = $duration; |
2941 | 2939 | |
@@ -2946,31 +2944,31 @@ discard block |
||
2946 | 2944 | // Can't handle conflict. Just ignore it. |
2947 | 2945 | $ignore_conflicts = true; |
2948 | 2946 | } |
2949 | - if(!$event['recur_type']) |
|
2947 | + if (!$event['recur_type']) |
|
2950 | 2948 | { |
2951 | 2949 | $this->bo->check_move_alarms($event, $old_event); |
2952 | 2950 | } |
2953 | 2951 | |
2954 | 2952 | // Drag a whole day to a time |
2955 | - if($durationT && $durationT != 'whole_day') |
|
2953 | + if ($durationT && $durationT != 'whole_day') |
|
2956 | 2954 | { |
2957 | 2955 | $event['whole_day'] = ($duration == DAY_s); |
2958 | 2956 | $event['non_blocking'] = false; |
2959 | 2957 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
2960 | 2958 | // so save the change now, and then let the conflict check happen. |
2961 | 2959 | $message = null; |
2962 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
2960 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
2963 | 2961 | |
2964 | 2962 | // Whole day non blocking with DAY_s would add a day |
2965 | - if($duration==DAY_s) $duration=0; |
|
2963 | + if ($duration == DAY_s) $duration = 0; |
|
2966 | 2964 | } |
2967 | 2965 | |
2968 | 2966 | $status_reset_to_unknown = false; |
2969 | 2967 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
2970 | - foreach((array)$event['participants'] as $uid => $status) |
|
2968 | + foreach ((array)$event['participants'] as $uid => $status) |
|
2971 | 2969 | { |
2972 | 2970 | $q = $r = null; |
2973 | - calendar_so::split_status($status,$q,$r); |
|
2971 | + calendar_so::split_status($status, $q, $r); |
|
2974 | 2972 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
2975 | 2973 | { |
2976 | 2974 | $preferences = new Api\Preferences($uid); |
@@ -2983,29 +2981,29 @@ discard block |
||
2983 | 2981 | if ($sameday) break; |
2984 | 2982 | default: |
2985 | 2983 | $status_reset_to_unknown = true; |
2986 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
2984 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
2987 | 2985 | // todo: report reset status to user |
2988 | 2986 | } |
2989 | 2987 | } |
2990 | 2988 | } |
2991 | 2989 | |
2992 | 2990 | $message = false; |
2993 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
2991 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
2994 | 2992 | |
2995 | 2993 | // Save links |
2996 | - if($links) |
|
2994 | + if ($links) |
|
2997 | 2995 | { |
2998 | 2996 | Link::link('calendar', $event['id'], $links); |
2999 | 2997 | } |
3000 | 2998 | |
3001 | - $this->update_client($event['id'],$d); |
|
2999 | + $this->update_client($event['id'], $d); |
|
3002 | 3000 | $response = Api\Json\Response::get(); |
3003 | - if(!is_array($conflicts) && $conflicts) |
|
3001 | + if (!is_array($conflicts) && $conflicts) |
|
3004 | 3002 | { |
3005 | - if(is_int($conflicts)) |
|
3003 | + if (is_int($conflicts)) |
|
3006 | 3004 | { |
3007 | 3005 | $event['id'] = $conflicts; |
3008 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3006 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3009 | 3007 | } |
3010 | 3008 | } |
3011 | 3009 | else if ($conflicts) |
@@ -3018,21 +3016,21 @@ discard block |
||
3018 | 3016 | .'&end='.$event['end'] |
3019 | 3017 | .'&non_interactive=true' |
3020 | 3018 | .'&cancel_needs_refresh=true', |
3021 | - '',750,410); |
|
3019 | + '', 750, 410); |
|
3022 | 3020 | } |
3023 | 3021 | else if ($message) |
3024 | 3022 | { |
3025 | - $response->call('egw.message', implode('<br />', $message)); |
|
3023 | + $response->call('egw.message', implode('<br />', $message)); |
|
3026 | 3024 | } |
3027 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
3025 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
3028 | 3026 | if ($status_reset_to_unknown) |
3029 | 3027 | { |
3030 | - foreach((array)$event['participants'] as $uid => $status) |
|
3028 | + foreach ((array)$event['participants'] as $uid => $status) |
|
3031 | 3029 | { |
3032 | 3030 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
3033 | 3031 | { |
3034 | - calendar_so::split_status($status,$q,$r); |
|
3035 | - $status = calendar_so::combine_status('U',$q,$r); |
|
3032 | + calendar_so::split_status($status, $q, $r); |
|
3033 | + $status = calendar_so::combine_status('U', $q, $r); |
|
3036 | 3034 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
3037 | 3035 | } |
3038 | 3036 | } |
@@ -3049,7 +3047,7 @@ discard block |
||
3049 | 3047 | { |
3050 | 3048 | list($eventId, $date) = explode(':', $_eventId); |
3051 | 3049 | $event = $this->bo->read($eventId); |
3052 | - if($date) |
|
3050 | + if ($date) |
|
3053 | 3051 | { |
3054 | 3052 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3055 | 3053 | } |
@@ -3059,29 +3057,29 @@ discard block |
||
3059 | 3057 | { |
3060 | 3058 | if (!empty($event['whole_day'])) |
3061 | 3059 | { |
3062 | - $d =& $this->bo->so->startOfDay($date); |
|
3060 | + $d = & $this->bo->so->startOfDay($date); |
|
3063 | 3061 | $d->setUser(); |
3064 | 3062 | } |
3065 | 3063 | $event = $this->bo->read($eventId, $d, true); |
3066 | 3064 | $date = $d->format('ts'); |
3067 | 3065 | } |
3068 | - if($event['participants'][$uid]) |
|
3066 | + if ($event['participants'][$uid]) |
|
3069 | 3067 | { |
3070 | 3068 | $q = $r = null; |
3071 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3072 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3073 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3069 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3070 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3071 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3074 | 3072 | } |
3075 | 3073 | else |
3076 | 3074 | { |
3077 | 3075 | // Group membership |
3078 | - foreach(array_keys($event['participants']) as $id) |
|
3076 | + foreach (array_keys($event['participants']) as $id) |
|
3079 | 3077 | { |
3080 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
3078 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
3081 | 3079 | { |
3082 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3083 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3084 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3080 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3081 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3082 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3085 | 3083 | break; |
3086 | 3084 | } |
3087 | 3085 | } |
@@ -3089,7 +3087,7 @@ discard block |
||
3089 | 3087 | |
3090 | 3088 | // Directly update stored data. If event is still visible, it will |
3091 | 3089 | // be notified & update itself. |
3092 | - $this->update_client($eventId,$d); |
|
3090 | + $this->update_client($eventId, $d); |
|
3093 | 3091 | } |
3094 | 3092 | |
3095 | 3093 | /** |
@@ -3097,8 +3095,8 @@ discard block |
||
3097 | 3095 | */ |
3098 | 3096 | public function ajax_delete($eventId) |
3099 | 3097 | { |
3100 | - list($id, $date) = explode(':',$eventId); |
|
3101 | - $event=$this->bo->read($id); |
|
3098 | + list($id, $date) = explode(':', $eventId); |
|
3099 | + $event = $this->bo->read($id); |
|
3102 | 3100 | $response = Api\Json\Response::get(); |
3103 | 3101 | |
3104 | 3102 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -3111,11 +3109,11 @@ discard block |
||
3111 | 3109 | { |
3112 | 3110 | $msg = lang('Event deleted'); |
3113 | 3111 | } |
3114 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
3112 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
3115 | 3113 | } |
3116 | 3114 | else |
3117 | 3115 | { |
3118 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
3116 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
3119 | 3117 | } |
3120 | 3118 | } |
3121 | 3119 | |
@@ -3128,10 +3126,10 @@ discard block |
||
3128 | 3126 | */ |
3129 | 3127 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
3130 | 3128 | { |
3131 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
3129 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
3132 | 3130 | |
3133 | 3131 | $event = $this->bo->read($eventId); |
3134 | - if($date) |
|
3132 | + if ($date) |
|
3135 | 3133 | { |
3136 | 3134 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3137 | 3135 | } |
@@ -3141,17 +3139,17 @@ discard block |
||
3141 | 3139 | { |
3142 | 3140 | if (!empty($event['whole_day'])) |
3143 | 3141 | { |
3144 | - $d =& $this->bo->so->startOfDay($date); |
|
3142 | + $d = & $this->bo->so->startOfDay($date); |
|
3145 | 3143 | $d->setUser(); |
3146 | 3144 | } |
3147 | 3145 | $event = $this->bo->read($eventId, $d, true); |
3148 | 3146 | // For DnD, create an exception if they gave the date |
3149 | 3147 | $preserv = null; |
3150 | - $this->_create_exception($event,$preserv); |
|
3148 | + $this->_create_exception($event, $preserv); |
|
3151 | 3149 | unset($event['id']); |
3152 | 3150 | |
3153 | 3151 | $messages = null; |
3154 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
3152 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
3155 | 3153 | if (!is_array($conflicts) && $conflicts) |
3156 | 3154 | { |
3157 | 3155 | // now we need to add the original start as recur-execption to the series |
@@ -3159,28 +3157,28 @@ discard block |
||
3159 | 3157 | $recur_event['recur_exception'][] = $d->format('ts'); |
3160 | 3158 | // check if we need to move the alarms, because they are next on that exception |
3161 | 3159 | $this->bo->check_move_alarms($recur_event, null, $d); |
3162 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3163 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3164 | - $this->bo->update($recur_event,true); // no conflict check here |
|
3160 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3161 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3162 | + $this->bo->update($recur_event, true); // no conflict check here |
|
3165 | 3163 | |
3166 | 3164 | // Sending null will trigger a removal of the original for that date |
3167 | 3165 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
3168 | 3166 | |
3169 | 3167 | unset($recur_event); |
3170 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3168 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3171 | 3169 | unset($preserv['edit_single']); |
3172 | 3170 | } |
3173 | 3171 | } |
3174 | - foreach($remove as $participant) |
|
3172 | + foreach ($remove as $participant) |
|
3175 | 3173 | { |
3176 | 3174 | unset($event['participants'][$participant]); |
3177 | 3175 | } |
3178 | - foreach($invite as $participant) |
|
3176 | + foreach ($invite as $participant) |
|
3179 | 3177 | { |
3180 | 3178 | $event['participants'][$participant] = 'U'; |
3181 | 3179 | } |
3182 | 3180 | $message = null; |
3183 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
3181 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
3184 | 3182 | |
3185 | 3183 | $response = Api\Json\Response::get(); |
3186 | 3184 | |
@@ -3188,8 +3186,8 @@ discard block |
||
3188 | 3186 | { |
3189 | 3187 | // Save it anyway, was done with explicit user interaction, |
3190 | 3188 | // and if we don't we lose the invite |
3191 | - $this->bo->update($event,true); // no conflict check here |
|
3192 | - $this->update_client($event['id'],$d); |
|
3189 | + $this->bo->update($event, true); // no conflict check here |
|
3190 | + $this->update_client($event['id'], $d); |
|
3193 | 3191 | $response->call( |
3194 | 3192 | 'egw_openWindowCentered2', |
3195 | 3193 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3198,22 +3196,22 @@ discard block |
||
3198 | 3196 | .'&end='.$event['end'] |
3199 | 3197 | .'&non_interactive=true' |
3200 | 3198 | .'&cancel_needs_refresh=true', |
3201 | - '',750,410); |
|
3199 | + '', 750, 410); |
|
3202 | 3200 | } |
3203 | 3201 | else if ($message) |
3204 | 3202 | { |
3205 | - $response->call('egw.message', implode('<br />', $message)); |
|
3203 | + $response->call('egw.message', implode('<br />', $message)); |
|
3206 | 3204 | } |
3207 | - if($conflicts) |
|
3205 | + if ($conflicts) |
|
3208 | 3206 | { |
3209 | - $this->update_client($event['id'],$d); |
|
3210 | - if(is_int($conflicts)) |
|
3207 | + $this->update_client($event['id'], $d); |
|
3208 | + if (is_int($conflicts)) |
|
3211 | 3209 | { |
3212 | 3210 | $event['id'] = $conflicts; |
3213 | 3211 | } |
3214 | - if($event['id']) |
|
3212 | + if ($event['id']) |
|
3215 | 3213 | { |
3216 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3214 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3217 | 3215 | } |
3218 | 3216 | } |
3219 | 3217 | } |
@@ -3224,13 +3222,13 @@ discard block |
||
3224 | 3222 | * @param array $mailContent = null mail content |
3225 | 3223 | * @return array |
3226 | 3224 | */ |
3227 | - function mail_import(array $mailContent=null) |
|
3225 | + function mail_import(array $mailContent = null) |
|
3228 | 3226 | { |
3229 | 3227 | // It would get called from compose as a popup with egw_data |
3230 | 3228 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
3231 | 3229 | { |
3232 | 3230 | // get raw mail data |
3233 | - Link::get_data ($_GET['egw_data']); |
|
3231 | + Link::get_data($_GET['egw_data']); |
|
3234 | 3232 | return false; |
3235 | 3233 | } |
3236 | 3234 | |
@@ -3240,7 +3238,7 @@ discard block |
||
3240 | 3238 | $AB = new Api\Contacts(); |
3241 | 3239 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
3242 | 3240 | |
3243 | - $participants[0] = array ( |
|
3241 | + $participants[0] = array( |
|
3244 | 3242 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
3245 | 3243 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
3246 | 3244 | 'status' => 'A', |
@@ -3248,23 +3246,23 @@ discard block |
||
3248 | 3246 | 'app' => 'User', |
3249 | 3247 | 'role' => 'REQ-PARTICIPANT' |
3250 | 3248 | ); |
3251 | - foreach($mailContent['addresses'] as $address) |
|
3249 | + foreach ($mailContent['addresses'] as $address) |
|
3252 | 3250 | { |
3253 | 3251 | // Get available contacts from the email |
3254 | 3252 | $contacts = $AB->search(array( |
3255 | 3253 | 'email' => $address['email'], |
3256 | 3254 | 'email_home' => $address['email'] |
3257 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
3255 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
3258 | 3256 | if (is_array($contacts)) |
3259 | 3257 | { |
3260 | - foreach($contacts as $account) |
|
3258 | + foreach ($contacts as $account) |
|
3261 | 3259 | { |
3262 | 3260 | $accounts[] = $account['account_id']; |
3263 | 3261 | } |
3264 | 3262 | } |
3265 | 3263 | else |
3266 | 3264 | { |
3267 | - $participants []= array ( |
|
3265 | + $participants [] = array( |
|
3268 | 3266 | 'app' => 'email', |
3269 | 3267 | 'uid' => 'e'.$address['email'], |
3270 | 3268 | 'status' => 'U', |
@@ -3272,7 +3270,7 @@ discard block |
||
3272 | 3270 | ); |
3273 | 3271 | } |
3274 | 3272 | } |
3275 | - $participants = array_merge($participants , array( |
|
3273 | + $participants = array_merge($participants, array( |
|
3276 | 3274 | "participant" => $accounts, |
3277 | 3275 | "role" => "REQ-PARTICIPANT", |
3278 | 3276 | "add" => "pressed" |
@@ -3296,14 +3294,14 @@ discard block |
||
3296 | 3294 | { |
3297 | 3295 | foreach ($mailContent['attachments'] as $attachment) |
3298 | 3296 | { |
3299 | - if($attachment['egw_data']) |
|
3297 | + if ($attachment['egw_data']) |
|
3300 | 3298 | { |
3301 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
3299 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
3302 | 3300 | } |
3303 | - else if(is_readable($attachment['tmp_name']) || |
|
3301 | + else if (is_readable($attachment['tmp_name']) || |
|
3304 | 3302 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
3305 | 3303 | { |
3306 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
3304 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
3307 | 3305 | } |
3308 | 3306 | } |
3309 | 3307 | } |