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


PHP Audit::save方法代码示例

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


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

示例1: logAudit

 public static function logAudit($entity, $action, $description)
 {
     $audit = new Audit();
     $audit->date = date('Y-m-d');
     $audit->description = $description;
     $audit->user = Confide::user()->username;
     $audit->entity = $entity;
     $audit->action = $action;
     $audit->save();
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:10,代码来源:Audit.php

示例2: save

 /**
  * Internal function which will create an audit record for the object that was
  * being tracked.
  *
  * @param string $object The name of the object that was being tracked.
  * @param mixed  $object_key The primary key of the object that was being tracked.
  * @param string $changes A (serialized) string containing the individual changes of the object.
  * @param string $query The SQL query that was executed for this record.
  * @param string $type The audit type. This can be one of the following constants: 
  *               TYPE_ADD, TYPE_UPDATE, TYPE_DELETE, or TYPE_SELECT
  * @return void
  */
 private function save($object, $object_key, $changes, $query, $type, $domain_id = 0)
 {
     $audit = new Audit();
     $audit->setRemoteIpAddress($this->getRemoteIP());
     $audit->setObject($object);
     $audit->setObjectKey($object_key);
     $audit->setDomainId($domain_id);
     $audit->setObjectChanges($changes);
     $audit->setQuery($query);
     $audit->setType($type);
     $audit->setCreatedAt(date($this->dateFormat));
     $audit->save();
 }
开发者ID:poliloco,项目名称:pdns-gui,代码行数:25,代码来源:sfPropelAuditBehavior.class.php

示例3: add

 public static function add($target, $action, $data = null, $log_message = null, $properties = array())
 {
     if (!($_target = AuditType::model()->find('name=?', array($target)))) {
         $_target = new AuditType();
         $_target->name = $target;
         if (!$_target->save()) {
             throw new Exception("Unable to save audit target: " . print_r($_target->getErrors(), true));
         }
     }
     if (!($_action = AuditAction::model()->find('name=?', array($action)))) {
         $_action = new AuditAction();
         $_action->name = $action;
         if (!$_action->save()) {
             throw new Exception("Unable to save audit action: " . print_r($_action->getErrors(), true));
         }
     }
     $audit = new Audit();
     $audit->type_id = $_target->id;
     $audit->action_id = $_action->id;
     $audit->data = $data;
     if (!isset($properties['user_id'])) {
         if (Yii::app()->session['user']) {
             $properties['user_id'] = Yii::app()->session['user']->id;
         }
     }
     if (isset($properties['module'])) {
         if ($et = EventType::model()->find('class_name=?', array($properties['module']))) {
             $properties['event_type_id'] = $et->id;
         } else {
             if (!($module = AuditModule::model()->find('name=?', array($properties['module'])))) {
                 $module = new AuditModule();
                 $module->name = $properties['module'];
                 if (!$module->save()) {
                     throw new Exception("Unable to create audit_module: " . print_r($module->getErrors(), true));
                 }
             }
             $properties['module_id'] = $module->id;
         }
         unset($properties['module']);
     }
     if (isset($properties['model'])) {
         if (!($model = AuditModel::model()->find('name=?', array($properties['model'])))) {
             $model = new AuditModel();
             $model->name = $properties['model'];
             if (!$model->save()) {
                 throw new Exception("Unable to save audit_model: " . print_r($model->getErrors(), true));
             }
         }
         $properties['model_id'] = $model->id;
         unset($properties['model']);
     }
     foreach ($properties as $key => $value) {
         $audit->{$key} = $value;
     }
     if (!$audit->save()) {
         throw new Exception("Failed to save audit entry: " . print_r($audit->getErrors(), true));
     }
     if (isset($properties['user_id'])) {
         $username = User::model()->findByPk($properties['user_id'])->username;
     }
     $log_message && OELog::log($log_message, @$username);
     return $audit;
 }
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:63,代码来源:Audit.php

示例4: authenticate

 /**
  * Authenticates a user.
  *
  * Uses either BASIC or LDAP authentication. BASIC authenticates against
  * the openeyes DB. LDAP uses whichever LDAP is specified in the params.php
  * config file.
  *
  * @return boolean whether authentication succeeds.
  * @throws
  */
 public function authenticate($force = false)
 {
     if (!in_array(Yii::app()->params['ldap_method'], array('native', 'zend'))) {
         throw new Exception('Unsupported LDAP authentication method: ' . Yii::app()->params['ldap_method'] . ', please use native or zend.');
     }
     Yii::app()->event->dispatch('user_before_login', array('username' => $this->username));
     /**
      * Usernames are case sensitive
      */
     $user = User::model()->find('username = ?', array($this->username));
     if ($user === null) {
         Audit::add('login', 'login-failed', null, "User not found in local database: {$this->username}");
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     } elseif (!$force && $user->active != 1) {
         $user->audit('login', 'login-failed', null, "User not active and so cannot login: {$this->username}");
         $this->errorCode = self::ERROR_USER_INACTIVE;
         return false;
     } elseif (!$force && !Yii::app()->getAuthManager()->checkAccess('OprnLogin', $user->id)) {
         $user->audit('login', 'login-failed', "User has not been assigned OprnLogin and so cannot login: {$this->username}", true);
         $this->errorCode = self::ERROR_USER_INACTIVE;
         return false;
     }
     if (in_array($user->username, Yii::app()->params['local_users'])) {
         Yii::app()->params['auth_source'] = 'BASIC';
     }
     $this->password = utf8_decode($this->password);
     /**
      * Here we diverge depending on the authentication source.
      */
     if (Yii::app()->params['auth_source'] == 'LDAP') {
         /**
          * Required for LDAP authentication
          */
         if (Yii::app()->params['ldap_method'] == 'zend') {
             Yii::import('application.vendors.*');
             require_once 'Zend/Ldap.php';
             /**
              * Check with LDAP for authentication
              */
             $options = array('host' => Yii::app()->params['ldap_server'], 'port' => Yii::app()->params['ldap_port'], 'username' => Yii::app()->params['ldap_admin_dn'], 'password' => Yii::app()->params['ldap_password'], 'baseDn' => Yii::app()->params['ldap_admin_dn'], 'useStartTls' => false);
             $ldap = $this->getLdap($options);
             /**
              * Try and bind to the login details provided. This indicates if
              * the user is in LDAP.
              */
             try {
                 $ldap->bind("cn=" . $this->username . "," . Yii::app()->params['ldap_dn'], $this->password);
             } catch (Exception $e) {
                 /**
                  * User not authenticated via LDAP
                  */
                 $audit = new Audit();
                 $audit->action = "login-failed";
                 $audit->target_type = "login";
                 $audit->user_id = $user->id;
                 $audit->data = "Login failed for user {$this->username}: LDAP authentication failed: " . $e->getMessage() . ": " . $this->username;
                 $audit->save();
                 OELog::log("Login failed for user {$this->username}: LDAP authentication failed: " . $e->getMessage(), $this->username);
                 $this->errorCode = self::ERROR_USERNAME_INVALID;
                 return false;
             }
             /**
              * User is in LDAP, get their details.
              */
             $info = $ldap->getEntry("cn=" . $this->username . "," . Yii::app()->params['ldap_dn'], array('givenname', 'sn', 'mail'));
         } else {
             if (!($link = ldap_connect(Yii::app()->params['ldap_server']))) {
                 throw new Exception('Unable to connect to LDAP server.');
             }
             ldap_set_option($link, LDAP_OPT_NETWORK_TIMEOUT, Yii::app()->params['ldap_native_timeout']);
             if (!@ldap_bind($link, "cn={$this->username}," . Yii::app()->params['ldap_dn'], $this->password)) {
                 $audit = new Audit();
                 $audit->action = "login-failed";
                 $audit->target_type = "login";
                 $audit->user_id = $user->id;
                 $audit->data = "Login failed for user {$this->username}: LDAP authentication failed: " . ldap_error($link);
                 $audit->save();
                 OELog::log("Login failed for user {$this->username}: LDAP authentication failed: " . ldap_error($link));
                 $this->errorCode = self::ERROR_USERNAME_INVALID;
                 return false;
             }
             $attempts = isset(Yii::app()->params['ldap_info_retries']) ? Yii::app()->params['ldap_info_retries'] : 1;
             for ($i = 0; $i < $attempts; $i++) {
                 if ($i > 0 && isset(Yii::app()->params['ldap_info_retry_delay'])) {
                     sleep(Yii::app()->params['ldap_info_retry_delay']);
                 }
                 $sr = ldap_search($link, "cn={$this->username}," . Yii::app()->params['ldap_dn'], "cn={$this->username}");
                 $info = ldap_get_entries($link, $sr);
                 if (isset($info[0])) {
//.........这里部分代码省略.........
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:101,代码来源:UserIdentity.php

示例5: function

| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
});
App::after(function ($request, $response) {
    //
});
Event::listen('audit', function ($entity, $action, $description) {
    $audit = new Audit();
    $audit->date = date('Y-m-d');
    $audit->description = $description;
    $audit->user = Confide::user()->username;
    $audit->entity = $entity;
    $audit->action = $action;
    $audit->save();
});
Route::filter('limit', function () {
    $organization = Organization::find(1);
    $members = count(Member::all());
    if ($organization->licensed <= $members) {
        return View::make('members.memberlimit');
    }
});
Route::filter('license', function () {
    $organization = Organization::find(1);
    $string = $organization->name;
    $license_key = $organization->license_key;
    $license_code = $organization->license_code;
    $validate = $organization->license_key_validator($license_key, $license_code, $string);
    if ($validate) {
开发者ID:kenkode,项目名称:xaraerp,代码行数:31,代码来源:filters.php

示例6: logAudit

 /**
  * Description: logs an audit on the database, 
  * ¡¡ assumes that there is an active transaction !!
  * @param type $user
  * @param type $dateTime
  * @param type $object
  * @param type $operation
  * @param type $description
  * @throws \Exception
  */
 public function logAudit($user, $dateTime, $object, $operation, $description)
 {
     $a = new Audit();
     $a->description = $description;
     $a->date_time = $dateTime->getTimestamp();
     $a->user = $user;
     $a->object = $object;
     $a->operation = $operation;
     if (!$a->save()) {
         throw new \Exception("Error logging audit: " + CJSON::encode($a->getErrors()));
     }
 }
开发者ID:pelo8888,项目名称:php-angular-yii,代码行数:22,代码来源:Audit.php


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