PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/eyeos/system/Frameworks/Calendar/interfaces.php

https://github.com/Seldaiendil/meyeOS
PHP | 529 lines | 394 code | 72 blank | 63 comment | 20 complexity | 7563ead02570b8a9fc4724c84edb6bb3 MD5 | raw file
  1. <?php
  2. /*
  3. * eyeos - The Open Source Cloud's Web Desktop
  4. * Version 2.0
  5. * Copyright (C) 2007 - 2010 eyeos Team
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU Affero General Public License version 3 as published by the
  9. * Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  14. * details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * version 3 along with this program in the file "LICENSE". If not, see
  18. * <http://www.gnu.org/licenses/agpl-3.0.txt>.
  19. *
  20. * See www.eyeos.org for more details. All requests should be sent to licensing@eyeos.org
  21. *
  22. * The interactive user interfaces in modified source and object code versions
  23. * of this program must display Appropriate Legal Notices, as required under
  24. * Section 5 of the GNU Affero General Public License version 3.
  25. *
  26. * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
  27. * these Appropriate Legal Notices must retain the display of the "Powered by
  28. * eyeos" logo and retain the original copyright notice. If the display of the
  29. * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
  30. * must display the words "Powered by eyeos" and retain the original copyright notice.
  31. */
  32. //
  33. // MANAGER
  34. //
  35. interface ICalendarManager extends ISingleton {
  36. public function deleteCalendar(ICalendar $calendar);
  37. public function deleteEvent(ICalendarEvent $event);
  38. public function getAllCalendarsFromOwner(IPrincipal $principal);
  39. public function getAllEventsFromCalendar(ICalendar $calendar);
  40. public function getCalendarById($calendarId);
  41. public function getEventById($eventId);
  42. public function getAllEventsByPeriod(ICalendar $calendar, $begin, $end);
  43. public function getNewCalendar();
  44. public function getNewEvent();
  45. public function saveCalendar(ICalendar $calendar);
  46. public function saveEvent(ICalendarEvent $event);
  47. public function search($string, ICalendar $calendar);
  48. }
  49. //
  50. // PROVIDER
  51. //
  52. interface ICalendarProvider extends ISingleton {
  53. public function createCalendar(ICalendar $calendar);
  54. public function createEvent(ICalendarEvent $event);
  55. public function deleteCalendar(ICalendar $calendar);
  56. public function deleteEvent(ICalendarEvent $event);
  57. public function retrieveAllCalendarsFromOwner(IPrincipal $principal);
  58. public function retrieveAllEventsFromCalendar(ICalendar $calendar, $timeFrom = null, $timeTo = null);
  59. public function retrieveCalendarById($calendarId);
  60. public function retrieveEventById($eventId);
  61. public function search($string, ICalendar $calendar);
  62. public function updateCalendar(ICalendar $calendar);
  63. public function updateEvent(ICalendarEvent $event);
  64. }
  65. //
  66. // MODEL
  67. //
  68. interface ICalendarEvent extends IShareable, ISimpleMapObject {
  69. //TODO: TO BE DEFINED
  70. const PRIVACY_DEFAULT = 'default';
  71. const PRIVACY_PRIVATE = 'private';
  72. const PRIVACY_PUBLIC = 'public';
  73. const TYPE_MEETING = 'meeting';
  74. const TYPE_LUNCH = 'lunch';
  75. const TYPE_DINNER = 'dinner';
  76. const TYPE_VISIT = 'visit';
  77. const TYPE_CALL = 'call';
  78. const TYPE_BIRTHDAY = 'birthday';
  79. const TYPE_CONFERENCE = 'conference';
  80. const TYPE_TRIP = 'trip';
  81. const TYPE_OTHER = 'other';
  82. public function __toString();
  83. public function getSubject();
  84. public function setSubject($subject);
  85. public function getLocation();
  86. public function setLocation($location);
  87. public function getDescription();
  88. public function setDescription($description);
  89. public function getIsAllDay();
  90. public function setIsAllDay($allDay);
  91. public function getTimeStart();
  92. public function setTimeStart($timeStart);
  93. public function getTimeEnd();
  94. public function setTimeEnd($timeEnd);
  95. public function getCreatorId();
  96. public function setCreatorId($principalId);
  97. public function getType();
  98. public function setType($type);
  99. public function getRepetition();
  100. public function setRepetition($repetition);
  101. public function getRepeatType();
  102. public function setRepeatType($repeatType);
  103. public function getFinalType();
  104. public function setFinalType($finalType);
  105. public function getFinalValue();
  106. public function setFinalValue($finalValue);
  107. public function getEventGroup();
  108. public function setEventGroup($eventGroup);
  109. public function getPrivacy();
  110. public function setPrivacy($privacy);
  111. public function getCalendarId();
  112. public function setCalendarId($calendarId);
  113. }
  114. interface ICalendar extends IShareable, ISimpleMapObject {
  115. public function __toString();
  116. public function getName();
  117. public function setName($name);
  118. public function getDescription();
  119. public function setDescription($description);
  120. public function getTimezone();
  121. public function setTimezone($timezone);
  122. public function getOwnerId();
  123. public function setOwnerId($ownerId);
  124. }
  125. interface ICalendarPrefs extends ISimpleMapObject {
  126. public function getId();
  127. public function setId($id);
  128. public function getCalendarId();
  129. public function setCalendarId($calendarId);
  130. public function getUserId();
  131. public function setUserId($userId);
  132. public function getColor();
  133. public function setColor($color);
  134. public function getNotifications();
  135. public function setNotifications($notifications);
  136. public function getVisible();
  137. public function setVisible($visible);
  138. }
  139. interface ICalendarEventPrefs extends ISimpleMapObject {
  140. public function getId();
  141. public function setId($id);
  142. public function getEventId();
  143. public function setEventId($eventId);
  144. public function getUserId();
  145. public function setUserId($userId);
  146. //...
  147. }
  148. //
  149. // PERMISSIONS
  150. //
  151. class AbstractCalendarEventPermission extends SharePermission {
  152. const VIEW_LIST = 'view_list';
  153. const INVITE_OTHERS = 'invite';
  154. const EDIT = 'edit';
  155. const ALL = 'view_list,invite,edit';
  156. }
  157. class AbstractCalendarPermission extends SharePermission {
  158. const SHARE = 'share';
  159. const EDIT = 'edit';
  160. const SEE = 'see';
  161. const SEE_DETAILS = 'see_details';
  162. const ALL = 'see_details,edit,share';
  163. }
  164. //
  165. // MODEL ABSTRACT CLASSES
  166. //
  167. abstract class AbstractCalendarEvent implements ICalendarEvent {
  168. private $id;
  169. private $subject;
  170. private $location;
  171. private $description;
  172. private $isAllDay;
  173. private $timeStart;
  174. private $timeEnd;
  175. private $creatorId;
  176. private $type;
  177. private $calendarId;
  178. private $privacy;
  179. private $repetition;
  180. private $repeatType;
  181. private $finalType;
  182. private $finalValue;
  183. private $eventGroup;
  184. private $gmtTimeDiffrence;
  185. public function __toString() {
  186. $props = get_object_vars($this);
  187. $string = get_class($this) . '[';
  188. foreach($props as $name => $value) {
  189. if (!is_object($value) && $value !== null) {
  190. // Adaptation for dates, for a more readable format
  191. if ($name == 'timeStart' || $name == 'timeEnd') {
  192. $string .= $value . '(' . gmdate('M d Y H:i:s', $value) . '),';
  193. } else {
  194. $string .= $name . '=' . $value . ',';
  195. }
  196. }
  197. }
  198. $string = utf8_substr($string, 0, -1) . ']';
  199. return $string;
  200. }
  201. public function getId($forceGeneration = true) {
  202. if ($this->id === null && $forceGeneration) {
  203. $this->id = ObjectIdGenerator::assignId($this);
  204. }
  205. return $this->id;
  206. }
  207. public function setId($id) {
  208. if ($this->id !== null) {
  209. throw new EyeBadMethodCallException('Cannot overwrite existing ID for event ' . $this->id . '.');
  210. }
  211. $this->id = $id;
  212. }
  213. public function getSubject() {
  214. return $this->subject;
  215. }
  216. public function setSubject($subject) {
  217. $this->subject = $subject;
  218. }
  219. public function getLocation() {
  220. return $this->location;
  221. }
  222. public function setLocation($location) {
  223. $this->location = $location;
  224. }
  225. public function getDescription() {
  226. return $this->description;
  227. }
  228. public function setDescription($description) {
  229. $this->description = $description;
  230. }
  231. public function getIsAllDay() {
  232. return $this->isAllDay;
  233. }
  234. public function setIsAllDay($isAllDay) {
  235. $this->isAllDay = $isAllDay;
  236. }
  237. /**
  238. * @return int The UNIX timestamp (in seconds).
  239. */
  240. public function getTimeStart() {
  241. return $this->timeStart;
  242. }
  243. /**
  244. * @param int $timeStart The UNIX timestamp (in seconds).
  245. */
  246. public function setTimeStart($timeStart) {
  247. $this->timeStart = $timeStart;
  248. }
  249. /**
  250. * @return int The UNIX timestamp (in seconds).
  251. */
  252. public function getTimeEnd() {
  253. return $this->timeEnd;
  254. }
  255. /**
  256. * @param int $timeStart The UNIX timestamp (in seconds).
  257. */
  258. public function setTimeEnd($timeEnd) {
  259. $this->timeEnd = $timeEnd;
  260. }
  261. public function getCreatorId() {
  262. return $this->creatorId;
  263. }
  264. public function setCreatorId($principalId) {
  265. $this->creatorId = $principalId;
  266. }
  267. public function getType() {
  268. return $this->type;
  269. }
  270. public function setType($type) {
  271. $this->type = $type;
  272. }
  273. public function getCalendarId() {
  274. return $this->calendarId;
  275. }
  276. public function setCalendarId($calendarId) {
  277. $this->calendarId = $calendarId;
  278. }
  279. public function getPrivacy() {
  280. return $this->privacy;
  281. }
  282. public function setPrivacy($privacy) {
  283. $this->privacy = $privacy;
  284. }
  285. public function getRepetition() {
  286. return $this->repetition;
  287. }
  288. public function setRepetition($repetition) {
  289. $this->repetition = $repetition;
  290. }
  291. public function getRepeatType() {
  292. return $this->repeatType;
  293. }
  294. public function setRepeatType($repeatType) {
  295. $this->repeatType = $repeatType;
  296. }
  297. public function getFinalType() {
  298. return $this->finalType;
  299. }
  300. public function setFinalType($finalType) {
  301. $this->finalType = $finalType;
  302. }
  303. public function getFinalValue() {
  304. return $this->finalValue;
  305. }
  306. public function setFinalValue($finalValue) {
  307. $this->finalValue = $finalValue;
  308. }
  309. public function getEventGroup() {
  310. return $this->eventGroup;
  311. }
  312. public function setEventGroup($eventGroup) {
  313. $this->eventGroup = $eventGroup;
  314. }
  315. public function getAttributesMap() {
  316. return get_object_vars($this);
  317. }
  318. // for remote calendars
  319. public function reSetId($id) {
  320. $this->id = $id;
  321. }
  322. public function setGmtTimeDiffrence($value) {
  323. $this->gmtTimeDiffrence = $value;
  324. }
  325. public function getGmtTimeDiffrence() {
  326. return $this->gmtTimeDiffrence;
  327. }
  328. }
  329. abstract class AbstractCalendar implements ICalendar {
  330. private $id = null;
  331. private $name;
  332. private $description;
  333. private $timezone;
  334. private $ownerId;
  335. public function __toString() {
  336. $props = get_object_vars($this);
  337. $string = get_class($this) . '[';
  338. foreach($props as $name => $value) {
  339. if (!is_object($value) && $value !== null) {
  340. $string .= $name . '=' . $value . ',';
  341. }
  342. }
  343. $string = utf8_substr($string, 0, -1) . ']';
  344. return $string;
  345. }
  346. public function getId($forceGeneration = true) {
  347. if ($this->id === null && $forceGeneration) {
  348. $this->id = ObjectIdGenerator::assignId($this);
  349. }
  350. return $this->id;
  351. }
  352. public function setId($id) {
  353. if ($this->id !== null) {
  354. throw new EyeBadMethodCallException('Cannot overwrite existing ID for calendar ' . $this->id . '.');
  355. }
  356. $this->id = $id;
  357. }
  358. public function getName() {
  359. return $this->name;
  360. }
  361. public function setName($name) {
  362. $this->name = $name;
  363. }
  364. public function getDescription() {
  365. return $this->description;
  366. }
  367. public function setDescription($description) {
  368. $this->description = $description;
  369. }
  370. public function getTimezone() {
  371. return $this->timezone;
  372. }
  373. public function setTimezone($timezone) {
  374. $this->timezone = $timezone;
  375. }
  376. public function getOwnerId() {
  377. return $this->ownerId;
  378. }
  379. public function setOwnerId($ownerId) {
  380. $this->ownerId = $ownerId;
  381. }
  382. public function getAttributesMap() {
  383. return get_object_vars($this);
  384. }
  385. }
  386. abstract class AbstractRemoteCalendar implements ICalendar {
  387. private $id = null;
  388. private $name;
  389. private $description;
  390. private $timezone;
  391. private $ownerId;
  392. /* private $username;
  393. private $password;*/
  394. public function __toString() {
  395. $props = get_object_vars($this);
  396. $string = get_class($this) . '[';
  397. foreach($props as $name => $value) {
  398. if (!is_object($value) && $value !== null) {
  399. $string .= $name . '=' . $value . ',';
  400. }
  401. }
  402. $string = utf8_substr($string, 0, -1) . ']';
  403. return $string;
  404. }
  405. public function getId($forceGeneration = true) {
  406. if ($this->id === null && $forceGeneration) {
  407. $this->id = ObjectIdGenerator::assignId($this);
  408. }
  409. return $this->id;
  410. }
  411. public function setId($id) {
  412. if ($this->id !== null) {
  413. throw new EyeBadMethodCallException('Cannot overwrite existing ID for calendar ' . $this->id . '.');
  414. }
  415. $this->id = $id;
  416. }
  417. public function getName() {
  418. return $this->name;
  419. }
  420. public function setName($name) {
  421. $this->name = $name;
  422. }
  423. public function getDescription() {
  424. return $this->description;
  425. }
  426. public function setDescription($description) {
  427. $this->description = $description;
  428. }
  429. public function getTimezone() {
  430. return $this->timezone;
  431. }
  432. public function setTimezone($timezone) {
  433. $this->timezone = $timezone;
  434. }
  435. public function getOwnerId() {
  436. return $this->ownerId;
  437. }
  438. public function setOwnerId($ownerId) {
  439. $this->ownerId = $ownerId;
  440. }
  441. public function getAttributesMap() {
  442. return get_object_vars($this);
  443. }
  444. public function getUsername() {
  445. return $this->username;
  446. }
  447. public function setUsername($username) {
  448. $this->username = $username;
  449. }
  450. public function getPassword() {
  451. return $this->password;
  452. }
  453. public function setPassword($password) {
  454. $this->password = $password;
  455. }
  456. }
  457. ?>