Current Path : /home/bitrix/ext_www/school1535.yacl.site/local/ajax/ |
Current File : /home/bitrix/ext_www/school1535.yacl.site/local/ajax/user_assistant.php |
<? // define("PUBLIC_AJAX_MODE", true); define("NO_KEEP_STATISTIC", "Y"); define("NO_AGENT_STATISTIC","Y"); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); $action = htmlspecialchars($_REQUEST['action']); if ($action == 'delete') { $user = intval($_REQUEST['user']); if ($user > 0) { $helper = new HighloadBlockHelper(13); $currentLink = $helper->getList(['filter' => ['UF_MAIN' => $USER->GetID(), 'UF_SUB' => $user], 'select' => ['ID']])->fetch(); if ($currentLink) { $helper->delete($currentLink['ID']); } } } elseif ($action == 'auth') { $user = intval($_REQUEST['user']); if ($user > 0) { $helper = new HighloadBlockHelper(13); $currentLink = $helper->getList(['filter' => ['UF_MAIN' => $user, 'UF_SUB' => $USER->GetID()], 'select' => ['ID']])->fetch(); if ($currentLink) { $USER->Authorize($user); } } } else { $user = intval($_REQUEST['new_user']); if (!$user) { $user = intval($_REQUEST['PROPERTY'][219][0]['VALUE']); } if ($user > 0) { $helper = new HighloadBlockHelper(13); $currentLink = $helper->getList(['filter' => ['UF_MAIN' => $USER->GetID(), 'UF_SUB' => $user], 'select' => ['ID']])->fetch(); if (!$currentLink) { $fields = ['UF_MAIN' => $USER->GetID(), 'UF_SUB' => $user]; if ($_REQUEST['noAuth']) { $fields['UF_NO_AUTH'] = true; } $helper->add($fields); } } } $result = [ 'success' => true, 'message' => 'Операция завершена успешно!', 'request' => print_r($_REQUEST, true), ]; echo json_encode($result);