Skip to content
Permalink
Browse files

Tested with Kohana 3.3.6, see davidstutz/kohana-demo.

  • Loading branch information...
davidstutz committed Nov 2, 2016
1 parent ef3aa22 commit a203a606d212f38991d01c48bdafeee811cc4d46
@@ -8,8 +8,12 @@ Yellow is part of a set of Kohana modules:
* [Blue](https://github.com/davidstutz/kohana-blue): Red based user configuration module.
* [Yellow](https://github.com/davidstutz/kohana-yellow): Green based logging solution.

**Make sure to use the correct SQL schema as given in `guide/yellow/sql-schema.md` or `schema.sql`!**

For documentation see the guide/ subfolder or use Kohana's [Userguide](https://github.com/kohana/userguide) module.

A demonstration application can be found at [davidstutz/kohana-demo](https://github.com/davidstutz/kohana-demo).

## Composer

Installation via composer:
@@ -33,7 +37,7 @@ Installation via composer:

## License

Copyright (c) 2013 - 2014 David Stutz
Copyright (c) 2013 - 2016 David Stutz
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -4,16 +4,16 @@
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Kohana_Yellow implements Kohana_Yellow_Logger {
/**
* Constants for all logging types.
*/
const CONTROLLER = 'log_controller';
const MODEL = 'log_model';
const CONTROLLER = 'Log_Controller';
const MODEL = 'Log_Model';
/**
* @var string type
@@ -4,7 +4,7 @@
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
interface Kohana_Yellow_Logger {
@@ -2,9 +2,9 @@
/**
* Default ACL user.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Model_Log_Controller extends Model_Yellow_Log_Controller {}
@@ -2,9 +2,9 @@
/**
* Default ACL user.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Model_Log_Model extends Model_Yellow_Log_Model {}
@@ -2,28 +2,28 @@
/**
* For logging controllers.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Model_Yellow_Log_Controller extends ORM {
/**
* @var string table
* @var string table
*/
protected $_table = 'log_controllers';
/**
* @var array created column
* @var array created column
*/
protected $_created_column = array(
'column' => 'created',
'format' => 'U',
);
/**
* @var array belongs to a user
* @var array belongs to a user
*/
protected $_belongs_to = array(
'user' => array(
@@ -2,28 +2,28 @@
/**
* For logging models.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Model_Yellow_Log_Model extends ORM {
/**
* @var string table
* @var string table
*/
protected $_table = 'log_models';
/**
* @var array created column
* @var array created column
*/
protected $_created_column = array(
'column' => 'created',
'format' => 'U',
);
/**
* @var array belongs to user
* @var array belongs to user
*/
protected $_belongs_to = array(
'user' => array(
@@ -2,9 +2,9 @@
/**
* Yellow - auth and acl log implementation.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
class Yellow extends Kohana_Yellow {}
@@ -4,7 +4,7 @@
"description": "User logging module based on kohana-red.",
"homepage": "https://davidstutz.de",
"license": "BSD-3-Clause",
"keywords": ["kohana", "framework", "logging"],
"keywords": ["kohana"],
"authors": [
{
"name": "David Stutz",
@@ -3,18 +3,18 @@
/**
* Userguide configuration for yellow module.
*
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2014 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
* @package Yellow
* @author David Stutz
* @copyright (c) 2013 - 2016 David Stutz
* @license http://opensource.org/licenses/bsd-3-clause
*/
return array(
'modules' => array(
'navigation' => array(
'enabled' => TRUE,
'name' => 'Yellow',
'description' => 'ORM based logging module to use with Green and Red.',
'copyright' => '(c) 2013 David Stutz',
),
)
'modules' => array(
'navigation' => array(
'enabled' => TRUE,
'name' => 'Yellow',
'description' => 'ORM based logging module to use with Green and Red.',
'copyright' => '(c) 2013 David Stutz',
),
)
);
@@ -1,3 +1,3 @@
## [Yellow](index)
- [SQL Scheme](sql-scheme)
- [SQL Schema](sql-schema)
- [Usage](usage)
@@ -0,0 +1,142 @@
# SQL Schema

The module should be used in conjunction with [Kohana Red](https://github.com/davidstutz/kohana-red)
and [Kohana Green](https://github.com/davidstutz/kohana-green).

SQL Schema for Red:

-- -----------------------------------------------------
-- Table `users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `users` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`email` VARCHAR(255) NOT NULL ,
`first_name` VARCHAR(255) NOT NULL ,
`last_name` VARCHAR(255) NOT NULL ,
`password` VARCHAR(65) NOT NULL ,
`salt` VARCHAR(255) DEFAULT NULL ,
-- Additional fields can be added ...
PRIMARY KEY (`id`) ,
UNIQUE INDEX `uniq_email` (`email` ASC))
DEFAULT CHARACTER SET = utf8;

-- -----------------------------------------------------
-- Table `user_roles`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `user_roles` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(32) NULL ,
-- Additional fields can be added ...
PRIMARY KEY (`id`) ,
UNIQUE INDEX `uniq_name` (`name` ASC));

-- -----------------------------------------------------
-- Table `users_user_roles`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `users_user_roles` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) UNSIGNED NOT NULL ,
`user_role_id` INT(11) UNSIGNED NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_users_user_roles_user_id` (`user_id` ASC) ,
INDEX `fk_users_user_roles_user_role_id` (`user_role_id` ASC) ,
CONSTRAINT `fk_users_user_roles_user_id`
FOREIGN KEY (`user_id`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `fk_users_user_roles_user_role_id`
FOREIGN KEY (`user_role_id`)
REFERENCES `user_roles` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;

-- -----------------------------------------------------
-- Table `user_logins`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `user_logins` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`ip` VARCHAR(65) NOT NULL ,
`agent` VARCHAR(65) NOT NULL ,
`login` VARCHAR(255) NOT NULL ,
`created` INT(11) UNSIGNED NOT NULL ,
`user_id` INT(11) DEFAULT NULL ,
PRIMARY KEY (`id`))
DEFAULT CHARACTER SET = utf8;

-- -----------------------------------------------------
-- Table `user_tokens`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `user_tokens` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`token` VARCHAR(40) NOT NULL ,
`user_id` INT(11) UNSIGNED NOT NULL ,
`user_agent` VARCHAR(64) NOT NULL ,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL ,
`expires` INT(11) UNSIGNED NOT NULL ,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `uniq_token` (`token`) ,
INDEX `fk_user_tokens_user_id` (`user_id` ASC) ,
CONSTRAINT `fk_user_tokens_user_id`
FOREIGN KEY (`user_id`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;

SQL Schema for Green:

-- -----------------------------------------------------
-- Table `rules`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `rules` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`type` VARCHAR(255) NOT NULL ,
`key` VARCHAR(255) NOT NULL ,
`rule` VARCHAR(255) NOT NULL ,
PRIMARY KEY (`id`))
DEFAULT CHARACTER SET = utf8;

SQL Schema for Yellow:

-- -----------------------------------------------------
-- Table `log_models`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `log_models` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`model` VARCHAR(255) NOT NULL ,
`model_id` INT(11) UNSIGNED NOT NULL ,
`user_id` INT(11) UNSIGNED NOT NULL ,
`method` VARCHAR(255) NOT NULL ,
`data` TEXT NOT NULL ,
`created` INT(11) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_log_models_user_id` (`user_id` ASC) ,
CONSTRAINT `fk_log_models_user_id`
FOREIGN KEY (`user_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `log_controllers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `log_controllers` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`controller` VARCHAR(255) NOT NULL ,
`uri` VARCHAR(255) NOT NULL , -- Assuming uri will not need more than 255 characters.
`user_id` INT(11) UNSIGNED NOT NULL ,
`created` INT(11) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_log_controllers_user_id` (`user_id` ASC) ,
CONSTRAINT `fk_log_controllers_user_id`
FOREIGN KEY (`user_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
DEFAULT CHARACTER SET = utf8;

This file was deleted.

0 comments on commit a203a60

Please sign in to comment.
You can’t perform that action at this time.