forked from Kylegoslin/moodle-block_cmanager
-
Notifications
You must be signed in to change notification settings - Fork 6
/
approve_mod.php
executable file
·166 lines (132 loc) · 5.51 KB
/
approve_mod.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
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?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");
global $CFG;
$formPath = "$CFG->libdir/formslib.php";
require_once($formPath);
global $USER, $DB;
$context = context_system::instance();
if (has_capability('block/cmanager:approverecord',$context)) {
} else {
print_error(get_string('cannotapproverecords', 'block_cmanager'));
}
/**
* Approving module
* Main interface for approving a module
* @package block_cmanager
* @copyright 2018 Kyle Goslin, Daniel McSweeney
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_cmanager_approve_module_form extends moodleform {
function definition() {
global $CFG, $DB;
$mform =& $this->_form; // Don't forget the underscore!
$mform->addElement('header', 'mainheader', get_string('approverequest_Title','block_cmanager'));
global $USER;
$mid = required_param('mid', PARAM_INT);
$currentRecord = $DB->get_record('block_cmanager_records', array('id'=>$mid));
$newCourseRecord = new stdClass();
$newCourseRecord->MAX_FILE_SIZE = "2097152";
$newCourseRecord->category= $currentRecord->cate;
$newCourseRecord->fullname= $currentRecord->modname;
$newCourseRecord->shortname= "CF1011X1171";
$newCourseRecord->idnumber= "s";
$newCourseRecord->summary= "asdasd";
$newCourseRecord->format= "weeks";
$newCourseRecord->numsections= "10";
$newCourseRecord->startdate= "1307664000";
$newCourseRecord->hiddensections= "0";
$newCourseRecord->newsitems= "5";
$newCourseRecord->showgrades= "1";
$newCourseRecord->showreports= "0";
$newCourseRecord->maxbytes= "2097152";
$newCourseRecord->metacourse= "0";
$newCourseRecord->enrol= "";
$newCourseRecord->defaultrole= "0";
$newCourseRecord->enrollable= "1";
$newCourseRecord->enrolstartdate= "1307577600";
$newCourseRecord->enrolstartdisabled= "1";
$newCourseRecord->enrolenddate= "1307577600";
$newCourseRecord->enrolenddisabled= "1";
$newCourseRecord->enrolperiod= "0";
$newCourseRecord->expirynotify= "0";
$newCourseRecord->notifystudents= "0";
$newCourseRecord->expirythreshold= "864000";
$newCourseRecord->groupmode= "0";
$newCourseRecord->groupmodeforce= "0";
$newCourseRecord->visible= "1";
$newCourseRecord->enrolpassword= "";
$newCourseRecord->guest= "0";
$newCourseRecord->lang= "";
$newCourseRecord->restrictmodules= "0";
$newCourseRecord->role_1= "";
$newCourseRecord->role_2= "";
$newCourseRecord->role_3= "";
$newCourseRecord->role_4= "";
$newCourseRecord->role_5= "";
$newCourseRecord->role_6= "";
$newCourseRecord->role_7= "";
$newCourseRecord->teacher= "Teacher";
$newCourseRecord->teachers= "Teachers";
$newCourseRecord->student= "Student";
$newCourseRecord->students= "Students";
$type = optional_param('type',0,PARAM_TEXT);
$htmlOutput = '';
$htmlOutput .= '<center>';
if ($type == '1') {
$course = create_course($newCourseRecord);
$htmlOutput .= get_string('approverequest_New','block_cmanager');
}
if ($type == '2') {
$htmlOutput .= get_string('approverequest_Process','block_cmanager');
}
$htmlOutput .= '</center>';
$mform->addElement('html', '<p><center><div name="addedmodules" id="addedmodules" align="left" style="border: 1px grey solid; width:700px;">
' . $htmlOutput . '<p></p> <p></p> </div></center>');
} // Close the function
} // Close the class
$mform = new block_cmanager_approve_module_form();//name of the form you defined in file above.
if ($mform->is_cancelled()) {
}
else if ($fromform=$mform->get_data()) {
//this branch is where you process validated data.
}
else {
// this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
// or on the first display of the form.
//setup strings for heading
print_header_simple($streditinga, '',
"<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
$strnav $streditinga", $mform->focus(), "", false);
//notice use of $mform->focus() above which puts the cursor
//in the first form field or the first field with an error.
//put data you want to fill out in the form into array $toform here then :
$mform->set_data($toform);
$mform->display();
print_footer($course);
}