-
Notifications
You must be signed in to change notification settings - Fork 2
/
do_signup.php
134 lines (129 loc) · 3.78 KB
/
do_signup.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
if (! verify_in_signup_sheets()) { die("not in signup_sheets"); }
$DEBUG = 4;
// look at the sheet access table and get all the sheets on which the current user can sign up
$accessibleSheets = getSignupAccessibleSheets(true);
echo '<div id="sus_accessible_sheets">'."\n";
if (count($accessibleSheets) < 1)
{
echo "There are no sheets on which you can sign up.";
} else
{
$course_based_sheets = array();
$other_based_sheets = array();
$prior_sheet_id = '';
foreach ($accessibleSheets as $sheet)
{
if ($sheet->s_id != $prior_sheet_id)
{
$prior_sheet_id = $sheet->s_id;
$cause = '';
$base_sheet_link = "<a href=\"$ss_href&action=signuponsheet&sheet={$sheet->s_id}&access={$sheet->a_id}\">{$sheet->s_name}</a>";
// NOTE: the A) through G) leads on the keys are used to sort. The display trims the first 3 chars from the key.
switch ($sheet->a_type)
{
case 'byuser':
$other_based_sheets['A) you were specifically given access'] .= " <li>$base_sheet_link</li>\n";
break;
case 'bycourse':
$course = get_record('course','id', $sheet->a_constraint_id);
$course_based_sheets[$course->fullname] .= " <li>$base_sheet_link</li>\n";
break;
case 'byinstr':
$instr = get_record('user','id', $sheet->a_constraint_id);
$other_based_sheets["B) you're in a course taught by"] .= " <li>Professor ".$instr->lastname." - $base_sheet_link</li>\n";
break;
case 'bydept':
$other_based_sheets["C) you're in a course in this department"] .= " <li>".$sheet->a_constraint_data." - $base_sheet_link</li>\n";
break;
case 'bygradyear':
$other_based_sheets["D) your grad year is {$sheet->a_constraint_data}"] .= " <li>$base_sheet_link</li>\n";
break;
case 'byrole':
if ($sheet->a_constraint_data == 'teacher')
{
$other_based_sheets["E) you're teaching a course"] .= " <li>$base_sheet_link</li>\n";
} else if ($sheet->a_constraint_data == 'student')
{
$other_based_sheets["F) you're a student in a course"] .= " <li>$base_sheet_link</li>\n";
}
break;
case 'byhasaccount':
$other_based_sheets['G) you have an account on this system'] .= " <li>$base_sheet_link</li>\n";
break;
default:
break;
}
} // end if new sheet (i.e. cur != prior)
}
ksort($course_based_sheets);
ksort($other_based_sheets);
if ($course_based_sheets && $other_based_sheets)
{?>
<div id="course_sheets">
<h3>Sheets available because you're enrolled in...</h3>
<ul>
<?php
foreach ($course_based_sheets as $course => $items)
{
echo "
<li>$course
<ul>
$items
</ul>
</li>
";
}
?>
</ul>
</div>
<div id="other_sheets">
<h3>Sheets available because...</h3>
<ul>
<?php
foreach ($other_based_sheets as $reason => $items)
{
echo "
<li>".substr($reason,3)."
<ul>
$items
</ul>
</li>
";
}
?>
</ul>
</div>
<?php
} else // only one list has info
{?>
You can sign up for:
<ul>
<?php
foreach ($course_based_sheets as $course => $items)
{
echo "
<li>$course
<ul>
$items
</ul>
</li>
";
}
foreach ($other_based_sheets as $reason => $items)
{
echo "
<li>".substr($reason,3)."
<ul>
$items
</ul>
</li>
";
}
?>
</ul>
<?php
}
}
?>
</div><!-- end sus_accessible_sheets -->