Blame view

sources/apps/calendar/lib/share/event.php 1.18 KB
d1bafeea1   Kload   [fix] Upgrade to ...
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
  <?php
  /**
   * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
   * This file is licensed under the Affero General Public License version 3 or
   * later.
   * See the COPYING-README file.
   */
  
  class OC_Share_Backend_Event implements OCP\Share_Backend {
  
  	const FORMAT_EVENT = 0;
  
  	private static $event;
  
  	public function isValidSource($itemSource, $uidOwner) {
  		self::$event = OC_Calendar_Object::find($itemSource);
  		if (self::$event) {
  			return true;
  		}
  		return false;
  	}
  
  	public function generateTarget($itemSource, $shareWith, $exclude = null) {
  		if(!self::$event) {
  			self::$event = OC_Calendar_Object::find($itemSource);
  		}
  		return self::$event['summary'];
  	}
  
  	public function formatItems($items, $format, $parameters = null) {
  		$events = array();
  		if ($format == self::FORMAT_EVENT) {
  			foreach ($items as $item) {
  				$event = OC_Calendar_Object::find($item['item_source']);
  				if ($event == False) {
  					\OCP\Util::writeLog('calendar', __METHOD__.', Missing event: ' . $item['item_target'], \OCP\Util::DEBUG);
  				}
  				else {
  					$event['summary'] = $item['item_target'];
  					$event['permissions'] = $item['permissions'];
  					$events[] = $event;
  				}
  			}
  		}
  		return $events;
  	}
  
  }