当前位置: 首页>>代码示例>>PHP>>正文


PHP SugarBean::get_audit_table_name方法代码示例

本文整理汇总了PHP中SugarBean::get_audit_table_name方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::get_audit_table_name方法的具体用法?PHP SugarBean::get_audit_table_name怎么用?PHP SugarBean::get_audit_table_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SugarBean的用法示例。


在下文中一共展示了SugarBean::get_audit_table_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: auditSQL

 /**
  * Generate query for audit table
  * @param SugarBean $bean SugarBean that was changed
  * @param array $changes List of changes, contains 'before' and 'after'
  * @return string  Audit table INSERT query
  */
 protected function auditSQL(SugarBean $bean, $changes)
 {
     global $current_user;
     $sql = "INSERT INTO " . $bean->get_audit_table_name();
     //get field defs for the audit table.
     require 'metadata/audit_templateMetaData.php';
     $fieldDefs = $dictionary['audit']['fields'];
     $values = array();
     $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']);
     $values['parent_id'] = $this->massageValue($bean->id, $fieldDefs['parent_id']);
     $values['field_name'] = $this->massageValue($changes['field_name'], $fieldDefs['field_name']);
     $values['data_type'] = $this->massageValue($changes['data_type'], $fieldDefs['data_type']);
     if ($changes['data_type'] == 'text') {
         $values['before_value_text'] = $this->massageValue($changes['before'], $fieldDefs['before_value_text']);
         $values['after_value_text'] = $this->massageValue($changes['after'], $fieldDefs['after_value_text']);
     } else {
         $values['before_value_string'] = $this->massageValue($changes['before'], $fieldDefs['before_value_string']);
         $values['after_value_string'] = $this->massageValue($changes['after'], $fieldDefs['after_value_string']);
     }
     $values['date_created'] = $this->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created']);
     $values['created_by'] = $this->massageValue($current_user->id, $fieldDefs['created_by']);
     $sql .= "(" . implode(",", array_keys($values)) . ") ";
     $sql .= "VALUES(" . implode(",", $values) . ")";
     return $sql;
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:31,代码来源:DBManager.php

示例2: 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;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:75,代码来源:Audit.php

示例3: save_audit_records

 /**
  * Saves changes to module's audit table
  *
  * @param object $bean    Sugarbean instance
  * @param array  $changes changes
  * @see DBHelper::getDataChanges()
  */
 public function save_audit_records(SugarBean $bean, $changes)
 {
     global $current_user;
     $sql = "INSERT INTO " . $bean->get_audit_table_name();
     //get field defs for the audit table.
     require 'metadata/audit_templateMetaData.php';
     $fieldDefs = $dictionary['audit']['fields'];
     $values = array();
     $values['id'] = $this->massageValue(create_guid(), $fieldDefs['id']);
     $values['parent_id'] = $bean->dbManager->getHelper()->massageValue($bean->id, $fieldDefs['parent_id']);
     $values['field_name'] = $bean->dbManager->getHelper()->massageValue($changes['field_name'], $fieldDefs['field_name']);
     $values['data_type'] = $bean->dbManager->getHelper()->massageValue($changes['data_type'], $fieldDefs['data_type']);
     if ($changes['data_type'] == 'text') {
         $bean->fetched_row[$changes['field_name']] = $changes['after'];
         $values['before_value_text'] = $bean->dbManager->getHelper()->massageValue($changes['before'], $fieldDefs['before_value_text']);
         $values['after_value_text'] = $bean->dbManager->getHelper()->massageValue($changes['after'], $fieldDefs['after_value_text']);
     } else {
         $bean->fetched_row[$changes['field_name']] = $changes['after'];
         $values['before_value_string'] = $bean->dbManager->getHelper()->massageValue($changes['before'], $fieldDefs['before_value_string']);
         $values['after_value_string'] = $bean->dbManager->getHelper()->massageValue($changes['after'], $fieldDefs['after_value_string']);
     }
     $values['date_created'] = $bean->dbManager->getHelper()->massageValue(TimeDate::getInstance()->nowDb(), $fieldDefs['date_created']);
     $values['created_by'] = $bean->dbManager->getHelper()->massageValue($current_user->id, $fieldDefs['created_by']);
     $sql .= "(" . implode(",", array_keys($values)) . ") ";
     $sql .= "VALUES(" . implode(",", $values) . ")";
     if ($this->db->dbType == 'oci8' && $changes['data_type'] == 'text') {
         $sql .= " RETURNING before_value_text, after_value_text INTO :before_value_text, :after_value_text";
         $stmt = oci_parse($this->db->getDatabase(), $sql);
         $err = oci_error($this->db->getDatabase());
         if ($err != false) {
             $GLOBALS['log']->fatal($sql . ">>" . $err['code'] . ":" . $err['message']);
             return false;
         }
         $before_value_text_LOB = oci_new_descriptor($this->db->getDatabase(), OCI_D_LOB);
         oci_bind_by_name($stmt, ":before_value_text", $before_value_text_LOB, -1, OCI_B_CLOB);
         $after_value_text_LOB = oci_new_descriptor($this->db->getDatabase(), OCI_D_LOB);
         oci_bind_by_name($stmt, ":after_value_text", $after_value_text_LOB, -1, OCI_B_CLOB);
         oci_execute($stmt, OCI_DEFAULT);
         $err = oci_error($this->db->getDatabase());
         if ($err != false) {
             $GLOBALS['log']->fatal($sql . ">>" . $err['code'] . ":" . $err['message']);
             return false;
         }
         $before_value_text_LOB->save($changes['before']);
         $after_value_text_LOB->save($changes['after']);
         oci_commit($this->db->getDatabase());
         $before_value_text_LOB->free();
         $after_value_text_LOB->free();
         oci_free_statement($stmt);
     } else {
         $bean->db->query($sql);
     }
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:60,代码来源:DBHelper.php


注:本文中的SugarBean::get_audit_table_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。