Esempio n. 1
0
<?php

require_once "../initialize.php";
$response = "";
if (isset($_GET['schoolid']) || isset($_GET['batchid']) || isset($_GET['sectionid'])) {
    if (isset($_GET['schoolid'])) {
        if (SchoolUser::userExists($session->user_id, $_GET['schoolid'])) {
            $object = SchoolUser::getUser($session->user_id, $_GET['schoolid']);
            $object->pending == 0;
            $object->update();
            $response = "success";
        } else {
            $response = "Error";
        }
    } else {
        if (isset($_GET['batchid'])) {
            if (BatchUser::userExists($session->user_id, $_GET['batchid'])) {
                $object = BatchUser::getUser($session->user_id, $_GET['batchid']);
                $object->update();
                $response = "success";
            } else {
                $response = "Error";
            }
        } else {
            if (isset($_GET['sectionid'])) {
                if (SectionUser::userExists($session->user_id, $_GET['sectionid'])) {
                    $object = SectionUser::getUser($session->user_id, $_GET['sectionid']);
                    $object->update();
                    $response = "success";
                } else {
                    $response = "Error";
Esempio n. 2
0
<?php

require_once "../initialize.php";
$response = "";
if ((isset($_GET['schoolid']) || isset($_GET['batchid']) || isset($_GET['sectionid'])) && isset($_GET['userid'])) {
    $user = User::get_by_id($_GET['userid']);
    if (isset($_GET['schoolid'])) {
        if (!SchoolUser::userExists($user->id, $_GET['schoolid'])) {
            $school = School::get_by_id($_GET['schoolid']);
            $object = new SchoolUser();
            $object->schoolid = $school->id;
            $object->userid = $user->id;
            $object->level = 0;
            $object->role = "student";
            $object->enabled = 1;
            $object->pending = 1;
            $object->create();
            $notification = new Notification();
            $notification->fromuserid = $session->user_id;
            $notification->touserid = $user->id;
            $notification->itemid = $object->id;
            $notification->itemtype = "schooluser";
            $notification->title = "Invites you";
            $notification->create();
            $response = "success";
        } else {
            $theuser = SchoolUser::getUser($user->id, $_GET['schoolid']);
            if ($theuser->pending == 0) {
                $response = "This user is already a member.";
            } else {
                $response = "This user is already pending.";
Esempio n. 3
0
<?php

require_once "../initialize.php";
$response = "";
$loggeduser = User::get_by_id($session->user_id);
if (isset($_GET['schoolid']) || isset($_GET['batchid']) || isset($_GET['sectionid'])) {
    if (isset($_GET['schoolid'])) {
        $school = School::get_by_id($_GET['schoolid']);
        if (SchoolUser::userExists($loggeduser->id, $school->id)) {
            $object = SchoolUser::getUser($loggeduser->id, $school->id);
            $object->delete();
            $response = "success";
            $notification = new Notification();
            $notification->fromuserid = $loggeduser->id;
            $notification->itemid = $object->id;
            $notification->itemtype = "message";
            $notification->title = "Opted Out";
            $admins = SchoolUser::getAdmins($school->id);
            foreach ($admins as $admin) {
                $notification->touserid = $admin->userid;
                $notification->create();
            }
        } else {
            $response = "Error";
        }
    } else {
        if (isset($_GET['batchid'])) {
            $batch = Batch::get_by_id($_GET['batchid']);
            if (BatchUser::userExists($loggeduser->id, $_GET['batchid'])) {
                $object = BatchUser::getUser($loggeduser->id, $_GET['batchid']);
                $object->delete();