46 "ERROR" =>
"alert-danger",
47 "ALERT" =>
"alert-warning",
48 "INFO" =>
"alert-success",
69 function raise($level =
"ERROR", $clsid,
$msg, $param =
"") {
72 $level = strtoupper($level);
73 if (! in_array($level, $this->ARRLEVEL)) {
74 throw new Exception(
'Missing or unknown level in a raise() call');
77 $arrInfos[
'clsid'] = $clsid;
78 $arrInfos[
'msg'] =
$msg;
79 $arrInfos[
'param'] = is_array($param)?$param:(empty($param)?
"":array($param));
81 $this->arrMessages[$level][] = $arrInfos;
93 foreach ($this->ARRLEVEL as $v) {
94 $this->arrMessages[$v] = array();
108 $level = strtoupper($level);
109 if (in_array($level, $this->ARRLEVEL)) {
110 return (count($this->arrMessages[$level]) > 0);
112 foreach ($this->arrMessages as $v) {
132 function msg_str($level =
"ERROR", $all =
true) {
135 $level = strtoupper($level);
136 if (! in_array($level, $this->ARRLEVEL)) {
137 throw new Exception(
'Missing or unknown level in a raise() call');
144 foreach ($this->arrMessages[$level] as $k => $arrMsg) {
145 $args = $arrMsg[
'param'];
147 if (is_array($args) && count($args) > 0) {
148 array_unshift($args, $arrMsg[
'msg']);
149 $str .= call_user_func_array(
"sprintf", $args) .
"\n";
151 $str .= $arrMsg[
'msg'] .
"\n";
155 $i = count($this->arrMessages[$level]) - 1;
157 $arr_msg=$this->arrMessages[$level][
$i];
158 $args = $arr_msg[
'param'];
159 if (is_array($args) && count($args) > 0) {
160 array_unshift($args, $arr_msg[
'msg']);
161 $str = call_user_func_array(
"sprintf", $args);
163 $str = $arr_msg[
'msgId'];
181 $level = strtoupper($level);
182 if (! in_array($level, $this->ARRLEVEL)) {
183 throw new Exception(
'Missing or unknown level in a raise() call');
186 if (count($this->arrMessages[$level]) == 0)
189 $str = $this->
msg_str($level, $all);
190 $str =
"<div class='alert " . $this->ARRCSS[$level] .
"'>" . nl2br($str) .
"</div>";
231 $args = $arrMsg[
'param'];
233 if (is_array($args) && count($args) > 0) {
234 array_unshift($args, $arrMsg[
'msg']);
235 $str = call_user_func_array(
"sprintf", $args);
237 $str = $arrMsg[
'msg'];
241 date(
"d/m/Y H:i:s") .
" - " .
get_remote_ip() .
" - $level - " .
$mem->user[
"login"] .
" - " . $str .
"\n",
258 function log($clsid, $function, $param =
"") {
260 return @file_put_contents(
262 date(
"d/m/Y H:i:s") .
" - " .
get_remote_ip() .
" - CALL - " .
$mem->user[
"login"] .
" - $clsid - $function - $param\n",
278 function debug($clsid, $function, $param =
"") {
280 if (
variable_get(
"debug_panel",
"0",
"Set it to 1 to enable panel debug in /var/log/alternc/bureau.log")) {
281 return @file_put_contents(
283 date(
"d/m/Y H:i:s") .
" - " .
get_remote_ip() .
" - DEBUG - " .
$mem->user[
"login"] .
" - $clsid - $function - $param\n",
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
Handle messages (error, warning, info, ok) appearing in API calls.
$ARRCSS
CSS classes for each level.
msg_str($level="ERROR", $all=true)
Return a string of concateneted messages of all recorded messages or only the last message.
log($clsid, $function, $param="")
Log an API function call into /var/log/alternc/bureau.log.
msg_html($level="ERROR", $all=true)
Return a message in HTML form with associated CSS.
has_msgs($level="")
Tell if there are stored messages for a specific level or for all levels (if level is empty)
logAlternC($level="ERROR", $arrMsg)
Log a message into /var/log/alternc/bureau.log.
msg_html_all($all=true, $init=false)
Return all the messages of all levels in HTML form with associated CSS.
debug($clsid, $function, $param="")
Log an API function call into /var/log/alternc/bureau.log.
$ARRLEVEL
List of possible message level.
init_msgs()
Reset the stored messages array.
$arrMessages
Contains the messages and their ID.
get_remote_ip()
Return the remote IP.