本文整理汇总了PHP中SugarBean::is_AuditEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::is_AuditEnabled方法的具体用法?PHP SugarBean::is_AuditEnabled怎么用?PHP SugarBean::is_AuditEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarBean
的用法示例。
在下文中一共展示了SugarBean::is_AuditEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuditLog
/**
* This method gets the Audit log and formats it specifically for the API.
* @param type SugarBean $bean
* @return array
*/
public function getAuditLog(SugarBean $bean)
{
global $timedate;
if (!$bean->is_AuditEnabled()) {
return array();
}
$auditTable = $bean->get_audit_table_name();
$query = "SELECT {$auditTable}.*, users.user_name AS created_by_username\n FROM {$auditTable}, users\n WHERE {$auditTable}.created_by = users.id AND {$auditTable}.parent_id = '{$bean->id}'\n ORDER BY {$auditTable}.date_created DESC";
$db = DBManagerFactory::getInstance();
$results = $db->query($query);
if (empty($results)) {
return array();
}
$fieldDefs = $this->fieldDefs;
$return = array();
while ($row = $db->fetchByAssoc($results)) {
if (!ACLField::hasAccess($row['field_name'], $bean->module_dir, $GLOBALS['current_user']->id, $bean->isOwner($GLOBALS['current_user']->id))) {
continue;
}
//convert date
$dateCreated = $timedate->fromDbType($db->fromConvert($row['date_created'], 'datetime'), "datetime");
$row['date_created'] = $timedate->asIso($dateCreated);
//If the team_set_id field has a log entry, we retrieve the list of teams to display
if ($row['field_name'] == 'team_set_id') {
$return[] = $this->handleTeamSetField($row);
continue;
}
// look for opportunities to relate ids to name values.
if (!empty($this->genericAssocFieldsArray[$row['field_name']]) || !empty($this->moduleAssocFieldsArray[$bean->object_name][$row['field_name']])) {
foreach ($fieldDefs as $field) {
if (in_array($field['name'], array('before_value_string', 'after_value_string'))) {
$row[$field['name']] = $this->getAssociatedFieldName($row['field_name'], $row[$field['name']]);
}
}
}
$row = $this->formatRowForApi($row);
$fieldName = $row['field_name'];
$fieldType = $db->getFieldType($bean->field_defs[$row['field_name']]);
switch ($fieldType) {
case 'date':
case 'time':
case 'datetime':
$row['before'] = $this->formatDateTime($row['before'], $fieldType);
$row['after'] = $this->formatDateTime($row['after'], $fieldType);
break;
case 'enum':
case 'multienum':
$row['before'] = explode(',', str_replace('^', '', $row['before']));
$row['after'] = explode(',', str_replace('^', '', $row['after']));
break;
case 'relate':
case 'link':
// get the other side
if (isset($bean->field_defs[$fieldName]['module'])) {
$module = $bean->field_defs[$fieldName]['module'];
$otherSideBeanBefore = BeanFactory::getBean($module, $row['before']);
$otherSideBeanAfter = BeanFactory::getBean($module, $row['after']);
if ($otherSideBeanBefore instanceof SugarBean) {
$row['before'] = $otherSideBeanBefore->get_summary_text();
}
if ($otherSideBeanAfter instanceof SugarBean) {
$row['after'] = $otherSideBeanAfter->get_summary_text();
}
}
break;
}
$return[] = $row;
}
return $return;
}