Adding clear logs functions

remotes/origin/stable
Alessandro Cosentino 14 years ago
parent d65f8bba73
commit 86dd023448
  1. 2
      apps/files_publiclink/js/admin.js
  2. 0
      config/.gitignore
  3. 1
      css/styles.css
  4. 14
      lib/log.php
  5. 18
      log/index.php
  6. 5
      log/js/log.js
  7. 14
      log/templates/index.php

@ -48,5 +48,5 @@ $(document).ready(function() {
}
}
});
})
});
});

@ -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; }

@ -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

@ -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);

@ -18,4 +18,7 @@ $(document).ready(function() {
}
}
});
});
$('#removeBeforeDate').datepicker({
dateFormat:'MM d, yy',
});
});

@ -14,7 +14,7 @@
<p>
<span>Show :</span>
<input type="text" maxlength="3" size="3" value="<?php echo $_['size']?>" name='size'/>&nbsp;entries per page.
<input class="prettybutton" type="submit" value="Save" />
<input class="prettybutton" type="submit" name="save" value="Save" />
</p>
</form>
@ -37,4 +37,16 @@
</tbody>
</table>
<div class="controls">
<form id="logs_options" method='post'>
<p>
<span>Clear log entries before </span>
<input type="date" id="removeBeforeDate" name="removeBeforeDate"/>
<input class="prettybutton nofloat" type="submit" name="clear" value="Clear" />
<input class="prettybutton" type="submit" name="clearall" value="Clear All" />
</p>
</form>
</div>
<?php echo $_['pager'];?>

Loading…
Cancel
Save