PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/MoodleWebRole/course/edit_form.php

#
PHP | 496 lines | 390 code | 76 blank | 30 comment | 65 complexity | 12bff994c1f5448c2d06490ea06d45fc MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, LGPL-2.0, GPL-2.0
  1. <?php //$Id: edit_form.php,v 1.37.2.20 2010/05/13 01:40:36 moodler Exp $
  2. if (!defined('MOODLE_INTERNAL')) {
  3. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  4. }
  5. require_once($CFG->libdir.'/formslib.php');
  6. class course_edit_form extends moodleform {
  7. function definition() {
  8. global $USER, $CFG;
  9. $courseconfig = get_config('moodlecourse');
  10. $mform =& $this->_form;
  11. $course = $this->_customdata['course'];
  12. $category = $this->_customdata['category'];
  13. $systemcontext = get_context_instance(CONTEXT_SYSTEM);
  14. $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
  15. $disable_meta = false; // basic meta course state protection; server-side security checks not needed
  16. if (!empty($course)) {
  17. $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
  18. $context = $coursecontext;
  19. if (course_in_meta($course)) {
  20. $disable_meta = get_string('metaalreadyinmeta');
  21. } else if ($course->metacourse) {
  22. if (count_records('course_meta', 'parent_course', $course->id) > 0) {
  23. $disable_meta = get_string('metaalreadyhascourses');
  24. }
  25. } else {
  26. // if users already enrolled directly into coures, do not allow switching to meta,
  27. // users with metacourse manage permission are exception
  28. // please note that we do not need exact results - anything unexpected here prevents metacourse
  29. $managers = get_users_by_capability($coursecontext, 'moodle/course:managemetacourse', 'u.id');
  30. $enrolroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $coursecontext);
  31. if ($users = get_role_users(array_keys($enrolroles), $coursecontext, false, 'u.id', 'u.id ASC')) {
  32. foreach($users as $user) {
  33. if (!isset($managers[$user->id])) {
  34. $disable_meta = get_string('metaalreadyhasenrolments');
  35. break;
  36. }
  37. }
  38. }
  39. unset($managers);
  40. unset($users);
  41. unset($enrolroles);
  42. }
  43. } else {
  44. $coursecontext = null;
  45. $context = $categorycontext;
  46. }
  47. /// form definition with new course defaults
  48. //--------------------------------------------------------------------------------
  49. $mform->addElement('header','general', get_string('general', 'form'));
  50. // Must have create course capability in both categories in order to move course
  51. if (has_capability('moodle/course:create', $categorycontext)) {
  52. $displaylist = array();
  53. $parentlist = array();
  54. make_categories_list($displaylist, $parentlist, 'moodle/course:create');
  55. $mform->addElement('select', 'category', get_string('category'), $displaylist);
  56. } else {
  57. $mform->addElement('hidden', 'category', null);
  58. $mform->setType('category', PARAM_INT);
  59. }
  60. $mform->setHelpButton('category', array('coursecategory', get_string('category')));
  61. $mform->setDefault('category', $category->id);
  62. $mform->setType('category', PARAM_INT);
  63. if ($course and !has_capability('moodle/course:changecategory', $coursecontext)) {
  64. $mform->hardFreeze('category');
  65. $mform->setConstant('category', $category->id);
  66. }
  67. $mform->addElement('text','fullname', get_string('fullname'),'maxlength="254" size="50"');
  68. $mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
  69. $mform->setDefault('fullname', get_string('defaultcoursefullname'));
  70. $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
  71. $mform->setType('fullname', PARAM_MULTILANG);
  72. if ($course and !has_capability('moodle/course:changefullname', $coursecontext)) {
  73. $mform->hardFreeze('fullname');
  74. $mform->setConstant('fullname', $course->fullname);
  75. }
  76. $mform->addElement('text','shortname', get_string('shortname'),'maxlength="100" size="20"');
  77. $mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
  78. $mform->setDefault('shortname', get_string('defaultcourseshortname'));
  79. $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
  80. $mform->setType('shortname', PARAM_MULTILANG);
  81. if ($course and !has_capability('moodle/course:changeshortname', $coursecontext)) {
  82. $mform->hardFreeze('shortname');
  83. $mform->setConstant('shortname', $course->shortname);
  84. }
  85. $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"');
  86. $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
  87. $mform->setType('idnumber', PARAM_RAW);
  88. if ($course and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
  89. $mform->hardFreeze('idnumber');
  90. $mform->setConstants('idnumber', $course->idnumber);
  91. }
  92. $mform->addElement('htmleditor','summary', get_string('summary'), array('rows'=> '10', 'cols'=>'65'));
  93. $mform->setHelpButton('summary', array('text', get_string('helptext')), true);
  94. $mform->setType('summary', PARAM_RAW);
  95. if ($course and !has_capability('moodle/course:changesummary', $coursecontext)) {
  96. $mform->hardFreeze('summary');
  97. }
  98. $courseformats = get_list_of_plugins('course/format');
  99. $formcourseformats = array();
  100. foreach ($courseformats as $courseformat) {
  101. $formcourseformats["$courseformat"] = get_string("format$courseformat","format_$courseformat");
  102. if($formcourseformats["$courseformat"]=="[[format$courseformat]]") {
  103. $formcourseformats["$courseformat"] = get_string("format$courseformat");
  104. }
  105. }
  106. $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
  107. $mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true);
  108. $mform->setDefault('format', $courseconfig->format);
  109. for ($i=1; $i<=52; $i++) {
  110. $sectionmenu[$i] = "$i";
  111. }
  112. $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
  113. $mform->setDefault('numsections', $courseconfig->numsections);
  114. $mform->addElement('date_selector', 'startdate', get_string('startdate'));
  115. $mform->setHelpButton('startdate', array('coursestartdate', get_string('startdate')), true);
  116. $mform->setDefault('startdate', time() + 3600 * 24);
  117. $choices = array();
  118. $choices['0'] = get_string('hiddensectionscollapsed');
  119. $choices['1'] = get_string('hiddensectionsinvisible');
  120. $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
  121. $mform->setHelpButton('hiddensections', array('coursehiddensections', get_string('hiddensections')), true);
  122. $mform->setDefault('hiddensections', $courseconfig->hiddensections);
  123. $options = range(0, 10);
  124. $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
  125. $mform->setHelpButton('newsitems', array('coursenewsitems', get_string('newsitemsnumber')), true);
  126. $mform->setDefault('newsitems', $courseconfig->newsitems);
  127. $mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
  128. $mform->setHelpButton('showgrades', array('coursegrades', get_string('grades')), true);
  129. $mform->setDefault('showgrades', $courseconfig->showgrades);
  130. $mform->addElement('selectyesno', 'showreports', get_string('showreports'));
  131. $mform->setHelpButton('showreports', array('coursereports', get_string('activityreport')), true);
  132. $mform->setDefault('showreports', $courseconfig->showreports);
  133. $choices = get_max_upload_sizes($CFG->maxbytes);
  134. $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
  135. $mform->setHelpButton('maxbytes', array('courseuploadsize', get_string('maximumupload')), true);
  136. $mform->setDefault('maxbytes', $courseconfig->maxbytes);
  137. if (!empty($CFG->allowcoursethemes)) {
  138. $themes=array();
  139. $themes[''] = get_string('forceno');
  140. $themes += get_list_of_themes();
  141. $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
  142. }
  143. $meta=array();
  144. $meta[0] = get_string('no');
  145. $meta[1] = get_string('yes');
  146. if ($disable_meta === false) {
  147. $mform->addElement('select', 'metacourse', get_string('managemeta'), $meta);
  148. $mform->setHelpButton('metacourse', array('metacourse', get_string('metacourse')), true);
  149. $mform->setDefault('metacourse', $courseconfig->metacourse);
  150. } else {
  151. // no metacourse element - we do not want to change it anyway!
  152. $mform->addElement('static', 'nometacourse', get_string('managemeta'),
  153. ((empty($course->metacourse)) ? $meta[0] : $meta[1]) . " - $disable_meta ");
  154. $mform->setHelpButton('nometacourse', array('metacourse', get_string('metacourse')), true);
  155. }
  156. //--------------------------------------------------------------------------------
  157. $mform->addElement('header','enrolhdr', get_string('enrolments'));
  158. $choices = array();
  159. $modules = explode(',', $CFG->enrol_plugins_enabled);
  160. foreach ($modules as $module) {
  161. $name = get_string('enrolname', "enrol_$module");
  162. $plugin = enrolment_factory::factory($module);
  163. if (method_exists($plugin, 'print_entry')) {
  164. $choices[$name] = $module;
  165. }
  166. }
  167. asort($choices);
  168. $choices = array_flip($choices);
  169. $choices = array_merge(array('' => get_string('sitedefault').' ('.get_string('enrolname', "enrol_$CFG->enrol").')'), $choices);
  170. $mform->addElement('select', 'enrol', get_string('enrolmentplugins'), $choices);
  171. $mform->setHelpButton('enrol', array('courseenrolmentplugins', get_string('enrolmentplugins')), true);
  172. $roles = get_assignable_roles($context);
  173. if (!empty($course)) {
  174. // add current default role, so that it is selectable even when user can not assign it
  175. if ($current_role = get_record('role', 'id', $course->defaultrole)) {
  176. $roles[$current_role->id] = strip_tags(format_string($current_role->name, true));
  177. }
  178. }
  179. $choices = array();
  180. if ($sitedefaultrole = get_record('role', 'id', $CFG->defaultcourseroleid)) {
  181. $choices[0] = get_string('sitedefault').' ('.$sitedefaultrole->name.')';
  182. } else {
  183. $choices[0] = get_string('sitedefault');
  184. }
  185. $choices = $choices + $roles;
  186. // fix for MDL-9197
  187. foreach ($choices as $choiceid => $choice) {
  188. $choices[$choiceid] = format_string($choice);
  189. }
  190. $mform->addElement('select', 'defaultrole', get_string('defaultrole', 'role'), $choices);
  191. $mform->setDefault('defaultrole', 0);
  192. $radio = array();
  193. $radio[] = &MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('no'), 0);
  194. $radio[] = &MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('yes'), 1);
  195. $radio[] = &MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('enroldate'), 2);
  196. $mform->addGroup($radio, 'enrollable', get_string('enrollable'), ' ', false);
  197. $mform->setHelpButton('enrollable', array('courseenrollable2', get_string('enrollable')), true);
  198. $mform->setDefault('enrollable', 1);
  199. $enroldatestartgrp = array();
  200. $enroldatestartgrp[] = &MoodleQuickForm::createElement('date_selector', 'enrolstartdate');
  201. $enroldatestartgrp[] = &MoodleQuickForm::createElement('checkbox', 'enrolstartdisabled', null, get_string('disable'));
  202. $mform->addGroup($enroldatestartgrp, 'enrolstartdategrp', get_string('enrolstartdate'), ' ', false);
  203. $mform->setDefault('enrolstartdate', 0);
  204. $mform->setDefault('enrolstartdisabled', 1);
  205. $mform->disabledIf('enrolstartdategrp', 'enrolstartdisabled', 'checked');
  206. $enroldateendgrp = array();
  207. $enroldateendgrp[] = &MoodleQuickForm::createElement('date_selector', 'enrolenddate');
  208. $enroldateendgrp[] = &MoodleQuickForm::createElement('checkbox', 'enrolenddisabled', null, get_string('disable'));
  209. $mform->addGroup($enroldateendgrp, 'enroldateendgrp', get_string('enrolenddate'), ' ', false);
  210. $mform->setDefault('enrolenddate', 0);
  211. $mform->setDefault('enrolenddisabled', 1);
  212. $mform->disabledIf('enroldateendgrp', 'enrolenddisabled', 'checked');
  213. $periodmenu=array();
  214. $periodmenu[0] = get_string('unlimited');
  215. for ($i=1; $i<=365; $i++) {
  216. $seconds = $i * 86400;
  217. $periodmenu[$seconds] = get_string('numdays', '', $i);
  218. }
  219. $mform->addElement('select', 'enrolperiod', get_string('enrolperiod'), $periodmenu);
  220. $mform->setDefault('enrolperiod', 0);
  221. //--------------------------------------------------------------------------------
  222. $mform->addElement('header','expirynotifyhdr', get_string('expirynotify'));
  223. $choices = array();
  224. $choices['0'] = get_string('no');
  225. $choices['1'] = get_string('yes');
  226. $mform->addElement('select', 'expirynotify', get_string('notify'), $choices);
  227. $mform->setHelpButton('expirynotify', array('expirynotify', get_string('expirynotify')), true);
  228. $mform->setDefault('expirynotify', 0);
  229. $mform->addElement('select', 'notifystudents', get_string('expirynotifystudents'), $choices);
  230. $mform->setHelpButton('notifystudents', array('expirynotifystudents', get_string('expirynotifystudents')), true);
  231. $mform->setDefault('notifystudents', 0);
  232. $thresholdmenu=array();
  233. for ($i=1; $i<=30; $i++) {
  234. $seconds = $i * 86400;
  235. $thresholdmenu[$seconds] = get_string('numdays', '', $i);
  236. }
  237. $mform->addElement('select', 'expirythreshold', get_string('expirythreshold'), $thresholdmenu);
  238. $mform->setHelpButton('expirythreshold', array('expirythreshold', get_string('expirythreshold')), true);
  239. $mform->setDefault('expirythreshold', 10 * 86400);
  240. //--------------------------------------------------------------------------------
  241. $mform->addElement('header','', get_string('groups', 'group'));
  242. $choices = array();
  243. $choices[NOGROUPS] = get_string('groupsnone', 'group');
  244. $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
  245. $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
  246. $mform->addElement('select', 'groupmode', get_string('groupmode'), $choices);
  247. $mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')), true);
  248. $mform->setDefault('groupmode', 0);
  249. $choices = array();
  250. $choices['0'] = get_string('no');
  251. $choices['1'] = get_string('yes');
  252. $mform->addElement('select', 'groupmodeforce', get_string('force'), $choices);
  253. $mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
  254. $mform->setDefault('groupmodeforce', 0);
  255. if (!empty($CFG->enablegroupings)) {
  256. //default groupings selector
  257. $options = array();
  258. $options[0] = get_string('none');
  259. $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
  260. }
  261. //--------------------------------------------------------------------------------
  262. $mform->addElement('header','', get_string('availability'));
  263. $choices = array();
  264. $choices['0'] = get_string('courseavailablenot');
  265. $choices['1'] = get_string('courseavailable');
  266. $mform->addElement('select', 'visible', get_string('availability'), $choices);
  267. $mform->setHelpButton('visible', array('courseavailability', get_string('availability')), true);
  268. $mform->setDefault('visible', 1);
  269. if ($course and !has_capability('moodle/course:visibility', $coursecontext)) {
  270. $mform->hardFreeze('visible');
  271. $mform->setConstant('visible', $course->visible);
  272. }
  273. $mform->addElement('passwordunmask', 'enrolpassword', get_string('enrolmentkey'), 'size="25"');
  274. $mform->setHelpButton('enrolpassword', array('enrolmentkey', get_string('enrolmentkey')), true);
  275. $mform->setDefault('enrolpassword', '');
  276. $mform->setType('enrolpassword', PARAM_RAW);
  277. if (empty($course) or ($course->password !== '' and $course->id != SITEID)) {
  278. // do not require password in existing courses that do not have password yet - backwards compatibility ;-)
  279. if (!empty($CFG->enrol_manual_requirekey)) {
  280. $mform->addRule('enrolpassword', get_string('required'), 'required', null, 'client');
  281. }
  282. }
  283. $choices = array();
  284. $choices['0'] = get_string('guestsno');
  285. $choices['1'] = get_string('guestsyes');
  286. $choices['2'] = get_string('guestskey');
  287. $mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
  288. $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
  289. $mform->setDefault('guest', 0);
  290. // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
  291. $enrol_object = $CFG;
  292. if (!empty($course)) {
  293. $enrol_object = $course;
  294. }
  295. // If the print_entry method exists and the course enrol method isn't manual (both set or inherited from site), show cost
  296. if (method_exists(enrolment_factory::factory($enrol_object->enrol), 'print_entry') && !($enrol_object->enrol == 'manual' || (empty($enrol_object->enrol) && $CFG->enrol == 'manual'))) {
  297. $costgroup=array();
  298. $currencies = get_list_of_currencies();
  299. $costgroup[]= &MoodleQuickForm::createElement('text','cost', '', 'maxlength="6" size="6"');
  300. $costgroup[]= &MoodleQuickForm::createElement('select', 'currency', '', $currencies);
  301. $mform->addGroup($costgroup, 'costgrp', get_string('cost'), '&nbsp;', false);
  302. //defining a rule for a form element within a group :
  303. $costgrprules=array();
  304. //set the message to null to tell Moodle to use a default message
  305. //available for most rules, fetched from language pack (err_{rulename}).
  306. $costgrprules['cost'][]=array(null, 'numeric', null, 'client');
  307. $mform->addGroupRule('costgrp',$costgrprules);
  308. $mform->setHelpButton('costgrp', array('cost', get_string('cost')), true);
  309. $mform->setDefault('cost', '');
  310. $mform->setDefault('currency', empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency);
  311. }
  312. //--------------------------------------------------------------------------------
  313. $mform->addElement('header','', get_string('language'));
  314. $languages=array();
  315. $languages[''] = get_string('forceno');
  316. $languages += get_list_of_languages();
  317. $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
  318. //--------------------------------------------------------------------------------
  319. if (has_capability('moodle/site:config', $systemcontext) && ((!empty($course->requested) && $CFG->restrictmodulesfor == 'requested') || $CFG->restrictmodulesfor == 'all')) {
  320. $mform->addElement('header', '', get_string('restrictmodules'));
  321. $options = array();
  322. $options['0'] = get_string('no');
  323. $options['1'] = get_string('yes');
  324. $mform->addElement('select', 'restrictmodules', get_string('restrictmodules'), $options);
  325. $mods = array(0=>get_string('allownone'));
  326. $mods += get_records_menu('modules', '','','','id, name');
  327. $mform->addElement('select', 'allowedmods', get_string('to'), $mods,
  328. array('multiple'=>'multiple', 'size'=>'10'));
  329. $mform->disabledIf('allowedmods', 'restrictmodules', 'eq', 0);
  330. } else {
  331. $mform->addElement('hidden', 'restrictmodules', null);
  332. $mform->setType('restrictmodules', PARAM_INT);
  333. }
  334. if ($CFG->restrictmodulesfor == 'all') {
  335. $mform->setDefault('allowedmods', explode(',',$CFG->defaultallowedmodules));
  336. if (!empty($CFG->restrictbydefault)) {
  337. $mform->setDefault('restrictmodules', 1);
  338. }
  339. }
  340. $mform->setType('restrictmodules', PARAM_INT);
  341. /// customizable role names in this course
  342. //--------------------------------------------------------------------------------
  343. $mform->addElement('header','rolerenaming', get_string('rolerenaming'));
  344. $mform->setHelpButton('rolerenaming', array('rolerenaming', get_string('rolerenaming')), true);
  345. if ($roles = get_records('role')) {
  346. foreach ($roles as $role) {
  347. $mform->addElement('text', 'role_'.$role->id, $role->name);
  348. $mform->setType('role_'.$role->id, PARAM_TEXT);
  349. if ($coursecontext) {
  350. if ($rolename = get_record('role_names', 'roleid', $role->id, 'contextid', $coursecontext->id)) {
  351. $mform->setDefault('role_'.$role->id, $rolename->name);
  352. }
  353. }
  354. }
  355. }
  356. //--------------------------------------------------------------------------------
  357. $this->add_action_buttons();
  358. //--------------------------------------------------------------------------------
  359. $mform->addElement('hidden', 'id', null);
  360. $mform->setType('id', PARAM_INT);
  361. // fill in default teacher and student names to keep backwards compatibility for a while
  362. $mform->addElement('hidden', 'teacher', get_string('defaultcourseteacher'));
  363. $mform->setType('teacher', PARAM_RAW);
  364. $mform->addElement('hidden', 'teachers', get_string('defaultcourseteachers'));
  365. $mform->setType('teachers', PARAM_RAW);
  366. $mform->addElement('hidden', 'student', get_string('defaultcoursestudent'));
  367. $mform->setType('student', PARAM_RAW);
  368. $mform->addElement('hidden', 'students', get_string('defaultcoursestudents'));
  369. $mform->setType('students', PARAM_RAW);
  370. }
  371. function definition_after_data() {
  372. global $CFG;
  373. $mform =& $this->_form;
  374. // add availabe groupings
  375. if ($courseid = $mform->getElementValue('id') and $mform->elementExists('defaultgroupingid')) {
  376. $options = array();
  377. if ($groupings = get_records('groupings', 'courseid', $courseid)) {
  378. foreach ($groupings as $grouping) {
  379. $options[$grouping->id] = format_string($grouping->name);
  380. }
  381. }
  382. $gr_el =& $mform->getElement('defaultgroupingid');
  383. $gr_el->load($options);
  384. }
  385. }
  386. /// perform some extra moodle validation
  387. function validation($data, $files) {
  388. global $CFG;
  389. $errors = parent::validation($data, $files);
  390. if ($foundcourses = get_records('course', 'shortname', $data['shortname'])) {
  391. if (!empty($data['id'])) {
  392. unset($foundcourses[$data['id']]);
  393. }
  394. if (!empty($foundcourses)) {
  395. foreach ($foundcourses as $foundcourse) {
  396. $foundcoursenames[] = $foundcourse->fullname;
  397. }
  398. $foundcoursenamestring = implode(',', $foundcoursenames);
  399. $errors['shortname']= get_string('shortnametaken', '', $foundcoursenamestring);
  400. }
  401. }
  402. if (empty($data['enrolenddisabled'])){
  403. if ($data['enrolenddate'] <= $data['enrolstartdate']){
  404. $errors['enroldateendgrp'] = get_string('enrolenddaterror');
  405. }
  406. }
  407. if (!empty($CFG->enrol_manual_usepasswordpolicy) and isset($data['enrolpassword']) and $data['enrolpassword'] != '') {
  408. $course = $this->_customdata['course'];
  409. if ($course->password !== $data['enrolpassword']) {
  410. // enforce password policy only if changing password - backwards compatibility
  411. $errmsg = '';
  412. if (!check_password_policy($data['enrolpassword'], $errmsg)) {
  413. $errors['enrolpassword'] = $errmsg;
  414. }
  415. }
  416. }
  417. return $errors;
  418. }
  419. }
  420. ?>