/** * @param $contactID * @param $tableName * @param $tableID * @param null $userID */ static function register($contactID, $tableName, $tableID, $userID = NULL) { if (!self::$_processed) { self::$_processed = array(); } if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } if (!$userID) { $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST'); if ($api_key && strtolower($api_key) != 'null') { $userID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key'); } } if (!$userID) { $userID = $contactID; } if (!$userID) { return; } $log = new CRM_Core_DAO_Log(); $log->id = NULL; if (isset(self::$_processed[$contactID])) { if (isset(self::$_processed[$contactID][$userID])) { $log->id = self::$_processed[$contactID][$userID]; } self::$_processed[$contactID][$userID] = 1; } else { self::$_processed[$contactID] = array($userID => 1); } $logData = "{$tableName},{$tableID}"; if (!$log->id) { $log->entity_table = 'civicrm_contact'; $log->entity_id = $contactID; $log->modified_id = $userID; $log->modified_date = date("YmdHis"); $log->data = $logData; $log->save(); } else { $query = "\nUPDATE civicrm_log\n SET data = concat( data, ':{$logData}' )\n WHERE id = {$log->id}\n"; CRM_Core_DAO::executeQuery($query); } self::$_processed[$contactID][$userID] = $log->id; }
static function register($contactID, $tableName, $tableID, $userID = null) { if (!self::$_processed) { self::$_processed = array(); } if (!$userID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); } if (!$userID) { $userID = $contactID; } if (!$userID) { return; } $log = new CRM_Core_DAO_Log(); $log->id = null; if (isset(self::$_processed[$contactID])) { if (isset(self::$_processed[$contactID][$userID])) { $log->id = self::$_processed[$contactID][$userID]; } self::$_processed[$contactID][$userID] = 1; } else { self::$_processed[$contactID] = array($userID => 1); } $logData = "{$tableName},{$tableID}"; if (!$log->id) { $log->entity_table = 'civicrm_contact'; $log->entity_id = $contactID; $log->modified_id = $userID; $log->modified_date = date("YmdHis"); $log->data = $logData; $log->save(); } else { $query = "\nUPDATE civicrm_log\n SET data = concat( data, ':{$logData}' )\n WHERE id = {$log->id}\n"; CRM_Core_DAO::executeQuery($query); } self::$_processed[$contactID][$userID] = $log->id; }