@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * Check if PHP function is trusted. |
259 | 259 | * |
260 | 260 | * @param string $function_name |
261 | - * @param object $compiler compiler object |
|
261 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
262 | 262 | * |
263 | 263 | * @return boolean true if function is trusted |
264 | 264 | * @throws SmartyCompilerException if php function is not trusted |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param string $class_name |
305 | 305 | * @param string $params |
306 | - * @param object $compiler compiler object |
|
306 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
307 | 307 | * |
308 | 308 | * @return boolean true if class method is trusted |
309 | 309 | * @throws SmartyCompilerException if static class method is not trusted |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * Check if PHP modifier is trusted. |
342 | 342 | * |
343 | 343 | * @param string $modifier_name |
344 | - * @param object $compiler compiler object |
|
344 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
345 | 345 | * |
346 | 346 | * @return boolean true if modifier is trusted |
347 | 347 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * Check if tag is trusted. |
364 | 364 | * |
365 | 365 | * @param string $tag_name |
366 | - * @param object $compiler compiler object |
|
366 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
367 | 367 | * |
368 | 368 | * @return boolean true if tag is trusted |
369 | 369 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * Check if special $smarty variable is trusted. |
399 | 399 | * |
400 | 400 | * @param string $var_name |
401 | - * @param object $compiler compiler object |
|
401 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
402 | 402 | * |
403 | 403 | * @return boolean true if tag is trusted |
404 | 404 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * Check if modifier plugin is trusted. |
420 | 420 | * |
421 | 421 | * @param string $modifier_name |
422 | - * @param object $compiler compiler object |
|
422 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
423 | 423 | * |
424 | 424 | * @return boolean true if tag is trusted |
425 | 425 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * Check if constants are enabled or trusted |
455 | 455 | * |
456 | 456 | * @param string $const constant name |
457 | - * @param object $compiler compiler object |
|
457 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
458 | 458 | * |
459 | 459 | * @return bool |
460 | 460 | */ |
@@ -13,710 +13,710 @@ |
||
13 | 13 | */ |
14 | 14 | class Smarty_Security |
15 | 15 | { |
16 | - /** |
|
17 | - * This determines how Smarty handles "<?php ... ?>" tags in templates. |
|
18 | - * possible values: |
|
19 | - * <ul> |
|
20 | - * <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li> |
|
21 | - * <li>Smarty::PHP_QUOTE -> escape tags as entities</li> |
|
22 | - * <li>Smarty::PHP_REMOVE -> remove php tags</li> |
|
23 | - * <li>Smarty::PHP_ALLOW -> execute php tags</li> |
|
24 | - * </ul> |
|
25 | - * |
|
26 | - * @var integer |
|
27 | - */ |
|
28 | - public $php_handling = Smarty::PHP_PASSTHRU; |
|
29 | - |
|
30 | - /** |
|
31 | - * This is the list of template directories that are considered secure. |
|
32 | - * $template_dir is in this list implicitly. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $secure_dir = array(); |
|
37 | - |
|
38 | - /** |
|
39 | - * This is an array of directories where trusted php scripts reside. |
|
40 | - * {@link $security} is disabled during their inclusion/execution. |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - public $trusted_dir = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * List of regular expressions (PCRE) that include trusted URIs |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - public $trusted_uri = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * List of trusted constants names |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - public $trusted_constants = array(); |
|
59 | - |
|
60 | - /** |
|
61 | - * This is an array of trusted static classes. |
|
62 | - * If empty access to all static classes is allowed. |
|
63 | - * If set to 'none' none is allowed. |
|
64 | - * |
|
65 | - * @var array |
|
66 | - */ |
|
67 | - public $static_classes = array(); |
|
68 | - |
|
69 | - /** |
|
70 | - * This is an nested array of trusted classes and static methods. |
|
71 | - * If empty access to all static classes and methods is allowed. |
|
72 | - * Format: |
|
73 | - * array ( |
|
74 | - * 'class_1' => array('method_1', 'method_2'), // allowed methods listed |
|
75 | - * 'class_2' => array(), // all methods of class allowed |
|
76 | - * ) |
|
77 | - * If set to null none is allowed. |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - public $trusted_static_methods = array(); |
|
82 | - |
|
83 | - /** |
|
84 | - * This is an array of trusted static properties. |
|
85 | - * If empty access to all static classes and properties is allowed. |
|
86 | - * Format: |
|
87 | - * array ( |
|
88 | - * 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed |
|
89 | - * 'class_2' => array(), // all properties of class allowed |
|
90 | - * ) |
|
91 | - * If set to null none is allowed. |
|
92 | - * |
|
93 | - * @var array |
|
94 | - */ |
|
95 | - public $trusted_static_properties = array(); |
|
96 | - |
|
97 | - /** |
|
98 | - * This is an array of trusted PHP functions. |
|
99 | - * If empty all functions are allowed. |
|
100 | - * To disable all PHP functions set $php_functions = null. |
|
101 | - * |
|
102 | - * @var array |
|
103 | - */ |
|
104 | - public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',); |
|
105 | - |
|
106 | - /** |
|
107 | - * This is an array of trusted PHP modifiers. |
|
108 | - * If empty all modifiers are allowed. |
|
109 | - * To disable all modifier set $php_modifiers = null. |
|
110 | - * |
|
111 | - * @var array |
|
112 | - */ |
|
113 | - public $php_modifiers = array('escape', 'count', 'nl2br',); |
|
114 | - |
|
115 | - /** |
|
116 | - * This is an array of allowed tags. |
|
117 | - * If empty no restriction by allowed_tags. |
|
118 | - * |
|
119 | - * @var array |
|
120 | - */ |
|
121 | - public $allowed_tags = array(); |
|
122 | - |
|
123 | - /** |
|
124 | - * This is an array of disabled tags. |
|
125 | - * If empty no restriction by disabled_tags. |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - public $disabled_tags = array(); |
|
130 | - |
|
131 | - /** |
|
132 | - * This is an array of allowed modifier plugins. |
|
133 | - * If empty no restriction by allowed_modifiers. |
|
134 | - * |
|
135 | - * @var array |
|
136 | - */ |
|
137 | - public $allowed_modifiers = array(); |
|
138 | - |
|
139 | - /** |
|
140 | - * This is an array of disabled modifier plugins. |
|
141 | - * If empty no restriction by disabled_modifiers. |
|
142 | - * |
|
143 | - * @var array |
|
144 | - */ |
|
145 | - public $disabled_modifiers = array(); |
|
146 | - |
|
147 | - /** |
|
148 | - * This is an array of disabled special $smarty variables. |
|
149 | - * |
|
150 | - * @var array |
|
151 | - */ |
|
152 | - public $disabled_special_smarty_vars = array(); |
|
153 | - |
|
154 | - /** |
|
155 | - * This is an array of trusted streams. |
|
156 | - * If empty all streams are allowed. |
|
157 | - * To disable all streams set $streams = null. |
|
158 | - * |
|
159 | - * @var array |
|
160 | - */ |
|
161 | - public $streams = array('file'); |
|
162 | - |
|
163 | - /** |
|
164 | - * + flag if constants can be accessed from template |
|
165 | - * |
|
166 | - * @var boolean |
|
167 | - */ |
|
168 | - public $allow_constants = true; |
|
169 | - |
|
170 | - /** |
|
171 | - * + flag if super globals can be accessed from template |
|
172 | - * |
|
173 | - * @var boolean |
|
174 | - */ |
|
175 | - public $allow_super_globals = true; |
|
176 | - |
|
177 | - /** |
|
178 | - * max template nesting level |
|
179 | - * |
|
180 | - * @var int |
|
181 | - */ |
|
182 | - public $max_template_nesting = 0; |
|
183 | - |
|
184 | - /** |
|
185 | - * current template nesting level |
|
186 | - * |
|
187 | - * @var int |
|
188 | - */ |
|
189 | - private $_current_template_nesting = 0; |
|
190 | - |
|
191 | - /** |
|
192 | - * Cache for $resource_dir lookup |
|
193 | - * |
|
194 | - * @var array |
|
195 | - */ |
|
196 | - protected $_resource_dir = array(); |
|
197 | - |
|
198 | - /** |
|
199 | - * Cache for $template_dir lookup |
|
200 | - * |
|
201 | - * @var array |
|
202 | - */ |
|
203 | - protected $_template_dir = array(); |
|
204 | - |
|
205 | - /** |
|
206 | - * Cache for $config_dir lookup |
|
207 | - * |
|
208 | - * @var array |
|
209 | - */ |
|
210 | - protected $_config_dir = array(); |
|
211 | - |
|
212 | - /** |
|
213 | - * Cache for $secure_dir lookup |
|
214 | - * |
|
215 | - * @var array |
|
216 | - */ |
|
217 | - protected $_secure_dir = array(); |
|
218 | - |
|
219 | - /** |
|
220 | - * Cache for $php_resource_dir lookup |
|
221 | - * |
|
222 | - * @var array |
|
223 | - */ |
|
224 | - protected $_php_resource_dir = null; |
|
225 | - |
|
226 | - /** |
|
227 | - * Cache for $trusted_dir lookup |
|
228 | - * |
|
229 | - * @var array |
|
230 | - */ |
|
231 | - protected $_trusted_dir = null; |
|
232 | - |
|
233 | - /** |
|
234 | - * Cache for include path status |
|
235 | - * |
|
236 | - * @var bool |
|
237 | - */ |
|
238 | - protected $_include_path_status = false; |
|
239 | - |
|
240 | - /** |
|
241 | - * Cache for $_include_array lookup |
|
242 | - * |
|
243 | - * @var array |
|
244 | - */ |
|
245 | - protected $_include_dir = array(); |
|
246 | - |
|
247 | - /** |
|
248 | - * @param Smarty $smarty |
|
249 | - */ |
|
250 | - public function __construct($smarty) |
|
251 | - { |
|
252 | - $this->smarty = $smarty; |
|
253 | - $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | - $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Check if PHP function is trusted. |
|
259 | - * |
|
260 | - * @param string $function_name |
|
261 | - * @param object $compiler compiler object |
|
262 | - * |
|
263 | - * @return boolean true if function is trusted |
|
264 | - * @throws SmartyCompilerException if php function is not trusted |
|
265 | - */ |
|
266 | - public function isTrustedPhpFunction($function_name, $compiler) |
|
267 | - { |
|
268 | - if (isset($this->php_functions) && |
|
269 | - (empty($this->php_functions) || in_array($function_name, $this->php_functions)) |
|
270 | - ) { |
|
271 | - return true; |
|
272 | - } |
|
273 | - |
|
274 | - $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); |
|
275 | - |
|
276 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Check if static class is trusted. |
|
281 | - * |
|
282 | - * @param string $class_name |
|
283 | - * @param object $compiler compiler object |
|
284 | - * |
|
285 | - * @return boolean true if class is trusted |
|
286 | - * @throws SmartyCompilerException if static class is not trusted |
|
287 | - */ |
|
288 | - public function isTrustedStaticClass($class_name, $compiler) |
|
289 | - { |
|
290 | - if (isset($this->static_classes) && |
|
291 | - (empty($this->static_classes) || in_array($class_name, $this->static_classes)) |
|
292 | - ) { |
|
293 | - return true; |
|
294 | - } |
|
295 | - |
|
296 | - $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); |
|
297 | - |
|
298 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Check if static class method/property is trusted. |
|
303 | - * |
|
304 | - * @param string $class_name |
|
305 | - * @param string $params |
|
306 | - * @param object $compiler compiler object |
|
307 | - * |
|
308 | - * @return boolean true if class method is trusted |
|
309 | - * @throws SmartyCompilerException if static class method is not trusted |
|
310 | - */ |
|
311 | - public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
|
312 | - { |
|
313 | - if (!isset($params[ 2 ])) { |
|
314 | - // fall back |
|
315 | - return $this->isTrustedStaticClass($class_name, $compiler); |
|
316 | - } |
|
317 | - if ($params[ 2 ] == 'method') { |
|
318 | - $allowed = $this->trusted_static_methods; |
|
319 | - $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
320 | - } else { |
|
321 | - $allowed = $this->trusted_static_properties; |
|
322 | - // strip '$' |
|
323 | - $name = substr($params[ 0 ], 1); |
|
324 | - } |
|
325 | - if (isset($allowed)) { |
|
326 | - if (empty($allowed)) { |
|
327 | - // fall back |
|
328 | - return $this->isTrustedStaticClass($class_name, $compiler); |
|
329 | - } |
|
330 | - if (isset($allowed[ $class_name ]) && |
|
331 | - (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
332 | - ) { |
|
333 | - return true; |
|
334 | - } |
|
335 | - } |
|
336 | - $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting"); |
|
337 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Check if PHP modifier is trusted. |
|
342 | - * |
|
343 | - * @param string $modifier_name |
|
344 | - * @param object $compiler compiler object |
|
345 | - * |
|
346 | - * @return boolean true if modifier is trusted |
|
347 | - * @throws SmartyCompilerException if modifier is not trusted |
|
348 | - */ |
|
349 | - public function isTrustedPhpModifier($modifier_name, $compiler) |
|
350 | - { |
|
351 | - if (isset($this->php_modifiers) && |
|
352 | - (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers)) |
|
353 | - ) { |
|
354 | - return true; |
|
355 | - } |
|
356 | - |
|
357 | - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); |
|
358 | - |
|
359 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Check if tag is trusted. |
|
364 | - * |
|
365 | - * @param string $tag_name |
|
366 | - * @param object $compiler compiler object |
|
367 | - * |
|
368 | - * @return boolean true if tag is trusted |
|
369 | - * @throws SmartyCompilerException if modifier is not trusted |
|
370 | - */ |
|
371 | - public function isTrustedTag($tag_name, $compiler) |
|
372 | - { |
|
373 | - // check for internal always required tags |
|
374 | - if (in_array($tag_name, |
|
375 | - array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', |
|
376 | - 'private_object_block_function', 'private_object_function', 'private_registered_function', |
|
377 | - 'private_registered_block', 'private_special_variable', 'private_print_expression', |
|
378 | - 'private_modifier'))) { |
|
379 | - return true; |
|
380 | - } |
|
381 | - // check security settings |
|
382 | - if (empty($this->allowed_tags)) { |
|
383 | - if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) { |
|
384 | - return true; |
|
385 | - } else { |
|
386 | - $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true); |
|
387 | - } |
|
388 | - } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) { |
|
389 | - return true; |
|
390 | - } else { |
|
391 | - $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true); |
|
392 | - } |
|
393 | - |
|
394 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Check if special $smarty variable is trusted. |
|
399 | - * |
|
400 | - * @param string $var_name |
|
401 | - * @param object $compiler compiler object |
|
402 | - * |
|
403 | - * @return boolean true if tag is trusted |
|
404 | - * @throws SmartyCompilerException if modifier is not trusted |
|
405 | - */ |
|
406 | - public function isTrustedSpecialSmartyVar($var_name, $compiler) |
|
407 | - { |
|
408 | - if (!in_array($var_name, $this->disabled_special_smarty_vars)) { |
|
409 | - return true; |
|
410 | - } else { |
|
411 | - $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", |
|
412 | - null, true); |
|
413 | - } |
|
414 | - |
|
415 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Check if modifier plugin is trusted. |
|
420 | - * |
|
421 | - * @param string $modifier_name |
|
422 | - * @param object $compiler compiler object |
|
423 | - * |
|
424 | - * @return boolean true if tag is trusted |
|
425 | - * @throws SmartyCompilerException if modifier is not trusted |
|
426 | - */ |
|
427 | - public function isTrustedModifier($modifier_name, $compiler) |
|
428 | - { |
|
429 | - // check for internal always allowed modifier |
|
430 | - if (in_array($modifier_name, array('default'))) { |
|
431 | - return true; |
|
432 | - } |
|
433 | - // check security settings |
|
434 | - if (empty($this->allowed_modifiers)) { |
|
435 | - if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) { |
|
436 | - return true; |
|
437 | - } else { |
|
438 | - $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null, |
|
439 | - true); |
|
440 | - } |
|
441 | - } elseif (in_array($modifier_name, $this->allowed_modifiers) && |
|
442 | - !in_array($modifier_name, $this->disabled_modifiers) |
|
443 | - ) { |
|
444 | - return true; |
|
445 | - } else { |
|
446 | - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null, |
|
447 | - true); |
|
448 | - } |
|
449 | - |
|
450 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Check if constants are enabled or trusted |
|
455 | - * |
|
456 | - * @param string $const constant name |
|
457 | - * @param object $compiler compiler object |
|
458 | - * |
|
459 | - * @return bool |
|
460 | - */ |
|
461 | - public function isTrustedConstant($const, $compiler) |
|
462 | - { |
|
463 | - if (in_array($const, array('true', 'false', 'null'))) { |
|
464 | - return true; |
|
465 | - } |
|
466 | - if (!empty($this->trusted_constants)) { |
|
467 | - if (!in_array($const, $this->trusted_constants)) { |
|
468 | - $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted"); |
|
469 | - return false; |
|
470 | - } |
|
471 | - return true; |
|
472 | - } |
|
473 | - if ($this->allow_constants) { |
|
474 | - return true; |
|
475 | - } |
|
476 | - $compiler->trigger_template_error("Security: access to constants not permitted"); |
|
477 | - return false; |
|
478 | - } |
|
479 | - |
|
480 | - /** |
|
481 | - * Check if stream is trusted. |
|
482 | - * |
|
483 | - * @param string $stream_name |
|
484 | - * |
|
485 | - * @return boolean true if stream is trusted |
|
486 | - * @throws SmartyException if stream is not trusted |
|
487 | - */ |
|
488 | - public function isTrustedStream($stream_name) |
|
489 | - { |
|
490 | - if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { |
|
491 | - return true; |
|
492 | - } |
|
493 | - |
|
494 | - throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); |
|
495 | - } |
|
496 | - |
|
497 | - /** |
|
498 | - * Check if directory of file resource is trusted. |
|
499 | - * |
|
500 | - * @param string $filepath |
|
501 | - * @param null|bool $isConfig |
|
502 | - * |
|
503 | - * @return bool true if directory is trusted |
|
504 | - * @throws \SmartyException if directory is not trusted |
|
505 | - */ |
|
506 | - public function isTrustedResourceDir($filepath, $isConfig = null) |
|
507 | - { |
|
508 | - if ($this->_include_path_status !== $this->smarty->use_include_path) { |
|
509 | - foreach ($this->_include_dir as $directory) { |
|
510 | - unset($this->_resource_dir[ $directory ]); |
|
511 | - } |
|
512 | - if ($this->smarty->use_include_path) { |
|
513 | - $this->_include_dir = array(); |
|
514 | - $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
|
515 | - foreach ($_dirs as $directory) { |
|
516 | - $this->_include_dir[] = $directory; |
|
517 | - $this->_resource_dir[ $directory ] = true; |
|
518 | - } |
|
519 | - } |
|
520 | - $this->_include_path_status = $this->smarty->use_include_path; |
|
521 | - } |
|
522 | - if ($isConfig !== true && |
|
523 | - (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
524 | - ) { |
|
525 | - $_dir = $this->smarty->getTemplateDir(); |
|
526 | - if ($this->_template_dir !== $_dir) { |
|
527 | - foreach ($this->_template_dir as $directory) { |
|
528 | - unset($this->_resource_dir[ $directory ]); |
|
529 | - } |
|
530 | - foreach ($_dir as $directory) { |
|
531 | - $this->_resource_dir[ $directory ] = true; |
|
532 | - } |
|
533 | - $this->_template_dir = $_dir; |
|
534 | - } |
|
535 | - $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
536 | - } |
|
537 | - if ($isConfig !== false && |
|
538 | - (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
539 | - ) { |
|
540 | - $_dir = $this->smarty->getConfigDir(); |
|
541 | - if ($this->_config_dir !== $_dir) { |
|
542 | - foreach ($this->_config_dir as $directory) { |
|
543 | - unset($this->_resource_dir[ $directory ]); |
|
544 | - } |
|
545 | - foreach ($_dir as $directory) { |
|
546 | - $this->_resource_dir[ $directory ] = true; |
|
547 | - } |
|
548 | - $this->_config_dir = $_dir; |
|
549 | - } |
|
550 | - $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
551 | - } |
|
552 | - if ($this->_secure_dir !== (array) $this->secure_dir) { |
|
553 | - foreach ($this->_secure_dir as $directory) { |
|
554 | - unset($this->_resource_dir[ $directory ]); |
|
555 | - } |
|
556 | - foreach ((array) $this->secure_dir as $directory) { |
|
557 | - $directory = $this->smarty->_realpath($directory . DS, true); |
|
558 | - $this->_resource_dir[ $directory ] = true; |
|
559 | - } |
|
560 | - $this->_secure_dir = (array) $this->secure_dir; |
|
561 | - } |
|
562 | - $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir); |
|
563 | - return true; |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Check if URI (e.g. {fetch} or {html_image}) is trusted |
|
568 | - * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}". |
|
569 | - * So "http://username:[email protected]:8080/some-path?some=query-string" |
|
570 | - * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}. |
|
571 | - * |
|
572 | - * @param string $uri |
|
573 | - * |
|
574 | - * @return boolean true if URI is trusted |
|
575 | - * @throws SmartyException if URI is not trusted |
|
576 | - * @uses $trusted_uri for list of patterns to match against $uri |
|
577 | - */ |
|
578 | - public function isTrustedUri($uri) |
|
579 | - { |
|
580 | - $_uri = parse_url($uri); |
|
581 | - if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | - $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
583 | - foreach ($this->trusted_uri as $pattern) { |
|
584 | - if (preg_match($pattern, $_uri)) { |
|
585 | - return true; |
|
586 | - } |
|
587 | - } |
|
588 | - } |
|
589 | - |
|
590 | - throw new SmartyException("URI '{$uri}' not allowed by security setting"); |
|
591 | - } |
|
592 | - |
|
593 | - /** |
|
594 | - * Check if directory of file resource is trusted. |
|
595 | - * |
|
596 | - * @param string $filepath |
|
597 | - * |
|
598 | - * @return boolean true if directory is trusted |
|
599 | - * @throws SmartyException if PHP directory is not trusted |
|
600 | - */ |
|
601 | - public function isTrustedPHPDir($filepath) |
|
602 | - { |
|
603 | - if (empty($this->trusted_dir)) { |
|
604 | - throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); |
|
605 | - } |
|
606 | - |
|
607 | - // check if index is outdated |
|
608 | - if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { |
|
609 | - $this->_php_resource_dir = array(); |
|
610 | - |
|
611 | - $this->_trusted_dir = $this->trusted_dir; |
|
612 | - foreach ((array) $this->trusted_dir as $directory) { |
|
613 | - $directory = $this->smarty->_realpath($directory . DS, true); |
|
614 | - $this->_php_resource_dir[ $directory ] = true; |
|
615 | - } |
|
616 | - } |
|
617 | - |
|
618 | - $this->_php_resource_dir = |
|
619 | - $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir); |
|
620 | - return true; |
|
621 | - } |
|
16 | + /** |
|
17 | + * This determines how Smarty handles "<?php ... ?>" tags in templates. |
|
18 | + * possible values: |
|
19 | + * <ul> |
|
20 | + * <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li> |
|
21 | + * <li>Smarty::PHP_QUOTE -> escape tags as entities</li> |
|
22 | + * <li>Smarty::PHP_REMOVE -> remove php tags</li> |
|
23 | + * <li>Smarty::PHP_ALLOW -> execute php tags</li> |
|
24 | + * </ul> |
|
25 | + * |
|
26 | + * @var integer |
|
27 | + */ |
|
28 | + public $php_handling = Smarty::PHP_PASSTHRU; |
|
29 | + |
|
30 | + /** |
|
31 | + * This is the list of template directories that are considered secure. |
|
32 | + * $template_dir is in this list implicitly. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $secure_dir = array(); |
|
37 | + |
|
38 | + /** |
|
39 | + * This is an array of directories where trusted php scripts reside. |
|
40 | + * {@link $security} is disabled during their inclusion/execution. |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + public $trusted_dir = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * List of regular expressions (PCRE) that include trusted URIs |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + public $trusted_uri = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * List of trusted constants names |
|
55 | + * |
|
56 | + * @var array |
|
57 | + */ |
|
58 | + public $trusted_constants = array(); |
|
59 | + |
|
60 | + /** |
|
61 | + * This is an array of trusted static classes. |
|
62 | + * If empty access to all static classes is allowed. |
|
63 | + * If set to 'none' none is allowed. |
|
64 | + * |
|
65 | + * @var array |
|
66 | + */ |
|
67 | + public $static_classes = array(); |
|
68 | + |
|
69 | + /** |
|
70 | + * This is an nested array of trusted classes and static methods. |
|
71 | + * If empty access to all static classes and methods is allowed. |
|
72 | + * Format: |
|
73 | + * array ( |
|
74 | + * 'class_1' => array('method_1', 'method_2'), // allowed methods listed |
|
75 | + * 'class_2' => array(), // all methods of class allowed |
|
76 | + * ) |
|
77 | + * If set to null none is allowed. |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + public $trusted_static_methods = array(); |
|
82 | + |
|
83 | + /** |
|
84 | + * This is an array of trusted static properties. |
|
85 | + * If empty access to all static classes and properties is allowed. |
|
86 | + * Format: |
|
87 | + * array ( |
|
88 | + * 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed |
|
89 | + * 'class_2' => array(), // all properties of class allowed |
|
90 | + * ) |
|
91 | + * If set to null none is allowed. |
|
92 | + * |
|
93 | + * @var array |
|
94 | + */ |
|
95 | + public $trusted_static_properties = array(); |
|
96 | + |
|
97 | + /** |
|
98 | + * This is an array of trusted PHP functions. |
|
99 | + * If empty all functions are allowed. |
|
100 | + * To disable all PHP functions set $php_functions = null. |
|
101 | + * |
|
102 | + * @var array |
|
103 | + */ |
|
104 | + public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',); |
|
105 | + |
|
106 | + /** |
|
107 | + * This is an array of trusted PHP modifiers. |
|
108 | + * If empty all modifiers are allowed. |
|
109 | + * To disable all modifier set $php_modifiers = null. |
|
110 | + * |
|
111 | + * @var array |
|
112 | + */ |
|
113 | + public $php_modifiers = array('escape', 'count', 'nl2br',); |
|
114 | + |
|
115 | + /** |
|
116 | + * This is an array of allowed tags. |
|
117 | + * If empty no restriction by allowed_tags. |
|
118 | + * |
|
119 | + * @var array |
|
120 | + */ |
|
121 | + public $allowed_tags = array(); |
|
122 | + |
|
123 | + /** |
|
124 | + * This is an array of disabled tags. |
|
125 | + * If empty no restriction by disabled_tags. |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + public $disabled_tags = array(); |
|
130 | + |
|
131 | + /** |
|
132 | + * This is an array of allowed modifier plugins. |
|
133 | + * If empty no restriction by allowed_modifiers. |
|
134 | + * |
|
135 | + * @var array |
|
136 | + */ |
|
137 | + public $allowed_modifiers = array(); |
|
138 | + |
|
139 | + /** |
|
140 | + * This is an array of disabled modifier plugins. |
|
141 | + * If empty no restriction by disabled_modifiers. |
|
142 | + * |
|
143 | + * @var array |
|
144 | + */ |
|
145 | + public $disabled_modifiers = array(); |
|
146 | + |
|
147 | + /** |
|
148 | + * This is an array of disabled special $smarty variables. |
|
149 | + * |
|
150 | + * @var array |
|
151 | + */ |
|
152 | + public $disabled_special_smarty_vars = array(); |
|
153 | + |
|
154 | + /** |
|
155 | + * This is an array of trusted streams. |
|
156 | + * If empty all streams are allowed. |
|
157 | + * To disable all streams set $streams = null. |
|
158 | + * |
|
159 | + * @var array |
|
160 | + */ |
|
161 | + public $streams = array('file'); |
|
162 | + |
|
163 | + /** |
|
164 | + * + flag if constants can be accessed from template |
|
165 | + * |
|
166 | + * @var boolean |
|
167 | + */ |
|
168 | + public $allow_constants = true; |
|
169 | + |
|
170 | + /** |
|
171 | + * + flag if super globals can be accessed from template |
|
172 | + * |
|
173 | + * @var boolean |
|
174 | + */ |
|
175 | + public $allow_super_globals = true; |
|
176 | + |
|
177 | + /** |
|
178 | + * max template nesting level |
|
179 | + * |
|
180 | + * @var int |
|
181 | + */ |
|
182 | + public $max_template_nesting = 0; |
|
183 | + |
|
184 | + /** |
|
185 | + * current template nesting level |
|
186 | + * |
|
187 | + * @var int |
|
188 | + */ |
|
189 | + private $_current_template_nesting = 0; |
|
190 | + |
|
191 | + /** |
|
192 | + * Cache for $resource_dir lookup |
|
193 | + * |
|
194 | + * @var array |
|
195 | + */ |
|
196 | + protected $_resource_dir = array(); |
|
197 | + |
|
198 | + /** |
|
199 | + * Cache for $template_dir lookup |
|
200 | + * |
|
201 | + * @var array |
|
202 | + */ |
|
203 | + protected $_template_dir = array(); |
|
204 | + |
|
205 | + /** |
|
206 | + * Cache for $config_dir lookup |
|
207 | + * |
|
208 | + * @var array |
|
209 | + */ |
|
210 | + protected $_config_dir = array(); |
|
211 | + |
|
212 | + /** |
|
213 | + * Cache for $secure_dir lookup |
|
214 | + * |
|
215 | + * @var array |
|
216 | + */ |
|
217 | + protected $_secure_dir = array(); |
|
218 | + |
|
219 | + /** |
|
220 | + * Cache for $php_resource_dir lookup |
|
221 | + * |
|
222 | + * @var array |
|
223 | + */ |
|
224 | + protected $_php_resource_dir = null; |
|
225 | + |
|
226 | + /** |
|
227 | + * Cache for $trusted_dir lookup |
|
228 | + * |
|
229 | + * @var array |
|
230 | + */ |
|
231 | + protected $_trusted_dir = null; |
|
232 | + |
|
233 | + /** |
|
234 | + * Cache for include path status |
|
235 | + * |
|
236 | + * @var bool |
|
237 | + */ |
|
238 | + protected $_include_path_status = false; |
|
239 | + |
|
240 | + /** |
|
241 | + * Cache for $_include_array lookup |
|
242 | + * |
|
243 | + * @var array |
|
244 | + */ |
|
245 | + protected $_include_dir = array(); |
|
246 | + |
|
247 | + /** |
|
248 | + * @param Smarty $smarty |
|
249 | + */ |
|
250 | + public function __construct($smarty) |
|
251 | + { |
|
252 | + $this->smarty = $smarty; |
|
253 | + $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | + $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Check if PHP function is trusted. |
|
259 | + * |
|
260 | + * @param string $function_name |
|
261 | + * @param object $compiler compiler object |
|
262 | + * |
|
263 | + * @return boolean true if function is trusted |
|
264 | + * @throws SmartyCompilerException if php function is not trusted |
|
265 | + */ |
|
266 | + public function isTrustedPhpFunction($function_name, $compiler) |
|
267 | + { |
|
268 | + if (isset($this->php_functions) && |
|
269 | + (empty($this->php_functions) || in_array($function_name, $this->php_functions)) |
|
270 | + ) { |
|
271 | + return true; |
|
272 | + } |
|
273 | + |
|
274 | + $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); |
|
275 | + |
|
276 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Check if static class is trusted. |
|
281 | + * |
|
282 | + * @param string $class_name |
|
283 | + * @param object $compiler compiler object |
|
284 | + * |
|
285 | + * @return boolean true if class is trusted |
|
286 | + * @throws SmartyCompilerException if static class is not trusted |
|
287 | + */ |
|
288 | + public function isTrustedStaticClass($class_name, $compiler) |
|
289 | + { |
|
290 | + if (isset($this->static_classes) && |
|
291 | + (empty($this->static_classes) || in_array($class_name, $this->static_classes)) |
|
292 | + ) { |
|
293 | + return true; |
|
294 | + } |
|
295 | + |
|
296 | + $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); |
|
297 | + |
|
298 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Check if static class method/property is trusted. |
|
303 | + * |
|
304 | + * @param string $class_name |
|
305 | + * @param string $params |
|
306 | + * @param object $compiler compiler object |
|
307 | + * |
|
308 | + * @return boolean true if class method is trusted |
|
309 | + * @throws SmartyCompilerException if static class method is not trusted |
|
310 | + */ |
|
311 | + public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
|
312 | + { |
|
313 | + if (!isset($params[ 2 ])) { |
|
314 | + // fall back |
|
315 | + return $this->isTrustedStaticClass($class_name, $compiler); |
|
316 | + } |
|
317 | + if ($params[ 2 ] == 'method') { |
|
318 | + $allowed = $this->trusted_static_methods; |
|
319 | + $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
320 | + } else { |
|
321 | + $allowed = $this->trusted_static_properties; |
|
322 | + // strip '$' |
|
323 | + $name = substr($params[ 0 ], 1); |
|
324 | + } |
|
325 | + if (isset($allowed)) { |
|
326 | + if (empty($allowed)) { |
|
327 | + // fall back |
|
328 | + return $this->isTrustedStaticClass($class_name, $compiler); |
|
329 | + } |
|
330 | + if (isset($allowed[ $class_name ]) && |
|
331 | + (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
332 | + ) { |
|
333 | + return true; |
|
334 | + } |
|
335 | + } |
|
336 | + $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting"); |
|
337 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Check if PHP modifier is trusted. |
|
342 | + * |
|
343 | + * @param string $modifier_name |
|
344 | + * @param object $compiler compiler object |
|
345 | + * |
|
346 | + * @return boolean true if modifier is trusted |
|
347 | + * @throws SmartyCompilerException if modifier is not trusted |
|
348 | + */ |
|
349 | + public function isTrustedPhpModifier($modifier_name, $compiler) |
|
350 | + { |
|
351 | + if (isset($this->php_modifiers) && |
|
352 | + (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers)) |
|
353 | + ) { |
|
354 | + return true; |
|
355 | + } |
|
356 | + |
|
357 | + $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); |
|
358 | + |
|
359 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Check if tag is trusted. |
|
364 | + * |
|
365 | + * @param string $tag_name |
|
366 | + * @param object $compiler compiler object |
|
367 | + * |
|
368 | + * @return boolean true if tag is trusted |
|
369 | + * @throws SmartyCompilerException if modifier is not trusted |
|
370 | + */ |
|
371 | + public function isTrustedTag($tag_name, $compiler) |
|
372 | + { |
|
373 | + // check for internal always required tags |
|
374 | + if (in_array($tag_name, |
|
375 | + array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', |
|
376 | + 'private_object_block_function', 'private_object_function', 'private_registered_function', |
|
377 | + 'private_registered_block', 'private_special_variable', 'private_print_expression', |
|
378 | + 'private_modifier'))) { |
|
379 | + return true; |
|
380 | + } |
|
381 | + // check security settings |
|
382 | + if (empty($this->allowed_tags)) { |
|
383 | + if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) { |
|
384 | + return true; |
|
385 | + } else { |
|
386 | + $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true); |
|
387 | + } |
|
388 | + } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) { |
|
389 | + return true; |
|
390 | + } else { |
|
391 | + $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true); |
|
392 | + } |
|
393 | + |
|
394 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Check if special $smarty variable is trusted. |
|
399 | + * |
|
400 | + * @param string $var_name |
|
401 | + * @param object $compiler compiler object |
|
402 | + * |
|
403 | + * @return boolean true if tag is trusted |
|
404 | + * @throws SmartyCompilerException if modifier is not trusted |
|
405 | + */ |
|
406 | + public function isTrustedSpecialSmartyVar($var_name, $compiler) |
|
407 | + { |
|
408 | + if (!in_array($var_name, $this->disabled_special_smarty_vars)) { |
|
409 | + return true; |
|
410 | + } else { |
|
411 | + $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", |
|
412 | + null, true); |
|
413 | + } |
|
414 | + |
|
415 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Check if modifier plugin is trusted. |
|
420 | + * |
|
421 | + * @param string $modifier_name |
|
422 | + * @param object $compiler compiler object |
|
423 | + * |
|
424 | + * @return boolean true if tag is trusted |
|
425 | + * @throws SmartyCompilerException if modifier is not trusted |
|
426 | + */ |
|
427 | + public function isTrustedModifier($modifier_name, $compiler) |
|
428 | + { |
|
429 | + // check for internal always allowed modifier |
|
430 | + if (in_array($modifier_name, array('default'))) { |
|
431 | + return true; |
|
432 | + } |
|
433 | + // check security settings |
|
434 | + if (empty($this->allowed_modifiers)) { |
|
435 | + if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) { |
|
436 | + return true; |
|
437 | + } else { |
|
438 | + $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null, |
|
439 | + true); |
|
440 | + } |
|
441 | + } elseif (in_array($modifier_name, $this->allowed_modifiers) && |
|
442 | + !in_array($modifier_name, $this->disabled_modifiers) |
|
443 | + ) { |
|
444 | + return true; |
|
445 | + } else { |
|
446 | + $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null, |
|
447 | + true); |
|
448 | + } |
|
449 | + |
|
450 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * Check if constants are enabled or trusted |
|
455 | + * |
|
456 | + * @param string $const constant name |
|
457 | + * @param object $compiler compiler object |
|
458 | + * |
|
459 | + * @return bool |
|
460 | + */ |
|
461 | + public function isTrustedConstant($const, $compiler) |
|
462 | + { |
|
463 | + if (in_array($const, array('true', 'false', 'null'))) { |
|
464 | + return true; |
|
465 | + } |
|
466 | + if (!empty($this->trusted_constants)) { |
|
467 | + if (!in_array($const, $this->trusted_constants)) { |
|
468 | + $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted"); |
|
469 | + return false; |
|
470 | + } |
|
471 | + return true; |
|
472 | + } |
|
473 | + if ($this->allow_constants) { |
|
474 | + return true; |
|
475 | + } |
|
476 | + $compiler->trigger_template_error("Security: access to constants not permitted"); |
|
477 | + return false; |
|
478 | + } |
|
479 | + |
|
480 | + /** |
|
481 | + * Check if stream is trusted. |
|
482 | + * |
|
483 | + * @param string $stream_name |
|
484 | + * |
|
485 | + * @return boolean true if stream is trusted |
|
486 | + * @throws SmartyException if stream is not trusted |
|
487 | + */ |
|
488 | + public function isTrustedStream($stream_name) |
|
489 | + { |
|
490 | + if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { |
|
491 | + return true; |
|
492 | + } |
|
493 | + |
|
494 | + throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); |
|
495 | + } |
|
496 | + |
|
497 | + /** |
|
498 | + * Check if directory of file resource is trusted. |
|
499 | + * |
|
500 | + * @param string $filepath |
|
501 | + * @param null|bool $isConfig |
|
502 | + * |
|
503 | + * @return bool true if directory is trusted |
|
504 | + * @throws \SmartyException if directory is not trusted |
|
505 | + */ |
|
506 | + public function isTrustedResourceDir($filepath, $isConfig = null) |
|
507 | + { |
|
508 | + if ($this->_include_path_status !== $this->smarty->use_include_path) { |
|
509 | + foreach ($this->_include_dir as $directory) { |
|
510 | + unset($this->_resource_dir[ $directory ]); |
|
511 | + } |
|
512 | + if ($this->smarty->use_include_path) { |
|
513 | + $this->_include_dir = array(); |
|
514 | + $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
|
515 | + foreach ($_dirs as $directory) { |
|
516 | + $this->_include_dir[] = $directory; |
|
517 | + $this->_resource_dir[ $directory ] = true; |
|
518 | + } |
|
519 | + } |
|
520 | + $this->_include_path_status = $this->smarty->use_include_path; |
|
521 | + } |
|
522 | + if ($isConfig !== true && |
|
523 | + (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
524 | + ) { |
|
525 | + $_dir = $this->smarty->getTemplateDir(); |
|
526 | + if ($this->_template_dir !== $_dir) { |
|
527 | + foreach ($this->_template_dir as $directory) { |
|
528 | + unset($this->_resource_dir[ $directory ]); |
|
529 | + } |
|
530 | + foreach ($_dir as $directory) { |
|
531 | + $this->_resource_dir[ $directory ] = true; |
|
532 | + } |
|
533 | + $this->_template_dir = $_dir; |
|
534 | + } |
|
535 | + $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
536 | + } |
|
537 | + if ($isConfig !== false && |
|
538 | + (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
539 | + ) { |
|
540 | + $_dir = $this->smarty->getConfigDir(); |
|
541 | + if ($this->_config_dir !== $_dir) { |
|
542 | + foreach ($this->_config_dir as $directory) { |
|
543 | + unset($this->_resource_dir[ $directory ]); |
|
544 | + } |
|
545 | + foreach ($_dir as $directory) { |
|
546 | + $this->_resource_dir[ $directory ] = true; |
|
547 | + } |
|
548 | + $this->_config_dir = $_dir; |
|
549 | + } |
|
550 | + $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
551 | + } |
|
552 | + if ($this->_secure_dir !== (array) $this->secure_dir) { |
|
553 | + foreach ($this->_secure_dir as $directory) { |
|
554 | + unset($this->_resource_dir[ $directory ]); |
|
555 | + } |
|
556 | + foreach ((array) $this->secure_dir as $directory) { |
|
557 | + $directory = $this->smarty->_realpath($directory . DS, true); |
|
558 | + $this->_resource_dir[ $directory ] = true; |
|
559 | + } |
|
560 | + $this->_secure_dir = (array) $this->secure_dir; |
|
561 | + } |
|
562 | + $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir); |
|
563 | + return true; |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Check if URI (e.g. {fetch} or {html_image}) is trusted |
|
568 | + * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}". |
|
569 | + * So "http://username:[email protected]:8080/some-path?some=query-string" |
|
570 | + * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}. |
|
571 | + * |
|
572 | + * @param string $uri |
|
573 | + * |
|
574 | + * @return boolean true if URI is trusted |
|
575 | + * @throws SmartyException if URI is not trusted |
|
576 | + * @uses $trusted_uri for list of patterns to match against $uri |
|
577 | + */ |
|
578 | + public function isTrustedUri($uri) |
|
579 | + { |
|
580 | + $_uri = parse_url($uri); |
|
581 | + if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | + $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
583 | + foreach ($this->trusted_uri as $pattern) { |
|
584 | + if (preg_match($pattern, $_uri)) { |
|
585 | + return true; |
|
586 | + } |
|
587 | + } |
|
588 | + } |
|
589 | + |
|
590 | + throw new SmartyException("URI '{$uri}' not allowed by security setting"); |
|
591 | + } |
|
592 | + |
|
593 | + /** |
|
594 | + * Check if directory of file resource is trusted. |
|
595 | + * |
|
596 | + * @param string $filepath |
|
597 | + * |
|
598 | + * @return boolean true if directory is trusted |
|
599 | + * @throws SmartyException if PHP directory is not trusted |
|
600 | + */ |
|
601 | + public function isTrustedPHPDir($filepath) |
|
602 | + { |
|
603 | + if (empty($this->trusted_dir)) { |
|
604 | + throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); |
|
605 | + } |
|
606 | + |
|
607 | + // check if index is outdated |
|
608 | + if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { |
|
609 | + $this->_php_resource_dir = array(); |
|
610 | + |
|
611 | + $this->_trusted_dir = $this->trusted_dir; |
|
612 | + foreach ((array) $this->trusted_dir as $directory) { |
|
613 | + $directory = $this->smarty->_realpath($directory . DS, true); |
|
614 | + $this->_php_resource_dir[ $directory ] = true; |
|
615 | + } |
|
616 | + } |
|
617 | + |
|
618 | + $this->_php_resource_dir = |
|
619 | + $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir); |
|
620 | + return true; |
|
621 | + } |
|
622 | 622 | |
623 | - /** |
|
624 | - * Check if file is inside a valid directory |
|
625 | - * |
|
626 | - * @param string $filepath |
|
627 | - * @param array $dirs valid directories |
|
628 | - * |
|
629 | - * @return array |
|
630 | - * @throws \SmartyException |
|
631 | - */ |
|
632 | - private function _checkDir($filepath, $dirs) |
|
633 | - { |
|
634 | - $directory = dirname($filepath) . DS; |
|
635 | - $_directory = array(); |
|
636 | - while (true) { |
|
637 | - // remember the directory to add it to _resource_dir in case we're successful |
|
638 | - $_directory[ $directory ] = true; |
|
639 | - // test if the directory is trusted |
|
640 | - if (isset($dirs[ $directory ])) { |
|
641 | - // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
|
642 | - $dirs = array_merge($dirs, $_directory); |
|
643 | - |
|
644 | - return $dirs; |
|
645 | - } |
|
646 | - // abort if we've reached root |
|
647 | - if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) { |
|
648 | - break; |
|
649 | - } |
|
650 | - // bubble up one level |
|
651 | - $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory); |
|
652 | - } |
|
653 | - |
|
654 | - // give up |
|
655 | - throw new SmartyException("directory '{$filepath}' not allowed by security setting"); |
|
656 | - } |
|
657 | - |
|
658 | - /** |
|
659 | - * Loads security class and enables security |
|
660 | - * |
|
661 | - * @param \Smarty $smarty |
|
662 | - * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
663 | - * |
|
664 | - * @return \Smarty current Smarty instance for chaining |
|
665 | - * @throws \SmartyException when an invalid class name is provided |
|
666 | - */ |
|
667 | - public static function enableSecurity(Smarty $smarty, $security_class) |
|
668 | - { |
|
669 | - if ($security_class instanceof Smarty_Security) { |
|
670 | - $smarty->security_policy = $security_class; |
|
671 | - return; |
|
672 | - } elseif (is_object($security_class)) { |
|
673 | - throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); |
|
674 | - } |
|
675 | - if ($security_class == null) { |
|
676 | - $security_class = $smarty->security_class; |
|
677 | - } |
|
678 | - if (!class_exists($security_class)) { |
|
679 | - throw new SmartyException("Security class '$security_class' is not defined"); |
|
680 | - } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { |
|
681 | - throw new SmartyException("Class '$security_class' must extend Smarty_Security."); |
|
682 | - } else { |
|
683 | - $smarty->security_policy = new $security_class($smarty); |
|
684 | - } |
|
685 | - return; |
|
686 | - } |
|
687 | - /** |
|
688 | - * Start template processing |
|
689 | - * |
|
690 | - * @param $template |
|
691 | - * |
|
692 | - * @throws SmartyException |
|
693 | - */ |
|
694 | - public function startTemplate($template) |
|
695 | - { |
|
696 | - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
697 | - throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
|
698 | - } |
|
699 | - } |
|
700 | - |
|
701 | - /** |
|
702 | - * Exit template processing |
|
703 | - * |
|
704 | - */ |
|
705 | - public function endTemplate() |
|
706 | - { |
|
707 | - if ($this->max_template_nesting > 0) { |
|
708 | - $this->_current_template_nesting --; |
|
709 | - } |
|
710 | - } |
|
711 | - |
|
712 | - /** |
|
713 | - * Register callback functions call at start/end of template rendering |
|
714 | - * |
|
715 | - * @param \Smarty_Internal_Template $template |
|
716 | - */ |
|
717 | - public function registerCallBacks(Smarty_Internal_Template $template) |
|
718 | - { |
|
719 | - $template->startRenderCallbacks[] = array($this, 'startTemplate'); |
|
720 | - $template->endRenderCallbacks[] = array($this, 'endTemplate'); |
|
721 | - } |
|
623 | + /** |
|
624 | + * Check if file is inside a valid directory |
|
625 | + * |
|
626 | + * @param string $filepath |
|
627 | + * @param array $dirs valid directories |
|
628 | + * |
|
629 | + * @return array |
|
630 | + * @throws \SmartyException |
|
631 | + */ |
|
632 | + private function _checkDir($filepath, $dirs) |
|
633 | + { |
|
634 | + $directory = dirname($filepath) . DS; |
|
635 | + $_directory = array(); |
|
636 | + while (true) { |
|
637 | + // remember the directory to add it to _resource_dir in case we're successful |
|
638 | + $_directory[ $directory ] = true; |
|
639 | + // test if the directory is trusted |
|
640 | + if (isset($dirs[ $directory ])) { |
|
641 | + // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
|
642 | + $dirs = array_merge($dirs, $_directory); |
|
643 | + |
|
644 | + return $dirs; |
|
645 | + } |
|
646 | + // abort if we've reached root |
|
647 | + if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) { |
|
648 | + break; |
|
649 | + } |
|
650 | + // bubble up one level |
|
651 | + $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory); |
|
652 | + } |
|
653 | + |
|
654 | + // give up |
|
655 | + throw new SmartyException("directory '{$filepath}' not allowed by security setting"); |
|
656 | + } |
|
657 | + |
|
658 | + /** |
|
659 | + * Loads security class and enables security |
|
660 | + * |
|
661 | + * @param \Smarty $smarty |
|
662 | + * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
663 | + * |
|
664 | + * @return \Smarty current Smarty instance for chaining |
|
665 | + * @throws \SmartyException when an invalid class name is provided |
|
666 | + */ |
|
667 | + public static function enableSecurity(Smarty $smarty, $security_class) |
|
668 | + { |
|
669 | + if ($security_class instanceof Smarty_Security) { |
|
670 | + $smarty->security_policy = $security_class; |
|
671 | + return; |
|
672 | + } elseif (is_object($security_class)) { |
|
673 | + throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); |
|
674 | + } |
|
675 | + if ($security_class == null) { |
|
676 | + $security_class = $smarty->security_class; |
|
677 | + } |
|
678 | + if (!class_exists($security_class)) { |
|
679 | + throw new SmartyException("Security class '$security_class' is not defined"); |
|
680 | + } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { |
|
681 | + throw new SmartyException("Class '$security_class' must extend Smarty_Security."); |
|
682 | + } else { |
|
683 | + $smarty->security_policy = new $security_class($smarty); |
|
684 | + } |
|
685 | + return; |
|
686 | + } |
|
687 | + /** |
|
688 | + * Start template processing |
|
689 | + * |
|
690 | + * @param $template |
|
691 | + * |
|
692 | + * @throws SmartyException |
|
693 | + */ |
|
694 | + public function startTemplate($template) |
|
695 | + { |
|
696 | + if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
697 | + throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
|
698 | + } |
|
699 | + } |
|
700 | + |
|
701 | + /** |
|
702 | + * Exit template processing |
|
703 | + * |
|
704 | + */ |
|
705 | + public function endTemplate() |
|
706 | + { |
|
707 | + if ($this->max_template_nesting > 0) { |
|
708 | + $this->_current_template_nesting --; |
|
709 | + } |
|
710 | + } |
|
711 | + |
|
712 | + /** |
|
713 | + * Register callback functions call at start/end of template rendering |
|
714 | + * |
|
715 | + * @param \Smarty_Internal_Template $template |
|
716 | + */ |
|
717 | + public function registerCallBacks(Smarty_Internal_Template $template) |
|
718 | + { |
|
719 | + $template->startRenderCallbacks[] = array($this, 'startTemplate'); |
|
720 | + $template->endRenderCallbacks[] = array($this, 'endTemplate'); |
|
721 | + } |
|
722 | 722 | } |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | public function __construct($smarty) |
251 | 251 | { |
252 | 252 | $this->smarty = $smarty; |
253 | - $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | - $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
253 | + $this->smarty->_cache['template_dir_new'] = true; |
|
254 | + $this->smarty->_cache['config_dir_new'] = true; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -310,25 +310,25 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
312 | 312 | { |
313 | - if (!isset($params[ 2 ])) { |
|
313 | + if (!isset($params[2])) { |
|
314 | 314 | // fall back |
315 | 315 | return $this->isTrustedStaticClass($class_name, $compiler); |
316 | 316 | } |
317 | - if ($params[ 2 ] == 'method') { |
|
317 | + if ($params[2] == 'method') { |
|
318 | 318 | $allowed = $this->trusted_static_methods; |
319 | - $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
319 | + $name = substr($params[0], 0, strpos($params[0], '(')); |
|
320 | 320 | } else { |
321 | 321 | $allowed = $this->trusted_static_properties; |
322 | 322 | // strip '$' |
323 | - $name = substr($params[ 0 ], 1); |
|
323 | + $name = substr($params[0], 1); |
|
324 | 324 | } |
325 | 325 | if (isset($allowed)) { |
326 | 326 | if (empty($allowed)) { |
327 | 327 | // fall back |
328 | 328 | return $this->isTrustedStaticClass($class_name, $compiler); |
329 | 329 | } |
330 | - if (isset($allowed[ $class_name ]) && |
|
331 | - (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
330 | + if (isset($allowed[$class_name]) && |
|
331 | + (empty($allowed[$class_name]) || in_array($name, $allowed[$class_name])) |
|
332 | 332 | ) { |
333 | 333 | return true; |
334 | 334 | } |
@@ -507,55 +507,55 @@ discard block |
||
507 | 507 | { |
508 | 508 | if ($this->_include_path_status !== $this->smarty->use_include_path) { |
509 | 509 | foreach ($this->_include_dir as $directory) { |
510 | - unset($this->_resource_dir[ $directory ]); |
|
510 | + unset($this->_resource_dir[$directory]); |
|
511 | 511 | } |
512 | 512 | if ($this->smarty->use_include_path) { |
513 | 513 | $this->_include_dir = array(); |
514 | 514 | $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
515 | 515 | foreach ($_dirs as $directory) { |
516 | 516 | $this->_include_dir[] = $directory; |
517 | - $this->_resource_dir[ $directory ] = true; |
|
517 | + $this->_resource_dir[$directory] = true; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | $this->_include_path_status = $this->smarty->use_include_path; |
521 | 521 | } |
522 | 522 | if ($isConfig !== true && |
523 | - (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
523 | + (!isset($this->smarty->_cache['template_dir_new']) || $this->smarty->_cache['template_dir_new']) |
|
524 | 524 | ) { |
525 | 525 | $_dir = $this->smarty->getTemplateDir(); |
526 | 526 | if ($this->_template_dir !== $_dir) { |
527 | 527 | foreach ($this->_template_dir as $directory) { |
528 | - unset($this->_resource_dir[ $directory ]); |
|
528 | + unset($this->_resource_dir[$directory]); |
|
529 | 529 | } |
530 | 530 | foreach ($_dir as $directory) { |
531 | - $this->_resource_dir[ $directory ] = true; |
|
531 | + $this->_resource_dir[$directory] = true; |
|
532 | 532 | } |
533 | 533 | $this->_template_dir = $_dir; |
534 | 534 | } |
535 | - $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
535 | + $this->smarty->_cache['template_dir_new'] = false; |
|
536 | 536 | } |
537 | 537 | if ($isConfig !== false && |
538 | - (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
538 | + (!isset($this->smarty->_cache['config_dir_new']) || $this->smarty->_cache['config_dir_new']) |
|
539 | 539 | ) { |
540 | 540 | $_dir = $this->smarty->getConfigDir(); |
541 | 541 | if ($this->_config_dir !== $_dir) { |
542 | 542 | foreach ($this->_config_dir as $directory) { |
543 | - unset($this->_resource_dir[ $directory ]); |
|
543 | + unset($this->_resource_dir[$directory]); |
|
544 | 544 | } |
545 | 545 | foreach ($_dir as $directory) { |
546 | - $this->_resource_dir[ $directory ] = true; |
|
546 | + $this->_resource_dir[$directory] = true; |
|
547 | 547 | } |
548 | 548 | $this->_config_dir = $_dir; |
549 | 549 | } |
550 | - $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
550 | + $this->smarty->_cache['config_dir_new'] = false; |
|
551 | 551 | } |
552 | 552 | if ($this->_secure_dir !== (array) $this->secure_dir) { |
553 | 553 | foreach ($this->_secure_dir as $directory) { |
554 | - unset($this->_resource_dir[ $directory ]); |
|
554 | + unset($this->_resource_dir[$directory]); |
|
555 | 555 | } |
556 | 556 | foreach ((array) $this->secure_dir as $directory) { |
557 | 557 | $directory = $this->smarty->_realpath($directory . DS, true); |
558 | - $this->_resource_dir[ $directory ] = true; |
|
558 | + $this->_resource_dir[$directory] = true; |
|
559 | 559 | } |
560 | 560 | $this->_secure_dir = (array) $this->secure_dir; |
561 | 561 | } |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | public function isTrustedUri($uri) |
579 | 579 | { |
580 | 580 | $_uri = parse_url($uri); |
581 | - if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | - $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
581 | + if (!empty($_uri['scheme']) && !empty($_uri['host'])) { |
|
582 | + $_uri = $_uri['scheme'] . '://' . $_uri['host']; |
|
583 | 583 | foreach ($this->trusted_uri as $pattern) { |
584 | 584 | if (preg_match($pattern, $_uri)) { |
585 | 585 | return true; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->_trusted_dir = $this->trusted_dir; |
612 | 612 | foreach ((array) $this->trusted_dir as $directory) { |
613 | 613 | $directory = $this->smarty->_realpath($directory . DS, true); |
614 | - $this->_php_resource_dir[ $directory ] = true; |
|
614 | + $this->_php_resource_dir[$directory] = true; |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | $_directory = array(); |
636 | 636 | while (true) { |
637 | 637 | // remember the directory to add it to _resource_dir in case we're successful |
638 | - $_directory[ $directory ] = true; |
|
638 | + $_directory[$directory] = true; |
|
639 | 639 | // test if the directory is trusted |
640 | - if (isset($dirs[ $directory ])) { |
|
640 | + if (isset($dirs[$directory])) { |
|
641 | 641 | // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
642 | 642 | $dirs = array_merge($dirs, $_directory); |
643 | 643 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | */ |
694 | 694 | public function startTemplate($template) |
695 | 695 | { |
696 | - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
696 | + if ($this->max_template_nesting > 0 && $this->_current_template_nesting++ >= $this->max_template_nesting) { |
|
697 | 697 | throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
698 | 698 | } |
699 | 699 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public function endTemplate() |
706 | 706 | { |
707 | 707 | if ($this->max_template_nesting > 0) { |
708 | - $this->_current_template_nesting --; |
|
708 | + $this->_current_template_nesting--; |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 |
@@ -126,7 +126,6 @@ |
||
126 | 126 | /** |
127 | 127 | * create Source Object container |
128 | 128 | * |
129 | - * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | 129 | * @param Smarty $smarty Smarty instance this source object belongs to |
131 | 130 | * @param string $resource full template_resource |
132 | 131 | * @param string $type type of resource |
@@ -11,200 +11,200 @@ |
||
11 | 11 | */ |
12 | 12 | class Smarty_Template_Source |
13 | 13 | { |
14 | - /** |
|
15 | - * Unique Template ID |
|
16 | - * |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $uid = null; |
|
20 | - |
|
21 | - /** |
|
22 | - * Template Resource (Smarty_Internal_Template::$template_resource) |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $resource = null; |
|
27 | - |
|
28 | - /** |
|
29 | - * Resource Type |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $type = null; |
|
34 | - |
|
35 | - /** |
|
36 | - * Resource Name |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - public $name = null; |
|
41 | - |
|
42 | - /** |
|
43 | - * Source Filepath |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - public $filepath = null; |
|
48 | - |
|
49 | - /** |
|
50 | - * Source Timestamp |
|
51 | - * |
|
52 | - * @var integer |
|
53 | - */ |
|
54 | - public $timestamp = null; |
|
55 | - |
|
56 | - /** |
|
57 | - * Source Existence |
|
58 | - * |
|
59 | - * @var boolean |
|
60 | - */ |
|
61 | - public $exists = false; |
|
62 | - |
|
63 | - /** |
|
64 | - * Source File Base name |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - public $basename = null; |
|
69 | - |
|
70 | - /** |
|
71 | - * The Components an extended template is made of |
|
72 | - * |
|
73 | - * @var \Smarty_Template_Source[] |
|
74 | - */ |
|
75 | - public $components = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * Resource Handler |
|
79 | - * |
|
80 | - * @var \Smarty_Resource |
|
81 | - */ |
|
82 | - public $handler = null; |
|
83 | - |
|
84 | - /** |
|
85 | - * Smarty instance |
|
86 | - * |
|
87 | - * @var Smarty |
|
88 | - */ |
|
89 | - public $smarty = null; |
|
90 | - |
|
91 | - /** |
|
92 | - * Resource is source |
|
93 | - * |
|
94 | - * @var bool |
|
95 | - */ |
|
96 | - public $isConfig = false; |
|
97 | - |
|
98 | - /** |
|
99 | - * Template source content eventually set by default handler |
|
100 | - * |
|
101 | - * @var string |
|
102 | - */ |
|
103 | - public $content = null; |
|
104 | - |
|
105 | - /** |
|
106 | - * Name of the Class to compile this resource's contents with |
|
107 | - * |
|
108 | - * @var string |
|
109 | - */ |
|
110 | - public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
|
111 | - |
|
112 | - /** |
|
113 | - * Name of the Class to tokenize this resource's contents with |
|
114 | - * |
|
115 | - * @var string |
|
116 | - */ |
|
117 | - public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
|
118 | - |
|
119 | - /** |
|
120 | - * Name of the Class to parse this resource's contents with |
|
121 | - * |
|
122 | - * @var string |
|
123 | - */ |
|
124 | - public $template_parser_class = 'Smarty_Internal_Templateparser'; |
|
125 | - |
|
126 | - /** |
|
127 | - * create Source Object container |
|
128 | - * |
|
129 | - * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | - * @param Smarty $smarty Smarty instance this source object belongs to |
|
131 | - * @param string $resource full template_resource |
|
132 | - * @param string $type type of resource |
|
133 | - * @param string $name resource name |
|
134 | - * |
|
135 | - */ |
|
136 | - public function __construct(Smarty $smarty, $resource, $type, $name) |
|
137 | - { |
|
138 | - $this->handler = |
|
139 | - isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | - Smarty_Resource::load($smarty, $type); |
|
141 | - $this->smarty = $smarty; |
|
142 | - $this->resource = $resource; |
|
143 | - $this->type = $type; |
|
144 | - $this->name = $name; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * initialize Source Object for given resource |
|
149 | - * Either [$_template] or [$smarty, $template_resource] must be specified |
|
150 | - * |
|
151 | - * @param Smarty_Internal_Template $_template template object |
|
152 | - * @param Smarty $smarty smarty object |
|
153 | - * @param string $template_resource resource identifier |
|
154 | - * |
|
155 | - * @return Smarty_Template_Source Source Object |
|
156 | - * @throws SmartyException |
|
157 | - */ |
|
158 | - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
159 | - $template_resource = null) |
|
160 | - { |
|
161 | - if ($_template) { |
|
162 | - $smarty = $_template->smarty; |
|
163 | - $template_resource = $_template->template_resource; |
|
164 | - } |
|
165 | - if (empty($template_resource)) { |
|
166 | - throw new SmartyException('Source: Missing name'); |
|
167 | - } |
|
168 | - // parse resource_name, load resource handler, identify unique resource name |
|
169 | - if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
|
170 | - $type = $match[ 1 ]; |
|
171 | - $name = $match[ 2 ]; |
|
172 | - } else { |
|
173 | - // no resource given, use default |
|
174 | - // or single character before the colon is not a resource type, but part of the filepath |
|
175 | - $type = $smarty->default_resource_type; |
|
176 | - $name = $template_resource; |
|
177 | - } |
|
178 | - // create new source object |
|
179 | - $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name); |
|
180 | - $source->handler->populate($source, $_template); |
|
181 | - if (!$source->exists && isset($_template->smarty->default_template_handler_func)) { |
|
182 | - Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
183 | - $source->handler->populate($source, $_template); |
|
184 | - } |
|
185 | - return $source; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Get source time stamp |
|
190 | - * |
|
191 | - * @return int |
|
192 | - */ |
|
193 | - public function getTimeStamp() |
|
194 | - { |
|
195 | - if (!isset($this->timestamp)) { |
|
196 | - $this->handler->populateTimestamp($this); |
|
197 | - } |
|
198 | - return $this->timestamp; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Get source content |
|
203 | - * |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function getContent() |
|
207 | - { |
|
208 | - return isset($this->content) ? $this->content : $this->handler->getContent($this); |
|
209 | - } |
|
14 | + /** |
|
15 | + * Unique Template ID |
|
16 | + * |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $uid = null; |
|
20 | + |
|
21 | + /** |
|
22 | + * Template Resource (Smarty_Internal_Template::$template_resource) |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $resource = null; |
|
27 | + |
|
28 | + /** |
|
29 | + * Resource Type |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $type = null; |
|
34 | + |
|
35 | + /** |
|
36 | + * Resource Name |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + public $name = null; |
|
41 | + |
|
42 | + /** |
|
43 | + * Source Filepath |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + public $filepath = null; |
|
48 | + |
|
49 | + /** |
|
50 | + * Source Timestamp |
|
51 | + * |
|
52 | + * @var integer |
|
53 | + */ |
|
54 | + public $timestamp = null; |
|
55 | + |
|
56 | + /** |
|
57 | + * Source Existence |
|
58 | + * |
|
59 | + * @var boolean |
|
60 | + */ |
|
61 | + public $exists = false; |
|
62 | + |
|
63 | + /** |
|
64 | + * Source File Base name |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + public $basename = null; |
|
69 | + |
|
70 | + /** |
|
71 | + * The Components an extended template is made of |
|
72 | + * |
|
73 | + * @var \Smarty_Template_Source[] |
|
74 | + */ |
|
75 | + public $components = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * Resource Handler |
|
79 | + * |
|
80 | + * @var \Smarty_Resource |
|
81 | + */ |
|
82 | + public $handler = null; |
|
83 | + |
|
84 | + /** |
|
85 | + * Smarty instance |
|
86 | + * |
|
87 | + * @var Smarty |
|
88 | + */ |
|
89 | + public $smarty = null; |
|
90 | + |
|
91 | + /** |
|
92 | + * Resource is source |
|
93 | + * |
|
94 | + * @var bool |
|
95 | + */ |
|
96 | + public $isConfig = false; |
|
97 | + |
|
98 | + /** |
|
99 | + * Template source content eventually set by default handler |
|
100 | + * |
|
101 | + * @var string |
|
102 | + */ |
|
103 | + public $content = null; |
|
104 | + |
|
105 | + /** |
|
106 | + * Name of the Class to compile this resource's contents with |
|
107 | + * |
|
108 | + * @var string |
|
109 | + */ |
|
110 | + public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
|
111 | + |
|
112 | + /** |
|
113 | + * Name of the Class to tokenize this resource's contents with |
|
114 | + * |
|
115 | + * @var string |
|
116 | + */ |
|
117 | + public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
|
118 | + |
|
119 | + /** |
|
120 | + * Name of the Class to parse this resource's contents with |
|
121 | + * |
|
122 | + * @var string |
|
123 | + */ |
|
124 | + public $template_parser_class = 'Smarty_Internal_Templateparser'; |
|
125 | + |
|
126 | + /** |
|
127 | + * create Source Object container |
|
128 | + * |
|
129 | + * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | + * @param Smarty $smarty Smarty instance this source object belongs to |
|
131 | + * @param string $resource full template_resource |
|
132 | + * @param string $type type of resource |
|
133 | + * @param string $name resource name |
|
134 | + * |
|
135 | + */ |
|
136 | + public function __construct(Smarty $smarty, $resource, $type, $name) |
|
137 | + { |
|
138 | + $this->handler = |
|
139 | + isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | + Smarty_Resource::load($smarty, $type); |
|
141 | + $this->smarty = $smarty; |
|
142 | + $this->resource = $resource; |
|
143 | + $this->type = $type; |
|
144 | + $this->name = $name; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * initialize Source Object for given resource |
|
149 | + * Either [$_template] or [$smarty, $template_resource] must be specified |
|
150 | + * |
|
151 | + * @param Smarty_Internal_Template $_template template object |
|
152 | + * @param Smarty $smarty smarty object |
|
153 | + * @param string $template_resource resource identifier |
|
154 | + * |
|
155 | + * @return Smarty_Template_Source Source Object |
|
156 | + * @throws SmartyException |
|
157 | + */ |
|
158 | + public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
159 | + $template_resource = null) |
|
160 | + { |
|
161 | + if ($_template) { |
|
162 | + $smarty = $_template->smarty; |
|
163 | + $template_resource = $_template->template_resource; |
|
164 | + } |
|
165 | + if (empty($template_resource)) { |
|
166 | + throw new SmartyException('Source: Missing name'); |
|
167 | + } |
|
168 | + // parse resource_name, load resource handler, identify unique resource name |
|
169 | + if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
|
170 | + $type = $match[ 1 ]; |
|
171 | + $name = $match[ 2 ]; |
|
172 | + } else { |
|
173 | + // no resource given, use default |
|
174 | + // or single character before the colon is not a resource type, but part of the filepath |
|
175 | + $type = $smarty->default_resource_type; |
|
176 | + $name = $template_resource; |
|
177 | + } |
|
178 | + // create new source object |
|
179 | + $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name); |
|
180 | + $source->handler->populate($source, $_template); |
|
181 | + if (!$source->exists && isset($_template->smarty->default_template_handler_func)) { |
|
182 | + Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
183 | + $source->handler->populate($source, $_template); |
|
184 | + } |
|
185 | + return $source; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Get source time stamp |
|
190 | + * |
|
191 | + * @return int |
|
192 | + */ |
|
193 | + public function getTimeStamp() |
|
194 | + { |
|
195 | + if (!isset($this->timestamp)) { |
|
196 | + $this->handler->populateTimestamp($this); |
|
197 | + } |
|
198 | + return $this->timestamp; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Get source content |
|
203 | + * |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function getContent() |
|
207 | + { |
|
208 | + return isset($this->content) ? $this->content : $this->handler->getContent($this); |
|
209 | + } |
|
210 | 210 | } |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | public function __construct(Smarty $smarty, $resource, $type, $name) |
137 | 137 | { |
138 | 138 | $this->handler = |
139 | - isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | - Smarty_Resource::load($smarty, $type); |
|
139 | + isset($smarty->_cache['resource_handlers'][$type]) ? $smarty->_cache['resource_handlers'][$type] : Smarty_Resource::load($smarty, $type); |
|
141 | 140 | $this->smarty = $smarty; |
142 | 141 | $this->resource = $resource; |
143 | 142 | $this->type = $type; |
@@ -167,8 +166,8 @@ discard block |
||
167 | 166 | } |
168 | 167 | // parse resource_name, load resource handler, identify unique resource name |
169 | 168 | if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
170 | - $type = $match[ 1 ]; |
|
171 | - $name = $match[ 2 ]; |
|
169 | + $type = $match[1]; |
|
170 | + $name = $match[2]; |
|
172 | 171 | } else { |
173 | 172 | // no resource given, use default |
174 | 173 | // or single character before the colon is not a resource type, but part of the filepath |
@@ -611,6 +611,7 @@ discard block |
||
611 | 611 | * @param integer $id - accountid |
612 | 612 | * @param array $parent_accounts - Array of all the parent accounts |
613 | 613 | * returns All the parent accounts of the given accountid in array format |
614 | + * @param integer[] $encountered_accounts |
|
614 | 615 | */ |
615 | 616 | public function __getParentAccounts($id, &$parent_accounts, &$encountered_accounts, $depthBase = 0) |
616 | 617 | { |
@@ -673,7 +674,7 @@ discard block |
||
673 | 674 | * Function to Recursively get all the child accounts of a given Account |
674 | 675 | * @param integer $id - accountid |
675 | 676 | * @param array $child_accounts - Array of all the child accounts |
676 | - * @param integer $depth - Depth at which the particular account has to be placed in the hierarchy |
|
677 | + * @param integer $depthBase - Depth at which the particular account has to be placed in the hierarchy |
|
677 | 678 | * returns All the child accounts of the given accountid in array format |
678 | 679 | */ |
679 | 680 | public function __getChildAccounts($id, &$child_accounts, $depthBase) |
@@ -99,18 +99,20 @@ discard block |
||
99 | 99 | vtlib_setup_modulevars($related_module, $other); |
100 | 100 | $singular_modname = vtlib_toSingular($related_module); |
101 | 101 | |
102 | - if ($singlepane_view == 'true') |
|
103 | - $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
104 | - else |
|
105 | - $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
102 | + if ($singlepane_view == 'true') { |
|
103 | + $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
104 | + } else { |
|
105 | + $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
106 | + } |
|
106 | 107 | |
107 | 108 | $button = ''; |
108 | 109 | |
109 | 110 | $button .= '<input type="hidden" name="email_directing_module"><input type="hidden" name="record">'; |
110 | 111 | |
111 | 112 | if ($actions) { |
112 | - if (is_string($actions)) |
|
113 | - $actions = explode(',', strtoupper($actions)); |
|
113 | + if (is_string($actions)) { |
|
114 | + $actions = explode(',', strtoupper($actions)); |
|
115 | + } |
|
114 | 116 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
115 | 117 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
116 | 118 | } |
@@ -136,8 +138,9 @@ discard block |
||
136 | 138 | |
137 | 139 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
138 | 140 | |
139 | - if ($return_value == null) |
|
140 | - $return_value = []; |
|
141 | + if ($return_value == null) { |
|
142 | + $return_value = []; |
|
143 | + } |
|
141 | 144 | $return_value['CUSTOM_BUTTON'] = $button; |
142 | 145 | |
143 | 146 | $log->debug("Exiting get_campaigns method ..."); |
@@ -163,16 +166,18 @@ discard block |
||
163 | 166 | vtlib_setup_modulevars($related_module, $other); |
164 | 167 | $singular_modname = vtlib_toSingular($related_module); |
165 | 168 | |
166 | - if ($singlepane_view == 'true') |
|
167 | - $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
168 | - else |
|
169 | - $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
169 | + if ($singlepane_view == 'true') { |
|
170 | + $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
171 | + } else { |
|
172 | + $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
173 | + } |
|
170 | 174 | |
171 | 175 | $button = ''; |
172 | 176 | $current_user = vglobal('current_user'); |
173 | 177 | if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'account_id', 'readwrite') == '0') { |
174 | - if (is_string($actions)) |
|
175 | - $actions = explode(',', strtoupper($actions)); |
|
178 | + if (is_string($actions)) { |
|
179 | + $actions = explode(',', strtoupper($actions)); |
|
180 | + } |
|
176 | 181 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
177 | 182 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
178 | 183 | } |
@@ -204,8 +209,9 @@ discard block |
||
204 | 209 | |
205 | 210 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
206 | 211 | |
207 | - if ($return_value == null) |
|
208 | - $return_value = []; |
|
212 | + if ($return_value == null) { |
|
213 | + $return_value = []; |
|
214 | + } |
|
209 | 215 | $return_value['CUSTOM_BUTTON'] = $button; |
210 | 216 | |
211 | 217 | $log->debug("Exiting get_contacts method ..."); |
@@ -231,16 +237,18 @@ discard block |
||
231 | 237 | vtlib_setup_modulevars($related_module, $other); |
232 | 238 | $singular_modname = vtlib_toSingular($related_module); |
233 | 239 | |
234 | - if ($singlepane_view == 'true') |
|
235 | - $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
236 | - else |
|
237 | - $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
240 | + if ($singlepane_view == 'true') { |
|
241 | + $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
242 | + } else { |
|
243 | + $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
244 | + } |
|
238 | 245 | |
239 | 246 | $button = ''; |
240 | 247 | $current_user = vglobal('current_user'); |
241 | 248 | if ($actions && getFieldVisibilityPermission($related_module, $current_user->id, 'parent_id', 'readwrite') == '0') { |
242 | - if (is_string($actions)) |
|
243 | - $actions = explode(',', strtoupper($actions)); |
|
249 | + if (is_string($actions)) { |
|
250 | + $actions = explode(',', strtoupper($actions)); |
|
251 | + } |
|
244 | 252 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
245 | 253 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
246 | 254 | } |
@@ -265,8 +273,9 @@ discard block |
||
265 | 273 | |
266 | 274 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
267 | 275 | |
268 | - if ($return_value == null) |
|
269 | - $return_value = []; |
|
276 | + if ($return_value == null) { |
|
277 | + $return_value = []; |
|
278 | + } |
|
270 | 279 | $return_value['CUSTOM_BUTTON'] = $button; |
271 | 280 | |
272 | 281 | $log->debug("Exiting get_tickets method ..."); |
@@ -292,16 +301,18 @@ discard block |
||
292 | 301 | vtlib_setup_modulevars($related_module, $other); |
293 | 302 | $singular_modname = vtlib_toSingular($related_module); |
294 | 303 | |
295 | - if ($singlepane_view == 'true') |
|
296 | - $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
297 | - else |
|
298 | - $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
304 | + if ($singlepane_view == 'true') { |
|
305 | + $returnset = '&return_module=' . $this_module . '&return_action=DetailView&return_id=' . $id; |
|
306 | + } else { |
|
307 | + $returnset = '&return_module=' . $this_module . '&return_action=CallRelatedList&return_id=' . $id; |
|
308 | + } |
|
299 | 309 | |
300 | 310 | $button = ''; |
301 | 311 | |
302 | 312 | if ($actions) { |
303 | - if (is_string($actions)) |
|
304 | - $actions = explode(',', strtoupper($actions)); |
|
313 | + if (is_string($actions)) { |
|
314 | + $actions = explode(',', strtoupper($actions)); |
|
315 | + } |
|
305 | 316 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
306 | 317 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
307 | 318 | } |
@@ -329,8 +340,9 @@ discard block |
||
329 | 340 | $query = sprintf($query, $entityIds); |
330 | 341 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
331 | 342 | |
332 | - if ($return_value == null) |
|
333 | - $return_value = []; |
|
343 | + if ($return_value == null) { |
|
344 | + $return_value = []; |
|
345 | + } |
|
334 | 346 | $return_value['CUSTOM_BUTTON'] = $button; |
335 | 347 | |
336 | 348 | $log->debug("Exiting get_products method ..."); |
@@ -372,10 +384,11 @@ discard block |
||
372 | 384 | $query .= $this->getNonAdminAccessControlQuery('Accounts', $current_user); |
373 | 385 | $where_auto = " vtiger_crmentity.deleted = 0 "; |
374 | 386 | |
375 | - if ($where != '') |
|
376 | - $query .= sprintf(' where (%s) && %s', $where, $where_auto); |
|
377 | - else |
|
378 | - $query .= sprintf(' where %s', $where_auto); |
|
387 | + if ($where != '') { |
|
388 | + $query .= sprintf(' where (%s) && %s', $where, $where_auto); |
|
389 | + } else { |
|
390 | + $query .= sprintf(' where %s', $where_auto); |
|
391 | + } |
|
379 | 392 | |
380 | 393 | $log->debug("Exiting create_export_query method ..."); |
381 | 394 | return $query; |
@@ -768,8 +781,9 @@ discard block |
||
768 | 781 | public function unlinkRelationship($id, $return_module, $return_id, $relatedName = false) |
769 | 782 | { |
770 | 783 | $log = vglobal('log'); |
771 | - if (empty($return_module) || empty($return_id)) |
|
772 | - return; |
|
784 | + if (empty($return_module) || empty($return_id)) { |
|
785 | + return; |
|
786 | + } |
|
773 | 787 | |
774 | 788 | if ($return_module == 'Campaigns') { |
775 | 789 | $this->db->delete('vtiger_campaign_records', 'crmid=? && campaignid=?', [$id, $return_id]); |
@@ -786,8 +800,9 @@ discard block |
||
786 | 800 | $db = PearDatabase::getInstance(); |
787 | 801 | $currentUser = Users_Record_Model::getCurrentUserModel(); |
788 | 802 | |
789 | - if (!is_array($with_crmids)) |
|
790 | - $with_crmids = [$with_crmids]; |
|
803 | + if (!is_array($with_crmids)) { |
|
804 | + $with_crmids = [$with_crmids]; |
|
805 | + } |
|
791 | 806 | if (!in_array($with_module, ['Products', 'Campaigns'])) { |
792 | 807 | parent::save_related_module($module, $crmid, $with_module, $with_crmids, $relatedName); |
793 | 808 | } else { |
@@ -831,8 +846,9 @@ discard block |
||
831 | 846 | $singular_modname = vtlib_toSingular($related_module); |
832 | 847 | $button = ''; |
833 | 848 | if ($actions) { |
834 | - if (is_string($actions)) |
|
835 | - $actions = explode(',', strtoupper($actions)); |
|
849 | + if (is_string($actions)) { |
|
850 | + $actions = explode(',', strtoupper($actions)); |
|
851 | + } |
|
836 | 852 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
837 | 853 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
838 | 854 | } |
@@ -873,8 +889,9 @@ discard block |
||
873 | 889 | |
874 | 890 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
875 | 891 | |
876 | - if ($return_value == null) |
|
877 | - $return_value = []; |
|
892 | + if ($return_value == null) { |
|
893 | + $return_value = []; |
|
894 | + } |
|
878 | 895 | $return_value['CUSTOM_BUTTON'] = $button; |
879 | 896 | return $return_value; |
880 | 897 | } |
@@ -901,10 +918,12 @@ discard block |
||
901 | 918 | continue; |
902 | 919 | } |
903 | 920 | // Setup the default JOIN conditions if not specified |
904 | - if (empty($relmap[1])) |
|
905 | - $relmap[1] = $other->table_name; |
|
906 | - if (empty($relmap[2])) |
|
907 | - $relmap[2] = $relmap[0]; |
|
921 | + if (empty($relmap[1])) { |
|
922 | + $relmap[1] = $other->table_name; |
|
923 | + } |
|
924 | + if (empty($relmap[2])) { |
|
925 | + $relmap[2] = $relmap[0]; |
|
926 | + } |
|
908 | 927 | $join .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
909 | 928 | } |
910 | 929 | } |
@@ -947,8 +966,9 @@ discard block |
||
947 | 966 | |
948 | 967 | $button = ''; |
949 | 968 | if ($actions) { |
950 | - if (is_string($actions)) |
|
951 | - $actions = explode(',', strtoupper($actions)); |
|
969 | + if (is_string($actions)) { |
|
970 | + $actions = explode(',', strtoupper($actions)); |
|
971 | + } |
|
952 | 972 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
953 | 973 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' " . |
954 | 974 | " type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$current_module&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\"" . |
@@ -973,10 +993,12 @@ discard block |
||
973 | 993 | if (!empty($other->related_tables)) { |
974 | 994 | foreach ($other->related_tables as $tname => $relmap) { |
975 | 995 | // Setup the default JOIN conditions if not specified |
976 | - if (empty($relmap[1])) |
|
977 | - $relmap[1] = $other->table_name; |
|
978 | - if (empty($relmap[2])) |
|
979 | - $relmap[2] = $relmap[0]; |
|
996 | + if (empty($relmap[1])) { |
|
997 | + $relmap[1] = $other->table_name; |
|
998 | + } |
|
999 | + if (empty($relmap[2])) { |
|
1000 | + $relmap[2] = $relmap[0]; |
|
1001 | + } |
|
980 | 1002 | $more_relation .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
981 | 1003 | } |
982 | 1004 | } |
@@ -998,8 +1020,9 @@ discard block |
||
998 | 1020 | |
999 | 1021 | $return_value = GetRelatedList($current_module, $related_module, $other, $query, $button, $returnset); |
1000 | 1022 | |
1001 | - if ($return_value == null) |
|
1002 | - $return_value = []; |
|
1023 | + if ($return_value == null) { |
|
1024 | + $return_value = []; |
|
1025 | + } |
|
1003 | 1026 | $return_value['CUSTOM_BUTTON'] = $button; |
1004 | 1027 | |
1005 | 1028 | return $return_value; |
@@ -1009,8 +1032,9 @@ discard block |
||
1009 | 1032 | public function getRelatedContactsIds($id = null) |
1010 | 1033 | { |
1011 | 1034 | $adb = PearDatabase::getInstance(); |
1012 | - if ($id == null) |
|
1013 | - $id = $this->id; |
|
1035 | + if ($id == null) { |
|
1036 | + $id = $this->id; |
|
1037 | + } |
|
1014 | 1038 | $entityIds = []; |
1015 | 1039 | $query = 'SELECT contactid FROM vtiger_contactdetails |
1016 | 1040 | INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid |
@@ -36,6 +36,9 @@ |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | + /** |
|
40 | + * @param Vtiger_Widget_Model $widget |
|
41 | + */ |
|
39 | 42 | public function getData(Vtiger_Request $request, $widget) |
40 | 43 | { |
41 | 44 | $db = PearDatabase::getInstance(); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $sql = $queryGenerator->getQuery(); |
57 | 57 | |
58 | 58 | if ($securityParameter != '') |
59 | - $sql.= $securityParameter; |
|
59 | + $sql .= $securityParameter; |
|
60 | 60 | |
61 | 61 | if (!empty($assetStatus)) { |
62 | 62 | $assetStatus = implode("','", $assetConfig['assetstatus']); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | $params[] = $currentUser->getId(); |
73 | - $sql.= ' ORDER BY vtiger_assets.dateinservice ASC LIMIT %s'; |
|
73 | + $sql .= ' ORDER BY vtiger_assets.dateinservice ASC LIMIT %s'; |
|
74 | 74 | $sql = sprintf($sql, $limit); |
75 | 75 | $result = $db->pquery($sql, $params); |
76 | 76 | $returnData = array(); |
@@ -55,8 +55,9 @@ |
||
55 | 55 | $queryGenerator->setFields($fields); |
56 | 56 | $sql = $queryGenerator->getQuery(); |
57 | 57 | |
58 | - if ($securityParameter != '') |
|
59 | - $sql.= $securityParameter; |
|
58 | + if ($securityParameter != '') { |
|
59 | + $sql.= $securityParameter; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | if (!empty($assetStatus)) { |
62 | 63 | $assetStatus = implode("','", $assetConfig['assetstatus']); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | /** Function to insert values in vtiger_activity_remainder table for the specified module, |
182 | - * @param $table_name -- table name:: Type varchar |
|
182 | + * @param string $table_name -- table name:: Type varchar |
|
183 | 183 | * @param $module -- module:: Type varchar |
184 | 184 | */ |
185 | 185 | public function insertIntoReminderTable($table_name, $module, $recurid) |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | // Code included by Jaguar - starts |
215 | 215 | /** Function to insert values in vtiger_recurringevents table for the specified tablename,module |
216 | - * @param $recurObj -- Recurring Object:: Type varchar |
|
216 | + * @param RecurringType $recurObj -- Recurring Object:: Type varchar |
|
217 | 217 | */ |
218 | 218 | public function insertIntoRecurringTable(& $recurObj) |
219 | 219 | { |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | /** |
712 | 712 | * Function to get calendar query for outlookplugin |
713 | - * @param string $username - User name * return string $query - sql query */ |
|
713 | + * @param string $user_name - User name * return string $query - sql query */ |
|
714 | 714 | public function get_calendarsforol($user_name) |
715 | 715 | { |
716 | 716 | $adb = PearDatabase::getInstance(); |
@@ -903,6 +903,9 @@ discard block |
||
903 | 903 | return $query; |
904 | 904 | } |
905 | 905 | |
906 | + /** |
|
907 | + * @param null|type $tabId |
|
908 | + */ |
|
906 | 909 | protected function setupTemporaryTable($tableName, $tabId, $user, $parentRole, $userGroups) |
907 | 910 | { |
908 | 911 | $module = null; |
@@ -821,40 +821,40 @@ |
||
821 | 821 | $query = $this->getRelationQuery($module, $secmodule, "vtiger_activity", "activityid", $queryPlanner); |
822 | 822 | |
823 | 823 | if ($queryPlanner->requireTable("vtiger_crmentityCalendar", $matrix)) { |
824 | - $query .=" left join vtiger_crmentity as vtiger_crmentityCalendar on vtiger_crmentityCalendar.crmid=vtiger_activity.activityid and vtiger_crmentityCalendar.deleted=0"; |
|
824 | + $query .= " left join vtiger_crmentity as vtiger_crmentityCalendar on vtiger_crmentityCalendar.crmid=vtiger_activity.activityid and vtiger_crmentityCalendar.deleted=0"; |
|
825 | 825 | } |
826 | 826 | if ($queryPlanner->requireTable("vtiger_contactdetailsCalendar")) { |
827 | - $query .=" left join vtiger_contactdetails as vtiger_contactdetailsCalendar on vtiger_contactdetailsCalendar.contactid= vtiger_activity.link"; |
|
827 | + $query .= " left join vtiger_contactdetails as vtiger_contactdetailsCalendar on vtiger_contactdetailsCalendar.contactid= vtiger_activity.link"; |
|
828 | 828 | } |
829 | 829 | if ($queryPlanner->requireTable("vtiger_activitycf")) { |
830 | - $query .=" left join vtiger_activitycf on vtiger_activitycf.activityid = vtiger_activity.activityid"; |
|
830 | + $query .= " left join vtiger_activitycf on vtiger_activitycf.activityid = vtiger_activity.activityid"; |
|
831 | 831 | } |
832 | 832 | if ($queryPlanner->requireTable("vtiger_activity_reminder")) { |
833 | - $query .=" left join vtiger_activity_reminder on vtiger_activity_reminder.activity_id = vtiger_activity.activityid"; |
|
833 | + $query .= " left join vtiger_activity_reminder on vtiger_activity_reminder.activity_id = vtiger_activity.activityid"; |
|
834 | 834 | } |
835 | 835 | if ($queryPlanner->requireTable("vtiger_recurringevents")) { |
836 | - $query .=" left join vtiger_recurringevents on vtiger_recurringevents.activityid = vtiger_activity.activityid"; |
|
836 | + $query .= " left join vtiger_recurringevents on vtiger_recurringevents.activityid = vtiger_activity.activityid"; |
|
837 | 837 | } |
838 | 838 | if ($queryPlanner->requireTable("vtiger_accountRelCalendar")) { |
839 | - $query .=" left join vtiger_account as vtiger_accountRelCalendar on vtiger_accountRelCalendar.accountid=vtiger_activity.link"; |
|
839 | + $query .= " left join vtiger_account as vtiger_accountRelCalendar on vtiger_accountRelCalendar.accountid=vtiger_activity.link"; |
|
840 | 840 | } |
841 | 841 | if ($queryPlanner->requireTable("vtiger_leaddetailsRelCalendar")) { |
842 | - $query .=" left join vtiger_leaddetails as vtiger_leaddetailsRelCalendar on vtiger_leaddetailsRelCalendar.leadid = vtiger_activity.link"; |
|
842 | + $query .= " left join vtiger_leaddetails as vtiger_leaddetailsRelCalendar on vtiger_leaddetailsRelCalendar.leadid = vtiger_activity.link"; |
|
843 | 843 | } |
844 | 844 | if ($queryPlanner->requireTable("vtiger_troubleticketsRelCalendar")) { |
845 | - $query .=" left join vtiger_troubletickets as vtiger_troubleticketsRelCalendar on vtiger_troubleticketsRelCalendar.ticketid = vtiger_activity.process"; |
|
845 | + $query .= " left join vtiger_troubletickets as vtiger_troubleticketsRelCalendar on vtiger_troubleticketsRelCalendar.ticketid = vtiger_activity.process"; |
|
846 | 846 | } |
847 | 847 | if ($queryPlanner->requireTable("vtiger_campaignRelCalendar")) { |
848 | - $query .=" left join vtiger_campaign as vtiger_campaignRelCalendar on vtiger_campaignRelCalendar.campaignid = vtiger_activity.process"; |
|
848 | + $query .= " left join vtiger_campaign as vtiger_campaignRelCalendar on vtiger_campaignRelCalendar.campaignid = vtiger_activity.process"; |
|
849 | 849 | } |
850 | 850 | if ($queryPlanner->requireTable("vtiger_groupsCalendar")) { |
851 | - $query .=" left join vtiger_groups as vtiger_groupsCalendar on vtiger_groupsCalendar.groupid = vtiger_crmentityCalendar.smownerid"; |
|
851 | + $query .= " left join vtiger_groups as vtiger_groupsCalendar on vtiger_groupsCalendar.groupid = vtiger_crmentityCalendar.smownerid"; |
|
852 | 852 | } |
853 | 853 | if ($queryPlanner->requireTable("vtiger_usersCalendar")) { |
854 | - $query .=" left join vtiger_users as vtiger_usersCalendar on vtiger_usersCalendar.id = vtiger_crmentityCalendar.smownerid"; |
|
854 | + $query .= " left join vtiger_users as vtiger_usersCalendar on vtiger_usersCalendar.id = vtiger_crmentityCalendar.smownerid"; |
|
855 | 855 | } |
856 | 856 | if ($queryPlanner->requireTable("vtiger_lastModifiedByCalendar")) { |
857 | - $query .=" left join vtiger_users as vtiger_lastModifiedByCalendar on vtiger_lastModifiedByCalendar.id = vtiger_crmentityCalendar.modifiedby "; |
|
857 | + $query .= " left join vtiger_users as vtiger_lastModifiedByCalendar on vtiger_lastModifiedByCalendar.id = vtiger_crmentityCalendar.modifiedby "; |
|
858 | 858 | } |
859 | 859 | if ($queryPlanner->requireTable("vtiger_createdbyCalendar")) { |
860 | 860 | $query .= " left join vtiger_users as vtiger_createdbyCalendar on vtiger_createdbyCalendar.id = vtiger_crmentityCalendar.smcreatorid "; |
@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | if (isset($this->column_fields['recurringtype']) && $this->column_fields['recurringtype'] != '' && $this->column_fields['recurringtype'] != '--None--') { |
113 | 113 | $recur_type = trim($this->column_fields['recurringtype']); |
114 | 114 | $recur_data = \vtlib\Functions::getRecurringObjValue(); |
115 | - if (is_object($recur_data)) |
|
116 | - $this->insertIntoRecurringTable($recur_data); |
|
115 | + if (is_object($recur_data)) { |
|
116 | + $this->insertIntoRecurringTable($recur_data); |
|
117 | + } |
|
117 | 118 | } |
118 | 119 | |
119 | 120 | //Insert into vtiger_activity_remainder table |
@@ -249,10 +250,10 @@ discard block |
||
249 | 250 | $sql = 'delete from vtiger_activity_reminder where activity_id=?'; |
250 | 251 | $adb->pquery($sql, array($activity_id)); |
251 | 252 | $flag = "false"; |
252 | - } else |
|
253 | - $flag = "false"; |
|
254 | - } |
|
255 | - else { |
|
253 | + } else { |
|
254 | + $flag = "false"; |
|
255 | + } |
|
256 | + } else { |
|
256 | 257 | $sql = 'delete from vtiger_activity_reminder where activity_id=?'; |
257 | 258 | $adb->pquery($sql, array($activity_id)); |
258 | 259 | $sql = 'delete from vtiger_recurringevents where activityid=?'; |
@@ -361,8 +362,9 @@ discard block |
||
361 | 362 | */ |
362 | 363 | public function getJoinClause($tableName) |
363 | 364 | { |
364 | - if ($tableName == "vtiger_activity_reminder") |
|
365 | - return 'LEFT JOIN'; |
|
365 | + if ($tableName == "vtiger_activity_reminder") { |
|
366 | + return 'LEFT JOIN'; |
|
367 | + } |
|
366 | 368 | return parent::getJoinClause($tableName); |
367 | 369 | } |
368 | 370 | |
@@ -375,10 +377,11 @@ discard block |
||
375 | 377 | { |
376 | 378 | $log = LoggerManager::getInstance(); |
377 | 379 | $log->debug('Entering getSortOrder() method ...'); |
378 | - if (AppRequest::has('sorder')) |
|
379 | - $sorder = $this->db->sql_escape_string(AppRequest::get('sorder')); |
|
380 | - else |
|
381 | - $sorder = (($_SESSION['ACTIVITIES_SORT_ORDER'] != '') ? ($_SESSION['ACTIVITIES_SORT_ORDER']) : ($this->default_sort_order)); |
|
380 | + if (AppRequest::has('sorder')) { |
|
381 | + $sorder = $this->db->sql_escape_string(AppRequest::get('sorder')); |
|
382 | + } else { |
|
383 | + $sorder = (($_SESSION['ACTIVITIES_SORT_ORDER'] != '') ? ($_SESSION['ACTIVITIES_SORT_ORDER']) : ($this->default_sort_order)); |
|
384 | + } |
|
382 | 385 | $log->debug('Exiting getSortOrder method ...'); |
383 | 386 | return $sorder; |
384 | 387 | } |
@@ -397,10 +400,11 @@ discard block |
||
397 | 400 | $use_default_order_by = $this->default_order_by; |
398 | 401 | } |
399 | 402 | |
400 | - if (AppRequest::has('order_by')) |
|
401 | - $order_by = $this->db->sql_escape_string(AppRequest::get('order_by')); |
|
402 | - else |
|
403 | - $order_by = (($_SESSION['ACTIVITIES_ORDER_BY'] != '') ? ($_SESSION['ACTIVITIES_ORDER_BY']) : ($use_default_order_by)); |
|
403 | + if (AppRequest::has('order_by')) { |
|
404 | + $order_by = $this->db->sql_escape_string(AppRequest::get('order_by')); |
|
405 | + } else { |
|
406 | + $order_by = (($_SESSION['ACTIVITIES_ORDER_BY'] != '') ? ($_SESSION['ACTIVITIES_ORDER_BY']) : ($use_default_order_by)); |
|
407 | + } |
|
404 | 408 | $log->debug("Exiting getOrderBy method ..."); |
405 | 409 | return $order_by; |
406 | 410 | } |
@@ -431,8 +435,9 @@ discard block |
||
431 | 435 | $button = ''; |
432 | 436 | |
433 | 437 | if ($actions) { |
434 | - if (is_string($actions)) |
|
435 | - $actions = explode(',', strtoupper($actions)); |
|
438 | + if (is_string($actions)) { |
|
439 | + $actions = explode(',', strtoupper($actions)); |
|
440 | + } |
|
436 | 441 | if (in_array('SELECT', $actions) && isPermitted($related_module, 4, '') == 'yes') { |
437 | 442 | $button .= "<input title='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "' class='crmbutton small edit' type='button' onclick=\"return window.open('index.php?module=$related_module&return_module=$currentModule&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid=$id','test','width=640,height=602,resizable=0,scrollbars=0');\" value='" . \includes\Language::translate('LBL_SELECT') . " " . \includes\Language::translate($related_module) . "'> "; |
438 | 443 | } |
@@ -448,8 +453,9 @@ discard block |
||
448 | 453 | |
449 | 454 | $return_value = GetRelatedList($this_module, $related_module, $other, $query, $button, $returnset); |
450 | 455 | |
451 | - if ($return_value == null) |
|
452 | - $return_value = []; |
|
456 | + if ($return_value == null) { |
|
457 | + $return_value = []; |
|
458 | + } |
|
453 | 459 | $return_value['CUSTOM_BUTTON'] = $button; |
454 | 460 | |
455 | 461 | $log->debug("Exiting get_contacts method ..."); |
@@ -478,8 +484,9 @@ discard block |
||
478 | 484 | $query = sprintf($query, $id); |
479 | 485 | $return_data = GetRelatedList('Calendar', 'Users', $focus, $query, $button, $returnset); |
480 | 486 | |
481 | - if ($return_data == null) |
|
482 | - $return_data = []; |
|
487 | + if ($return_data == null) { |
|
488 | + $return_data = []; |
|
489 | + } |
|
483 | 490 | $return_data['CUSTOM_BUTTON'] = $button; |
484 | 491 | |
485 | 492 | $log->debug("Exiting get_users method ..."); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param $userid -- The user Id:: Type integer |
57 | 57 | * @param $from_datetime -- The start date Obj :: Type Array |
58 | 58 | * @param $to_datetime -- The end date Obj :: Type Array |
59 | - * @param $view -- The calendar view :: Type String |
|
59 | + * @param string $view -- The calendar view :: Type String |
|
60 | 60 | * @returns $list :: Type Array |
61 | 61 | */ |
62 | 62 | public function readAppointment($userid, &$from_datetime, &$to_datetime, $view) |
@@ -286,6 +286,9 @@ discard block |
||
286 | 286 | return ($a->start_time->ts < $b->start_time->ts) ? -1 : 1; |
287 | 287 | } |
288 | 288 | |
289 | +/** |
|
290 | + * @param string $fldname |
|
291 | + */ |
|
289 | 292 | function getRoleBasesdPickList($fldname, $exist_val) |
290 | 293 | { |
291 | 294 | $adb = PearDatabase::getInstance(); |
@@ -169,7 +169,7 @@ |
||
169 | 169 | //Get Recurring events |
170 | 170 | $q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then $userNameSql else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid"; |
171 | 171 | $q .= getNonAdminAccessControlQuery('Calendar', $current_user); |
172 | - $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') && (cast(concat(recurringdate, ' ', time_start) as datetime) between ? and ?) "; |
|
172 | + $q .= " where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') && (cast(concat(recurringdate, ' ', time_start) as datetime) between ? and ?) "; |
|
173 | 173 | |
174 | 174 | // User Select Customization |
175 | 175 | $q .= $query_filter_prefix; |
@@ -221,13 +221,15 @@ discard block |
||
221 | 221 | $que = "select * from vtiger_sharedcalendar where sharedid=? and userid=?"; |
222 | 222 | $row = $adb->pquery($que, array($current_user->id, $act_array["smownerid"])); |
223 | 223 | $no = $adb->getRowCount($row); |
224 | - if ($no > 0) |
|
225 | - $this->shared = true; |
|
224 | + if ($no > 0) { |
|
225 | + $this->shared = true; |
|
226 | + } |
|
226 | 227 | } |
227 | 228 | } |
228 | 229 | $this->image_name = $act_array["activitytype"] . ".gif"; |
229 | - if (!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"])) |
|
230 | - $this->recurring = "Recurring.gif"; |
|
230 | + if (!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"])) { |
|
231 | + $this->recurring = "Recurring.gif"; |
|
232 | + } |
|
231 | 233 | |
232 | 234 | $this->record = $act_array["activityid"]; |
233 | 235 | $date = new DateTimeField($act_array["date_start"] . ' ' . $act_array['time_start']); |
@@ -295,8 +297,9 @@ discard block |
||
295 | 297 | $roleid = $current_user->roleid; |
296 | 298 | $roleids = Array(); |
297 | 299 | $subrole = getRoleSubordinates($roleid); |
298 | - if (count($subrole) > 0) |
|
299 | - $roleids = $subrole; |
|
300 | + if (count($subrole) > 0) { |
|
301 | + $roleids = $subrole; |
|
302 | + } |
|
300 | 303 | array_push($roleids, $roleid); |
301 | 304 | |
302 | 305 | //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... |
@@ -310,12 +313,14 @@ discard block |
||
310 | 313 | $res_val = $adb->pquery($pick_query, array($roleids)); |
311 | 314 | $num_val = $adb->num_rows($res_val); |
312 | 315 | } |
313 | - if ($num_val > 0) |
|
316 | + if ($num_val > 0) { |
|
317 | + $pick_val = $exist_val; |
|
318 | + } else { |
|
319 | + $pick_val = \includes\Language::translate('LBL_NOT_ACCESSIBLE'); |
|
320 | + } |
|
321 | + } else { |
|
314 | 322 | $pick_val = $exist_val; |
315 | - else |
|
316 | - $pick_val = \includes\Language::translate('LBL_NOT_ACCESSIBLE'); |
|
317 | - } else |
|
318 | - $pick_val = $exist_val; |
|
323 | + } |
|
319 | 324 | |
320 | 325 | return $pick_val; |
321 | 326 | } |
@@ -253,7 +253,7 @@ |
||
253 | 253 | |
254 | 254 | /** |
255 | 255 | * this function returns the days in a month in an array format |
256 | - * @param object $date_time - the date time object for the current month |
|
256 | + * @param vt_DateTime|null $date_time - the date time object for the current month |
|
257 | 257 | * @return array $result - the array containing current months days information |
258 | 258 | */ |
259 | 259 | function getCalendarDaysInMonth($date_time) |
@@ -127,10 +127,12 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function get_datechange_info($type) |
129 | 129 | { |
130 | - if ($type == 'next') |
|
131 | - $mode = 'increment'; |
|
132 | - if ($type == 'prev') |
|
133 | - $mode = 'decrment'; |
|
130 | + if ($type == 'next') { |
|
131 | + $mode = 'increment'; |
|
132 | + } |
|
133 | + if ($type == 'prev') { |
|
134 | + $mode = 'decrment'; |
|
135 | + } |
|
134 | 136 | switch ($this->view) { |
135 | 137 | case 'day': |
136 | 138 | $day = $this->date_time->get_changed_day($mode); |
@@ -209,8 +211,9 @@ discard block |
||
209 | 211 | $this->year_array[$value->formatted_datetime]->activities = array(); |
210 | 212 | } |
211 | 213 | array_push($this->year_array[$value->formatted_datetime]->activities, $value); |
212 | - } else |
|
213 | - die("view:" . $this->view . " is not defined"); |
|
214 | + } else { |
|
215 | + die("view:" . $this->view . " is not defined"); |
|
216 | + } |
|
214 | 217 | } |
215 | 218 | } |
216 | 219 | } |
@@ -233,12 +236,15 @@ discard block |
||
233 | 236 | { |
234 | 237 | $this->view = $view; |
235 | 238 | $this->start_time = $time; |
236 | - if ($view == 'month') |
|
237 | - $this->end_time = $this->start_time->getMonthendtime(); |
|
238 | - if ($view == 'day') |
|
239 | - $this->end_time = $this->start_time->getDayendtime(); |
|
240 | - if ($view == 'hour') |
|
241 | - $this->end_time = $this->start_time->getHourendtime(); |
|
239 | + if ($view == 'month') { |
|
240 | + $this->end_time = $this->start_time->getMonthendtime(); |
|
241 | + } |
|
242 | + if ($view == 'day') { |
|
243 | + $this->end_time = $this->start_time->getDayendtime(); |
|
244 | + } |
|
245 | + if ($view == 'hour') { |
|
246 | + $this->end_time = $this->start_time->getHourendtime(); |
|
247 | + } |
|
242 | 248 | } |
243 | 249 | |
244 | 250 | /** |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | /** |
386 | 386 | * |
387 | - * @return Date |
|
387 | + * @return string |
|
388 | 388 | */ |
389 | 389 | public function get_DB_formatted_date() |
390 | 390 | { |
@@ -529,10 +529,6 @@ discard block |
||
529 | 529 | * This should be used whereever possible |
530 | 530 | * |
531 | 531 | * @param integer $index - number between 0 to 42 |
532 | - * @param string $day - date |
|
533 | - * @param string $month - month |
|
534 | - * @param string $year - year |
|
535 | - * return vt_DateTime obj $datetimevalue |
|
536 | 532 | */ |
537 | 533 | public function getThisMonthsDayByIndex($index) |
538 | 534 | { |
@@ -87,12 +87,15 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function getTodayDatetimebyIndex($index, $day = '', $month = '', $year = '') |
89 | 89 | { |
90 | - if ($day === '') |
|
91 | - $day = $this->day; |
|
92 | - if ($month === '') |
|
93 | - $month = $this->month; |
|
94 | - if ($year === '') |
|
95 | - $year = $this->year; |
|
90 | + if ($day === '') { |
|
91 | + $day = $this->day; |
|
92 | + } |
|
93 | + if ($month === '') { |
|
94 | + $month = $this->month; |
|
95 | + } |
|
96 | + if ($year === '') { |
|
97 | + $year = $this->year; |
|
98 | + } |
|
96 | 99 | $day_array = array(); |
97 | 100 | |
98 | 101 | if ($index < 0 || $index > 23) { |
@@ -140,12 +143,15 @@ discard block |
||
140 | 143 | */ |
141 | 144 | public function getThismonthDaysbyIndex($index, $day = '', $month = '', $year = '') |
142 | 145 | { |
143 | - if ($day == '') |
|
144 | - $day = $index + 1; |
|
145 | - if ($month == '') |
|
146 | - $month = $this->month; |
|
147 | - if ($year == '') |
|
148 | - $year = $this->year; |
|
146 | + if ($day == '') { |
|
147 | + $day = $index + 1; |
|
148 | + } |
|
149 | + if ($month == '') { |
|
150 | + $month = $this->month; |
|
151 | + } |
|
152 | + if ($year == '') { |
|
153 | + $year = $this->year; |
|
154 | + } |
|
149 | 155 | $month_array = array(); |
150 | 156 | $month_array['day'] = $day; |
151 | 157 | $month_array['month'] = $month; |
@@ -356,8 +362,9 @@ discard block |
||
356 | 362 | } else { |
357 | 363 | die("year was not set"); |
358 | 364 | } |
359 | - if (empty($hour) && $hour !== 0) |
|
360 | - $hour = 0; |
|
365 | + if (empty($hour) && $hour !== 0) { |
|
366 | + $hour = 0; |
|
367 | + } |
|
361 | 368 | $this->ts = mktime($hour, $minute, $second, $month, $day, $year); |
362 | 369 | $this->setDateTime($this->ts); |
363 | 370 | } |
@@ -399,10 +406,12 @@ discard block |
||
399 | 406 | { |
400 | 407 | $hour = $this->z_hour; |
401 | 408 | $min = $this->minute; |
402 | - if (empty($hour)) |
|
403 | - $hour = '00'; |
|
404 | - if (empty($min)) |
|
405 | - $min = '00'; |
|
409 | + if (empty($hour)) { |
|
410 | + $hour = '00'; |
|
411 | + } |
|
412 | + if (empty($min)) { |
|
413 | + $min = '00'; |
|
414 | + } |
|
406 | 415 | return $hour . ':' . $min; |
407 | 416 | } |
408 | 417 | |
@@ -413,10 +422,11 @@ discard block |
||
413 | 422 | */ |
414 | 423 | public function get_changed_day($mode) |
415 | 424 | { |
416 | - if ($mode == 'increment') |
|
417 | - $day = $this->day + 1; |
|
418 | - else |
|
419 | - $day = $this->day - 1; |
|
425 | + if ($mode == 'increment') { |
|
426 | + $day = $this->day + 1; |
|
427 | + } else { |
|
428 | + $day = $this->day - 1; |
|
429 | + } |
|
420 | 430 | $date_data = array('day' => $day, |
421 | 431 | 'month' => $this->month, |
422 | 432 | 'year' => $this->year |
@@ -432,10 +442,11 @@ discard block |
||
432 | 442 | public function get_first_day_of_changed_week($mode) |
433 | 443 | { |
434 | 444 | $first_day = $this->getThisweekDaysbyIndex(1); |
435 | - if ($mode == 'increment') |
|
436 | - $day = $first_day->day + 7; |
|
437 | - else |
|
438 | - $day = $first_day->day - 7; |
|
445 | + if ($mode == 'increment') { |
|
446 | + $day = $first_day->day + 7; |
|
447 | + } else { |
|
448 | + $day = $first_day->day - 7; |
|
449 | + } |
|
439 | 450 | $date_data = array('day' => $day, |
440 | 451 | 'month' => $first_day->month, |
441 | 452 | 'year' => $first_day->year |
@@ -11,6 +11,10 @@ |
||
11 | 11 | class VTJsonCondition |
12 | 12 | { |
13 | 13 | |
14 | + /** |
|
15 | + * @param VTEntityCache $entityCache |
|
16 | + * @param string $id |
|
17 | + */ |
|
14 | 18 | function evaluate($condition, $entityCache, $id) |
15 | 19 | { |
16 | 20 | $expr = \includes\utils\Json::decode($condition); |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | $i = 0; |
25 | 25 | foreach ($expr as $cond) { |
26 | 26 | $conditionGroup = $cond['groupid']; |
27 | - if (empty($conditionGroup)) |
|
28 | - $conditionGroup = 0; |
|
27 | + if (empty($conditionGroup)) { |
|
28 | + $conditionGroup = 0; |
|
29 | + } |
|
29 | 30 | preg_match('/(\w+) : \((\w+)\) (\w+)/', $cond['fieldname'], $matches); |
30 | 31 | if (count($matches) == 0) { |
31 | 32 | $expressionResults[$conditionGroup][$i]['result'] = $this->checkCondition($entityData, $cond); |
@@ -117,8 +118,9 @@ discard block |
||
117 | 118 | $data = $entityData->getData(); |
118 | 119 | |
119 | 120 | $condition = $cond['operation']; |
120 | - if (empty($condition)) |
|
121 | - return false; |
|
121 | + if (empty($condition)) { |
|
122 | + return false; |
|
123 | + } |
|
122 | 124 | if ($cond['fieldname'] == 'date_start' || $cond['fieldname'] == 'due_date') { |
123 | 125 | $fieldName = $cond['fieldname']; |
124 | 126 | $dateTimePair = array('date_start' => 'time_start', 'due_date' => 'time_end'); |
@@ -238,8 +240,9 @@ discard block |
||
238 | 240 | } |
239 | 241 | return strpos($fieldValue, $value) !== FALSE; |
240 | 242 | case 'does not contain': |
241 | - if (empty($value)) |
|
242 | - unset($value); |
|
243 | + if (empty($value)) { |
|
244 | + unset($value); |
|
245 | + } |
|
243 | 246 | if (is_array($value)) { |
244 | 247 | return !in_array($fieldValue, $value); |
245 | 248 | } |