-
Notifications
You must be signed in to change notification settings - Fork 0
/
addAssignment.php
59 lines (58 loc) · 2.11 KB
/
addAssignment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
session_start();
$id = $_POST['class'];
include "core/sqlconnect.php";
include "core/class.user.php";
$subdomain = array_shift((explode(".",$_SERVER['HTTP_HOST'])));
$user = new user();
$user->inClass($id);
if(!$user->isTeacher()){
header("Location 404.html");
exit;
}
$class = $id;
// Let's check for empty values
if($class != ""){
if($_POST['assignment'] != ""){
$name = $_POST['assignment'];
if($_POST['type'] == "1" || $_POST['type'] == "2"){
$type = $_POST['type'];
if($_POST['date']){
$date = "" . $_POST['date'] . " " . $_POST['time'] . "";
$newDate = strtotime($date);
$time = strtotime($postTime);
mysql_query("INSERT INTO `assignments` (`name`,`timeAssigned`,`timeDue`,`class`,`type`) VALUES ('" . mysql_real_escape_string($name) . "', '" . time() . "', '" . mysql_real_escape_string($newDate) . "', '" . mysql_real_escape_string($class) . "', '" . mysql_real_escape_string($type) . "')");
mkdir("./datafiles/class/" . $id . "/" . mysql_insert_id()."/",0777,true);
fopen("./datafiles/class/" . $id . "/" . mysql_insert_id()."/index.php", "w");
$danewwun = mysql_insert_id();
$arry = $user->getUsersFrom($user->getUserInfo("school"));
foreach($arry as $users){
$find = strpos($user->fetchProfileInfo($users,"classes"),$class);
if($find !== false){
if($users != $user->getUserInfo("id")){
$user->addNotification($user->getUserInfo("id"),$users,"" . $user->getUserInfo("firstName") . " " . $user->getUserInfo("lastName") . " has added a new assignment titled " . $name . " due " . date("F j Y, g:i a", $newDate) . "");
}
}
}
header("Location: http://" . $subdomain . ".aristocratlms.com/editAssignment.php?id=" . $danewwun . "");
exit;
}
else
{
header("Location: http://" . $subdomain . ".aristocratlms.com/editCourse.php?id=" . $class . "&error=date");
exit;
}
}
else
{
header("Location: http://alpha.aristocratlms.com/editCourse.php?id=" . $class . "&error=type");
exit;
}
}
else
{
header("Location: http://alpha.aristocratlms.com/editCourse.php?id=" . $class . "&error=name");
exit;
}
}
?>