Exemplo n.º 1
0
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";
                }
Exemplo n.º 2
0
         $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.";
         }
     }
 } else {
     if (isset($_GET['batchid'])) {
         if (!BatchUser::userExists($user->id, $_GET['batchid'])) {
             $batch = Batch::get_by_id($_GET['batchid']);
             $school = School::get_by_id($batch->schoolid);
             $object = new BatchUser();
             $object->schoolid = $school->id;
             $object->batchid = $batch->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;
Exemplo n.º 3
0
         $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();
             $response = "success";
             $notification = new Notification();
             $notification->fromuserid = $loggeduser->id;
             $notification->itemid = $object->id;
             $notification->itemtype = "message";
             $notification->title = "Opted Out";
             $admins = BatchUser::getAdmins($batch->id);
             foreach ($admins as $admin) {
                 $notification->touserid = $admin->userid;
                 $notification->create();
             }
         } else {
             $response = "Error";