public function __construct() { $timeNow = time(); //test $checkOffset = new \DateTime(date('d.m.Y', $timeNow), new \DateTimeZone(self::$tz)); $calcSumWin = $checkOffset->getOffset(); $this->nowTime = strtotime(date('d.m.Y H:i', $timeNow)) + $calcSumWin; if (\OC::$server->getSession()->get('public_link_token')) { $linkItem = \OCP\Share::getShareByToken(\OC::$server->getSession()->get('public_link_token', false)); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { if ($linkItem['item_type'] === App::SHARECALENDAR) { $sPrefix = App::SHARECALENDARPREFIX; } if ($linkItem['item_type'] === App::SHAREEVENT) { $sPrefix = App::SHAREEVENTPREFIX; } if ($linkItem['item_type'] === App::SHARETODO) { $sPrefix = App::SHARETODOPREFIX; } $itemSource = App::validateItemSource($linkItem['item_source'], $sPrefix); $rootLinkItem = Calendar::find($itemSource); $this->aCalendars[] = $rootLinkItem; } } else { $this->aCalendars = Calendar::allCalendars(\OCP\User::getUser()); $this->checkAlarm(); } }
/** * @brief Deletes all calendars of a certain user * @param paramters parameters from postDeleteUser-Hook * @return array */ public static function deleteUser($parameters) { \OCP\Util::writeLog('calendarplus', 'Hook DEL ID-> ' . $parameters['uid'], \OCP\Util::DEBUG); $calendars = Calendar::allCalendars($parameters['uid']); foreach ($calendars as $calendar) { if ($parameters['uid'] === $calendar['userid']) { Calendar::deleteCalendar($calendar['id']); } } //delete preferences return true; }
public function createCalendarName() { $calendars = Calendar::allCalendars($this->userid); $calendarname = $guessedcalendarname = !is_null($this->guessCalendarName()) ? $this->guessCalendarName() : App::$l10n->t('New Calendar'); $i = 1; while (!Calendar::isCalendarNameavailable($calendarname, $this->userid)) { $calendarname = $guessedcalendarname . ' (' . $i . ')'; $i++; } return $calendarname; }