todo add user todo
This commit is contained in:
parent
2bc0177819
commit
fa049970e9
@ -129,6 +129,7 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1001, 42, 2, 1000, 'todo', 'todo', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1002, 42, 2, 1000, 'open', 'todo', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1003, 42, 2, 1000, 'close', 'todo', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1004, 42, 2, 1000, 'add', 'todo', 'STRING');
|
||||
|
||||
|
||||
-- INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_docu', 'action', NULL);
|
||||
|
||||
@ -8,6 +8,7 @@ class system_todo {
|
||||
const FIELD_ID = 'ID';
|
||||
const FIELD_CLASS = 'class';
|
||||
const FIELD_MESSAGE = 'message';
|
||||
const FIELD_MESSAGE_HASH = 'message_hash';
|
||||
const FIELD_CODE = 'code';
|
||||
const FIELD_FILE = 'file';
|
||||
const FIELD_LINE = 'line';
|
||||
|
||||
@ -13,8 +13,8 @@ class SYS_SAIMOD_TODO_EXCEPTION_INSERT extends \SYSTEM\DB\QP {
|
||||
\SYSTEM\DBD\system_todo::FIELD_SERVER_NAME.'","'.\SYSTEM\DBD\system_todo::FIELD_SERVER_PORT.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_REQUEST_URI.'","'.\SYSTEM\DBD\system_todo::FIELD_POST.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_HTTP_REFERER.'","'.\SYSTEM\DBD\system_todo::FIELD_HTTP_USER_AGENT.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_USER.'","'.\SYSTEM\DBD\system_todo::FIELD_THROWN.'")'.
|
||||
'VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_USER.'","'.\SYSTEM\DBD\system_todo::FIELD_THROWN.'","'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE_HASH.'")'.
|
||||
'VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, SHA1($2))'.
|
||||
'ON DUPLICATE KEY UPDATE '.\SYSTEM\DBD\system_todo::FIELD_COUNT.'='.\SYSTEM\DBD\system_todo::FIELD_COUNT.'+1, '.\SYSTEM\DBD\system_todo::FIELD_TIME.'=VALUES('.\SYSTEM\DBD\system_todo::FIELD_TIME.'), '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.';',
|
||||
//mys
|
||||
'INSERT INTO '.\SYSTEM\DBD\system_todo::NAME_MYS.
|
||||
@ -26,7 +26,7 @@ class SYS_SAIMOD_TODO_EXCEPTION_INSERT extends \SYSTEM\DB\QP {
|
||||
\SYSTEM\DBD\system_todo::FIELD_SERVER_PORT.','.\SYSTEM\DBD\system_todo::FIELD_REQUEST_URI.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_POST.','.\SYSTEM\DBD\system_todo::FIELD_HTTP_REFERER.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_HTTP_USER_AGENT.','.\SYSTEM\DBD\system_todo::FIELD_USER.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_THROWN.')'.
|
||||
'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_THROWN.','.\SYSTEM\DBD\system_todo::FIELD_MESSAGE_HASH.')'.
|
||||
'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SHA1(?))'.
|
||||
'ON DUPLICATE KEY UPDATE '.\SYSTEM\DBD\system_todo::FIELD_COUNT.'='.\SYSTEM\DBD\system_todo::FIELD_COUNT.'+1, '.\SYSTEM\DBD\system_todo::FIELD_TIME.'=VALUES('.\SYSTEM\DBD\system_todo::FIELD_TIME.'), '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.';'
|
||||
);}}
|
||||
@ -8,10 +8,10 @@ class SYS_SAIMOD_TODO_TODO_LIST extends \SYSTEM\DB\QQ {
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_todo::NAME_PG.
|
||||
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_PG.' ON '.\SYSTEM\DBD\system_todo::FIELD_USER.'='.\SYSTEM\DBD\system_user::NAME_PG.'.'.\SYSTEM\DBD\system_user::FIELD_ID.
|
||||
' WHERE '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.
|
||||
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;',
|
||||
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;',
|
||||
//mys
|
||||
'SELECT * FROM '.\SYSTEM\DBD\system_todo::NAME_MYS.
|
||||
' LEFT JOIN '.\SYSTEM\DBD\system_user::NAME_MYS.' ON '.\SYSTEM\DBD\system_todo::FIELD_USER.'='.\SYSTEM\DBD\system_user::NAME_MYS.'.'.\SYSTEM\DBD\system_user::FIELD_ID.
|
||||
' WHERE '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.
|
||||
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;'
|
||||
' ORDER BY '.\SYSTEM\DBD\system_todo::FIELD_TYPE.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_COUNT.' DESC, '.\SYSTEM\DBD\system_todo::FIELD_TIME.' DESC LIMIT 100;'
|
||||
);}}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace SYSTEM\DBD;
|
||||
|
||||
class SYS_SAIMOD_TODO_USER_EXCEPTION_INSERT extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'INSERT INTO '.\SYSTEM\DBD\system_todo::NAME_PG.
|
||||
'("'.\SYSTEM\DBD\system_todo::FIELD_CLASS.'","'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_CODE.'","'.\SYSTEM\DBD\system_todo::FIELD_FILE.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_LINE.'","'.\SYSTEM\DBD\system_todo::FIELD_TRACE.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_IP.'","'.\SYSTEM\DBD\system_todo::FIELD_QUERYTIME.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_SERVER_NAME.'","'.\SYSTEM\DBD\system_todo::FIELD_SERVER_PORT.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_REQUEST_URI.'","'.\SYSTEM\DBD\system_todo::FIELD_POST.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_HTTP_REFERER.'","'.\SYSTEM\DBD\system_todo::FIELD_HTTP_USER_AGENT.'","'.
|
||||
\SYSTEM\DBD\system_todo::FIELD_USER.'","'.\SYSTEM\DBD\system_todo::FIELD_THROWN.'","'.\SYSTEM\DBD\system_todo::FIELD_MESSAGE_HASH.'","'.\SYSTEM\DBD\system_todo::FIELD_TYPE.'")'.
|
||||
'VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, SHA1($2), '.\SYSTEM\DBD\system_todo::FIELD_TYPE_USER.')'.
|
||||
'ON DUPLICATE KEY UPDATE '.\SYSTEM\DBD\system_todo::FIELD_COUNT.'='.\SYSTEM\DBD\system_todo::FIELD_COUNT.'+1, '.\SYSTEM\DBD\system_todo::FIELD_TIME.'=VALUES('.\SYSTEM\DBD\system_todo::FIELD_TIME.'), '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.';',
|
||||
//mys
|
||||
'INSERT INTO '.\SYSTEM\DBD\system_todo::NAME_MYS.
|
||||
'('.\SYSTEM\DBD\system_todo::FIELD_CLASS.','.\SYSTEM\DBD\system_todo::FIELD_MESSAGE.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_CODE.','.\SYSTEM\DBD\system_todo::FIELD_FILE.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_LINE.','.\SYSTEM\DBD\system_todo::FIELD_TRACE.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_IP.','.\SYSTEM\DBD\system_todo::FIELD_QUERYTIME.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_TIME.','.\SYSTEM\DBD\system_todo::FIELD_SERVER_NAME.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_SERVER_PORT.','.\SYSTEM\DBD\system_todo::FIELD_REQUEST_URI.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_POST.','.\SYSTEM\DBD\system_todo::FIELD_HTTP_REFERER.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_HTTP_USER_AGENT.','.\SYSTEM\DBD\system_todo::FIELD_USER.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_THROWN.','.\SYSTEM\DBD\system_todo::FIELD_MESSAGE_HASH.','.
|
||||
\SYSTEM\DBD\system_todo::FIELD_TYPE.')'.
|
||||
'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SHA1(?), '.\SYSTEM\DBD\system_todo::FIELD_TYPE_USER.')'.
|
||||
'ON DUPLICATE KEY UPDATE '.\SYSTEM\DBD\system_todo::FIELD_COUNT.'='.\SYSTEM\DBD\system_todo::FIELD_COUNT.'+1, '.\SYSTEM\DBD\system_todo::FIELD_TIME.'=VALUES('.\SYSTEM\DBD\system_todo::FIELD_TIME.'), '.\SYSTEM\DBD\system_todo::FIELD_STATE.'='.\SYSTEM\DBD\system_todo::FIELD_STATE_OPEN.';'
|
||||
);}}
|
||||
@ -22,7 +22,16 @@ function register_new(){
|
||||
}
|
||||
|
||||
function register_newform(){
|
||||
//TODO
|
||||
$('#btn_add').click(function(){
|
||||
$.ajax({ type : 'GET',
|
||||
url : SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_todo&action=add&todo='+$('#input_message').val(),
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
load_todo_tab('todolist');
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function load_todo_tab(action){
|
||||
|
||||
@ -9,6 +9,9 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_open($todo){
|
||||
\SYSTEM\DBD\SYS_SAIMOD_TODO_OPEN::QI(array($todo));
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_action_add($todo){
|
||||
self::exception(new \Exception($todo), false, true);
|
||||
return \SYSTEM\LOG\JsonResult::ok();}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo(){
|
||||
$vars = array();
|
||||
@ -126,23 +129,37 @@ class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_flag_js(){return \SYSTEM\LOG\JsonResult::toString(
|
||||
array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_todo/saimod_sys_todo.js')));}
|
||||
|
||||
public static function exception(\Exception $E, $thrown){
|
||||
public static function exception(\Exception $E, $thrown, $user = false){
|
||||
try{
|
||||
if(\property_exists(get_class($E), 'todo_logged') && $E->todo_logged){
|
||||
return false;} //alrdy logged(this prevents proper thrown value for every system exception)
|
||||
|
||||
\SYSTEM\DBD\SYS_SAIMOD_TODO_EXCEPTION_INSERT::Q1( array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0),
|
||||
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),date('Y-m-d H:i:s', microtime(true)),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown));
|
||||
if($user){
|
||||
\SYSTEM\DBD\SYS_SAIMOD_TODO_USER_EXCEPTION_INSERT::Q1( array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0),
|
||||
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),date('Y-m-d H:i:s', microtime(true)),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown,$E->getMessage()));
|
||||
} else {
|
||||
\SYSTEM\DBD\SYS_SAIMOD_TODO_EXCEPTION_INSERT::Q1( array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0),
|
||||
array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),
|
||||
getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),date('Y-m-d H:i:s', microtime(true)),
|
||||
$_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST),
|
||||
array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null,
|
||||
array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
||||
($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown,$E->getMessage()));
|
||||
}
|
||||
if(\property_exists(get_class($E), 'logged')){
|
||||
$E->todo_logged = true;} //we just did log
|
||||
} catch (\Exception $E){return false;} //Error -> Ignore
|
||||
|
||||
@ -1,25 +1,5 @@
|
||||
<h3>New ToDo</h3>
|
||||
<table class="table table-hover table-condensed">
|
||||
<tr><th>Property</th><th>Value</th></tr>
|
||||
<tr><td>ID</td><td>${ID}</td></tr>
|
||||
<tr><td>class</td><td>${class}</td></tr>
|
||||
<tr><td>code</td><td>${code}</td></tr>
|
||||
<tr><td>file</td><td>${file}</td></tr>
|
||||
<tr><td>line</td><td>${line}</td></tr>
|
||||
<tr><td>trace</td><td>${trace}</td></tr>
|
||||
<tr><td>ip</td><td>${ip}</td></tr>
|
||||
<tr><td>querytime</td><td>${querytime}</td></tr>
|
||||
<tr><td>time</td><td>${time}</td></tr>
|
||||
<tr><td>server_name</td><td>${server_name}</td></tr>
|
||||
<tr><td>server_port</td><td>${server_port}</td></tr>
|
||||
<tr><td>request_uri</td><td>${request_uri}</td></tr>
|
||||
<tr><td>url</td><td><a href="${server_name}:${server_port}${request_uri}">${server_name}:${server_port}${request_uri}</a></td></tr>
|
||||
<tr><td>post</td><td>${post}</td></tr>
|
||||
<tr><td>http_referer</td><td>${http_referer}</td></tr>
|
||||
<tr><td>http_user_agent</td><td>${http_user_agent}</td></tr>
|
||||
<tr><td>user</td><td>${username}</td></tr>
|
||||
<tr><td>thrown</td><td>${thrown}</td></tr>
|
||||
<tr><td>message</td><td>${message}</td></tr>
|
||||
<tr><td>Message</td><td><textarea style="width: 80%; height: 400px;" id="input_message"></textarea></td></tr>
|
||||
</table>
|
||||
<button id="btn_add" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;">Add</button>
|
||||
<button id="btn_back" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Back</button>
|
||||
<button id="btn_back" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: left;">Back</button>
|
||||
<button id="btn_add" class="btn-danger" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Add</button>
|
||||
@ -21,6 +21,6 @@
|
||||
<tr><td>thrown</td><td>${thrown}</td></tr>
|
||||
<tr><td>message</td><td>${message}</td></tr>
|
||||
</table>
|
||||
<button id="btn_back" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: left;">Back</button>
|
||||
<button id="btn_close" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Close</button>
|
||||
<button id="btn_open" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Open</button>
|
||||
<button id="btn_back" class="btn-success" style="margin-right: 15px; height: 32px; font-size: 13px; float: right;">Back</button>
|
||||
<button id="btn_open" class="btn-danger" style="display: none; margin-right: 15px; height: 32px; font-size: 13px; float: right;" todo="${ID}">Open</button>
|
||||
Loading…
x
Reference in New Issue
Block a user