/**
  * get by id
  *
  * @param string $_id
  * @return Tinebase_Record_RecordSet
  * @throws  Tinebase_Exception_AccessDenied
  */
 public function get($_id)
 {
     $configRecord = $this->_configBackend->get($_id);
     $app = Tinebase_Application::getInstance()->getApplicationById($configRecord->application_id);
     if (!Tinebase_Core::getUser()->hasRight($app->name, 'admin')) {
         throw new Tinebase_Exception_AccessDenied("You do not have admin rights for {$app->name}");
     }
     $appConfigObject = Tinebase_Config::getAppConfig($app->name);
     $definition = $appConfigObject->getDefinition($configRecord->name);
     $this->_mergeDefinition($configRecord, $definition);
     $configRecord->source = Tinebase_Model_Config::SOURCE_DB;
     return $configRecord;
 }
 /**
  * persist vacation data in db
  */
 protected function _saveVacation()
 {
     if (empty($this->_vacation)) {
         return;
     }
     $vacationRecord = new Expressomail_Model_Sieve_Vacation();
     $vacationRecord->setFromFSV($this->_vacation);
     $vacationRecord->account_id = $this->_accountId;
     $vacationRecord->setId($this->_accountId);
     $vacationRecord->addresses = Zend_Json::encode($vacationRecord->addresses);
     try {
         $oldVac = $this->_vacationBackend->get($vacationRecord->getId());
         $this->_vacationBackend->update($vacationRecord);
     } catch (Tinebase_Exception_NotFound $tenf) {
         $this->_vacationBackend->create($vacationRecord);
     }
 }
 /**
  * persist vacation data in db
  */
 protected function _saveVacation()
 {
     if (empty($this->_vacation)) {
         return;
     }
     $vacationRecord = new Felamimail_Model_Sieve_Vacation();
     $vacationRecord->setFromFSV($this->_vacation);
     $vacationRecord->account_id = $this->_accountId;
     $vacationRecord->setId($this->_accountId);
     $vacationRecord->addresses = Zend_Json::encode($vacationRecord->addresses);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Saving vacation in DB: ' . print_r($vacationRecord->toArray(), TRUE));
     }
     try {
         $oldVac = $this->_vacationBackend->get($vacationRecord->getId());
         $this->_vacationBackend->update($vacationRecord);
     } catch (Tinebase_Exception_NotFound $tenf) {
         $this->_vacationBackend->create($vacationRecord);
     }
 }
 /**
  * update to 8.3
  * - normalize all rrules
  */
 public function update_2()
 {
     // find all events with rrule
     $eventIds = $this->_db->query("SELECT " . $this->_db->quoteIdentifier('id') . " FROM " . $this->_db->quoteIdentifier(SQL_TABLE_PREFIX . "cal_events") . " WHERE " . $this->_db->quoteIdentifier("rrule") . " IS NOT NULL")->fetchAll(Zend_Db::FETCH_ASSOC);
     // NOTE: we need a generic sql BE to circumvent calendar specific acl issues
     $eventBE = new Tinebase_Backend_Sql(array('modelName' => 'Calendar_Model_Event', 'tableName' => 'cal_events', 'modlogActive' => false));
     foreach ($eventIds as $eventId) {
         $event = $eventBE->get($eventId['id']);
         $oldRruleString = (string) $event->rrule;
         $rrule = Calendar_Model_Rrule::getRruleFromString($oldRruleString);
         $rrule->normalize($event);
         if ($oldRruleString != (string) $rrule) {
             $event->rrule = (string) $rrule;
             try {
                 $eventBE->update($event);
             } catch (Tinebase_Exception_Record_Validation $terv) {
                 Tinebase_Exception::log($terv, null, $event->toArray());
             } catch (Tinebase_Exception_UnexpectedValue $teuv) {
                 Tinebase_Exception::log($teuv, null, $event->toArray());
             }
         }
     }
     $this->setApplicationVersion('Calendar', '8.3');
 }