diff --git a/www/admin/class_test.php b/www/admin/class_test.php
index b42094d3..a08a2934 100644
--- a/www/admin/class_test.php
+++ b/www/admin/class_test.php
@@ -8,35 +8,36 @@ if ($DEBUG_ALL) {
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
}
+ob_start();
+
define('USE_DATABASE', true);
// sample config
require("config.inc");
// set session name
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
-// session_name(EDIT_SESSION_NAME);
-// session_start();
// basic class test file
-foreach (array ('Login', 'Admin.Backend') as $class) {
- _spl_autoload('Class.'.$class.'.inc');
-}
-
+// set language for l10n
$lang = 'en_utf8';
-
+// define log file id
DEFINE('LOG_FILE_ID', 'classTest');
-$login = new login($DB_CONFIG[LOGIN_DB], $lang);
-// init with standard
-// $basic = new db_io($DB_CONFIG[MAIN_DB]);
-$basic = new AdminBackend($DB_CONFIG[MAIN_DB], $lang);
-$basic->db_info(1);
+// init login & backend class
+$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
+$basic = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
+$basic->dbInfo(1);
+ob_end_flush();
// set + check edit access id
$edit_access_id = 3;
-print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."
";
-print "ACCESS CHECK: ".$login->login_check_edit_access($edit_access_id)."
";
-if ($login->login_check_edit_access($edit_access_id)) {
- $basic->edit_access_id = $edit_access_id;
+if (array_key_exists('unit', $login->acl)) {
+ print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."
";
+ print "ACCESS CHECK: ".$login->loginCheckEditAccess($edit_access_id)."
";
+ if ($login->loginCheckEditAccess($edit_access_id)) {
+ $basic->edit_access_id = $edit_access_id;
+ } else {
+ $basic->edit_access_id = $login->acl['unit_id'];
+ }
} else {
- $basic->edit_access_id = $login->acl['unit_id'];
+ print "Something went wrong with the login
";
}
// $basic->debug('SESSION', $basic->print_ar($_SESSION));
@@ -59,12 +60,12 @@ print "DEBUG OUT ALL: ".$basic->debug_output_all."
";
print "ECHO OUT ALL: ".$basic->echo_output_all."
";
print "PRINT OUT ALL: ".$basic->print_output_all."
";
-print "CALLER BACKTRACE: ".$basic->get_caller_method()."
";
+print "CALLER BACKTRACE: ".$basic->getCallerMethod()."
";
$basic->debug('SOME MARK', 'Some error output');
print "EDIT ACCESS ID: ".$basic->edit_access_id."
";
// print "ACL:
".$basic->print_ar($login->acl)."
";
-$basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl));
+$basic->debug('ACL', "ACL: ".$basic->printAr($login->acl));
// print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
";
// print "DEFAULT ACL:
".$basic->print_ar($login->default_acl_list)."
";
// $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; }));
@@ -72,51 +73,54 @@ $basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl));
// DEPRICATED CALL
// $basic->adbSetACL($login->acl);
-while ($res = $basic->db_return("SELECT * FROM max_test")) {
+// DB client encoding
+print "DB Client encoding: ".$basic->dbGetEncoding()."
";
+
+while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
print "TIME: ".$res['time']."
";
}
-$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
+$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
";
-print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
";
-$basic->db_prepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
-$status = $basic->db_execute("ins_foo", array('BAR TEST '.time()));
+print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
";
+$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
+$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time()));
print "PREPARE INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
";
-print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
";
+print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
";
// returning test with multiple entries
// $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id");
-$status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
+$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
";
// no returning, but not needed ;
-$status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
+$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."
";
# db write class test
$table = 'foo';
-print "TABLE META DATA: ".$basic->print_ar($basic->db_show_table_meta_data($table))."
";
+print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."
";
$primary_key = ''; # unset
$db_write_table = array ('test', 'string_a', 'number_a', 'some_bool');
// $db_write_table = array ('test');
$object_fields_not_touch = array ();
$object_fields_not_update = array ();
$data = array ('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5);
-$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
+$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key
";
$data = array ('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
-$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
+$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key
";
$data = array ('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
-$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
+$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key
";
$data = array ('test' => 'BOOL TEST UNSET '.time());
-$primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
+$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key
";
# async test queries
-/* $basic->db_exec_async("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
+/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
echo "WAITING FOR ASYNC: ";
$chars = array('|', '/', '-', '\\');
-while (($ret = $basic->db_check_async()) === true)
+while (($ret = $basic->dbCheckAsync()) === true)
{
if ((list($_, $char) = each($chars)) === FALSE)
{
@@ -128,37 +132,37 @@ while (($ret = $basic->db_check_async()) === true)
flush();
}
print "
END STATUS: ".$ret."
";
-// while ($res = $basic->db_fetch_array($ret))
-while ($res = $basic->db_fetch_array())
+// while ($res = $basic->dbFetchArray($ret))
+while ($res = $basic->dbFetchArray())
{
echo "RES: ".$res['test']."
";
}
# test async insert
-$basic->db_exec_async("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
+$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
echo "WAITING FOR ASYNC INSERT: ";
-while (($ret = $basic->db_check_async()) === true)
+while (($ret = $basic->dbCheckAsync()) === true)
{
print ".";
sleep(1);
flush();
}
print "
END STATUS: ".$ret." | PK: ".$basic->insert_id."
";
-print "ASYNC PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; */
+print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."
"; */
$to_db_version = '9.1.9';
-print "VERSION DB: ".$basic->db_version()."
";
-print "DB Version smaller $to_db_version: ".$basic->db_compare_version('<'.$to_db_version)."
";
-print "DB Version smaller than $to_db_version: ".$basic->db_compare_version('<='.$to_db_version)."
";
-print "DB Version equal $to_db_version: ".$basic->db_compare_version('='.$to_db_version)."
";
-print "DB Version bigger than $to_db_version: ".$basic->db_compare_version('>='.$to_db_version)."
";
-print "DB Version bigger $to_db_version: ".$basic->db_compare_version('>'.$to_db_version)."
";
+print "VERSION DB: ".$basic->dbVersion()."
";
+print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."
";
+print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."
";
+print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."
";
+print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."
";
+print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."
";
/* $q = "SELECT FOO FRO BAR";
// $q = "Select * from foo";
-$foo = $basic->db_exec_async($q);
+$foo = $basic->dbExecAsync($q);
print "[ERR] Query: ".$q."
";
print "[ERR] RESOURCE: $foo
";
-while (($ret = $basic->db_check_async()) === true)
+while (($ret = $basic->dbCheckAsync()) === true)
{
print "[ERR]: $ret
";
// sleep(5);
@@ -166,30 +170,33 @@ while (($ret = $basic->db_check_async()) === true)
// search path check
$q = "SHOW search_path";
-$cursor = $basic->db_exec($q);
-$data = $basic->db_fetch_array($cursor)['search_path'];
+$cursor = $basic->dbExec($q);
+$data = $basic->dbFetchArray($cursor)['search_path'];
print "RETURN DATA FOR search_path: ".$data."
";
-// print "RETURN DATA FOR search_path: ".$basic->print_ar($data)."
";
+// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."
";
// insert something into test.schema_test and see if we get the PK back
-$status = $basic->db_exec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
+$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."
";
// time string thest
$timestamp = 5887998.33445;
-$time_string = $basic->TimeStringFormat($timestamp);
+$time_string = $basic->timeStringFormat($timestamp);
print "TIME STRING TEST: ".$time_string."
";
-print "REVERSE TIME STRING: ".$basic->StringToTime($time_string);
+print "REVERSE TIME STRING: ".$basic->stringToTime($time_string);
// magic links test
-print $basic->magic_links('user@bubu.at').'
';
-print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'
';
+print $basic->magicLinks('user@bubu.at').'
';
+print $basic->magicLinks('http://test.com/foo/bar.php?foo=1').'
';
// compare date
$date_1 = '2017/1/5';
$date_2 = '2017-01-05';
-print "COMPARE DATE: ".$basic->CompareDate($date_1, $date_2)."
";
+print "COMPARE DATE: ".$basic->compareDate($date_1, $date_2)."
";
// print error messages
-print $basic->print_error_msg();
+print $login->printErrorMsg();
+print $basic->printErrorMsg();
print "