markuspoerschke /
iCal
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the eluceo/iCal package. |
||
| 5 | * |
||
| 6 | * (c) Markus Poerschke <[email protected]> |
||
| 7 | * |
||
| 8 | * This source file is subject to the MIT license that is bundled |
||
| 9 | * with this source code in the file LICENSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Eluceo\iCal\Component; |
||
| 13 | |||
| 14 | use Eluceo\iCal\Component; |
||
| 15 | use Eluceo\iCal\PropertyBag; |
||
| 16 | |||
| 17 | class Calendar extends Component |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Methods for calendar components. |
||
| 21 | * |
||
| 22 | * According to RFC 5545: 3.7.2. Method |
||
| 23 | * |
||
| 24 | * @see http://tools.ietf.org/html/rfc5545#section-3.7.2 |
||
| 25 | * |
||
| 26 | * And then according to RFC 2446: 3 APPLICATION PROTOCOL ELEMENTS |
||
| 27 | * @see https://tools.ietf.org/html/rfc2446#section-3.2 |
||
| 28 | */ |
||
| 29 | const METHOD_PUBLISH = 'PUBLISH'; |
||
| 30 | const METHOD_REQUEST = 'REQUEST'; |
||
| 31 | const METHOD_REPLY = 'REPLY'; |
||
| 32 | const METHOD_ADD = 'ADD'; |
||
| 33 | const METHOD_CANCEL = 'CANCEL'; |
||
| 34 | const METHOD_REFRESH = 'REFRESH'; |
||
| 35 | const METHOD_COUNTER = 'COUNTER'; |
||
| 36 | const METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * This property defines the calendar scale used for the calendar information specified in the iCalendar object. |
||
| 40 | * |
||
| 41 | * According to RFC 5545: 3.7.1. Calendar Scale |
||
| 42 | * |
||
| 43 | * @see http://tools.ietf.org/html/rfc5545#section-3.7 |
||
| 44 | */ |
||
| 45 | const CALSCALE_GREGORIAN = 'GREGORIAN'; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * The Product Identifier. |
||
| 49 | * |
||
| 50 | * According to RFC 5545: 3.7.3 Product Identifier |
||
| 51 | * |
||
| 52 | * This property specifies the identifier for the product that created the Calendar object. |
||
| 53 | * |
||
| 54 | * @see https://tools.ietf.org/html/rfc5545#section-3.7.3 |
||
| 55 | * |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | protected $prodId = null; |
||
| 59 | protected $method = null; |
||
| 60 | protected $name = null; |
||
| 61 | protected $description = null; |
||
| 62 | protected $timezone = null; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * This property defines the calendar scale used for the |
||
| 66 | * calendar information specified in the iCalendar object. |
||
| 67 | * |
||
| 68 | * Also identifies the calendar type of a non-Gregorian recurring appointment. |
||
| 69 | * |
||
| 70 | * @var string |
||
| 71 | * |
||
| 72 | * @see http://tools.ietf.org/html/rfc5545#section-3.7 |
||
| 73 | * @see http://msdn.microsoft.com/en-us/library/ee237520(v=exchg.80).aspx |
||
| 74 | */ |
||
| 75 | protected $calendarScale = null; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Specifies whether or not the iCalendar file only contains one appointment. |
||
| 79 | * |
||
| 80 | * @var bool |
||
| 81 | * |
||
| 82 | * @see http://msdn.microsoft.com/en-us/library/ee203486(v=exchg.80).aspx |
||
| 83 | */ |
||
| 84 | protected $forceInspectOrOpen = false; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Specifies a globally unique identifier for the calendar. |
||
| 88 | * |
||
| 89 | * @var string |
||
| 90 | * |
||
| 91 | * @see http://msdn.microsoft.com/en-us/library/ee179588(v=exchg.80).aspx |
||
| 92 | */ |
||
| 93 | protected $calId = null; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Specifies a suggested iCalendar file download frequency for clients and |
||
| 97 | * servers with sync capabilities. |
||
| 98 | * |
||
| 99 | * For example you can set the value to 'P1W' if the calendar should be |
||
| 100 | * synced once a week. Use 'P3H' to sync the file every 3 hours. |
||
| 101 | * |
||
| 102 | * @var string |
||
| 103 | * |
||
| 104 | * @see http://msdn.microsoft.com/en-us/library/ee178699(v=exchg.80).aspx |
||
| 105 | */ |
||
| 106 | protected $publishedTTL = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Specifies a color for the calendar in calendar for Apple/Outlook. |
||
| 110 | * |
||
| 111 | * @var string |
||
| 112 | * |
||
| 113 | * @see http://msdn.microsoft.com/en-us/library/ee179588(v=exchg.80).aspx |
||
| 114 | */ |
||
| 115 | protected $calendarColor = null; |
||
| 116 | |||
| 117 | 20 | public function __construct($prodId) |
|
| 118 | { |
||
| 119 | 20 | if (empty($prodId)) { |
|
| 120 | 1 | throw new \UnexpectedValueException('PRODID cannot be empty'); |
|
| 121 | } |
||
| 122 | |||
| 123 | 19 | $this->prodId = $prodId; |
|
| 124 | 19 | } |
|
| 125 | |||
| 126 | /** |
||
| 127 | * {@inheritdoc} |
||
| 128 | */ |
||
| 129 | 18 | public function getType() |
|
| 130 | { |
||
| 131 | 18 | return 'VCALENDAR'; |
|
| 132 | } |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @param $method |
||
| 136 | * |
||
| 137 | * @return $this |
||
| 138 | */ |
||
| 139 | 1 | public function setMethod($method) |
|
| 140 | { |
||
| 141 | 1 | $this->method = $method; |
|
| 142 | |||
| 143 | 1 | return $this; |
|
| 144 | } |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @param $name |
||
| 148 | * |
||
| 149 | * @return $this |
||
| 150 | */ |
||
| 151 | 1 | public function setName($name) |
|
| 152 | { |
||
| 153 | 1 | $this->name = $name; |
|
| 154 | |||
| 155 | 1 | return $this; |
|
| 156 | } |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @param $description |
||
| 160 | * |
||
| 161 | * @return $this |
||
| 162 | */ |
||
| 163 | 1 | public function setDescription($description) |
|
| 164 | { |
||
| 165 | 1 | $this->description = $description; |
|
| 166 | |||
| 167 | 1 | return $this; |
|
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @param $timezone |
||
| 172 | * |
||
| 173 | * @return $this |
||
| 174 | */ |
||
| 175 | 2 | public function setTimezone($timezone) |
|
| 176 | { |
||
| 177 | 2 | $this->timezone = $timezone; |
|
| 178 | |||
| 179 | 2 | return $this; |
|
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @param $calendarColor |
||
| 184 | * |
||
| 185 | * @return $this |
||
| 186 | */ |
||
| 187 | 1 | public function setCalendarColor($calendarColor) |
|
| 188 | { |
||
| 189 | 1 | $this->calendarColor = $calendarColor; |
|
| 190 | |||
| 191 | 1 | return $this; |
|
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * @param $calendarScale |
||
| 196 | * |
||
| 197 | * @return $this |
||
| 198 | */ |
||
| 199 | 1 | public function setCalendarScale($calendarScale) |
|
| 200 | { |
||
| 201 | 1 | $this->calendarScale = $calendarScale; |
|
| 202 | |||
| 203 | 1 | return $this; |
|
| 204 | } |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @param bool $forceInspectOrOpen |
||
| 208 | * |
||
| 209 | * @return $this |
||
| 210 | */ |
||
| 211 | 1 | public function setForceInspectOrOpen($forceInspectOrOpen) |
|
| 212 | { |
||
| 213 | 1 | $this->forceInspectOrOpen = $forceInspectOrOpen; |
|
| 214 | |||
| 215 | 1 | return $this; |
|
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @param string $calId |
||
| 220 | * |
||
| 221 | * @return $this |
||
| 222 | */ |
||
| 223 | 1 | public function setCalId($calId) |
|
| 224 | { |
||
| 225 | 1 | $this->calId = $calId; |
|
| 226 | |||
| 227 | 1 | return $this; |
|
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @param string $ttl |
||
| 232 | * |
||
| 233 | * @return $this |
||
| 234 | */ |
||
| 235 | 1 | public function setPublishedTTL($ttl) |
|
| 236 | { |
||
| 237 | 1 | $this->publishedTTL = $ttl; |
|
| 238 | |||
| 239 | 1 | return $this; |
|
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * {@inheritdoc} |
||
| 244 | */ |
||
| 245 | 18 | public function buildPropertyBag() |
|
| 246 | { |
||
| 247 | 18 | $propertyBag = new PropertyBag(); |
|
| 248 | 18 | $propertyBag->set('VERSION', '2.0'); |
|
| 249 | 18 | $propertyBag->set('PRODID', $this->prodId); |
|
| 250 | |||
| 251 | 18 | if ($this->method) { |
|
| 252 | 1 | $propertyBag->set('METHOD', $this->method); |
|
| 253 | } |
||
| 254 | |||
| 255 | 18 | if ($this->calendarColor) { |
|
| 256 | 1 | $propertyBag->set('X-APPLE-CALENDAR-COLOR', $this->calendarColor); |
|
| 257 | 1 | $propertyBag->set('X-OUTLOOK-COLOR', $this->calendarColor); |
|
| 258 | 1 | $propertyBag->set('X-FUNAMBOL-COLOR', $this->calendarColor); |
|
| 259 | } |
||
| 260 | |||
| 261 | 18 | if ($this->calendarScale) { |
|
| 262 | 1 | $propertyBag->set('CALSCALE', $this->calendarScale); |
|
| 263 | 1 | $propertyBag->set('X-MICROSOFT-CALSCALE', $this->calendarScale); |
|
| 264 | } |
||
| 265 | |||
| 266 | 18 | if ($this->name) { |
|
| 267 | 1 | $propertyBag->set('X-WR-CALNAME', $this->name); |
|
| 268 | } |
||
| 269 | |||
| 270 | 18 | if ($this->description) { |
|
| 271 | 1 | $propertyBag->set('X-WR-CALDESC', $this->description); |
|
| 272 | } |
||
| 273 | |||
| 274 | 18 | if ($this->timezone) { |
|
| 275 | 2 | if ($this->timezone instanceof Timezone) { |
|
| 276 | 1 | $propertyBag->set('X-WR-TIMEZONE', $this->timezone->getZoneIdentifier()); |
|
| 277 | 1 | $this->addComponent($this->timezone); |
|
|
0 ignored issues
–
show
|
|||
| 278 | } else { |
||
| 279 | 1 | $propertyBag->set('X-WR-TIMEZONE', $this->timezone); |
|
| 280 | 1 | $this->addComponent(new Timezone($this->timezone)); |
|
|
0 ignored issues
–
show
new \Eluceo\iCal\Compone...mezone($this->timezone) is of type object<Eluceo\iCal\Component\Timezone>, but the function expects a object<self>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 281 | } |
||
| 282 | } |
||
| 283 | |||
| 284 | 18 | if ($this->forceInspectOrOpen) { |
|
| 285 | 1 | $propertyBag->set('X-MS-OLK-FORCEINSPECTOROPEN', $this->forceInspectOrOpen); |
|
| 286 | } |
||
| 287 | |||
| 288 | 18 | if ($this->calId) { |
|
| 289 | 1 | $propertyBag->set('X-WR-RELCALID', $this->calId); |
|
| 290 | } |
||
| 291 | |||
| 292 | 18 | if ($this->publishedTTL) { |
|
| 293 | 1 | $propertyBag->set('X-PUBLISHED-TTL', $this->publishedTTL); |
|
| 294 | } |
||
| 295 | |||
| 296 | 18 | return $propertyBag; |
|
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * Adds an Event to the Calendar. |
||
| 301 | * |
||
| 302 | * Wrapper for addComponent() |
||
| 303 | * |
||
| 304 | * @see Eluceo\iCal::addComponent |
||
| 305 | * @deprecated Please, use public method addComponent() from abstract Component class |
||
| 306 | */ |
||
| 307 | 1 | public function addEvent(Event $event) |
|
| 308 | { |
||
| 309 | 1 | $this->addComponent($event); |
|
|
0 ignored issues
–
show
$event is of type object<Eluceo\iCal\Component\Event>, but the function expects a object<self>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 310 | 1 | } |
|
| 311 | |||
| 312 | /** |
||
| 313 | * @return string|null |
||
| 314 | */ |
||
| 315 | 1 | public function getProdId() |
|
| 316 | { |
||
| 317 | 1 | return $this->prodId; |
|
| 318 | } |
||
| 319 | |||
| 320 | 1 | public function getMethod() |
|
| 321 | { |
||
| 322 | 1 | return $this->method; |
|
| 323 | } |
||
| 324 | } |
||
| 325 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: