diff options
Diffstat (limited to 'lib/log.php')
-rw-r--r-- | lib/log.php | 125 |
1 files changed, 70 insertions, 55 deletions
diff --git a/lib/log.php b/lib/log.php index f2f935b466b..289ab18faba 100644 --- a/lib/log.php +++ b/lib/log.php @@ -1,75 +1,90 @@ <?php - /** -* ownCloud -* -* @author Frank Karlitschek -* @copyright 2010 Frank Karlitschek karlitschek@kde.org -* -* 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 -* version 3 of the License, or any later version. -* -* 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 -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ - + * ownCloud + * + * @author Frank Karlitschek + * @author Jakob Sack + * @copyright 2010 Frank Karlitschek karlitschek@kde.org + * + * 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 + * version 3 of the License, or any later version. + * + * 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 + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ +/* + * + * The following SQL statement is just a help for developers and will not be + * executed! + * + * CREATE TABLE `log` ( + * `id` INT PRIMARY KEY AUTO INCREMENT, + * `timestamp` DATETIME NOT NULL, + * `appid` VARCHAR( 255 ) NOT NULL , + * `subject` VARCHAR( 255 ), + * `predicate` VARCHAR( 255 ), + * `object` TEXT + * ) + * + */ /** - * Class for logging features - * + * This class is for logging */ class OC_LOG { - /** - * array to define different log types + * @brief adds an entry to the log + * @param $appid id of the app + * @param $subject username + * @param $predicate action + * @param $object = null; additional information + * @returns true/false * + * This function adds another entry to the log database */ - public static $TYPE = array ( - 1=>'login', - 2=>'logout', - 3=>'read', - 4=>'write' ); - + public static function add( $subject, $predicate, $object = null ){ + // TODO: write function + return true; + } /** - * log an event + * @brief Fetches log entries + * @param $filter = array(); array with filter options + * @returns array with entries + * + * This function fetches the log entries according to the filter options + * passed. * - * @param username $user - * @param type $type - * @param message $message + * $filter is an associative array. + * The following keys are optional: + * - from: all entries after this date + * - until: all entries until this date + * - user: username (default: current user) + * - app: only entries for this app */ - public static function event($user,$type,$message){ - global $CONFIG_DBTABLEPREFIX; - $result = OC_DB::query('INSERT INTO `' . $CONFIG_DBTABLEPREFIX . 'log` (`timestamp`,`user`,`type`,`message`) VALUES ('.time().',\''.addslashes($user).'\','.addslashes($type).',\''.addslashes($message).'\');'); + public static function get( $filter = array()){ + // TODO: write function + return array(); } - /** - * get log entries + * @brief removes log entries + * @param $date delete entries older than this date + * @returns true/false + * + * This function deletes all entries that are older than $date. */ - public static function get(){ - global $CONFIG_DATEFORMAT; - global $CONFIG_DBTABLEPREFIX; - - $result; - - if(OC_USER::ingroup($_SESSION['username_clean'],'admin')){ - $result = OC_DB::select('select `timestamp`,`user`,`type`,`message` from '.$CONFIG_DBTABLEPREFIX.'log order by timestamp desc limit 20'); - } - else{ - $user=$_SESSION['username_clean']; - $result = OC_DB::select('select `timestamp`,`user`,`type`,`message` from '.$CONFIG_DBTABLEPREFIX.'log where user=\''.$user.'\' order by timestamp desc limit 20'); - } - - return $result; + public static function deleteBefore( $date ){ + // TODO: write function + return true; } } |