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


PHP EventLog::purge方法代码示例

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


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

示例1: ajax_delete_logs

 /**
  * Handles AJAX from /logs.
  * Used to delete logs.
  */
 public function ajax_delete_logs($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $count = 0;
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         Session::error(_t('WSSE authentication failed.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     foreach ($_POST as $id => $delete) {
         // skip POST elements which are not log ids
         if (preg_match('/^p\\d+$/', $id) && $delete) {
             $id = (int) substr($id, 1);
             $ids[] = array('id' => $id);
         }
     }
     if ((!isset($ids) || empty($ids)) && $handler_vars['action'] != 'purge') {
         Session::notice(_t('No logs selected.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     switch ($handler_vars['action']) {
         case 'delete':
             $to_delete = EventLog::get(array('date' => 'any', 'where' => $ids, 'nolimit' => 1));
             foreach ($to_delete as $log) {
                 $log->delete();
                 $count++;
             }
             Session::notice(_t('Deleted %d logs.', array($count)));
             break;
         case 'purge':
             $result = EventLog::purge();
             Session::notice(_t('Logs purged.'));
             break;
     }
     echo Session::messages_get(true, array('Format', 'json_messages'));
 }
开发者ID:ringmaster,项目名称:system,代码行数:42,代码来源:adminlogshandler.php

示例2: fetch_logs

 private function fetch_logs()
 {
     // load all the values for our filter drop-downs
     $dates = $this->fetch_log_dates();
     $users = $this->fetch_log_users();
     $ips = $this->fetch_log_ips();
     extract($this->fetch_log_modules_types());
     // $modules and $types
     $severities = LogEntry::list_severities();
     // parse out the arguments we'll fetch logs for
     // the initial arguments
     $arguments = array('limit' => Controller::get_var('limit', 20), 'offset' => Controller::get_var('offset', 0));
     // filter for the search field
     $search = Controller::get_var('search', '');
     if ($search != '') {
         $arguments['criteria'] = $search;
     }
     // filter by date
     $date = Controller::get_var('date', 'any');
     if ($date != 'any') {
         $d = DateTime::create($date);
         // ! means fill any non-specified pieces with default Unix Epoch ones
         $arguments['year'] = $d->format('Y');
         $arguments['month'] = $d->format('m');
     }
     // filter by user
     $user = Controller::get_var('user', 'any');
     if ($user != 'any') {
         $arguments['user_id'] = $user;
     }
     // filter by ip
     $ip = Controller::get_var('address', 'any');
     if ($ip != 'any') {
         $arguments['ip'] = $ip;
     }
     // filter modules and types
     // @todo get events of a specific type in a specific module, instead of either of the two
     // the interface doesn't currently make any link between module and type, so we won't worry about it for now
     $module = Controller::get_var('module', 'any');
     $type = Controller::get_var('type', 'any');
     if ($module != 'any') {
         // we get a slugified key back, get the actual module name
         $arguments['module'] = $modules[$module];
     }
     if ($type != 'any') {
         // we get a slugified key back, get the actual type name
         $arguments['type'] = $types[$type];
     }
     // filter by severity
     $severity = Controller::get_var('severity', 0);
     if ($severity != 0) {
         $arguments['severity'] = $severity;
     }
     // get the logs!
     $logs = EventLog::get($arguments);
     // last, but not least, generate the list of years used for the timeline
     $months = EventLog::get(array_merge($arguments, array('month_cts' => true)));
     $years = array();
     foreach ($months as $m) {
         $years[$m->year][] = $m;
     }
     // assign all our theme values in one spot
     // first the filter options
     $this->theme->dates = $dates;
     $this->theme->users = $users;
     $this->theme->addresses = $ips;
     $this->theme->modules = $modules;
     $this->theme->types = $types;
     $this->theme->severities = $severities;
     // next the filter criteria we used
     $this->theme->search_args = $search;
     $this->theme->date = $date;
     $this->theme->user = $user;
     $this->theme->address = $ip;
     $this->theme->module = $module;
     $this->theme->type = $type;
     $this->theme->severity = $severity;
     $this->theme->logs = $logs;
     $this->theme->years = $years;
     $form = new FormUI('logs_batch', 'logs_batch');
     $form->append(FormControlAggregate::create('entries')->set_selector('.log_entry')->set_value(array())->label('None Selected'));
     $form->append($actions = FormControlDropbutton::create('actions'));
     $actions->append(FormControlSubmit::create('delete_selected')->on_success(function (FormUI $form) {
         $ids = $form->entries->value;
         $count = 0;
         /** @var LogEntry $log */
         foreach ($ids as $id) {
             $logs = EventLog::get(array('id' => $id));
             foreach ($logs as $log) {
                 $log->delete();
                 $count++;
             }
         }
         Session::notice(_t('Deleted %d logs.', array($count)));
         $form->bounce(false);
     })->set_caption(_t('Delete Selected')));
     $actions->append(FormControlSubmit::create('purge_logs')->on_success(function (FormUI $form) {
         if (EventLog::purge()) {
             Session::notice(_t('Logs purged.'));
         } else {
//.........这里部分代码省略.........
开发者ID:habari,项目名称:system,代码行数:101,代码来源:adminlogshandler.php


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