本文整理汇总了PHP中ModTracker::isTrackingEnabledForModule方法的典型用法代码示例。如果您正苦于以下问题:PHP ModTracker::isTrackingEnabledForModule方法的具体用法?PHP ModTracker::isTrackingEnabledForModule怎么用?PHP ModTracker::isTrackingEnabledForModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModTracker
的用法示例。
在下文中一共展示了ModTracker::isTrackingEnabledForModule方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleEvent
function handleEvent($eventName, $data)
{
global $log, $current_module, $adb, $current_user;
$moduleName = $data->getModuleName();
$flag = ModTracker::isTrackingEnabledForModule($moduleName);
if ($flag) {
if ($eventName == 'vtiger.entity.aftersave.final') {
$recordId = $data->getId();
$columnFields = $data->getData();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
$newerEntity = $vtEntityDelta->getNewEntity($moduleName, $recordId);
$newerColumnFields = $newerEntity->getData();
if (is_array($delta)) {
$inserted = false;
foreach ($delta as $fieldName => $values) {
if ($fieldName != 'modifiedtime') {
if (!$inserted) {
$checkRecordPresentResult = $adb->pquery('SELECT * FROM vtiger_modtracker_basic WHERE
crmid = ?', array($recordId));
if ($adb->num_rows($checkRecordPresentResult)) {
$status = ModTracker::$UPDATED;
} else {
$status = ModTracker::$CREATED;
}
// get modified time from database in case it has been hidden in GUI
$crmrs = $adb->pquery('select modifiedtime from vtiger_crmentity where crmid=?', array($recordId));
$modtime = $adb->query_result($crmrs, 0, 0);
$this->id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($this->id, $recordId, $moduleName, $current_user->id, $modtime, $status));
$inserted = true;
}
$adb->pquery('INSERT INTO vtiger_modtracker_detail(id,fieldname,prevalue,postvalue) VALUES(?,?,?,?)', array($this->id, $fieldName, $values['oldValue'], $values['currentValue']));
}
}
}
}
if ($eventName == 'vtiger.entity.beforedelete') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($id, $recordId, $moduleName, $current_user->id, date('Y-m-d H:i:s', time()), ModTracker::$DELETED));
}
if ($eventName == 'vtiger.entity.afterrestore') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($id, $recordId, $moduleName, $current_user->id, date('Y-m-d H:i:s', time()), ModTracker::$RESTORED));
}
}
}
示例2: transferRecordsOwnership
public function transferRecordsOwnership($module, $transferOwnerId, $relatedModuleRecordIds)
{
$currentUser = vglobal('current_user');
$db = PearDatabase::getInstance();
$db->update('vtiger_crmentity', ['smownerid' => $transferOwnerId, 'modifiedby' => $currentUser->id, 'modifiedtime' => date('Y-m-d H:i:s')], 'crmid IN (' . implode(',', $relatedModuleRecordIds) . ')');
vimport('~modules/ModTracker/ModTracker.php');
$flag = ModTracker::isTrackingEnabledForModule($module);
if ($flag) {
foreach ($relatedModuleRecordIds as $record) {
$id = $db->getUniqueID('vtiger_modtracker_basic');
$query = 'INSERT INTO vtiger_modtracker_basic ( id, whodid, whodidsu, changedon, crmid, module ) SELECT ? , ? , ?, ?, crmid, setype FROM vtiger_crmentity WHERE crmid = ?';
$db->pquery($query, [$id, $currentUser->id, Vtiger_Session::get('baseUserId'), date('Y-m-d H:i:s', time()), $record]);
$query = 'INSERT INTO vtiger_modtracker_detail ( id, fieldname, postvalue , prevalue ) SELECT ? , ? ,? , smownerid FROM vtiger_crmentity WHERE crmid = ?';
$db->pquery($query, [$id, 'assigned_user_id', $currentUser->id, $record]);
}
}
}
示例3: isTrackingEnabled
/**
* Function checks if the module is enabled for tracking changes
* @return <Boolean>
*/
public function isTrackingEnabled()
{
require_once 'modules/ModTracker/ModTracker.php';
$trackingEnabled = ModTracker::isTrackingEnabledForModule($this->getName());
return $this->isActive() && $trackingEnabled;
}
示例4: handleEvent
function handleEvent($eventName, $data)
{
$adb = PearDatabase::getInstance();
$current_user = vglobal('current_user');
$log = vglobal('log');
$current_module = vglobal('current_module');
if (!is_object($data)) {
$extendedData = $data;
$data = $extendedData['entityData'];
}
$moduleName = $data->getModuleName();
$flag = ModTracker::isTrackingEnabledForModule($moduleName);
if ($flag) {
if ($eventName == 'vtiger.entity.aftersave.final') {
$recordId = $data->getId();
$columnFields = $data->getData();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
$newerEntity = $vtEntityDelta->getNewEntity($moduleName, $recordId);
$newerColumnFields = $newerEntity->getData();
$newerColumnFields = array_change_key_case($newerColumnFields, CASE_LOWER);
$delta = array_change_key_case($delta, CASE_LOWER);
if (is_array($delta)) {
$inserted = false;
foreach ($delta as $fieldName => $values) {
if ($fieldName != 'modifiedtime') {
if (!$inserted) {
$checkRecordPresentResult = $adb->pquery('SELECT * FROM vtiger_modtracker_basic WHERE crmid = ?', array($recordId));
if (!$adb->num_rows($checkRecordPresentResult) && $data->isNew()) {
$status = ModTracker::$CREATED;
} else {
$status = ModTracker::$UPDATED;
}
$this->id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->insert('vtiger_modtracker_basic', ['id' => $this->id, 'crmid' => $recordId, 'module' => $moduleName, 'whodid' => $current_user->id, 'changedon' => $newerColumnFields['modifiedtime'], 'status' => $status, 'whodidsu' => Vtiger_Session::get('baseUserId')]);
$inserted = true;
}
$adb->pquery('INSERT INTO vtiger_modtracker_detail(id,fieldname,prevalue,postvalue) VALUES(?,?,?,?)', array($this->id, $fieldName, $values['oldValue'], $values['currentValue']));
}
}
}
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
if ($eventName == 'vtiger.entity.beforedelete') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->insert('vtiger_modtracker_basic', ['id' => $id, 'crmid' => $recordId, 'module' => $moduleName, 'whodid' => $current_user->id, 'changedon' => date('Y-m-d H:i:s', time()), 'status' => ModTracker::$DELETED, 'whodidsu' => Vtiger_Session::get('baseUserId')]);
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
if ($eventName == 'vtiger.entity.afterrestore') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->insert('vtiger_modtracker_basic', ['id' => $id, 'crmid' => $recordId, 'module' => $moduleName, 'whodid' => $current_user->id, 'changedon' => date('Y-m-d H:i:s', time()), 'status' => ModTracker::$RESTORED, 'whodidsu' => Vtiger_Session::get('baseUserId')]);
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
if ($eventName == 'vtiger.entity.link.after') {
ModTracker::linkRelation($extendedData['sourceModule'], $extendedData['sourceRecordId'], $extendedData['destinationModule'], $extendedData['destinationRecordId']);
}
if ($eventName == 'vtiger.entity.unlink.after') {
ModTracker::unLinkRelation($extendedData['sourceModule'], $extendedData['sourceRecordId'], $extendedData['destinationModule'], $extendedData['destinationRecordId']);
}
}
}
示例5: vtws_history
function vtws_history($element, $user)
{
$MAXLIMIT = 100;
$adb = PearDatabase::getInstance();
// Mandatory input validation
if (empty($element['module']) && empty($element['record'])) {
throw new WebServiceException(WebServiceErrorCode::$MANDFIELDSMISSING, "Missing mandatory input values.");
}
if (!CRMEntity::getInstance('ModTracker') || !vtlib_isModuleActive('ModTracker')) {
throw new WebServiceException("TRACKING_MODULE_NOT_ACTIVE", "Tracking module not active.");
}
$idComponents = NULL;
$moduleName = $element['module'];
$record = $element['record'];
$mode = empty($element['mode']) ? 'Private' : $element['mode'];
// Private or All
$page = empty($element['page']) ? 0 : intval($element['page']);
// Page to start
$acrossAllModule = false;
if ($moduleName == 'Home') {
$acrossAllModule = true;
}
// Pre-condition check
if (empty($moduleName)) {
$moduleName = Mobile_WS_Utils::detectModulenameFromRecordId($record);
$idComponents = vtws_getIdComponents($record);
// We have it - as the input is validated.
}
if (!$acrossAllModule && !ModTracker::isTrackingEnabledForModule($moduleName)) {
throw new WebServiceException("Module_NOT_TRACKED", "Module not tracked for changes.");
}
// Per-condition has been met, perform the operation
$sql = '';
$params = array();
// REFER: modules/ModTracker/ModTracker.php
// Two split phases for data extraction - so we can apply limit of retrieveal at record level.
$sql = 'SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic
INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid
AND vtiger_crmentity.deleted = 0';
if ($mode == 'Private') {
$sql .= ' WHERE vtiger_modtracker_basic.whodid = ?';
$params[] = $user->getId();
} else {
if ($mode == 'All') {
if ($acrossAllModule) {
// TODO collate only active (or enabled) modules for tracking.
} else {
if ($moduleName) {
$sql .= ' WHERE vtiger_modtracker_basic.module = ?';
$params[] = $moduleName;
} else {
$sql .= ' WHERE vtiger_modtracker_basic.crmid = ?';
$params[] = $idComponents[1];
}
}
}
}
// Get most recently tracked changes with limit
$start = $page * $MAXLIMIT;
if ($start > 0) {
$start = $start + 1;
}
// Adjust the start range
$sql .= sprintf(' ORDER BY vtiger_modtracker_basic.id DESC LIMIT %s,%s', $start, $MAXLIMIT);
$result = $adb->pquery($sql, $params);
$recordValuesMap = array();
$orderedIds = array();
while ($row = $adb->fetch_array($result)) {
$orderedIds[] = $row['id'];
$whodid = vtws_history_entityIdHelper('Users', $row['whodid']);
$crmid = vtws_history_entityIdHelper($acrossAllModule ? '' : $moduleName, $row['crmid']);
$status = $row['status'];
$statuslabel = '';
switch ($status) {
case ModTracker::$UPDATED:
$statuslabel = 'updated';
break;
case ModTracker::$DELETED:
$statuslabel = 'deleted';
break;
case ModTracker::$CREATED:
$statuslabel = 'created';
break;
case ModTracker::$RESTORED:
$statuslabel = 'restored';
break;
case ModTracker::$LINK:
$statuslabel = 'link';
break;
case ModTracker::$UNLINK:
$statuslabel = 'unlink';
break;
}
$item['modifieduser'] = $whodid;
$item['id'] = $crmid;
$item['modifiedtime'] = $row['changedon'];
$item['status'] = $status;
$item['statuslabel'] = $statuslabel;
$item['values'] = array();
$recordValuesMap[$row['id']] = $item;
//.........这里部分代码省略.........
示例6: handleEvent
function handleEvent($eventName, $data)
{
global $log, $current_module, $adb, $current_user;
$moduleName = $data->getModuleName();
$flag = ModTracker::isTrackingEnabledForModule($moduleName);
if ($flag) {
if ($eventName == 'vtiger.entity.aftersave.final') {
$recordId = $data->getId();
$columnFields = $data->getData();
$vtEntityDelta = new VTEntityDelta();
$delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
$newerEntity = $vtEntityDelta->getNewEntity($moduleName, $recordId);
$newerColumnFields = $newerEntity->getData();
$newerColumnFields = array_change_key_case($newerColumnFields, CASE_LOWER);
$delta = array_change_key_case($delta, CASE_LOWER);
if (is_array($delta)) {
$inserted = false;
foreach ($delta as $fieldName => $values) {
if ($fieldName != 'modifiedtime') {
if (!$inserted) {
$checkRecordPresentResult = $adb->pquery('SELECT * FROM vtiger_modtracker_basic WHERE
crmid = ?', array($recordId));
if (!$adb->num_rows($checkRecordPresentResult) && $data->isNew()) {
$status = ModTracker::$CREATED;
} else {
$status = ModTracker::$UPDATED;
}
$this->id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($this->id, $recordId, $moduleName, $current_user->id, $newerColumnFields['modifiedtime'], $status));
$inserted = true;
}
$adb->pquery('INSERT INTO vtiger_modtracker_detail(id,fieldname,prevalue,postvalue) VALUES(?,?,?,?)', array($this->id, $fieldName, $values['oldValue'], $values['currentValue']));
}
}
}
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
if ($eventName == 'vtiger.entity.beforedelete') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($id, $recordId, $moduleName, $current_user->id, date('Y-m-d H:i:s', time()), ModTracker::$DELETED));
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
if ($eventName == 'vtiger.entity.afterrestore') {
$recordId = $data->getId();
$columnFields = $data->getData();
$id = $adb->getUniqueId('vtiger_modtracker_basic');
$adb->pquery('INSERT INTO vtiger_modtracker_basic(id, crmid, module, whodid, changedon, status)
VALUES(?,?,?,?,?,?)', array($id, $recordId, $moduleName, $current_user->id, date('Y-m-d H:i:s', time()), ModTracker::$RESTORED));
$isMyRecord = $adb->pquery('SELECT crmid FROM vtiger_crmentity WHERE smownerid <> ? AND crmid = ?', array($current_user->id, $recordId));
if ($adb->num_rows($isMyRecord) > 0) {
$adb->pquery("UPDATE vtiger_crmentity SET was_read = 0 WHERE crmid = ?;", array($recordId));
}
}
}
}