Exemplo n.º 1
0
    $success = true;
    $errors = [];
    if ($newName == "") {
        array_push($errors, "Username not set");
        $success = false;
    }
    if ($newEmail == "") {
        array_push($errors, "Email not set");
        $success = false;
    }
    if ($newPassword == "") {
        array_push($errors, "Password not set");
        $success = false;
    }
    if ($success) {
        $result = RegisterNewUser($newName, $newEmail, md5($newPassword));
        if ($result !== false) {
            echo json_encode(makeUserFromRaw($result, "info", $lang));
        } else {
            echo json_encode(array("Error" => "User with this email already exists"));
        }
    } else {
        echo '{"errors":' . json_encode($errors) . '}';
    }
} else {
    $usersRaw = GetAllUsers();
    if (!isset($_GET["id"])) {
        $users = [];
        for ($i = 0; $i < count($usersRaw); $i++) {
            if (isset($_GET['type'])) {
                $newUser = makeUserFromRaw($usersRaw[$i], $_GET['type'], $lang);
Exemplo n.º 2
0
<?php

if (!Defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!IsModuleInstalled("bitrix24") || !$USER->CanDoOperation('bitrix24_invite')) {
    die;
}
include dirname(__FILE__) . "/functions.php";
$arResult["ERRORS"] = "";
if ($_SERVER["REQUEST_METHOD"] === "POST" && check_bitrix_sessid()) {
    if ($_POST["reinvite"] == "Y" && intval($_POST["user_id"]) > 0) {
        ReinviteUser(SITE_ID, intval($_POST["user_id"]));
        $APPLICATION->RestartBuffer();
        return;
    } elseif (strlen($_POST["EMAIL"]) > 0) {
        $ID = RegisterNewUser(SITE_ID, $_POST);
        if (is_array($ID)) {
            $arResult["ERRORS"] = implode("<br/>", $ID);
        } elseif (intval($ID)) {
            $arResult["SUCCESS"] = "Y";
        }
    }
}
$this->IncludeComponentTemplate();