Autorisations_-tendues/inc/tester_autorisation.php
tofulm 0ea8ab59f6 Maintenant que le plugin ajoute un champ boss dans spip_auteurs et une
autorisation boss, on ajoute ce test dans notre fonction. On le place
dans notre if $secret, pour pouvoir le désactiver via notre 4e arg
2020-02-11 21:53:20 +01:00

33 lines
597 B
PHP

<?php
if (!defined('_ECRIRE_INC_VERSION')){
return;
}
function tester_autorisation($faire, $type, $qui, $secret = true) {
include_spip('inc/autoriser');
if (autoriser('webmestre', null, null, $qui, null)) {
return true;
}
if ($secret) {
if ($qui['boss'] === "oui") {
return true;
}
if (pipeline('super_autorisation',$qui)) {
return true;
}
}
$Tauts = [];
if (!empty($qui['autorisations'])) {
$Tauts = json_decode($qui['autorisations'],true);
}
if (array_key_exists($type, $Tauts)) {
if (in_array($faire, $Tauts[$type])) {
return true;
}
}
return false;
}