nextcloud/log/index.php

107 lines
2.9 KiB
PHP
Raw Normal View History

2010-03-10 15:03:40 +03:00
<?php
/**
* ownCloud - ajax frontend
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.com
2010-03-10 15:03:40 +03:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
2010-03-10 15:03:40 +03:00
* version 3 of the License, or any later version.
*
2010-03-10 15:03:40 +03:00
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
2010-03-10 15:03:40 +03:00
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
2010-03-10 15:03:40 +03:00
*/
//require_once('../../config/config.php');
require_once('../lib/base.php');
2011-04-22 01:12:32 +04:00
2011-07-29 23:36:03 +04:00
if( !OC_User::isLoggedIn()){
header( 'Location: '.OC_Helper::linkTo( 'index.php' ));
2011-06-19 20:50:25 +04:00
exit();
}
2011-04-22 01:12:32 +04:00
//load the script
2011-07-29 23:36:03 +04:00
OC_Util::addScript( "log", "log" );
2011-04-22 01:12:32 +04:00
$allActions=array('login','logout','read','write','create','delete');
2011-06-07 23:48:21 +04:00
//check for a submitted config
if(isset($_POST['save'])){
2011-04-22 01:12:32 +04:00
$selectedActions=array();
foreach($allActions as $action){
if(isset($_POST[$action]) and $_POST[$action]=='on'){
$selectedActions[]=$action;
}
}
2011-07-29 23:36:03 +04:00
OC_Preferences::setValue(OC_User::getUser(),'log','actions',implode(',',$selectedActions));
OC_Preferences::setValue(OC_User::getUser(),'log','pagesize',$_POST['size']);
2011-04-22 01:12:32 +04:00
}
2011-06-07 23:48:21 +04:00
//clear log entries
2011-06-19 20:50:25 +04:00
elseif(isset($_POST['clear'])){
$removeBeforeDate=(isset($_POST['removeBeforeDate']))?$_POST['removeBeforeDate']:0;
if($removeBeforeDate!==0){
$removeBeforeDate=strtotime($removeBeforeDate);
2011-07-29 23:36:03 +04:00
OC_Log::deleteBefore($removeBeforeDate);
2011-06-19 20:50:25 +04:00
}
2011-06-07 23:48:21 +04:00
}
2011-06-19 20:50:25 +04:00
elseif(isset($_POST['clearall'])){
2011-07-29 23:36:03 +04:00
OC_Log::deleteAll();
2011-06-07 23:48:21 +04:00
}
2011-04-22 01:12:32 +04:00
2011-07-29 23:36:03 +04:00
OC_App::setActiveNavigationEntry( 'log' );
$logs=OC_Log::get();
2011-04-22 01:12:32 +04:00
2011-06-07 23:48:21 +04:00
2011-07-29 23:36:03 +04:00
$selectedActions=explode(',',OC_Preferences::getValue(OC_User::getUser(),'log','actions',implode(',',$allActions)));
$logs=OC_Log::filterAction($logs,$selectedActions);
2011-04-22 01:12:32 +04:00
2011-07-29 23:36:03 +04:00
$pageSize=OC_Preferences::getValue(OC_User::getUser(),'log','pagesize',20);
2011-04-22 01:12:32 +04:00
$pageCount=ceil(count($logs)/$pageSize);
$page=isset($_GET['page'])?$_GET['page']:0;
if($page>=$pageCount){
$page=$pageCount-1;
}
$logs=array_slice($logs,$page*$pageSize,$pageSize);
foreach( $logs as &$i ){
$i['date'] =$i['moment'];
2011-04-22 01:12:32 +04:00
}
2011-07-29 23:36:03 +04:00
$url=OC_Helper::linkTo( 'log', 'index.php' ).'?page=';
$pager=OC_Util::getPageNavi($pageCount,$page,$url);
2011-04-22 01:12:32 +04:00
if($pager){
$pagerHTML=$pager->fetchPage();
2011-06-19 20:50:25 +04:00
}
else{
2011-04-22 01:12:32 +04:00
$pagerHTML='';
}
$showActions=array();
foreach($allActions as $action){
if(array_search($action,$selectedActions)!==false){
$showActions[$action]='checked="checked"';
2011-06-19 20:50:25 +04:00
}
else{
2011-04-22 01:12:32 +04:00
$showActions[$action]='';
}
}
2010-03-10 15:03:40 +03:00
2011-07-29 23:36:03 +04:00
$tmpl = new OC_Template( 'log', 'index', 'admin' );
2011-04-22 01:12:32 +04:00
$tmpl->assign( 'logs', $logs );
$tmpl->assign( 'pager', $pagerHTML );
$tmpl->assign( 'size', $pageSize );
$tmpl->assign( 'showActions', $showActions );
$tmpl->printPage();
2010-03-10 15:03:40 +03:00
?>