Skip to content
Snippets Groups Projects
Commit 04637992 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

actionlog class: fix linebraek; reformat code

parent 9f45eeb3
No related branches found
No related tags found
1 merge request!62V2.0
...@@ -6,7 +6,8 @@ require_once 'user.class.php'; ...@@ -6,7 +6,8 @@ require_once 'user.class.php';
* *
* @author hahn * @author hahn
*/ */
class Actionlog { class Actionlog
{
private $_dbfile = ''; private $_dbfile = '';
private $_aLoglevels = array("info", "warning", "error", "success"); // array of valid loglevels private $_aLoglevels = array("info", "warning", "error", "success"); // array of valid loglevels
...@@ -44,7 +45,8 @@ class Actionlog { ...@@ -44,7 +45,8 @@ class Actionlog {
* @global array $aConfig settings * @global array $aConfig settings
* @param string $sProject project ID * @param string $sProject project ID
*/ */
public function __construct($sProject = false) { public function __construct($sProject = false)
{
global $aConfig; global $aConfig;
if (!isset($aConfig["appRootDir"])) { if (!isset($aConfig["appRootDir"])) {
die(__CLASS__ . "::" . __FUNCTION__ . " ERROR: configuration with \$aConfig was not loaded."); die(__CLASS__ . "::" . __FUNCTION__ . " ERROR: configuration with \$aConfig was not loaded.");
...@@ -71,7 +73,8 @@ class Actionlog { ...@@ -71,7 +73,8 @@ class Actionlog {
/** /**
* create sqlite database - called in constructor if the file does not exist * create sqlite database - called in constructor if the file does not exist
*/ */
private function _createDb() { private function _createDb()
{
echo "try to create file $this->_dbfile ...<br>\n"; echo "try to create file $this->_dbfile ...<br>\n";
return $this->_makeQuery($this->_sCreate); return $this->_makeQuery($this->_sCreate);
} }
...@@ -81,7 +84,8 @@ class Actionlog { ...@@ -81,7 +84,8 @@ class Actionlog {
* @param string $sSql sql statement * @param string $sSql sql statement
* @return database object * @return database object
*/ */
private function _makeQuery($sSql) { private function _makeQuery($sSql)
{
// $this->_log(__FUNCTION__."($sSql)"); // $this->_log(__FUNCTION__."($sSql)");
// echo "<pre>".htmlentities($sSql)."</pre>"; // echo "<pre>".htmlentities($sSql)."</pre>";
$db = new PDO("sqlite:" . $this->_dbfile); $db = new PDO("sqlite:" . $this->_dbfile);
...@@ -102,7 +106,8 @@ class Actionlog { ...@@ -102,7 +106,8 @@ class Actionlog {
* @param string $sLoglevel loglevel * @param string $sLoglevel loglevel
* @return type * @return type
*/ */
public function add($sMessage, $sAction = "", $sLoglevel = "info", $sTimeStart = false) { public function add($sMessage, $sAction = "", $sLoglevel = "info", $sTimeStart = false)
{
if (array_search($sLoglevel, $this->_aLoglevels) === false) { if (array_search($sLoglevel, $this->_aLoglevels) === false) {
die(__class__ . ": loglevel $sLoglevel is invalid"); die(__class__ . ": loglevel $sLoglevel is invalid");
} }
...@@ -143,7 +148,8 @@ class Actionlog { ...@@ -143,7 +148,8 @@ class Actionlog {
* @param string $sOKChars good chars to keep * @param string $sOKChars good chars to keep
* @return string * @return string
*/ */
private function _filterAllowedChars($sVal, $sOKChars){ private function _filterAllowedChars($sVal, $sOKChars)
{
return preg_replace('/[^' . $sOKChars . ']/i', '', $sVal); return preg_replace('/[^' . $sOKChars . ']/i', '', $sVal);
} }
...@@ -157,7 +163,8 @@ class Actionlog { ...@@ -157,7 +163,8 @@ class Actionlog {
* 'limit' - limit clausel - part behind "LIMIT " * 'limit' - limit clausel - part behind "LIMIT "
* @return array * @return array
*/ */
public function getLogs($aFilter = array()) { public function getLogs($aFilter = array())
{
// var_dump(R::findAll( 'log' )); // var_dump(R::findAll( 'log' ));
$aReturn = array(); $aReturn = array();
...@@ -203,7 +210,8 @@ class Actionlog { ...@@ -203,7 +210,8 @@ class Actionlog {
* 'limit' - limit clausel - part behind "LIMIT " * 'limit' - limit clausel - part behind "LIMIT "
* @return string * @return string
*/ */
public function renderLogs($aFilter = array(), $bIsFullsearch=false) { public function renderLogs($aFilter = array(), $bIsFullsearch = false)
{
$sReturn = ''; $sReturn = '';
static $bWasShown; static $bWasShown;
...@@ -239,7 +247,8 @@ class Actionlog { ...@@ -239,7 +247,8 @@ class Actionlog {
), ),
'validate' => array(), 'validate' => array(),
'form' => array(), 'form' => array(),
)); )
);
// generate filter for log table // generate filter for log table
// $bIsFullsearch: true = show all inputs; false: no interactive search // $bIsFullsearch: true = show all inputs; false: no interactive search
...@@ -280,12 +289,12 @@ class Actionlog { ...@@ -280,12 +289,12 @@ class Actionlog {
'options' => $aLimits, 'options' => $aLimits,
'inline' => true, 'inline' => true,
); );
// force a line break
$aForms["filter"]["form"]['line'] = array( $aForms["filter"]["form"]['line'] = array(
'type' => 'markup', 'type' => 'markup',
'value' => '', 'value' => '<div class="col-sm-12"></div>',
); );
} else { } else {
// write filters as hidden fields // write filters as hidden fields
...@@ -310,7 +319,7 @@ class Actionlog { ...@@ -310,7 +319,7 @@ class Actionlog {
'onkeyup' => 'filterLogTable();', 'onkeyup' => 'filterLogTable();',
'onkeypress' => 'filterLogTable();', 'onkeypress' => 'filterLogTable();',
'onchange' => 'filterLogTable();', 'onchange' => 'filterLogTable();',
'size' => 20, //'size' => 20,
); );
if (!$bIsFullsearch) { if (!$bIsFullsearch) {
$aForms["filter"]["form"]['btnalllogs'] = array( $aForms["filter"]["form"]['btnalllogs'] = array(
...@@ -386,5 +395,4 @@ class Actionlog { ...@@ -386,5 +395,4 @@ class Actionlog {
} }
return $sReturn; return $sReturn;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment