Files
pathfinder/app/main/model/activitylogmodel.php
Exodus4D b2cce3cde2 - new "activity log" for user actions (create/update/delete) of (systems/connections/signatures), resolves #280, relates #271
- new added cronjob to delete old statistics data (older 1 year) (weekly)
- updated main menu structure (added new headlines,...)
- updated "feature page", added new section for "statistics"
- updated "system delete" function. systems with no changes (description/alias) will now get deleted instead of set "active = 0", #184
- changed max expire time from file caching (/tmp/cache) from 20d -> 10d
- changed "character log" TTL from 10s to 5s
- changed cronjob interval for "deleteExpiredData" from "weekly" to "downtime"
- changed "delete" icon (e.g. context menu on map) from "eraser" to "trash"
- removed cronjob output logging (cron_deactivateMapData.log)
- fixed non click-able character panels on login page, closed #332
2016-10-17 14:01:46 +02:00

150 lines
4.2 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Exodus
* Date: 01.10.2016
* Time: 15:11
*/
namespace Model;
use DB\SQL\Schema;
class ActivityLogModel extends BasicModel {
protected $table = 'activity_log';
protected $fieldConf = [
'active' => [
'type' => Schema::DT_BOOL,
'nullable' => false,
'default' => 1,
'index' => true
],
'characterId' => [
'type' => Schema::DT_INT,
'index' => true,
'belongs-to-one' => 'Model\CharacterModel',
'constraint' => [
[
'table' => 'character',
'on-delete' => 'CASCADE'
]
]
],
'mapId' => [
'type' => Schema::DT_INT,
'index' => true,
'belongs-to-one' => 'Model\MapModel',
'constraint' => [
[
'table' => 'map',
'on-delete' => 'SET NULL' // keep log data on map delete
]
]
],
// system actions -----------------------------------------------------
'systemCreate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'systemUpdate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'systemDelete' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
// connection actions -------------------------------------------------
'connectionCreate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'connectionUpdate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'connectionDelete' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
// signature actions -------------------------------------------------
'signatureCreate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'signatureUpdate' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
'signatureDelete' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => 0,
],
];
public function __construct($db = NULL, $table = NULL, $fluid = NULL, $ttl = 0){
$this->addStaticDateFieldConfig();
parent::__construct($db, $table, $fluid, $ttl);
}
/**
* extent the fieldConf Array with static fields for each table
*/
private function addStaticDateFieldConfig(){
if(is_array($this->fieldConf)){
$staticFieldConfig = [
'year' => [
'type' => Schema::DT_SMALLINT,
'nullable' => false,
'default' => date('o'), // 01.01 could be week 53 -> NOT "current" year!
'index' => true
],
'week' => [ // week in year [1-53]
'type' => Schema::DT_TINYINT,
'nullable' => false,
'default' => 1,
'index' => true
],
];
$this->fieldConf = array_merge($staticFieldConfig, $this->fieldConf);
}
}
/**
* overwrites parent
* @param null $db
* @param null $table
* @param null $fields
* @return bool
*/
public static function setup($db=null, $table=null, $fields=null){
$status = parent::setup($db,$table,$fields);
if($status === true){
$status = parent::setMultiColumnIndex(['year', 'week', 'characterId', 'mapId'], true);
if($status === true){
$status = parent::setMultiColumnIndex(['year', 'week', 'characterId']);
}
}
return $status;
}
}