/** * get preference defaults if no default is found in the database * * @param string $_preferenceName * @param string|Tinebase_Model_User $_accountId * @param string $_accountType * @return Tinebase_Model_Preference */ public function getApplicationPreferenceDefaults($_preferenceName, $_accountId = NULL, $_accountType = Tinebase_Acl_Rights::ACCOUNT_TYPE_USER) { $preference = $this->_getDefaultBasePreference($_preferenceName); switch ($_preferenceName) { case self::DAYSVIEW_STARTTIME: $doc = new DomDocument('1.0'); $options = $doc->createElement('options'); $doc->appendChild($options); $time = new Tinebase_DateTime('@0'); for ($i = 0; $i < 48; $i++) { $time->addMinute($i ? 30 : 0); $timeString = $time->format('H:i'); $value = $doc->createElement('value'); $value->appendChild($doc->createTextNode($timeString)); $label = $doc->createElement('label'); $label->appendChild($doc->createTextNode($timeString)); // @todo l10n $option = $doc->createElement('option'); $option->appendChild($value); $option->appendChild($label); $options->appendChild($option); } $preference->value = '08:00'; $preference->options = $doc->saveXML(); break; case self::DEFAULTCALENDAR: $this->_getDefaultContainerPreferenceDefaults($preference, $_accountId); break; case self::DEFAULTPERSISTENTFILTER: $preference->value = Tinebase_PersistentFilter::getPreferenceValues('Calendar', $_accountId, "All my events"); break; case self::NOTIFICATION_LEVEL: $translate = Tinebase_Translation::getTranslation($this->_application); // need to put the translations strings here because they were not found in the xml below :/ // _('Never') _('On invitation and cancellation only') _('On time changes') _('On all updates but attendee responses') _('On attendee responses too') $preference->value = Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_EVENT_RESCHEDULE; $preference->options = '<?xml version="1.0" encoding="UTF-8"?> <options> <option> <value>' . Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_NONE . '</value> <label>' . $translate->_('Never') . '</label> </option> <option> <value>' . Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_INVITE_CANCEL . '</value> <label>' . $translate->_('On invitation and cancellation only') . '</label> </option> <option> <value>' . Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_EVENT_RESCHEDULE . '</value> <label>' . $translate->_('On time changes') . '</label> </option> <option> <value>' . Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_EVENT_UPDATE . '</value> <label>' . $translate->_('On all updates but attendee responses') . '</label> </option> <option> <value>' . Calendar_Controller_EventNotifications::NOTIFICATION_LEVEL_ATTENDEE_STATUS_UPDATE . '</value> <label>' . $translate->_('On attendee responses too') . '</label> </option> </options>'; break; case self::SEND_NOTIFICATION_OF_OWN_ACTIONS: $preference->value = 0; $preference->options = '<?xml version="1.0" encoding="UTF-8"?> <options> <special>' . Tinebase_Preference_Abstract::YES_NO_OPTIONS . '</special> </options>'; break; default: throw new Tinebase_Exception_NotFound('Default preference with name ' . $_preferenceName . ' not found.'); } return $preference; }