/usr/share/php/Horde/Itip/Response.php is in php-horde-itip 2.0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | <?php
/**
* Handles Itip response data.
*
* PHP version 5
*
* @category Horde
* @package Itip
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @link http://pear.horde.org/index.php?package=Itip
*/
/**
* Handles Itip response data.
*
* Copyright 2002-2013 Horde LLC (http://www.horde.org/)
* Copyright 2004-2010 Klarälvdalens Datakonsult AB
*
* See the enclosed file COPYING for license information (LGPL). If you did not
* receive this file, see
* {@link http://www.horde.org/licenses/lgpl21 LGPL}.
*
* @category Horde
* @package Itip
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @link http://pear.horde.org/index.php?package=Itip
*/
class Horde_Itip_Response
{
/**
* The request we are going to answer.
*
* @var Horde_Itip_Event
*/
private $_request;
/**
* The requested resource.
*
* @var Horde_Itip_Resource
*/
private $_resource;
/**
* Constructor.
*
* @param Horde_Itip_Event $request The request this instance will
* respond to.
* @param Horde_Itip_Resource $resource The requested resource.
*/
public function __construct(
Horde_Itip_Event $request,
Horde_Itip_Resource $resource
)
{
$this->_request = $request;
$this->_resource = $resource;
}
/**
* Return the original request.
*
* @return Horde_Itip_Event The original request.
*/
public function getRequest()
{
return $this->_request;
}
/**
* Return the response as an iCalendar vEvent object.
*
* @param Horde_Itip_Response_Type $type The response type.
* @param Horde_Icalendar|boolean $vCal The parent container or false if not
* provided.
*
* @return Horde_Icalendar_Vevent The response object.
*/
public function getVevent(
Horde_Itip_Response_Type $type,
$vCal = false
)
{
$itip_reply = new Horde_Itip_Event_Vevent(
Horde_Icalendar::newComponent('VEVENT', $vCal)
);
$this->_request->copyEventInto($itip_reply);
$type->setRequest($this->_request);
$itip_reply->setAttendee(
$this->_resource->getMailAddress(),
$this->_resource->getCommonName(),
$type->getStatus()
);
return $itip_reply->getVevent();
}
/**
* Return the response as an iCalendar object.
*
* @param Horde_Itip_Response_Type $type The response type.
* @param Horde_Itip_Response_Options $options The options for the response.
*
* @return Horde_Icalendar The response object.
*/
public function getIcalendar(
Horde_Itip_Response_Type $type,
Horde_Itip_Response_Options $options
)
{
$vCal = new Horde_Icalendar();
$options->prepareIcalendar($vCal);
$vCal->setAttribute('METHOD', 'REPLY');
$vCal->addComponent($this->getVevent($type, $vCal));
return $vCal;
}
/**
* Return the response as a MIME message.
*
* @param Horde_Itip_Response_Type $type The response type.
* @param Horde_Itip_Response_Options $options The options for the response.
*
* @return array A list of two object: The mime headers and the mime
* message.
*/
public function getMessage(
Horde_Itip_Response_Type $type,
Horde_Itip_Response_Options $options
)
{
$message = new Horde_Mime_Part();
$message->setType('text/calendar');
$options->prepareIcsMimePart($message);
$message->setContents(
$this->getIcalendar($type, $options)->exportvCalendar()
);
$message->setEOL("\r\n");
$message->setName('event-reply.ics');
$message->setContentTypeParameter('METHOD', 'REPLY');
// Build the reply headers.
$from = $this->_resource->getFrom();
$reply_to = $this->_resource->getReplyTo();
$headers = new Horde_Mime_Headers();
$headers->addHeader('Date', date('r'));
$headers->addHeader('From', $from);
$headers->addHeader('To', $this->_request->getOrganizer());
if (!empty($reply_to) && $reply_to != $from) {
$headers->addHeader('Reply-to', $reply_to);
}
$headers->addHeader(
'Subject', $type->getSubject()
);
$options->prepareResponseMimeHeaders($headers);
return array($headers, $message);
}
/**
* Return the response as a MIME message.
*
* @param Horde_Itip_Response_Type $type The response type.
* @param Horde_Itip_Response_Options $options The options for the response.
*
* @return array A list of two object: The mime headers and the mime
* message.
*/
public function getMultiPartMessage(
Horde_Itip_Response_Type $type,
Horde_Itip_Response_Options $options
)
{
$message = new Horde_Mime_Part();
$message->setType('multipart/alternative');
list($headers, $ics) = $this->getMessage($type, $options);
$body = new Horde_Mime_Part();
$body->setType('text/plain');
$options->prepareMessageMimePart($body);
$body->setContents(Horde_String::wrap($type->getMessage(), 76));
$message->addPart($body);
$message->addPart($ics);
return array($headers, $message);
}
}
|