MDL-10107 Fixed the definition of message providers ... it now works through files...
[moodle.git] / message / edit_form.php
CommitLineData
3b120e46 1<?php
2
3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.com //
9// //
10// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
11// //
12// This program is free software; you can redistribute it and/or modify //
13// it under the terms of the GNU General Public License as published by //
14// the Free Software Foundation; either version 2 of the License, or //
15// (at your option) any later version. //
16// //
17// This program is distributed in the hope that it will be useful, //
18// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20// GNU General Public License for more details: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
25
26/**
27 * Edit user message form
28 *
29 * @author Luis Rodrigues
30 * @version $Id$
31 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
32 * @package
33 */
34
35require_once($CFG->dirroot.'/lib/formslib.php');
36
37class user_edit_form extends moodleform {
38
39 // Define the form
40 function definition () {
41 global $CFG, $COURSE, $DB;
42
43 $mform =& $this->_form;
44 $strrequired = get_string('required');
45
46 /// Add some extra hidden fields
47 $mform->addElement('hidden', 'id'); //the userid
48 $mform->addElement('hidden', 'course', $COURSE->id); //courseid
49
50 //get a listing of all the message processors
51 $processors = $DB->get_records('message_processors');
52
53 //create the general config section
54 $mform->addElement('header', 'general_config', get_string('general_config', 'message') );
55 $mform->addElement('checkbox', 'showmessagewindow', get_string('showmessagewindow', 'message') );
56 $mform->addElement('checkbox', 'blocknoncontacts', get_string('blocknoncontacts', 'message') );
57 $mform->addElement('checkbox', 'beepnewmessage', get_string('beepnewmessage', 'message') );
58 $mform->addElement('checkbox', 'noframesjs', get_string('noframesjs', 'message') );
59
60
61 //create the providers config section
62 $mform->addElement('header', 'providers_config', get_string('providers_config', 'message') );
120b3758 63 $providers = message_get_my_providers();
3b120e46 64 foreach ( $providers as $providerid => $provider){
120b3758 65
66 $providername = get_string('messageprovider:'.$provider->name, $provider->component);
67
68 $mform->addElement('static', 'label'.$provider->component, $providername, '');
3b120e46 69
70 $test = array();
71 foreach ( $processors as $processorid => $processor){
120b3758 72 $test[] = &$mform->createElement('checkbox', $provider->component.'_loggedin_'.$processor->name, $processor->name, $processor->name);
3b120e46 73 }
120b3758 74 $mform->addGroup($test, $provider->component.'_loggedin', get_string('loggedin', 'message'));
3b120e46 75
76 $test = array();
77 foreach ( $processors as $processorid => $processor){
120b3758 78 $test[] = &$mform->createElement('checkbox', $provider->component.'_loggedoff_'.$processor->name, $processor->name, $processor->name);
3b120e46 79 }
120b3758 80 $mform->addGroup($test, $provider->component.'_loggedoff', get_string('loggedoff', 'message'));
3b120e46 81 }
82
83 //create the processors config section (need to get config items from processor's lib.php
84 $mform->addElement('header', 'processors_config', get_string('processor_config', 'message') );
85 foreach ( $processors as $processorid => $processor){
86 $processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/lib.php';
87 if ( is_readable($processorfile) ) {
88 include_once( $processorfile );
89 $processfunc = $processor->name .'_config_form';
90 if ( function_exists($processfunc) ){
91 $processfunc($mform);
92 }
93 }
94 }
95
96 $this->add_action_buttons(false, get_string('updatemyprofile'));
97 }
98
99 function definition_after_data() {
100 return true;
101 }
102
103 function validation ($messageconf) {
104 return true;
105 }
106
107}
108
109?>