From: Alessandro Cosentino Date: Tue, 7 Jun 2011 19:48:21 +0000 (-0400) Subject: Adding clear logs functions X-Git-Tag: v3.0~267^2~542 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=86dd023448a1aed54a076df9533ecdf50c4dcd97;p=nextcloud-server.git Adding clear logs functions --- diff --git a/apps/files_publiclink/js/admin.js b/apps/files_publiclink/js/admin.js index 017c62cb42a..9a0bad604a2 100644 --- a/apps/files_publiclink/js/admin.js +++ b/apps/files_publiclink/js/admin.js @@ -48,5 +48,5 @@ $(document).ready(function() { } } }); - }) + }); }); \ No newline at end of file diff --git a/config/.gitignore b/config/.gitignore old mode 100644 new mode 100755 diff --git a/css/styles.css b/css/styles.css index 2790c5c0492..5027a6b6fe9 100644 --- a/css/styles.css +++ b/css/styles.css @@ -269,6 +269,7 @@ p.actions a.delete, div.actions a.delete { background-image:url('../img/delete.p #logs_options span { margin:0 2em 0 0.5em; font-weight:bold; } #logs_options label { margin:0 1em 0 0; } #logs_options input[type="submit"] { float:right; margin:0 2em 0 0; } +#logs_options input[type="submit"].nofloat { float:none; margin:0 2em 0 0; } #logs_options input[type="text"] { margin:0; padding:0; border:1px solid #ccc; text-align:right; } li.error{ list-style:none; width:640px; margin:4em auto; padding:1em 1em 1em 4em; background-color:#fee; background-image:url('../img/task-attention.png'); background-position:0.8em 0.8em; background-repeat:no-repeat; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } diff --git a/lib/log.php b/lib/log.php index aebeba7d4b3..894575ef059 100644 --- a/lib/log.php +++ b/lib/log.php @@ -79,7 +79,7 @@ class OC_LOG { * - app: only entries for this app */ public static function get( $filter = array()){ - $queryString='SELECT * FROM *PREFIX*log WHERE 1=1 '; + $queryString='SELECT * FROM *PREFIX*log WHERE 1=1 ORDER BY moment DESC'; $params=array(); if(isset($filter['from'])){ $queryString.='AND moment>? '; @@ -120,6 +120,18 @@ class OC_LOG { $query->execute(array($date)); return true; } + + /** + * @brief removes all log entries + * @returns true/false + * + * This function deletes all log entries. + */ + public static function deleteAll(){ + $query=OC_DB::prepare("DELETE FROM *PREFIX*log"); + $query->execute(); + return true; + } /** * @brief filter an array of log entries on action diff --git a/log/index.php b/log/index.php index 675396a4d10..db476b85605 100644 --- a/log/index.php +++ b/log/index.php @@ -37,8 +37,10 @@ OC_UTIL::addScript( "log", "log" ); $allActions=array('login','logout','read','write','create','delete'); -//check for a submited config -if(isset($_POST['size'])){ +$removeBeforeDate = 0; + +//check for a submitted config +if(isset($_POST['save'])){ $selectedActions=array(); foreach($allActions as $action){ if(isset($_POST[$action]) and $_POST[$action]=='on'){ @@ -48,10 +50,22 @@ if(isset($_POST['size'])){ OC_PREFERENCES::setValue($_SESSION['user_id'],'log','actions',implode(',',$selectedActions)); OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']); } +//clear log entries +else if(isset($_POST['clear'])){ + $removeBeforeDate=(isset($_POST['removeBeforeDate']))?$_POST['removeBeforeDate']:0; + if($removeBeforeDate!==0){ + $removeBeforeDate=strtotime($removeBeforeDate); + OC_LOG::deleteBefore($removeBeforeDate); + } +} +else if(isset($_POST['clearall'])){ + OC_LOG::deleteAll(); +} OC_APP::setActiveNavigationEntry( 'log' ); $logs=OC_LOG::get(); + $selectedActions=explode(',',OC_PREFERENCES::getValue($_SESSION['user_id'],'log','actions',implode(',',$allActions))); $logs=OC_LOG::filterAction($logs,$selectedActions); diff --git a/log/js/log.js b/log/js/log.js index 47c20b3e860..5ec75b94f4b 100644 --- a/log/js/log.js +++ b/log/js/log.js @@ -18,4 +18,7 @@ $(document).ready(function() { } } }); -}); \ No newline at end of file + $('#removeBeforeDate').datepicker({ + dateFormat:'MM d, yy', + }); +}); diff --git a/log/templates/index.php b/log/templates/index.php index 1e294091e3f..efd32ca057a 100644 --- a/log/templates/index.php +++ b/log/templates/index.php @@ -14,7 +14,7 @@

Show :  entries per page. - +

@@ -37,4 +37,16 @@ +
+
+

+ Clear log entries before + + + + +

+
+
+