2018-12-27 17:59:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Wruczek\TSWebsite\Assigner;
|
|
|
|
use Wruczek\TSWebsite\Auth;
|
|
|
|
use Wruczek\TSWebsite\Utils\TemplateUtils;
|
|
|
|
|
|
|
|
require_once __DIR__ . "/private/php/load.php";
|
|
|
|
|
2019-10-18 17:58:05 +00:00
|
|
|
$data = [
|
|
|
|
"isLoggedIn" => Auth::isLoggedIn()
|
|
|
|
];
|
2018-12-27 17:59:49 +00:00
|
|
|
|
|
|
|
if (Auth::isLoggedIn()) {
|
2019-10-18 17:58:05 +00:00
|
|
|
$canUseAssigner = Assigner::canUseAssigner();
|
|
|
|
$data["canUseAssigner"] = $canUseAssigner;
|
|
|
|
|
|
|
|
if (isset($_POST["assigner"]) && $canUseAssigner) {
|
2018-12-27 17:59:49 +00:00
|
|
|
$groups = array_keys($_POST["assigner"]); // get all group ids
|
|
|
|
$groups = array_filter($groups, "is_int"); // only keep integers
|
|
|
|
|
|
|
|
$changeGroups = Assigner::changeGroups($groups);
|
|
|
|
$data["groupChangeStatus"] = $changeGroups;
|
|
|
|
|
|
|
|
if ($changeGroups === 0) {
|
|
|
|
// if groups have been successfully updated,
|
|
|
|
// invalidate the cache
|
|
|
|
Auth::invalidateUserGroupCache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$assignerConfig = Assigner::getAssignerArray();
|
|
|
|
$assignerConfig = array_chunk($assignerConfig, 2);
|
|
|
|
} catch (\Exception $e) {}
|
|
|
|
|
|
|
|
// suppress warnings - might be null on exception
|
|
|
|
$data["assignerConfig"] = @$assignerConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateUtils::i()->renderTemplate("assigner", $data);
|