Example #1
0
 /**
  * update modlog / metadata / add systemnote for multiple records defined by filter
  * 
  * @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;
     }
     list($currentAccountId, $currentTime) = Tinebase_Timemachine_ModificationLog::getCurrentAccountIdAndTime();
     $updateMetaData = array('last_modified_by' => $currentAccountId, 'last_modified_time' => $currentTime);
     $this->_backend->updateMultiple($ids, $updateMetaData);
     if ($this->_omitModLog !== TRUE) {
         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->_backend->getType(), $updateMetaData);
         Tinebase_Notes::getInstance()->addMultipleModificationSystemNotes($currentMods, $currentAccountId);
     }
 }
 /**
  * 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);
         /** @noinspection PhpUndefinedVariableInspection */
         Tinebase_Notes::getInstance()->addMultipleModificationSystemNotes($currentMods, $currentAccountId, $this->_modelName);
     }
 }