}
}
});
- })
+ });
});
\ No newline at end of file
#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; }
* - 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>? ';
$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
$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'){
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);
}
}
});
-});
\ No newline at end of file
+ $('#removeBeforeDate').datepicker({
+ dateFormat:'MM d, yy',
+ });
+});
<p>
<span>Show :</span>
<input type="text" maxlength="3" size="3" value="<?php echo $_['size']?>" name='size'/> entries per page.
- <input class="prettybutton" type="submit" value="Save" />
+ <input class="prettybutton" type="submit" name="save" value="Save" />
</p>
</form>
</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'];?>