/** * update one record * * @param Tinebase_Record_Interface $_record * @param boolean $_duplicateCheck * @return Tinebase_Record_Interface * @throws Tinebase_Exception_AccessDenied * * @todo fix duplicate check on update / merge needs to remove the changed record / ux discussion */ public function update(Tinebase_Record_Interface $_record, $_duplicateCheck = TRUE) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . ' Record to update: ' . print_r($_record->toArray(), TRUE)); } if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Update ' . $this->_modelName); } $db = method_exists($this->_backend, 'getAdapter') ? $this->_backend->getAdapter() : Tinebase_Core::getDb(); try { $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db); $_record->isValid(TRUE); $currentRecord = $this->get($_record->getId()); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Current record: ' . print_r($currentRecord->toArray(), TRUE)); } // add _doForceModlogInfo behavior $origRecord = clone $_record; $this->_updateACLCheck($_record, $currentRecord); $this->_concurrencyManagement($_record, $currentRecord); $this->_forceModlogInfo($_record, $origRecord, 'update'); $this->_inspectBeforeUpdate($_record, $currentRecord); // NOTE removed the duplicate check because we can not remove the changed record yet // if ($_duplicateCheck) { // $this->_duplicateCheck($_record); // } $updatedRecord = $this->_backend->update($_record); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Updated record: ' . print_r($updatedRecord->toArray(), TRUE)); } $this->_inspectAfterUpdate($updatedRecord, $_record, $currentRecord); $updatedRecordWithRelatedData = $this->_setRelatedData($updatedRecord, $_record, TRUE); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Updated record with related data: ' . print_r($updatedRecordWithRelatedData->toArray(), TRUE)); } $currentMods = $this->_writeModLog($updatedRecordWithRelatedData, $currentRecord); $this->_setNotes($updatedRecordWithRelatedData, $_record, Tinebase_Model_Note::SYSTEM_NOTE_NAME_CHANGED, $currentMods); if ($this->_sendNotifications && count($currentMods) > 0) { $this->doSendNotifications($updatedRecordWithRelatedData, Tinebase_Core::getUser(), 'changed', $currentRecord); } if ($_record->has('container_id') && $currentRecord->container_id !== $updatedRecord->container_id) { $this->_increaseContainerContentSequence($currentRecord, Tinebase_Model_ContainerContent::ACTION_DELETE); $this->_increaseContainerContentSequence($updatedRecord, Tinebase_Model_ContainerContent::ACTION_CREATE); } else { $this->_increaseContainerContentSequence($updatedRecord, Tinebase_Model_ContainerContent::ACTION_UPDATE); } Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId); } catch (Exception $e) { $this->_handleRecordCreateOrUpdateException($e); } if ($this->_clearCustomFieldsCache) { Tinebase_Core::getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('customfields')); } return $this->get($updatedRecord->getId()); }