Ejemplo n.º 1
0
 /**
  * Helper function for SingleCalendar::storeEvent().
  *
  * @param CalendarEvent $event The ecent to store.
  * @param type $attendee_ids The user ids of the attendees.
  * @return bool|int The number of stored events or false if an error occured.
  */
 private function storeAttendeeEvents(CalendarEvent $event, $attendee_ids)
 {
     $ret = 0;
     $new_attendees = array();
     foreach ($attendee_ids as $attendee_id) {
         if (trim($attendee_id)) {
             $attendee_calendar = new SingleCalendar($attendee_id);
             if ($attendee_calendar->havePermission(Calendar::PERMISSION_WRITABLE)) {
                 $attendee_event = new CalendarEvent(array($attendee_calendar->getRangeId(), $event->event_id));
                 $attendee_event->event = $event->event;
                 $is_new = $attendee_event->isNew();
                 $stored = $attendee_event->store();
                 if ($stored !== false) {
                     // send message if not own calendar
                     if (!$attendee_calendar->havePermission(Calendar::PERMISSION_OWN)) {
                         $this->sendStoreMessage($attendee_event, $is_new);
                     }
                     $new_attendees[] = $attendee_event->range_id;
                     $ret += $stored;
                 } else {
                     return false;
                 }
             }
         }
     }
     $events_delete = CalendarEvent::findBySQL('event_id = ? AND range_id NOT IN(?)', array($event->event_id, $new_attendees));
     foreach ($events_delete as $event_delete) {
         $calendar = new SingleCalendar($event_delete->range_id);
         $calendar->deleteEvent($event_delete);
     }
     return $ret;
 }
Ejemplo n.º 2
0
 protected function getTitle(SingleCalendar $calendar, $title_end)
 {
     $title = '';
     $status = '';
     if ($calendar->getRangeId() == $GLOBALS['user']->id) {
         $title = _('Mein persönlicher Terminkalender');
     } else {
         if ($calendar->getRange() == Calendar::RANGE_USER) {
             $title = sprintf(_('Terminkalender von %s'), $calendar->range_object->getFullname());
         } else {
             $title = getHeaderLine($calendar->getRangeId());
         }
         if ($calendar->havePermission(Calendar::PERMISSION_WRITABLE)) {
             $status = ' (' . _('schreibberechtigt') . ')';
         } else {
             $status = ' (' . _('leseberechtigt') . ')';
         }
     }
     return $title . ' - ' . $title_end . $status;
 }