-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcourse_exists.php
executable file
·177 lines (118 loc) · 5.89 KB
/
course_exists.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
// ---------------------------------------------------------
// block_cmanager is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// block_cmanager is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
//
// COURSE REQUEST MANAGER BLOCK FOR MOODLE
// by Kyle Goslin & Daniel McSweeney
// Copyright 2012-2018 - Institute of Technology Blanchardstown.
// ---------------------------------------------------------
/**
* COURSE REQUEST MANAGER
*
* @package block_cmanager
* @copyright 2018 Kyle Goslin, Daniel McSweeney
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
require_once("$CFG->libdir/formslib.php");
require_once("lib.php");
require_login();
global $CFG, $DB, $USER;
/** Navigation Bar **/
$PAGE->navbar->ignore_active();
$PAGE->navbar->add(get_string('cmanagerDisplay', 'block_cmanager'), new moodle_url('/blocks/cmanager/module_manager.php'));
$PAGE->navbar->add(get_string('courseexists', 'block_cmanager'));
$PAGE->set_url('/blocks/cmanager/course_exists.php');
$PAGE->set_context(context_system::instance());
$PAGE->set_heading(get_string('pluginname', 'block_cmanager'));
$PAGE->set_title(get_string('pluginname', 'block_cmanager'));
// Main variable for storing the current session id.
$currentSess = '00';
$currentSess = $_SESSION['cmanager_session'];
?>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php
class block_cmanager_course_exists_form extends moodleform {
function definition() {
global $CFG, $DB, $currentSess;
$currentRecord = $DB->get_record('block_cmanager_records', array('id'=>$currentSess));
$mform =& $this->_form; // Don't forget the underscore!
$mform->addElement('header', 'mainheader', '<span style="font-size:18px">'. get_string('modrequestfacility','block_cmanager') . '</span>');
// Page description text
$mform->addElement('html', '<p></p> ' . get_string('modexists','block_cmanager'). '<p></p> ');
$mform->addElement('html', '<center>
<div id="twobordertitlewide" style="background:transparent; width:820px">
<div style="text-align: left; float: left; width:160px"> <b>' . get_string('modcode','block_cmanager'). '</b></div>
<div style="text-align: left; float: left; width:160px"> <b>' . get_string('modname','block_cmanager'). '</b></div>
<div style="text-align: left; float: left; width:160px"> <b>' . get_string('catlocation','block_cmanager'). '</b></div>
<div style="text-align: left; float: left; width:160px"> <b>' . get_string('lecturingstaff','block_cmanager'). '</b></div>
<div style="text-align: left; float: left; width:160px"> <b>' . get_string('actions','block_cmanager'). '</b></div>
</div>
');
// Get out record
$currentRecord = $DB->get_record('block_cmanager_records', array('id'=>$currentSess));
$modCode = $currentRecord->modcode;
$modTitle = $currentRecord->modname;
$modMode = $currentRecord->modmode;
$spaceCheck = substr($modCode, 0, 4) . ' ' . substr($modCode, 4, strlen($modCode));
$selectQuery = "shortname LIKE '%$modCode%'
OR (shortname LIKE '%$spaceCheck%'
AND shortname LIKE '%$modMode%')
OR shortname LIKE '%$spaceCheck%'";
$recordsExist = $DB->record_exists_select('course', $selectQuery);
$allRecords = $DB->get_recordset_select('course', $select=$selectQuery);
foreach($allRecords as $record){
$lecturerHTML = '';
// Get the full category name
$categoryName = $DB->get_record('course_categories', array('id'=>$record->category));
// Get lecturer info
$lecturerHTML = block_cmanager_get_lecturer_info($record->id);
// Check if the category name is blank
if(!empty($categoryName->name)){
$catLocation = $categoryName->name;
} else {
$catLocation = ' ';
}
$mform->addElement('html', '
<div id="singleborderwide" style="background:transparent">
<div style="text-align: left; float: left; width:160px">' . $record->shortname . '</div>
<div style="text-align: left; float: left; width:160px">' . $record->fullname .'</div>
<div style="text-align: left; float: left; width:160px"> ' . $catLocation . '</div>
<div style="text-align: left; float: left; width:160px">' . $lecturerHTML. ' </div>
<div style="text-align: left; float: left; width:160px"><span style="font-size: 10px;"><a href="requests/request_control.php?id=' . $record->id . '">'.get_string('request_requestControl','block_cmanager').'</a>
<p></p>
<a href="mailto:' . block_cmanager_get_list_of_lecturer_emails($record->id). '">'.get_string('emailSubj_requester','block_cmanager').'</a></span></div>
</div>
');
}
echo '<script>function noneOfThese(){
window.location="course_new.php?status=None";
}</script>';
$mform->addElement('html', '</center>');
// Page description text
$mform->addElement('html', '<p></p><center>' . get_string('noneofthese','block_cmanager'). ', <input type="button" value="'.get_string('clickhere','block_cmanager').'" onclick="noneOfThese()"><p></p></center>');
$mform->closeHeaderBefore('buttonar');
}
}
$mform = new block_cmanager_course_exists_form();//name of the form you defined in file above.
if ($mform->is_cancelled()){
} else if ($fromform=$mform->get_data()){
} else {
echo $OUTPUT->header();
$mform->focus();
$mform->set_data($mform);
$mform->display();
echo $OUTPUT->footer();
}
?>