/**
  * update modlog / metadata / add systemnote for multiple records defined by filter
  * 
  * NOTE: this should be done in a transaction because of the concurrency handling as
  *  we want the same seq in the record and in the modlog
  * 
  * @param Tinebase_Model_Filter_FilterGroup|array $_filterOrIds
  * @param array $_oldData
  * @param array $_newData
  */
 public function concurrencyManagementAndModlogMultiple($_filterOrIds, $_oldData, $_newData)
 {
     $ids = $_filterOrIds instanceof Tinebase_Model_Filter_FilterGroup ? $this->search($_filterOrIds, NULL, FALSE, TRUE, 'update') : $_filterOrIds;
     if (!is_array($ids) || count($ids) === 0) {
         return;
     }
     if ($this->_omitModLog !== TRUE) {
         $recordSeqs = $this->_backend->getPropertyByIds($ids, 'seq');
         list($currentAccountId, $currentTime) = Tinebase_Timemachine_ModificationLog::getCurrentAccountIdAndTime();
         $updateMetaData = array('last_modified_by' => $currentAccountId, 'last_modified_time' => $currentTime, 'seq' => new Zend_Db_Expr('seq + 1'), 'recordSeqs' => $recordSeqs);
     } else {
         $updateMetaData = array();
     }
     $this->_backend->updateMultiple($ids, $updateMetaData);
     if ($this->_omitModLog !== TRUE && is_object(Tinebase_Core::getUser())) {
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Writing modlog for ' . count($ids) . ' records ...');
         }
         $currentMods = Tinebase_Timemachine_ModificationLog::getInstance()->writeModLogMultiple($ids, $_oldData, $_newData, $this->_modelName, $this->_getBackendType(), $updateMetaData);
         Tinebase_Notes::getInstance()->addMultipleModificationSystemNotes($currentMods, $currentAccountId, $this->_modelName);
     }
 }
Example #2
0
 /**
  * creates a common modlog record
  * 
  * @param string $_model
  * @param string $_backend
  * @param array $_updateMetaData
  * @param string $_recordId
  * @return Tinebase_Model_ModificationLog
  */
 protected function _getCommonModlog($_model, $_backend, $_updateMetaData = array(), $_recordId = NULL)
 {
     if (empty($_updateMetaData)) {
         list($currentAccountId, $currentTime) = Tinebase_Timemachine_ModificationLog::getCurrentAccountIdAndTime();
     } else {
         $currentAccountId = $_updateMetaData['last_modified_by'];
         $currentTime = $_updateMetaData['last_modified_time'];
     }
     list($appName, $i, $modelName) = explode('_', $_model);
     $commonModLogEntry = new Tinebase_Model_ModificationLog(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName($appName)->getId(), 'record_id' => $_recordId, 'record_type' => $_model, 'record_backend' => $_backend, 'modification_time' => $currentTime, 'modification_account' => $currentAccountId), TRUE);
     return $commonModLogEntry;
 }