Browse Source

Add fields

develop_fields
Flottertotte 10 years ago
parent
commit
2e89a98b64
  1. 8
      lang/en/enrol_apply.php
  2. 78
      lib.php
  3. 151
      locallib.php
  4. 2
      version.php

8
lang/en/enrol_apply.php

@ -52,12 +52,4 @@ $string['applymanage'] = 'Manage enrolment applications';
$string['status_desc'] = 'Allow course access of internally enrolled users.';
$string['user_profile'] = 'User Profile';
$string['firstname'] = 'First name';
$string['lastname'] = 'Surname';
$string['email'] = 'Email address';
$string['city'] = 'City/town';
$string['country'] = 'Country';
$string['lang'] = 'Preferred language';
$string['description_editor'] = 'Description';
?>

78
lib.php

@ -79,8 +79,12 @@ class enrol_apply_plugin extends enrol_plugin {
if ($instance->id == $instanceid) {
if ($data = $form->get_data()) {
$userInfo = $data;
$applydescription = $userInfo->applydescription;
unset($userInfo->applydescription);
$userInfo->id = $USER->id;
$res = $DB->update_record('user',$userInfo);
//echo "<pre>";print_r($userInfo);exit;
//var_dump($res);exit;
$enrol = enrol_get_plugin('self');
$timestart = time();
if ($instance->enrolperiod) {
@ -96,8 +100,8 @@ class enrol_apply_plugin extends enrol_plugin {
}
$this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1);
sendConfirmMailToTeachers($instance->courseid, $instance->id, $data);
sendConfirmMailToManagers($instance->courseid,$data);
sendConfirmMailToTeachers($instance->courseid, $instance->id, $data, $applydescription);
sendConfirmMailToManagers($instance->courseid,$data, $applydescription);
add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere!
redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid");
@ -268,7 +272,7 @@ function sendConfirmMail($info){
email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body);
}
function sendConfirmMailToTeachers($courseid,$instanceid,$info){
function sendConfirmMailToTeachers($courseid,$instanceid,$info,$applydescription){
global $DB;
global $CFG;
global $USER;
@ -283,16 +287,33 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){
$editTeacher = $DB->get_record('user',array('id'=>$teacher->userid));
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('email', 'enrol_apply') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('city', 'enrol_apply') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('country', 'enrol_apply') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('lang', 'enrol_apply') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('email') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('city') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('country') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('lang') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>';
$body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>';
$body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>';
$body .= '<p>'. get_string('url') .': '.$info->url.'</p>';
$body .= '<p>'. get_string('icq') .': '.$info->icq.'</p>';
$body .= '<p>'. get_string('skype') .': '.$info->skype.'</p>';
$body .= '<p>'. get_string('aim') .': '.$info->aim.'</p>';
$body .= '<p>'. get_string('yahoo') .': '.$info->yahoo.'</p>';
$body .= '<p>'. get_string('msn') .': '.$info->msn.'</p>';
$body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>';
$body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>';
$body .= '<p>'. get_string('department') .': '.$info->department.'</p>';
$body .= '<p>'. get_string('phone1') .': '.$info->phone1.'</p>';
$body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>';
$body .= '<p>'. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'</p>';
$contact = core_user::get_support_user();
@ -303,7 +324,7 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){
}
}
function sendConfirmMailToManagers($courseid,$info){
function sendConfirmMailToManagers($courseid,$info,$applydescription){
global $DB;
global $CFG;
global $USER;
@ -318,15 +339,32 @@ function sendConfirmMailToManagers($courseid,$info){
$userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid));
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('email', 'enrol_apply') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('city', 'enrol_apply') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('country', 'enrol_apply') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('lang', 'enrol_apply') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('email') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('city') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('country') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('lang') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>';
$body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>';
$body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>';
$body .= '<p>'. get_string('url') .': '.$info->url.'</p>';
$body .= '<p>'. get_string('icq') .': '.$info->icq.'</p>';
$body .= '<p>'. get_string('skype') .': '.$info->skype.'</p>';
$body .= '<p>'. get_string('aim') .': '.$info->aim.'</p>';
$body .= '<p>'. get_string('yahoo') .': '.$info->yahoo.'</p>';
$body .= '<p>'. get_string('msn') .': '.$info->msn.'</p>';
$body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>';
$body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>';
$body .= '<p>'. get_string('department') .': '.$info->department.'</p>';
$body .= '<p>'. get_string('phone1') .': '.$info->phone1.'</p>';
$body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>';
$body .= '<p>'. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'</p>';
$contact = core_user::get_support_user();
$info = $userWithManagerRole;

151
locallib.php

@ -37,6 +37,7 @@ class enrol_apply_enrol_form extends moodleform {
}
public function definition() {
global $DB;
$mform = $this->_form;
$instance = $this->_customdata;
$this->instance = $instance;
@ -66,149 +67,11 @@ class enrol_apply_enrol_form extends moodleform {
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/user/lib.php');
$user = $USER;
$personalcontext = context_user::instance($user->id);
//profile_load_data($user);
$user = $DB->get_record('user',array('id'=>$USER->id));
$editoroptions = $filemanageroptions = null;
$mform->addElement('header', 'selfheader', 'User profile');
//useredit_load_preferences($user, false);
$strrequired = get_string('required');
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
$mform->addRule($fullname, $strrequired, 'required', null, 'client');
$mform->setType($fullname, PARAM_NOTAGS);
}
$enabledusernamefields = useredit_get_enabled_name_fields();
foreach ($enabledusernamefields as $addname) {
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
$mform->setType($addname, PARAM_NOTAGS);
}
//Do not show email field if change confirmation is pending
if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id='.$user->id.'">'
. get_string('emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
$mform->setType('email', PARAM_EMAIL);
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
} else {
$choices['0'] = get_string('site').' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0);
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', 0);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) {
$mform->setDefault('city', $CFG->defaultcity);
}
$choices = get_string_manager()->get_list_of_countries();
$choices= array(''=>get_string('selectacountry').'...') + $choices;
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (!empty($CFG->country)) {
$mform->setDefault('country', $CFG->country);
}
$choices = get_list_of_timezones();
$choices['99'] = get_string('serverlocaltime');
if ($CFG->forcetimezone != 99) {
$mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
} else {
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setDefault('timezone', '99');
}
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $CFG->lang);
// Multi-Calendar Support - see MDL-18375.
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
// We do not want to show this option unless there is more than one calendar type to display.
if (count($calendartypes) > 1) {
$mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
}
if (!empty($CFG->allowuserthemes)) {
$choices = array();
$choices[''] = get_string('default');
$themes = get_list_of_themes();
foreach ($themes as $key=>$theme) {
if (empty($theme->hidefromselector)) {
$choices[$key] = get_string('pluginname', 'theme_'.$theme->name);
}
}
$mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
}
$mform->addElement('editor', 'description_editor', get_string('userdescription'), null, null);
$mform->setType('description_editor', PARAM_CLEANHTML);
useredit_shared_definition($mform, $editoroptions, $filemanageroptions);
profile_definition($mform, $user->id);
$profile_default_values = $user;
if (is_object($profile_default_values)) {
@ -225,6 +88,10 @@ class enrol_apply_enrol_form extends moodleform {
$mform->addElement('hidden', 'instance');
$mform->setType('instance', PARAM_INT);
$mform->setDefault('instance', $instance->id);
//$mform->addElement('html',"<script type='text/javascript' src='../../lib/jquery/jquery-1.10.2.min.js'></script>");
//$mform->addElement('html','<script>$(document).ready(function(){$(".collapsible-actions a").trigger("click");})</script>');
//$mform->addElement('html','<script type="text/javascript">$(document).ready(function(){setTimeout(function(){$(".collapseexpand").trigger("click");},3000)})</script>');
}
public function validation($data, $files) {

2
version.php

@ -18,7 +18,7 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015012500;
$plugin->version = 2015032701;
$plugin->requires = 2011080100;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = 'Course Enrol Apply Plugin Version 1.3.1 (build 2014091000)';

Loading…
Cancel
Save