$batch = new Batch(); $batch->comments = $_POST['comments']; $batch->about = $_POST['about']; $batch->pending = $_POST['pending']; $batch->enabled = $_POST['enabled']; $batch->fromyear = $_POST['fromyear']; $batch->schoolid = $_POST['schoolid']; $batch->create(); $batchuser = new BatchUser(); $batchuser->pending = 0; $batchuser->enabled = 1; $batchuser->schoolid = $batch->schoolid; $batchuser->batchid = $batch->id; $batchuser->userid = $session->user_id; $batchuser->level = 1; $batchuser->create(); $folder_path = "../../public/schools/" . $batch->schoolid . "/yearbooks/" . $batch->id . "/"; mkdir($folder_path, 0700); mkdir($folder_path . "pages", 0700); mkdir($folder_path . "files", 0700); copy("../../public/index.php", $folder_path . "/pages/index.php"); copy("../../public/page1.html", $folder_path . "/pages/page1.html"); $log = new Log($session->user_id, $clientip, "WEB", "CREATED BATCH: " . $_POST['id']); $log->create(); } else { if ($_POST['oper'] == 'edit') { $batch = Batch::get_by_id($_POST['id']); $batch->comments = $_POST['comments']; $batch->about = $_POST['about']; $batch->pending = $_POST['pending']; $batch->enabled = $_POST['enabled'];
} } } 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; $notification->itemtype = "batchuser"; $notification->title = "Invites you"; $notification->create(); $response = "success"; } else { $theuser = BatchUser::getUser($user->id, $_GET['batchid']); if ($theuser->pending == 0) { $response = "This user is already a member."; } else { $response = "This user is already pending."; }