new saimod proto todo and docu, small fixes

This commit is contained in:
Ulf Gebhardt 2013-09-25 03:42:08 +02:00
parent 1b3262974e
commit af31a72e68
10 changed files with 218 additions and 19 deletions

View File

@ -84,13 +84,13 @@ class api {
$commands[count($commands)-1][1] != $item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]){
continue;}
//all parameters are required
//all parameters are NOT required - just continue
if(!isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME]);}
continue;}
//verify parameter
if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) ||
!$verifyclassname->$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) ||
!call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]);}
$parameters_opt[] = array($item, $params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]);
@ -99,7 +99,7 @@ class api {
//strict check
if( $strict &&
count($params) != (count($parameters) + count($commands)) ){
count($params) != (count($parameters) + count($commands) + count($parameters_opt)) ){
throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid: '.$_SERVER["REQUEST_URI"]);}
//Function Name

View File

@ -4,15 +4,5 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/page','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/page/default_page','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_login','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_log','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_security','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_mod','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_config','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_calls','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_locale','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_cache','SYSTEM\SAI');
require_once dirname(__FILE__).'/modules/autoload_modules.php';
require_once dirname(__FILE__).'/modules/register_modules.php';

View File

@ -0,0 +1,13 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__),'SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_login','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_log','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_security','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_mod','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_config','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_calls','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_locale','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_cache','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_docu','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_todo','SYSTEM\SAI');

View File

@ -9,4 +9,5 @@
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_calls');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_locale');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_cache');
//\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_docu');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_todo');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_docu');

View File

@ -39,7 +39,7 @@ class saimod_sys_cache extends \SYSTEM\SAI\SaiModule {
return 'success';
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_cache">Cache</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_cache">Cache</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}

View File

@ -0,0 +1,15 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_docu extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu(){
return "todo";
}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_docu">Docu</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu_flag_js(){}
}

View File

@ -0,0 +1,87 @@
<h1>${register}</h1>
<br />
<br />
<form class="textbox" id="register_user_form">
<div class="control-group" id="register_username_control_group">
<table id="userRegisterTable" class="table table-striped">
<tbody>
<tr>
<th style="width: 200px;">${loginUsername}</th>
<td>
<div class="control-group controls">
<input type="text"
size="30"
style="margin-bottom: 15px; float: left;"
id="register_username"
placeholder="${enter_username}"
minlength="3" data-validation-minlength-message="${login_username_too_short}"
required data-validation-required-message="${login_username_required}"/>
<br/>
<div id="register-help-block-username" class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</td>
</tr>
<tr>
<th>E-Mail</th>
<td>
<div class="control-group controls">
<input type="email"
size="30"
style="margin-bottom: 15px; float: left;"
id="register_email"
placeholder="${enter_email}"
data-validation-email-message="${check_mail_format}"
required data-validation-required-message="${email_required}"/>
<br/>
<div id="register-help-block-email" class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</td>
</tr>
<tr>
<th>${loginPassword}</th>
<td>
<div class="control-group" id="change_user_password">
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_register_password1"
name="user_register_password1"
placeholder="${enter_password}"
minlength="5" data-validation-minlength-message="${login_password_too_short}"
required data-validation-required-message="${login_password_required}"/>
<br/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_register_password2"
name="user_register_password2"
placeholder="${retype_password}"
data-validation-matches-match="user_register_password1"
data-validation-matches-message="${register_password_dont_math}"/>
<br/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</div>
</td>
</tr>
<tr>
<th>${locale}</th>
<td>
<div id="change_user_locale">
<select size="1" id="register_locale_select">
<option value="deDE">deDE</option>
<option value="enUS">enUS</option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" type="submit"><i class="icon-ok icon-white"></i> ${register}</button>
<button class="btn btn-primary" type="reset" id="btn_user_registration_cancel"><i class="icon-remove icon-white"></i> ${cancel}</button>
</div>
</form>

View File

@ -40,4 +40,69 @@ function init__SYSTEM_SAI_saimod_sys_login() {
$('span#user_last_active').text(new Date(data.last_active * 1000).toString('yyyy-MM-dd h:mm:ss'));
$('span#user_locale').text(data.locale);
});
};
$("#register_link").click(function(){
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=registerform');
});
$('#btn_user_registration_cancel').click(function(){
$('#site-content-wrapper').slideUp('slow');
site_content_is_visible = false;
showNavbarControls();
$('#navigation-left').children().children().removeClass('active');
$("#map-link").parent().attr('class', 'active');
});
//jqBootstrapValidation
$("#register_user_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function (form, event, errors) {},
submitSuccess: function($form, event){
var username = document.getElementById('register_username').value;
var email = document.getElementById('register_email').value;
var password = document.getElementById('user_register_password2').value;
var select_locale = document.getElementById('register_locale_select');
var locale = "";
for (var i = 0; i < select_locale.options.length; i++) {
if(select_locale.options[i].selected ){
locale = select_locale.options[i].value;
}
}
$.ajax({
dataType: "json",
url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=register&username='+username+'&password_sha='+$.sha1(password)+'&email='+email+'&locale='+locale,
data: null,
success: function (dataCreate) {
if(dataCreate.status === true){ // reload -> user will be loged in
window.location.href = location.href.replace(/#/g, "");
}else{ // show errors
var result = dataCreate.result;
var code = result.code;
var msg = result.message;
switch (code){
case 1: // username invalid
case 2: // username already exists
$('#register-help-block-username').html('<ul role="alert"><li><font color="red">'+msg+'</font></li></ul>');
break;
case 3: // invalid email
$('#register-help-block-email').html('<ul role="alert"><li><font color="red">'+msg+'</font></li></ul>');
break;
case 4: //registration failed
alert(msg);
break;
default:
break;
}
}
}
});
event.preventDefault();
}
});
};

View File

@ -24,6 +24,12 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
return \SYSTEM\SECURITY\Security::logout();}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_login($username,$password_sha,$password_md5){
return \SYSTEM\SECURITY\Security::login(new \DBD\dasensePostgres(), $username, $password_sha, $password_md5);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_register($username,$password_sha,$password_md5,$email, $locale = 'deDE'){
return \SYSTEM\SECURITY\Security::create(new \DBD\dasensePostgres(), $username, $password_sha, $password_md5, $email, $locale);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_registerform(){
$vars = \SYSTEM\locale::getStrings(\DBD\locale_string::VALUE_CATEGORY_DASENSE);
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/register.tpl'), $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}
public static function right_public(){return true;}

View File

@ -0,0 +1,22 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo(){
$result = '<div id="table-wrapper"><table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'time ago in days'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'reporttype'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'suggestion'.'</th>'.'<th>'.'additional sources'.'</th>'.'<th>'.'author'.'</th>'.'<th>'.'assigned'.'</th>'.'<th>'.'state of todo(closed/in progress)'.'</th>'.'<th>'.'action'.'</th>'.'</tr>'.
'<tr class="info">'.'<td>'.'5d'.'</td>'.'<td>'.'5days ago obviously'.'</td>'.'<td>'.'Feature Request'.'</td>'.'<td>'.'Do some new stuff the old stuff sucks.'.'</td>'.'<td>'.'not a valid field for this type of report(ment for error suggestions)'.'</td>'.'<td>'.'http:... here some fancy examples what i want'.'</td>'.'<td>'.'Mr. Pink'.'</td>'.'<td>'.'I_S and many more'.'</td>'.'<td>'.'in progress'.'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete">'.'<input type="submit" class="btn" value="edit">'.'<input type="submit" class="btn" value="assign">'.'</th>'.'</tr>'.
'<tr class="error">'.'<td>'.'5d'.'</td>'.'<td>'.'5days ago obviously'.'</td>'.'<td>'.'Bugreport'.'</td>'.'<td>'.'Do some new stuff the old stuff sucks.'.'</td>'.'<td>'.'not a valid field for this type of report(ment for error suggestions)'.'</td>'.'<td>'.'http:... here some fancy examples what i want'.'</td>'.'<td>'.'Mr. Pink'.'</td>'.'<td>'.'I_S and many more'.'</td>'.'<td>'.'in progress'.'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete">'.'<input type="submit" class="btn" value="edit">'.'<input type="submit" class="btn" value="assign">'.'</th>'.'</tr>'.
'<tr class="warning">'.'<td>'.'5d'.'</td>'.'<td>'.'5days ago obviously'.'</td>'.'<td>'.'Unasigned Category - what is this?'.'</td>'.'<td>'.'Do some new stuff the old stuff sucks.'.'</td>'.'<td>'.'not a valid field for this type of report(ment for error suggestions)'.'</td>'.'<td>'.'http:... here some fancy examples what i want'.'</td>'.'<td>'.'Mr. Pink'.'</td>'.'<td>'.'I_S and many more'.'</td>'.'<td>'.'in progress'.'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete">'.'<input type="submit" class="btn" value="edit">'.'<input type="submit" class="btn" value="assign">'.'</th>'.'</tr>'.
'<tr class="success">'.'<td>'.'5d'.'</td>'.'<td>'.'5days ago obviously'.'</td>'.'<td>'.'Closed FR/BR/OT'.'</td>'.'<td>'.'Do some new stuff the old stuff sucks.'.'</td>'.'<td>'.'not a valid field for this type of report(ment for error suggestions)'.'</td>'.'<td>'.'http:... here some fancy examples what i want'.'</td>'.'<td>'.'Mr. Pink'.'</td>'.'<td>'.'I_S and many more'.'</td>'.'<td>'.'in progress'.'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete">'.'<input type="submit" class="btn" value="edit">'.'<input type="submit" class="btn" value="assign">'.'</th>'.'</tr>'.
'<tr>'.'<td>'.'5d'.'</td>'.'<td>'.'5days ago obviously'.'</td>'.'<td>'.'Note/Reminder'.'</td>'.'<td>'.'Do some new stuff the old stuff sucks.'.'</td>'.'<td>'.'not a valid field for this type of report(ment for error suggestions)'.'</td>'.'<td>'.'http:... here some fancy examples what i want'.'</td>'.'<td>'.'Mr. Pink'.'</td>'.'<td>'.'I_S and many more'.'</td>'.'<td>'.'in progress'.'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete">'.'<input type="submit" class="btn" value="edit">'.'<input type="submit" class="btn" value="assign">'.'</th>'.'</tr>';
return $result;
}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_todo">ToDo</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_flag_js(){}
}