-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteunit.php
46 lines (45 loc) · 1.1 KB
/
deleteunit.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
<?php
session_start();
require_once "includer.php";
require_once "includes/check_logged.php";
if(no_get("unit")){
redirect("courses.php");
}
if(!is_hod()){
//redirect("index.php");
}
$id = get("unit");
if(empty($id)){
redirect("courses.php");
}
$unit = Unit::getById($id);
//print_r($unit);
if(zero($unit)){
redirect("courses.php");
}
$course = $unit->getCourse();
$department = $course->getDepartment();
//print_r(session("id"));
$logged = Hod::getById(session("id"));
if(zero($logged)){
redirect("index.php");
}
//print_r($logged1);
$logged_department = $logged->getDepartment();
if(zero($logged_department)){
redirect("courses.php");
} else{
if($logged_department->getId() !== $department->getId()){
redirect("courses.php");
}
else{
$unit_handler = new Unit();
$res = $unit_handler->delete($unit->getId());
// $url = "units.php?course=".$course->getId();
// $url = urlencode($url);
// print_r($url);
header("location: units.php?course=".$course->getId());
// redirect($url);
}
}
redirect("units.php?course=".$course->getId());