Пример #1
0
function AddTeamUser($organ, $course, $email, $level)
{
    $resp = "-1";
    $userAdd = "-1";
    $userTable = "-1";
    try {
        if ($level == "D") {
            $exists = CheckIfMenteeExists($email);
            if ($exists == "0") {
                $userAdd = AddToUserTable($email, $level);
                $userTable = AddToMenteeTable($organ, $course, $email, "Mentee");
            } else {
                if ($exists == "-1") {
                    $resp = "-1";
                } else {
                    $resp = "0";
                    // record already exists in the table.
                }
            }
        } else {
            $resp = "-1";
        }
        if ($userAdd == "1" && $userTable == "1") {
            // successful insertions.
            SendTeamMemberMail($email);
            $resp = "1";
        }
        return $resp;
    } catch (Exception $e) {
        $resp = "-1";
        return $resp;
    }
}
Пример #2
0
function AddUser($organ, $course, $email, $level)
{
    $resp = "-1";
    $userAdd = "-1";
    $userTable = "-1";
    try {
        if ($level == "B") {
            // for adding the director.
            $userAdd = AddToUserTable($email, $level);
            $userTable = AddToDirectorTable($organ, $email, "Director");
        } else {
            if ($level == "C") {
                $userAdd = AddToUserTable($email, $level);
                $userTable = AddToMentorTable($organ, $course, $email, "Mentor");
            } else {
                if ($level == "D") {
                    $userAdd = AddToUserTable($email, $level);
                    $userTable = AddToMenteeTable($organ, $course, $email, "Mentee");
                } else {
                    $resp = "-1";
                }
            }
        }
        if ($userAdd == "1" && $userTable == "1") {
            // successful insertions.
            SendNewUserMail($email);
            $resp = "1";
        } else {
            $resp = "-1";
        }
        echo $resp;
    } catch (Exception $e) {
        $resp = "-1";
        echo $resp;
    }
}