Test Failed
Push — master ( 647c72...cd42b5 )
by
unknown
10:25
created

BusyTimeListModule   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createNotifiers() 0 2 1
B processItems() 0 31 7
1
<?php
2
	/**
3
	 * BusyTime Module
4
	*/
5
	
6
	require_once(BASE_PATH . 'server/includes/mapi/class.recurrence.php'); // FIXME: included by appointmentlistmodule
7
	require_once(BASE_PATH . 'server/includes/modules/class.appointmentlistmodule.php');
8
	
9
	class BusyTimeListModule extends AppointmentListModule
10
	{
11
		/**
12
		 * @var array the properties sent back to the client - a minimal set of data
13
		 */
14
		private $minproperties;
15
16
		/**
17
		 * Constructor
18
		 * @param int $id unique id.
19
		 * @param array $data list of all actions.
20
		 */
21
		function __construct($id, $data)
22
		{
23
			parent::__construct($id, $data);
24
			$this->minproperties = $GLOBALS["properties"]->getBusyTimeProperties();
25
		}
26
27
		/**
28
		 * Creates the notifiers for this module,
29
		 * and register them to the Bus.
30
		 */
31
		function createNotifiers()
32
		{
33
			// Keep empty, the BusyTimeListModule doesn't need notifiers.
34
		}
35
36
		/**
37
		 * Process calendar items to prepare them for being sent back to the client
38
		 * @param array $calendaritems array of appointments retrieved from the mapi tablwe
39
 		 * @param object $store message store
40
		 * @param object $calendar folder
41
		 * @param date $start startdate of the interval
42
		 * @param date $end enddate of the interval
43
		 * @return array $items processed items
44
		 */
45
		function processItems($calendaritems, $store, $entryid, $start, $end)
46
		{
47
			$items = Array();
48
			foreach($calendaritems as $calendaritem)
49
			{
50
				if (isset($calendaritem[$this->properties["recurring"]]) && $calendaritem[$this->properties["recurring"]]) {
51
					$recurrence = new Recurrence($store, $calendaritem);
0 ignored issues
show
Bug introduced by
$store of type object is incompatible with the type resource expected by parameter $store of Recurrence::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
					$recurrence = new Recurrence(/** @scrutinizer ignore-type */ $store, $calendaritem);
Loading history...
52
					$recuritems = $recurrence->getItems($start, $end);
53
					
54
					foreach($recuritems as $recuritem)
55
					{
56
						$item = Conversion::mapMAPI2XML($this->minproperties, $recuritem);
57
						
58
						// only add it in response if its not removed by above function
59
						if(!empty($item)) {
60
							array_push($items, $item['props']);
61
						}
62
					}
63
				} else {
64
					$item = Conversion::mapMAPI2XML($this->minproperties, $calendaritem);
65
66
					
67
68
					// only add it in response if its not removed by above function
69
					if(!empty($item)) {
70
						array_push($items,$item['props']);
71
					}
72
				}
73
			}
74
75
			return $items;
76
		}
77
	}
78
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
79