1
0
moha/presence.php

78 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2022-08-28 23:44:21 +02:00
function presence($argList)
2022-08-28 23:44:21 +02:00
{
global $presence;
2022-08-28 23:44:21 +02:00
if(array_key_exists("nom", $argList))
2022-08-28 23:44:21 +02:00
{
$name = $argList["nom"];
}else
{
2022-09-01 18:48:20 +02:00
return _("Le paramètre 'nom' est obligatoire<br>present&nom=<nom>&presence=<true/false>") . EOLH;
}
if(array_key_exists("presence", $argList))
{
2022-09-01 18:48:20 +02:00
$key = $argList["presence"];
}else
{
2022-09-01 18:48:20 +02:00
return _("Le paramètre 'presence' est obligatoire<br>present&nom=<nom>&presence=<true/false>") . EOLH;
}
if (!array_key_exists($name, $presence))
{
2022-09-01 18:48:20 +02:00
return sprintf(_("Ce nom (%s) n'existe pas dans la base."), $name) . EOLH;
}
2022-08-28 23:44:21 +02:00
2022-09-01 18:48:20 +02:00
if ($key == "true")
{
2022-09-01 18:48:20 +02:00
if ($presence[$name] == false)
{
2022-09-01 18:48:20 +02:00
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__ , $device);
//echo $name . " est présent";
$presence[$name] = true;
}
2022-09-01 18:48:20 +02:00
}elseif ($presence[$name] == true)
{
$presence[$name] = false;
2022-09-01 18:48:20 +02:00
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__, $device);
2022-08-28 23:44:21 +02:00
}
2022-09-01 18:48:20 +02:00
return _("demande prise en compte");
2022-08-28 23:44:21 +02:00
}
function isPresent($name = false, $returnNames = false)
{
global $presence;
$r = false;
$list = "";
if ($name === false)
{
foreach($presence as $name => $value)
{
if ($value === true)
{
$r &= true;
$liste .= $name . EOLH;
}
}
}elseif (array_key_exists($name, $presence))
{
$r = $presence[$name];
}else
{
return -1;
}
if ($returnNames and !empty($liste))
{
return $liste;
}else
{
return $r;
}
}
2022-08-28 23:44:21 +02:00
?>