/
account.php
98 lines (81 loc) · 1.56 KB
/
account.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
abstract class Account
{
//This returns true if the account can upload files for a course
abstract public function canUpload();
//This returns true if the account can change accountType of other users for a course
abstract public function canPromote();
//This returns true if the account can delete files for a course
abstract public function canDelete();
//This returns an Account object with particular permissions given a certain accountType string
//The default account object returned is Student if the user is a student or the accountType string was not recognized
public static function factory( $accountType )
{
if ( Instructor::getName() === $accountType )
{
return new Instructor();
}
if ( Uploader::getName() === $accountType )
{
return new Uploader();
}
return new Student();
}
}
class Instructor extends Account
{
public function canUpload()
{
return TRUE;
}
public function canPromote()
{
return TRUE;
}
public function canDelete()
{
return TRUE;
}
public static function getName()
{
return "instructor";
}
}
class Uploader extends Account
{
public function canUpload()
{
return TRUE;
}
public function canPromote()
{
return FALSE;
}
public function canDelete()
{
return FALSE;
}
public static function getName()
{
return "uploader";
}
}
class Student extends Account
{
public function canUpload()
{
return FALSE;
}
public function canPromote()
{
return FALSE;
}
public function canDelete()
{
return FALSE;
}
public static function getName()
{
return "student";
}
}