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

server/includes/download_appointment.php (1 issue)

Severity
1
<?php
2
// required to handle php errors
3
require_once(__DIR__ . '/exceptions/class.ZarafaErrorException.php');
4
require_once(__DIR__ . '/download_base.php');
5
6
/**
7
 * DownloadAppointment
8
 *
9
 * A class to manage downloading of appointment as a file,
10
 * it will generate the appointment as RFC2445-formatted ics stream.
11
 * It extends the DownloadBase class.
12
 */
13
class DownloadAppointment extends DownloadBase
14
{
15
	/**
16
	 * Function get appointment using respective mapi function.
17
	 * It also sends the ics file to the client.
18
	 */
19
	function downloadAppointmentAsFile()
20
	{
21
		if($this->message && $this->store) {
22
			// Get addressbook for current session
23
			$addrBook = $GLOBALS['mapisession']->getAddressbook();
24
25
			// get message properties.
26
			$messageProps = mapi_getprops($this->message, array(PR_SUBJECT));
27
28
			// Read the appointment as RFC2445-formatted ics stream.
29
			$appointmentStream = mapi_mapitoical($GLOBALS['mapisession']->getSession(), $addrBook, $this->message, array());
30
31
			$filename = (!empty($messageProps[PR_SUBJECT])) ? $messageProps[PR_SUBJECT] : _('Untitled');
32
			$filename .= '.ics';
33
34
			$this->setNecessaryHeaders($filename, strlen($appointmentStream));
35
36
			$split = str_split($appointmentStream, BLOCK_SIZE);
37
			foreach ($split as $s) echo $s;
38
		}
39
	}
40
41
	/**
42
	 * Generic function to check received data and download ics file.
43
	 */
44
	public function download()
45
	{
46
		$this->downloadAppointmentAsFile();
47
	}
48
}
49
50
// create instance of class to download message as file
51
$messageInstance = new DownloadAppointment();
52
53
try {
54
	// initialize variables
55
	$messageInstance->init($_GET);
56
57
	// download message
58
	$messageInstance->download();
59
} catch (Exception $e) {
60
	$messageInstance->handleSaveMessageException($e);
61
}
62
?>
0 ignored issues
show
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...
63