/** * Returns instance of Tinebase_Config * * @return Tinebase_Config */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new self(); } return self::$_instance; }
/** * get all possible application prefs * * @return array all application prefs */ public function getAllApplicationPreferences() { $cropDays = Calendar_Config::getInstance()->get(Calendar_Config::CROP_DAYS_VIEW); $allPrefs = array(self::DAYSVIEW_STARTTIME, self::DAYSVIEW_ENDTIME, self::DEFAULTCALENDAR, self::DEFAULTPERSISTENTFILTER, self::NOTIFICATION_LEVEL, self::SEND_NOTIFICATION_OF_OWN_ACTIONS, self::SEND_ALARM_NOTIFICATIONS, self::DEFAULTALARM_ENABLED, self::DEFAULTALARM_MINUTESBEFORE, self::DEFAULTATTENDEE_STRATEGY, self::DEFAULT_TIMEINCREMENT, self::DEFAULTATTENDEE_STRATEGY, self::DEFAULT_EVENTS_RRIVATE, self::FIRSTDAYOFWEEK); if ($cropDays) { array_unshift($allPrefs, self::DAYSVIEW_DEFAULT_STARTTIME); } return $allPrefs; }
/** * get default period filter * * @return Calendar_Model_PeriodFilter */ protected function _getDefaultPeriodFilter() { $now = Tinebase_DateTime::now()->setTime(0, 0, 0); $from = $now->getClone()->subMonth(Calendar_Config::getInstance()->get(Calendar_Config::MAX_JSON_DEFAULT_FILTER_PERIOD_FROM, 0)); $until = $now->getClone()->addMonth(Calendar_Config::getInstance()->get(Calendar_Config::MAX_JSON_DEFAULT_FILTER_PERIOD_UNTIL, 1)); $periodFilter = new Calendar_Model_PeriodFilter(array('field' => 'period', 'operator' => 'within', 'value' => array("from" => $from, "until" => $until))); return $periodFilter; }
public function getRoleString() { $rolesConfig = Calendar_Config::getInstance()->attendeeRoles; $rolesRecord = $rolesConfig && $rolesConfig->records instanceof Tinebase_Record_RecordSet ? $rolesConfig->records->getById($this->role) : false; return $rolesRecord ? $rolesRecord->value : $this->role; }
/** * get max period (from) in months (default: 2) * * @return integer */ protected function _getMaxPeriodFrom() { // if the client does support sync tokens and the plugin Tinebase_WebDav_Plugin_SyncToken is active if (Calendar_Convert_Event_VCalendar_Factory::supportsSyncToken($_SERVER['HTTP_USER_AGENT'])) { $result = Calendar_Config::getInstance()->get(Calendar_Config::MAX_FILTER_PERIOD_CALDAV_SYNCTOKEN, 100); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' SyncToken active: allow to filter for all calendar events => return ' . $result . ' months'); } return $result; } return Calendar_Config::getInstance()->get(Calendar_Config::MAX_FILTER_PERIOD_CALDAV, 2); }
/** * test client config retrival * */ public function testGetClientRegistryConfig() { $clientConfig = $this->_instance->getClientRegistryConfig(); $this->assertTrue($clientConfig instanceof Tinebase_Config_Struct, 'clientconfig is not a struct'); $this->assertTrue($clientConfig->Calendar instanceof Tinebase_Config_Struct, 'calendar clientconfig is not a struct'); $this->assertEquals(Calendar_Config::getInstance()->fixedCalendars, $clientConfig->Calendar->fixedCalendars->value, 'fixed calendar config not correct'); $this->assertFalse(isset($clientConfig->Tinebase['SMTP']) || array_key_exists('SMTP', $clientConfig->Tinebase), 'SMTP is not a client config'); }
/** * get max period (from) in months (default: 2) * * @return integer */ protected function _getMaxPeriodFrom() { //if the client does support sync tokens and the plugin Tinebase_WebDav_Plugin_SyncToken is active, allow to filter for all calendar events => return 100 years if (Calendar_Convert_Event_VCalendar_Factory::supportsSyncToken($_SERVER['HTTP_USER_AGENT'])) { return 100; } return Calendar_Config::getInstance()->get(Calendar_Config::MAX_FILTER_PERIOD_CALDAV, 2); }
/** * Enable by a preference which sends mails to every user who got permissions to edit the resource */ public function testResourceNotificationForGrantedUsers($userIsAttendee = true, $suppress_notification = false) { // Enable feature, disabled by default! Calendar_Config::getInstance()->set(Calendar_Config::RESOURCE_MAIL_FOR_EDITORS, true); $resource = $this->_getResource(); $resource->email = Tinebase_Core::getUser()->accountEmailAddress; $resource->suppress_notification = $suppress_notification; $persistentResource = Calendar_Controller_Resource::getInstance()->create($resource); $event = $this->_getEvent(true); $event->attendee->addRecord($this->_createAttender($persistentResource->getId(), Calendar_Model_Attender::USERTYPE_RESOURCE)); if (!$userIsAttendee) { // remove organizer attendee foreach ($event->attendee as $idx => $attender) { if ($attender->user_id === $event->organizer) { $event->attendee->removeRecord($attender); } } } $grants = Tinebase_Container::getInstance()->getGrantsOfContainer($resource->container_id); $newGrants = array('account_id' => $this->_personas['sclever']->getId(), 'account_type' => 'user', Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_EDIT => true); Tinebase_Container::getInstance()->setGrants($resource->container_id, new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array_merge(array($newGrants), $grants->toArray())), TRUE); self::flushMailer(); $persistentEvent = $this->_eventController->create($event); $messages = self::getMessages(); Tinebase_Container::getInstance()->setGrants($resource->container_id, $grants); $this->assertContains('Resource "' . $persistentResource->name . '" was booked', print_r($messages, true)); $this->assertContains('Meeting Room (Required, No response)', print_r($messages, true)); if ($suppress_notification) { $this->assertEquals(2, count($messages), 'two mails should be send to current user (resource + attender)'); } else { $this->assertEquals(4, count($messages), 'four mails should be send to current user (resource + attender + everybody who is allowed to edit this resource)'); $this->assertEquals(count($event->attendee), count($persistentEvent->attendee)); } }
/** * testDisabledExternalImip */ public function testDisabledExternalImip() { Calendar_Config::getInstance()->set(Calendar_Config::DISABLE_EXTERNAL_IMIP, true); $complete = $this->_addImipMessageToEmailCache(); $fmailJson = new Felamimail_Frontend_Json(); $jsonMessage = $fmailJson->getMessage($complete->getId()); Calendar_Config::getInstance()->set(Calendar_Config::DISABLE_EXTERNAL_IMIP, false); $this->assertEmpty($jsonMessage['preparedParts']); }
/** * * * @param Calendar_Model_iMIP $_iMIP * @param bool $_assertExistence * @param bool $_assertOriginator * @param bool $_assertAccount * @return Addressbook_Model_Contact * @throws Calendar_Exception_iMIP * * @todo this needs to be splitted into assertExternalOrganizer / assertInternalOrganizer */ protected function _assertOrganizer($_iMIP, $_assertExistence, $_assertOriginator, $_assertAccount = false) { $result = TRUE; $existingEvent = $this->getExistingEvent($_iMIP); $organizer = $existingEvent ? $existingEvent->resolveOrganizer() : $_iMIP->getEvent()->resolveOrganizer(); if ($_assertExistence && !$organizer) { $_iMIP->addFailedPrecondition(Calendar_Model_iMIP::PRECONDITION_ORGANIZER, "processing {$_iMIP->method} without organizer is not possible"); $result = FALSE; } // NOTE: originator might also be reply-to instead of from // NOTE: originator might act on behalf of organizer ("SENT-BY ") // NOTE: an existing event might be updateable by an non organizer ("SENT-BY ") originator // NOTE: CUA might skip the SENT-BY param => bad luck /* if ($_assertOriginator) { $result &= $this->_assertOriginator($_iMIP, $organizer, 'organizer'); } */ if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Organizer: ' . ($organizer ? print_r($organizer->toArray(), true) : 'not found')); } // config setting overwrites method param $assertAccount = Calendar_Config::getInstance()->get(Calendar_Config::DISABLE_EXTERNAL_IMIP, $_assertAccount); if ($assertAccount && (!$organizer || !$organizer->account_id)) { $_iMIP->addFailedPrecondition(Calendar_Model_iMIP::PRECONDITION_ORGANIZER, "processing {$_iMIP->method} without organizer user account is not possible"); $result = FALSE; } return $result; }
/** * @param $attender * @param $_notificationLevel * @param $recipients * @param $action * @param $sendLevel * @return bool */ protected function _handleResourceEditors($attender, $_notificationLevel, &$recipients, &$action, &$sendLevel, $_updates) { // Add additional recipients for resources if ($attender->user_type !== Calendar_Model_Attender::USERTYPE_RESOURCE || !Calendar_Config::getInstance()->get(Calendar_Config::RESOURCE_MAIL_FOR_EDITORS)) { return true; } // Set custom startus booked if ($action == 'created') { $action = 'booked'; } $resource = Calendar_Controller_Resource::getInstance()->get($attender->user_id); if ($resource->suppress_notification) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Do not send Notifications for this resource: " . $resource->name); } // $recipients will still contain the resource itself return true; } // The resource has no account there for the organizer preference (sendLevel) is used. We don't want that $sendLevel = self::NOTIFICATION_LEVEL_EVENT_RESCHEDULE; //handle attendee status change if (!empty($_updates['attendee']) && !empty($_updates['attendee']['toUpdate'])) { foreach ($_updates['attendee']['toUpdate'] as $updatedAttendee) { if ($updatedAttendee->user_type == Calendar_Model_Attender::USERTYPE_RESOURCE && $resource->getId() == $updatedAttendee->user_id) { $sendLevel = self::NOTIFICATION_LEVEL_ATTENDEE_STATUS_UPDATE; } } } /* if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Attender: ". $attender); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Action: ". $action); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Notification Level: ". $_notificationLevel); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Send Level: ". $sendLevel); */ $recipients = array_merge($recipients, Calendar_Controller_Resource::getInstance()->getNotificationRecipients(Calendar_Controller_Resource::getInstance()->get($attender->user_id))); }
/** * get max period (from) in months (default: 2) * * @return integer */ protected function _getMaxPeriodFrom() { return Calendar_Config::getInstance()->get(Calendar_Config::MAX_FILTER_PERIOD_CALDAV, 2); }
public function testGetChildrenSkipDoubleEvents() { Calendar_Config::getInstance()->set(Calendar_Config::SKIP_DOUBLE_EVENTS, 'personal'); $children = $this->testGetChildren(true); $this->assertEquals(0, count($children)); Calendar_Config::getInstance()->set(Calendar_Config::SKIP_DOUBLE_EVENTS, 'shared'); $children = $this->testGetChildren(true); $this->assertEquals(2, count($children)); }
/** * add period filter if none is given / configure from+until * * @see 0009688: allow to configure default period filter in json frontend */ public function testSearchEventsWithOutPeriodFilterConfiguredFromAndUntil() { Calendar_Config::getInstance()->set(Calendar_Config::MAX_JSON_DEFAULT_FILTER_PERIOD_FROM, 12); $filter = array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId())); $searchResultData = $this->_uit->searchEvents($filter, array()); $now = Tinebase_DateTime::now()->setTime(0, 0, 0); foreach ($searchResultData['filter'] as $filter) { if ($filter['field'] === 'period') { $this->assertEquals($now->getClone()->subYear(1)->toString(), $filter['value']['from']); $this->assertEquals($now->getClone()->addMonth(1)->toString(), $filter['value']['until']); } } }
/** * @param $attender * @param $_notificationLevel * @param $recipients * @param $action * @param $sendLevel * @return bool */ protected function _handleResourceEditors($attender, $_notificationLevel, &$recipients, &$action, &$sendLevel) { // Add additional recipients for resources if ($attender->user_type !== Calendar_Model_Attender::USERTYPE_RESOURCE || !Calendar_Config::getInstance()->get(Calendar_Config::RESOURCE_MAIL_FOR_EDITORS)) { return true; } $resource = Calendar_Controller_Resource::getInstance()->get($attender->user_id); if ($resource->suppress_notification) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Do not send Notifications for this resource: " . $resource->name); } return true; } if ($action == 'created') { $action = 'booked'; } // Consider all notification level (Resource Users have a send level of 30) $sendLevel = self::NOTIFICATION_LEVEL_ATTENDEE_STATUS_UPDATE; $recipients = array_merge($recipients, Calendar_Controller_Resource::getInstance()->getNotificationRecipients(Calendar_Controller_Resource::getInstance()->get($attender->user_id), $_notificationLevel)); }