mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 21:45:37 +02:00
Merged branch 'ou-messaging-release' of git://git.luns.net.uk/moodle with conflict resolution for MDL-27171
This commit is contained in:
commit
9186cb7e98
@ -355,7 +355,6 @@ if (during_initial_install()) {
|
||||
}
|
||||
// login user and let him set password and admin details
|
||||
$adminuser->newadminuser = 1;
|
||||
message_set_default_message_preferences($adminuser);
|
||||
complete_user_login($adminuser, false);
|
||||
redirect("$CFG->wwwroot/user/editadvanced.php?id=$adminuser->id"); // Edit thyself
|
||||
|
||||
|
70
admin/message.php
Normal file
70
admin/message.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// Moodle 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/>.
|
||||
|
||||
/**
|
||||
* Message outputs configuration page
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page
|
||||
admin_externalpage_setup('managemessageoutputs');
|
||||
|
||||
// Require site configuration capability
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
|
||||
if (!empty($disable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id)); // Disable output
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey() ) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
$DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id)); // Enable output
|
||||
}
|
||||
|
||||
if ($disable || $enable) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
// Page settings
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
|
||||
// Display the manage message outputs interface
|
||||
$processors = get_message_processors();
|
||||
$messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
|
||||
// Display the page
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('managemessageoutputs', 'message'));
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
@ -46,6 +46,27 @@ if ($hassiteconfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// message outputs
|
||||
$ADMIN->add('modules', new admin_category('messageoutputs', get_string('messageoutputs', 'message')));
|
||||
$ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
|
||||
$ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
|
||||
require_once($CFG->dirroot.'/message/lib.php');
|
||||
$processors = get_message_processors();
|
||||
foreach ($processors as $processor) {
|
||||
$processorname = $processor->name;
|
||||
if (!$processor->available) {
|
||||
continue;
|
||||
}
|
||||
if ($processor->hassettings) {
|
||||
$strprocessorname = get_string('pluginname', 'message_'.$processorname);
|
||||
$settings = new admin_settingpage('messagesetting'.$processorname, $strprocessorname, 'moodle/site:config', !$processor->enabled);
|
||||
include($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php');
|
||||
if ($settings) {
|
||||
$ADMIN->add('messageoutputs', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// authentication plugins
|
||||
$ADMIN->add('modules', new admin_category('authsettings', get_string('authentication', 'admin')));
|
||||
|
||||
|
@ -17,46 +17,8 @@ $ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
|
||||
// "email" settingpage
|
||||
$temp = new admin_settingpage('mail', get_string('mail','admin'));
|
||||
$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
|
||||
'01' => '01',
|
||||
'02' => '02',
|
||||
'03' => '03',
|
||||
'04' => '04',
|
||||
'05' => '05',
|
||||
'06' => '06',
|
||||
'07' => '07',
|
||||
'08' => '08',
|
||||
'09' => '09',
|
||||
'10' => '10',
|
||||
'11' => '11',
|
||||
'12' => '12',
|
||||
'13' => '13',
|
||||
'14' => '14',
|
||||
'15' => '15',
|
||||
'16' => '16',
|
||||
'17' => '17',
|
||||
'18' => '18',
|
||||
'19' => '19',
|
||||
'20' => '20',
|
||||
'21' => '21',
|
||||
'22' => '22',
|
||||
'23' => '23')));
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // not needed here
|
||||
$options = array();
|
||||
$options['0'] = 'UTF-8';
|
||||
$options = array_merge($options, $charsets);
|
||||
$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '0', $options));
|
||||
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
|
||||
$options = array('LF'=>'LF', 'CRLF'=>'CRLF');
|
||||
$temp->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'admin'), get_string('configmailnewline','admin'), 'LF', $options));
|
||||
// "supportcontact" settingpage
|
||||
$temp = new admin_settingpage('supportcontact', get_string('supportcontact','admin'));
|
||||
if (isloggedin()) {
|
||||
global $USER;
|
||||
$primaryadminemail = $USER->email;
|
||||
@ -73,17 +35,6 @@ $temp->add(new admin_setting_configtext('supportpage', get_string('supportpage',
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
// Jabber settingpage
|
||||
$temp = new admin_settingpage('jabber', get_string('jabber', 'admin'));
|
||||
$temp->add(new admin_setting_configtext('jabberhost', get_string('jabberhost', 'admin'), get_string('configjabberhost', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('jabberserver', get_string('jabberserver', 'admin'), get_string('configjabberserver', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('jabberusername', get_string('jabberusername', 'admin'), get_string('configjabberusername', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configpasswordunmask('jabberpassword', get_string('jabberpassword', 'admin'), get_string('configjabberpassword', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configtext('jabberport', get_string('jabberport', 'admin'), get_string('configjabberport', 'admin'), 5222, PARAM_INT));
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
|
||||
// "sessionhandling" settingpage
|
||||
$temp = new admin_settingpage('sessionhandling', get_string('sessionhandling', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('dbsessions', get_string('dbsessions', 'admin'), get_string('configdbsessions', 'admin'), 1));
|
||||
|
@ -51,7 +51,6 @@ $string['allowobjectembed'] = 'Allow EMBED and OBJECT tags';
|
||||
$string['allowrenames'] = 'Allow renames';
|
||||
$string['allowthemechangeonurl'] = 'Allow theme changes in the URL';
|
||||
$string['allowuserblockhiding'] = 'Allow users to hide blocks';
|
||||
$string['allowusermailcharset'] = 'Allow user to select character set';
|
||||
$string['allowuserswitchrolestheycantassign'] = 'Allow users without the assign roles capability to switch roles';
|
||||
$string['allowuserthemes'] = 'Allow user themes';
|
||||
$string['antivirus'] = 'Anti-Virus';
|
||||
@ -133,7 +132,6 @@ $string['configallowoverride2'] = 'Select which role(s) can be overridden by eac
|
||||
$string['configallowswitch'] = 'Select which roles a user may switch to, based on which roles they already have. In addition to an entry in this table, a user must also have the moodle/role:switchroles capability to be able to switch.<br />Note that it is only possible to switch to roles that have the moodle/course:view capability, and that do not have the moodle/site:doanything capability, so some columns in this table are disabled.';
|
||||
$string['configallowthemechangeonurl'] = 'If enabled, the theme can be changed by adding theme={themename} to any Moodle URL.';
|
||||
$string['configallowuserblockhiding'] = 'Do you want to allow users to hide/show side blocks throughout this site? This feature uses Javascript and cookies to remember the state of each collapsible block, and only affects the user\'s own view.';
|
||||
$string['configallowusermailcharset'] = 'Enabling this, every user in the site will be able to specify his own charset for email.';
|
||||
$string['configallowuserswitchrolestheycantassign'] = 'By default, moodle/role:assign is required for users to switch roles. Enabling this setting removes this requirement, and results in the roles available in the "Switch role to" dropdown menu being determined by settings in the "Allow role assignments" table only.
|
||||
It is recommended that the settings in the "Allow role assignments" table do not allow users to switch to a role with more capabilities than their existing role.';
|
||||
$string['configallowuserthemes'] = 'If you enable this, then users will be allowed to set their own themes. User themes override site themes (but not course themes)';
|
||||
@ -240,11 +238,6 @@ $string['configintroadmin'] = 'On this page you should configure your main admin
|
||||
$string['configintrosite'] = 'This page allows you to configure the front page and name of this new site. You can come back here later to change these settings any time using the Administration menus.';
|
||||
$string['configintrotimezones'] = 'This page will search for new information about world timezones (including daylight savings time rules) and update your local database with this information. These locations will be checked, in order: {$a} This procedure is generally very safe and can not break normal installations. Do you wish to update your timezones now?';
|
||||
$string['configiplookup'] = 'When you click on an IP address (such as 34.12.222.93), such as in the logs, you are shown a map with a best guess of where that IP is located. There are different plugins for this that you can choose from, each has benefits and disadvantages.';
|
||||
$string['configjabberhost'] = 'The server to connect to to send jabber message notifications';
|
||||
$string['configjabberserver'] = 'XMPP host ID (can be left empty if the same as Jabber host)';
|
||||
$string['configjabberusername'] = 'The user name to use when connecting to the Jabber server';
|
||||
$string['configjabberpassword'] = 'The password to use when connecting to the Jabber server';
|
||||
$string['configjabberport'] = 'The port to use when connecting to the Jabber server';
|
||||
$string['configkeeptagnamecase'] = 'Check this if you want tag names to keep the original casing as entered by users who created them';
|
||||
$string['configlang'] = 'Choose a default language for the whole site. Users can override this setting using the language menu or the setting in their personal profile.';
|
||||
$string['configlangstringcache'] = 'Caches all the language strings into compiled files in the data directory. If you are translating Moodle or changing strings in the Moodle source code then you may want to switch this off. Otherwise leave it on to see performance benefits.';
|
||||
@ -256,7 +249,6 @@ $string['configlocale'] = 'Choose a sitewide locale - this will override the for
|
||||
$string['configloginhttps'] = 'Turning this on will make Moodle use a secure https connection just for the login page (providing a secure login), and then afterwards revert back to the normal http URL for general speed. CAUTION: this setting REQUIRES https to be specifically enabled on the web server - if it is not then YOU COULD LOCK YOURSELF OUT OF YOUR SITE.';
|
||||
$string['configloglifetime'] = 'This specifies the length of time you want to keep logs about user activity. Logs that are older than this age are automatically deleted. It is best to keep logs as long as possible, in case you need them, but if you have a very busy server and are experiencing performance problems, then you may want to lower the log lifetime. Values lower than 30 are not recommended because statistics may not work properly.';
|
||||
$string['configlookahead'] = 'Days to look ahead';
|
||||
$string['configmailnewline'] = 'Newline characters used in mail messages. CRLF is required according to RFC 822bis, some mail servers do automatic conversion from LF to CRLF, other mail servers do incorrect conversion from CRLF to CRCRLF, yet others reject mails with bare LF (qmail for example). Try changing this setting if you are having problems with undelivered emails or double newlines.';
|
||||
$string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP settings post_max_size and upload_max_filesize, as well as the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level. If \'Server Limit\' is chosen, the server maximum allowed by the server will be used.';
|
||||
$string['configmaxconsecutiveidentchars'] = 'Passwords must not have more than this number of consecutive identical characters. Use 0 to disable this check.';
|
||||
$string['configmaxeditingtime'] = 'This specifies the amount of time people have to re-edit forum postings, glossary comments etc. Usually 30 minutes is a good value.';
|
||||
@ -277,7 +269,6 @@ $string['configmypagelocked'] = 'This setting prevents the default page from bei
|
||||
$string['confignavcourselimit'] = 'Limits the number of courses shown to the user when they are either not logged in or are not enrolled in any courses.';
|
||||
$string['confignavshowallcourses'] = 'Setting this ensures that all courses on the site are shown in the navigation at all times.';
|
||||
$string['confignavshowcategories'] = 'Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.';
|
||||
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
|
||||
$string['confignotifyloginfailures'] = 'If login failures have been recorded, email notifications can be sent out. Who should see these notifications?';
|
||||
$string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?';
|
||||
$string['confignotloggedinroleid'] = 'Users who are not logged in to the site will be treated as if they have this role granted to them at the site context. Guest is almost always what you want here, but you might want to create roles that are less or more restrictive. Things like creating posts still require the user to log in properly.';
|
||||
@ -330,14 +321,10 @@ $string['configshowcommentscount'] = 'Show comments count, it will cost one more
|
||||
$string['configshowsiteparticipantslist'] = 'All of these site students and site teachers will be listed on the site participants list. Who shall be allowed to see this site participants list?';
|
||||
$string['configsitedefaultlicense'] = 'Default site licence';
|
||||
$string['configsitedefaultlicensehelp'] = 'The default licence for publishing content on this site';
|
||||
$string['configsitemailcharset'] = 'All the emails generated by your site will be sent in the charset specified here. Anyway, every individual user will be able to adjust it if the next setting is enabled.';
|
||||
$string['configsitemaxcategorydepth'] = 'Maximum category depth';
|
||||
$string['configsitemaxcategorydepthhelp'] = 'This specifies the maximum depth of child categories shown';
|
||||
$string['configslasharguments'] = 'Files (images, uploads etc) are provided via a script using \'slash arguments\'. This method allows files to be more easily cached in web browsers, proxy servers etc. Unfortunately, some PHP servers don\'t allow this method, so if you have trouble viewing uploaded files or images (eg user pictures), disable this setting.';
|
||||
$string['configsmartpix'] = 'With this on, icons are served through a PHP script that searches the current theme, then all parent themes, then the Moodle /pix folder. This reduces the need to duplicate image files within themes, but has a slight performance cost.';
|
||||
$string['configsmtphosts'] = 'Give the full name of one or more local SMTP servers that Moodle should use to send mail (eg \'mail.a.com\' or \'mail.a.com;mail.b.com\'). To specify a non-default port (i.e other than port 25), you can use the [server]:[port] syntax (eg \'mail.a.com:587\'. If you leave it blank, Moodle will use the PHP default method of sending mail.';
|
||||
$string['configsmtpmaxbulk'] = 'Maximum number of messages sent per SMTP session. Grouping messages may speed up the sending of emails. Values lower than 2 force creation of new SMTP session for each email.';
|
||||
$string['configsmtpuser'] = 'If you have specified an SMTP server above, and the server requires authentication, then enter the username and password here.';
|
||||
$string['configstartwday'] = 'Start of week';
|
||||
$string['configstatsfirstrun'] = 'This specifies how far back the logs should be processed <b>the first time</b> the cronjob wants to process statistics. If you have a lot of traffic and are on shared hosting, it\'s probably not a good idea to go too far back, as it could take a long time to run and be quite resource intensive. (Note that for this setting, 1 month = 28 days. In the graphs and reports generated, 1 month = 1 calendar month.)';
|
||||
$string['configstatsmaxruntime'] = 'Stats processing can be quite intensive, so use a combination of this field and the next one to specify when it will run and how long for.';
|
||||
@ -631,12 +618,6 @@ It is recommended to install local copy of free GeoLite City database from MaxMi
|
||||
IP address location is displayed on simple map or using Google Maps. Please note that you need to have a Google account and apply for free Google Maps API key to enable interactive maps.';
|
||||
$string['iplookupmaxmindnote'] = 'This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com/">http://www.maxmind.com/</a>.';
|
||||
$string['iplookupnetgeonote'] = 'The NetGeo server is currently being used to look up geographical information. For more accurate results we recommend installing a local copy of the MaxMind GeoLite database.';
|
||||
$string['jabber'] = 'Jabber';
|
||||
$string['jabberhost'] = 'Jabber host';
|
||||
$string['jabberserver'] = 'Jabber server';
|
||||
$string['jabberusername'] = 'Jabber user name';
|
||||
$string['jabberpassword'] = 'Jabber password';
|
||||
$string['jabberport'] = 'Jabber port';
|
||||
$string['keeptagnamecase'] = 'Keep tag name casing';
|
||||
$string['lang'] = 'Default language';
|
||||
$string['langcache'] = 'Cache language menu';
|
||||
@ -682,8 +663,6 @@ $string['logguests_help'] = 'This setting enables logging of actions by guest ac
|
||||
$string['loginhttps'] = 'Use HTTPS for logins';
|
||||
$string['loglifetime'] = 'Keep logs for';
|
||||
$string['longtimewarning'] = '<b>Please note that this process can take a long time.</b>';
|
||||
$string['mail'] = 'Email';
|
||||
$string['mailnewline'] = 'Newline characters in mail';
|
||||
$string['maintenancemode'] = 'In maintenance mode';
|
||||
$string['maintfileopenerror'] = 'Error opening maintenance files!';
|
||||
$string['maintinprogress'] = 'Maintenance is in progress...';
|
||||
@ -764,7 +743,6 @@ $string['nolangupdateneeded'] = 'All your language packs are up to date, no upda
|
||||
$string['nomissingstrings'] = 'No missing strings';
|
||||
$string['nonewsettings'] = 'No new settings were added during this upgrade.';
|
||||
$string['nonexistentbookmark'] = 'The bookmark you requested does not exist.';
|
||||
$string['noreplyaddress'] = 'No-reply address';
|
||||
$string['noresults'] = 'No results found.';
|
||||
$string['noroles'] = 'No roles';
|
||||
$string['notifications'] = 'Notifications';
|
||||
@ -956,7 +934,6 @@ $string['showdetails'] = 'Show details';
|
||||
$string['simpletest'] = 'Unit tests';
|
||||
$string['simplexmlrequired'] = 'The SimpleXML PHP extension is now required by Moodle.';
|
||||
$string['sitelangchanged'] = 'Site language setting changed successfully';
|
||||
$string['sitemailcharset'] = 'Character set';
|
||||
$string['sitemaintenance'] = 'The site is undergoing maintenance and is currently not available';
|
||||
$string['sitemaintenancemode'] = 'Maintenance mode';
|
||||
$string['sitemaintenanceoff'] = 'Maintenance mode has been disabled and the site is running normally again';
|
||||
@ -971,10 +948,6 @@ $string['sitepolicyguest_help'] = 'If you have a site policy that all guests mus
|
||||
$string['sitesectionhelp'] = 'If selected, a topic section will be displayed on the site\'s front page.';
|
||||
$string['slasharguments'] = 'Use slash arguments';
|
||||
$string['smartpix'] = 'Smart pix search';
|
||||
$string['smtphosts'] = 'SMTP hosts';
|
||||
$string['smtpmaxbulk'] = 'SMTP session limit';
|
||||
$string['smtppass'] = 'SMTP password';
|
||||
$string['smtpuser'] = 'SMTP username';
|
||||
$string['soaprecommended'] = 'Installing the optional soap extension is useful for web services and some contrib modules.';
|
||||
$string['spellengine'] = 'Spell engine';
|
||||
$string['splrequired'] = 'The SPL PHP extension is now required by Moodle.';
|
||||
@ -990,6 +963,7 @@ $string['stickyblocksduplicatenotice'] = 'If any block you add here is already p
|
||||
$string['stickyblocksmymoodle'] = 'My Moodle';
|
||||
$string['stickyblockspagetype'] = 'Page type to configure';
|
||||
$string['stripalltitletags'] = 'Remove HTML tags from all activity names';
|
||||
$string['supportcontact'] = 'Support contact';
|
||||
$string['supportemail'] = 'Support email';
|
||||
$string['supportname'] = 'Support name';
|
||||
$string['supportpage'] = 'Support page';
|
||||
|
@ -37,19 +37,23 @@ $string['blockcontact'] = 'Block contact';
|
||||
$string['blockedmessages'] = '{$a} message(s) to/from blocked users';
|
||||
$string['blockedusers'] = 'Blocked users ({$a})';
|
||||
$string['blocknoncontacts'] = 'Prevent non-contacts from messaging me';
|
||||
$string['cannotsavemessageprefs'] = 'Could not save user messaging preferences';
|
||||
$string['contactlistempty'] = 'Your contact list is empty';
|
||||
$string['contacts'] = 'Contacts';
|
||||
$string['context'] = 'context';
|
||||
$string['couldnotfindpreference'] = 'Could not load preference {$a}. Does the component and name you supplied to message_send() match a row in message_providers? Message providers must appear in the database so users can configure how they will be notified when they receive messages.';
|
||||
$string['defaultmessageoutputs'] = 'Default message outputs';
|
||||
$string['defaults'] = 'Defaults';
|
||||
$string['deletemessagesdays'] = 'Number of days before old messages are automatically deleted';
|
||||
$string['disabled'] = 'Messaging is disabled on this site';
|
||||
$string['disallowed'] = 'Disallowed';
|
||||
$string['discussion'] = 'Discussion';
|
||||
$string['editmymessage'] = 'Messaging';
|
||||
$string['emailmessages'] = 'Email messages when I am offline';
|
||||
$string['emailtagline'] = 'This is a copy of a message sent to you at "{$a->sitename}". Go to {$a->url} to reply.';
|
||||
$string['emptysearchstring'] = 'You must search for something';
|
||||
$string['errorcallingprocessor'] = 'Error calling defined processor';
|
||||
$string['errortranslatingdefault'] = 'Error translating default setting provided by plugin, using system defaults instead.';
|
||||
$string['forced'] = 'Forced';
|
||||
$string['formorethan'] = 'For more than';
|
||||
$string['guestnoeditmessage'] = 'Guest user can not edit messaging options';
|
||||
$string['guestnoeditmessageother'] = 'Guest user can not edit other user messaging options';
|
||||
@ -64,6 +68,8 @@ $string['loggedindescription'] = 'When I\'m logged in';
|
||||
$string['loggedoff'] = 'Not online';
|
||||
$string['loggedoffdescription'] = 'When I\'m offline';
|
||||
$string['managecontacts'] = 'Manage my contacts';
|
||||
$string['managemessageoutputs'] = 'Manage message outputs';
|
||||
$string['messageoutputs'] = 'Message outputs';
|
||||
$string['mostrecent'] = 'Recent messages';
|
||||
$string['mostrecentconversations'] = 'Recent conversations';
|
||||
$string['mostrecentnotifications'] = 'Recent notifications';
|
||||
@ -83,6 +89,7 @@ $string['nomessages'] = 'No messages waiting';
|
||||
$string['nomessagesfound'] = 'No messages were found';
|
||||
$string['noreply'] = 'Do not reply to this message';
|
||||
$string['nosearchresults'] = 'There were no results from your search';
|
||||
$string['notpermitted'] = 'Not permitted';
|
||||
$string['offline'] = 'Offline';
|
||||
$string['offlinecontacts'] = 'Offline contacts ({$a})';
|
||||
$string['online'] = 'Online';
|
||||
@ -90,7 +97,13 @@ $string['onlinecontacts'] = 'Online contacts ({$a})';
|
||||
$string['onlyfromme'] = 'Only messages from me';
|
||||
$string['onlymycourses'] = 'Only in my courses';
|
||||
$string['onlytome'] = 'Only messages to me';
|
||||
$string['outputdisabled'] = 'Output disabled';
|
||||
$string['outputdoesnotexist'] = 'Message output does not exists';
|
||||
$string['outputenabled'] = 'Output enabled';
|
||||
$string['outputnotavailable'] = 'Not available';
|
||||
$string['outputnotconfigured'] = 'Not configured';
|
||||
$string['pagerefreshes'] = 'This page refreshes automatically every {$a} seconds';
|
||||
$string['permitted'] = 'Permitted';
|
||||
$string['private_config'] = 'Popup message window';
|
||||
$string['processortag'] = 'Destination';
|
||||
$string['providers_config'] = 'Configure notification methods for incoming messages';
|
||||
@ -103,6 +116,8 @@ $string['search'] = 'Search';
|
||||
$string['searchforperson'] = 'Search for a person';
|
||||
$string['searchmessages'] = 'Search messages';
|
||||
$string['searchcombined'] = 'Search people and messages';
|
||||
$string['sendingvia'] = 'Sending "{$a->provider}" via "{$a->processor}"';
|
||||
$string['sendingviawhen'] = 'Sending "{$a->provider}" via "{$a->processor}" when {$a->state}';
|
||||
$string['sendmessage'] = 'Send message';
|
||||
$string['sendmessageto'] = 'Send message to {$a}';
|
||||
$string['sendmessagetopopup'] = 'Send message to {$a} - new window';
|
||||
|
@ -107,6 +107,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
/// Add libraries
|
||||
require_once($CFG->libdir.'/ddllib.php');
|
||||
require_once($CFG->libdir.'/xmlize.php');
|
||||
require_once($CFG->libdir.'/messagelib.php');
|
||||
|
||||
define('INSECURE_DATAROOT_WARNING', 1);
|
||||
define('INSECURE_DATAROOT_ERROR', 2);
|
||||
@ -260,6 +261,14 @@ function uninstall_plugin($type, $name) {
|
||||
// delete the module configuration records
|
||||
unset_all_config_for_plugin($pluginname);
|
||||
|
||||
// delete message provider
|
||||
message_provider_uninstall($component);
|
||||
|
||||
// delete message processor
|
||||
if ($type === 'message') {
|
||||
message_processor_uninstall($name);
|
||||
}
|
||||
|
||||
// delete the plugin tables
|
||||
$xmldbfilepath = $plugindirectory . '/db/install.xml';
|
||||
drop_plugin_tables($pluginname, $xmldbfilepath, false);
|
||||
@ -4938,6 +4947,75 @@ class admin_page_manageblocks extends admin_externalpage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Message outputs configuration
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_page_managemessageoutputs extends admin_externalpage {
|
||||
/**
|
||||
* Calls parent::__construct with specific arguments
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
parent::__construct('managemessageoutputs', get_string('managemessageoutputs', 'message'), new moodle_url('/admin/message.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a specific message processor
|
||||
*
|
||||
* @param string $query The string to search for
|
||||
* @return array
|
||||
*/
|
||||
public function search($query) {
|
||||
global $CFG, $DB;
|
||||
if ($result = parent::search($query)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$found = false;
|
||||
if ($processors = get_message_processors()) {
|
||||
$textlib = textlib_get_instance();
|
||||
foreach ($processors as $processor) {
|
||||
if (!$processor->available) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($processor->name, $query) !== false) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
$strprocessorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
if (strpos($textlib->strtolower($strprocessorname), $query) !== false) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($found) {
|
||||
$result = new stdClass();
|
||||
$result->page = $this;
|
||||
$result->settings = array();
|
||||
return array($this->name => $result);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default message outputs configuration
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_page_defaultmessageoutputs extends admin_page_managemessageoutputs {
|
||||
/**
|
||||
* Calls parent::__construct with specific arguments
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
admin_externalpage::__construct('defaultmessageoutputs', get_string('defaultmessageoutputs', 'message'), new moodle_url('/message/defaultoutputs.php'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Question type manage page
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20110523" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20110525" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -2297,8 +2297,9 @@
|
||||
</TABLE>
|
||||
<TABLE NAME="message_processors" COMMENT="List of message output plugins" PREVIOUS="message_providers" NEXT="message_working">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" COMMENT="id of the table, please edit me" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="166" NOTNULL="true" SEQUENCE="false" COMMENT="Default comment for the field, please edit me" PREVIOUS="id"/>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="166" NOTNULL="true" SEQUENCE="false" COMMENT="Name of the message processor" PREVIOUS="id" NEXT="enabled"/>
|
||||
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="Defines if processor is enabled" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
|
||||
|
@ -39,6 +39,10 @@ $messageproviders = array (
|
||||
),
|
||||
|
||||
'instantmessage' => array (
|
||||
'defaults' => array(
|
||||
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
|
||||
'email' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDOFF,
|
||||
),
|
||||
),
|
||||
|
||||
'backup' => array (
|
||||
|
@ -6514,6 +6514,23 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint(true, 2011060500);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011060800) {
|
||||
// Add enabled field to message_processors
|
||||
$table = new xmldb_table('message_processors');
|
||||
$field = new xmldb_field('enabled');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'name');
|
||||
|
||||
// Launch add field addition
|
||||
if (!$dbman->field_exists($table,$field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Populate default messaging settings
|
||||
upgrade_populate_default_messaging_prefs();
|
||||
|
||||
upgrade_main_savepoint(true, 2011060800);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6521,4 +6538,4 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
// 1/ drop block_pinned_old table here and in install.xml
|
||||
// 2/ drop block_instance_old table here and in install.xml
|
||||
|
||||
//TODO: AFTER 2.0 remove the column user->emailstop and the user preference "message_showmessagewindow"
|
||||
//TODO: AFTER 2.0 remove the column user->emailstop and the user preference "message_showmessagewindow"
|
||||
|
@ -645,3 +645,54 @@ function update_fix_automated_backup_config() {
|
||||
unset_config('backup_sche_gradebook_history');
|
||||
unset_config('disablescheduleddbackups');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to set default messaging preferences when the new
|
||||
* admin-level messaging defaults settings have been introduced.
|
||||
*/
|
||||
function upgrade_populate_default_messaging_prefs() {
|
||||
global $DB;
|
||||
|
||||
$providers = $DB->get_records('message_providers');
|
||||
$processors = $DB->get_records('message_processors');
|
||||
$defaultpreferences = (object)$DB->get_records_menu('config_plugins', array('plugin'=>'message'), '', 'name,value');
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
$setting = new stdClass();
|
||||
$setting->plugin = 'message';
|
||||
|
||||
foreach ($providers as $provider) {
|
||||
$componentproviderbase = $provider->component.'_'.$provider->name;
|
||||
// set MESSAGE_PERMITTED to all combinations of message types
|
||||
// (providers) and outputs (processors)
|
||||
foreach ($processors as $processor) {
|
||||
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_permitted';
|
||||
if (!isset($defaultpreferences->{$preferencename})) {
|
||||
$setting->name = $preferencename;
|
||||
$setting->value = 'permitted';
|
||||
$DB->insert_record('config_plugins', $setting);
|
||||
}
|
||||
}
|
||||
// for email output we also have to set MESSAGE_DEFAULT_OFFLINE + MESSAGE_DEFAULT_ONLINE
|
||||
foreach(array('loggedin', 'loggedoff') as $state) {
|
||||
$preferencename = 'message_provider_'.$componentproviderbase.'_'.$state;
|
||||
if (!isset($defaultpreferences->{$preferencename})) {
|
||||
$setting->name = $preferencename;
|
||||
$setting->value = 'email';
|
||||
// except instant message where default for popup should be
|
||||
// MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF and for email
|
||||
// MESSAGE_DEFAULT_LOGGEDOFF.
|
||||
if ($componentproviderbase == 'moodle_instantmessage') {
|
||||
if ($state == 'loggedoff') {
|
||||
$setting->value = 'email,popup';
|
||||
} else {
|
||||
$setting->value = 'popup';
|
||||
}
|
||||
}
|
||||
$DB->insert_record('config_plugins', $setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
@ -574,7 +574,6 @@ function install_cli_database(array $options, $interactive) {
|
||||
$admins = get_admins();
|
||||
$admin = reset($admins);
|
||||
session_set_user($admin);
|
||||
message_set_default_message_preferences($admin);
|
||||
|
||||
// apply all default settings, do it twice to fill all defaults - some settings depend on other setting
|
||||
admin_apply_default_settings(NULL, true);
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/message/lib.php');
|
||||
|
||||
/**
|
||||
* Called when a message provider wants to send a message.
|
||||
* This functions checks the user's processor configuration to send the given type of message,
|
||||
@ -34,8 +36,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* Required parameter $eventdata structure:
|
||||
* component string component name. must exist in message_providers
|
||||
* name string message type name. must exist in message_providers
|
||||
* userfrom object the user sending the message
|
||||
* userto object the message recipient
|
||||
* userfrom object|int the user sending the message
|
||||
* userto object|int the message recipient
|
||||
* subject string the message subject
|
||||
* fullmessage - the full message in a given format
|
||||
* fullmessageformat - the format if the full message (FORMAT_MOODLE, FORMAT_HTML, ..)
|
||||
@ -57,12 +59,10 @@ function message_send($eventdata) {
|
||||
$DB->transactions_forbidden();
|
||||
|
||||
if (is_int($eventdata->userto)) {
|
||||
mtrace('message_send() userto is a user ID when it should be a user object');
|
||||
$eventdata->userto = $DB->get_record('user', array('id' => $eventdata->useridto));
|
||||
$eventdata->userto = $DB->get_record('user', array('id' => $eventdata->userto));
|
||||
}
|
||||
if (is_int($eventdata->userfrom)) {
|
||||
mtrace('message_send() userfrom is a user ID when it should be a user object');
|
||||
$eventdata->userfrom = $DB->get_record('user', array('id' => $message->userfrom));
|
||||
$eventdata->userfrom = $DB->get_record('user', array('id' => $eventdata->userfrom));
|
||||
}
|
||||
|
||||
//after how long inactive should the user be considered logged off?
|
||||
@ -109,25 +109,55 @@ function message_send($eventdata) {
|
||||
|
||||
$savemessage->timecreated = time();
|
||||
|
||||
// Find out what processors are defined currently
|
||||
// When a user doesn't have settings none gets return, if he doesn't want contact "" gets returned
|
||||
$preferencename = 'message_provider_'.$eventdata->component.'_'.$eventdata->name.'_'.$userstate;
|
||||
// Fetch enabled processors
|
||||
$processors = get_message_processors(true);
|
||||
// Fetch default (site) preferences
|
||||
$defaultpreferences = get_message_output_default_preferences();
|
||||
|
||||
$processor = get_user_preferences($preferencename, null, $eventdata->userto->id);
|
||||
if ($processor == NULL) { //this user never had a preference, save default
|
||||
if (!message_set_default_message_preferences($eventdata->userto)) {
|
||||
print_error('cannotsavemessageprefs', 'message');
|
||||
}
|
||||
$processor = get_user_preferences($preferencename, NULL, $eventdata->userto->id);
|
||||
if (empty($processor)) {
|
||||
// Preset variables
|
||||
$processorlist = array();
|
||||
$preferencebase = $eventdata->component.'_'.$eventdata->name;
|
||||
// Fill in the array of processors to be used based on default and user preferences
|
||||
foreach ($processors as $processor) {
|
||||
// First find out permissions
|
||||
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$permitted = $defaultpreferences->{$defaultpreference};
|
||||
} else {
|
||||
//MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
|
||||
//exist in the message_provider table
|
||||
//exist in the message_provider table (thus there is no default settings for them)
|
||||
$preferrormsg = get_string('couldnotfindpreference', 'message', $preferencename);
|
||||
throw new coding_exception($preferrormsg,'blah');
|
||||
}
|
||||
|
||||
// Find out if user has configured this output
|
||||
$userisconfigured = $processor->object->is_user_configured($eventdata->userto);
|
||||
|
||||
// DEBUG: noify if we are forcing unconfigured output
|
||||
if ($permitted == 'forced' && !$userisconfigured) {
|
||||
debugging('Attempt to force message delivery to user who has "'.$processor->name.'" output unconfigured', DEBUG_NORMAL);
|
||||
}
|
||||
|
||||
// Populate the list of processors we will be using
|
||||
if ($permitted == 'forced' && $userisconfigured) {
|
||||
// We force messages for this processor, so use this processor unconditionally if user has configured it
|
||||
$processorlist[] = $processor->name;
|
||||
} else if ($permitted == 'permitted' && $userisconfigured) {
|
||||
// User settings are permitted, see if user set any, otherwise use site default ones
|
||||
$userpreferencename = 'message_provider_'.$preferencebase.'_'.$userstate;
|
||||
if ($userpreference = get_user_preferences($userpreferencename, null, $eventdata->userto->id)) {
|
||||
if (in_array($processor->name, explode(',', $userpreference))) {
|
||||
$processorlist[] = $processor->name;
|
||||
}
|
||||
} else if (isset($defaultpreferences->{$userpreferencename})) {
|
||||
if (in_array($processor->name, explode(',', $defaultpreferences->{$userpreferencename}))) {
|
||||
$processorlist[] = $processor->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($processor=='none' && $savemessage->notification) {
|
||||
if (empty($processorlist) && $savemessage->notification) {
|
||||
//if they have deselected all processors and its a notification mark it read. The user doesnt want to be bothered
|
||||
$savemessage->timeread = time();
|
||||
$messageid = $DB->insert_record('message_read', $savemessage);
|
||||
@ -137,29 +167,14 @@ function message_send($eventdata) {
|
||||
$eventdata->savedmessageid = $savemessage->id;
|
||||
|
||||
// Try to deliver the message to each processor
|
||||
if ($processor!='none') {
|
||||
$processorlist = explode(',', $processor);
|
||||
if (!empty($processorlist)) {
|
||||
foreach ($processorlist as $procname) {
|
||||
$processorfile = $CFG->dirroot. '/message/output/'.$procname.'/message_output_'.$procname.'.php';
|
||||
|
||||
if (is_readable($processorfile)) {
|
||||
include_once($processorfile); // defines $module with version etc
|
||||
$processclass = 'message_output_' . $procname;
|
||||
|
||||
if (class_exists($processclass)) {
|
||||
$pclass = new $processclass();
|
||||
|
||||
if (!$pclass->send_message($eventdata)) {
|
||||
debugging('Error calling message processor '.$procname);
|
||||
$messageid = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debugging('Error finding message processor '.$procname);
|
||||
if (!$processors[$procname]->object->send_message($eventdata)) {
|
||||
debugging('Error calling message processor '.$procname);
|
||||
$messageid = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if messaging is disabled and they previously had forum notifications handled by the popup processor
|
||||
//or any processor that puts a row in message_working then the notification will remain forever
|
||||
//unread. To prevent this mark the message read if messaging is disabled
|
||||
@ -180,6 +195,7 @@ function message_send($eventdata) {
|
||||
|
||||
/**
|
||||
* This code updates the message_providers table with the current set of providers
|
||||
*
|
||||
* @param $component - examples: 'moodle', 'mod_forum', 'block_quiz_results'
|
||||
* @return boolean
|
||||
*/
|
||||
@ -195,7 +211,7 @@ function message_update_providers($component='moodle') {
|
||||
foreach ($fileproviders as $messagename => $fileprovider) {
|
||||
|
||||
if (!empty($dbproviders[$messagename])) { // Already exists in the database
|
||||
|
||||
// check if capability has changed
|
||||
if ($dbproviders[$messagename]->capability == $fileprovider['capability']) { // Same, so ignore
|
||||
// exact same message provider already present in db, ignore this entry
|
||||
unset($dbproviders[$messagename]);
|
||||
@ -217,19 +233,128 @@ function message_update_providers($component='moodle') {
|
||||
$provider->component = $component;
|
||||
$provider->capability = $fileprovider['capability'];
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$DB->insert_record('message_providers', $provider);
|
||||
message_set_default_message_preference($component, $messagename, $fileprovider);
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($dbproviders as $dbprovider) { // Delete old ones
|
||||
$DB->delete_records('message_providers', array('id' => $dbprovider->id));
|
||||
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_{$dbprovider->name}_%"));
|
||||
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_{$dbprovider->name}_%"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function populates default message preferences for all existing providers
|
||||
* when the new message processor is added.
|
||||
*
|
||||
* @param string $processorname The name of message processor plugin (e.g. 'email', 'jabber')
|
||||
* @return void
|
||||
* @throws invalid_parameter_exception if $processorname does not exist
|
||||
*/
|
||||
function message_update_processors($processorname) {
|
||||
global $DB;
|
||||
|
||||
// validate if our processor exists
|
||||
$processor = $DB->get_records('message_processors', array('name' => $processorname));
|
||||
if (empty($processor)) {
|
||||
throw new invalid_parameter_exception();
|
||||
}
|
||||
|
||||
$providers = $DB->get_records_sql('SELECT DISTINCT component FROM {message_providers}');
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
foreach ($providers as $provider) {
|
||||
// load message providers from files
|
||||
$fileproviders = message_get_providers_from_file($provider->component);
|
||||
foreach ($fileproviders as $messagename => $fileprovider) {
|
||||
message_set_default_message_preference($provider->component, $messagename, $fileprovider, $processorname);
|
||||
}
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting default messaging preference for particular message provider
|
||||
*
|
||||
* @param string $component The name of component (e.g. moodle, mod_forum, etc.)
|
||||
* @param string $messagename The name of message provider
|
||||
* @param array $fileprovider The value of $messagename key in the array defined in plugin messages.php
|
||||
* @param string $processorname The optinal name of message processor
|
||||
* @return void
|
||||
*/
|
||||
function message_set_default_message_preference($component, $messagename, $fileprovider, $processorname='') {
|
||||
global $DB;
|
||||
|
||||
// Fetch message processors
|
||||
$condition = null;
|
||||
// If we need to process a particular processor, set the select condition
|
||||
if (!empty($processorname)) {
|
||||
$condition = array('name' => $processorname);
|
||||
}
|
||||
$processors = $DB->get_records('message_processors', $condition);
|
||||
|
||||
// load default messaging preferences
|
||||
$defaultpreferences = get_message_output_default_preferences();
|
||||
|
||||
// Setting default preference
|
||||
$componentproviderbase = $component.'_'.$messagename;
|
||||
$loggedinpref = array();
|
||||
$loggedoffpref = array();
|
||||
// set 'permitted' preference first for each messaging processor
|
||||
foreach ($processors as $processor) {
|
||||
$preferencename = $processor->name.'_provider_'.$componentproviderbase.'_permitted';
|
||||
// if we do not have this setting yet, set it
|
||||
if (!isset($defaultpreferences->{$preferencename})) {
|
||||
// determine plugin default settings
|
||||
$plugindefault = 0;
|
||||
if (isset($fileprovider['defaults'][$processor->name])) {
|
||||
$plugindefault = $fileprovider['defaults'][$processor->name];
|
||||
}
|
||||
// get string values of the settings
|
||||
list($permitted, $loggedin, $loggedoff) = translate_message_default_setting($plugindefault, $processor->name);
|
||||
// store default preferences for current processor
|
||||
set_config($preferencename, $permitted, 'message');
|
||||
// save loggedin/loggedoff settings
|
||||
if ($loggedin) {
|
||||
$loggedinpref[] = $processor->name;
|
||||
}
|
||||
if ($loggedoff) {
|
||||
$loggedoffpref[] = $processor->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
// now set loggedin/loggedoff preferences
|
||||
if (!empty($loggedinpref)) {
|
||||
$preferencename = 'message_provider_'.$componentproviderbase.'_loggedin';
|
||||
if (isset($defaultpreferences->{$preferencename})) {
|
||||
// We have the default preferences for this message provider, which
|
||||
// likely means that we have been adding a new processor. Add defaults
|
||||
// to exisitng preferences.
|
||||
$loggedinpref = array_merge($loggedinpref, explode(',', $defaultpreferences->{$preferencename}));
|
||||
}
|
||||
set_config($preferencename, join(',', $loggedinpref), 'message');
|
||||
}
|
||||
if (!empty($loggedoffpref)) {
|
||||
$preferencename = 'message_provider_'.$componentproviderbase.'_loggedoff';
|
||||
if (isset($defaultpreferences->{$preferencename})) {
|
||||
// We have the default preferences for this message provider, which
|
||||
// likely means that we have been adding a new processor. Add defaults
|
||||
// to exisitng preferences.
|
||||
$loggedoffpref = array_merge($loggedoffpref, explode(',', $defaultpreferences->{$preferencename}));
|
||||
}
|
||||
set_config($preferencename, join(',', $loggedoffpref), 'message');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active providers for the current user, based on capability
|
||||
*
|
||||
* @return array of message providers
|
||||
*/
|
||||
function message_get_my_providers() {
|
||||
@ -253,6 +378,7 @@ function message_get_my_providers() {
|
||||
|
||||
/**
|
||||
* Gets the message providers that are in the database for this component.
|
||||
*
|
||||
* @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
|
||||
* @return array of message providers
|
||||
*
|
||||
@ -267,6 +393,7 @@ function message_get_providers_from_db($component) {
|
||||
/**
|
||||
* Loads the messages definitions for the component (from file). If no
|
||||
* messages are defined for the component, we simply return an empty array.
|
||||
*
|
||||
* @param $component - examples: 'moodle', 'mod_forum', 'block_quiz_results'
|
||||
* @return array of message providerss or empty array if not exists
|
||||
*
|
||||
@ -285,64 +412,43 @@ function message_get_providers_from_file($component) {
|
||||
if (empty($messageprovider['capability'])) {
|
||||
$messageproviders[$name]['capability'] = NULL;
|
||||
}
|
||||
if (empty($messageprovider['defaults'])) {
|
||||
$messageproviders[$name]['defaults'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $messageproviders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all message providers
|
||||
* @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
|
||||
* Remove all message providers for particular plugin and corresponding settings
|
||||
*
|
||||
* @param string $component - examples: 'moodle', 'mod_forum', 'block_quiz_results'
|
||||
* @return void
|
||||
*/
|
||||
function message_uninstall($component) {
|
||||
function message_provider_uninstall($component) {
|
||||
global $DB;
|
||||
return $DB->delete_records('message_providers', array('component' => $component));
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$DB->delete_records('message_providers', array('component' => $component));
|
||||
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_%"));
|
||||
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_%"));
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default message preferences.
|
||||
* @param $user - User to set message preferences
|
||||
* Remove message processor
|
||||
*
|
||||
* @param string $name - examples: 'email', 'jabber'
|
||||
* @return void
|
||||
*/
|
||||
function message_set_default_message_preferences($user) {
|
||||
function message_processor_uninstall($name) {
|
||||
global $DB;
|
||||
|
||||
//check for the pre 2.0 disable email setting
|
||||
$useemail = empty($user->emailstop);
|
||||
|
||||
//look for the pre-2.0 preference if it exists
|
||||
$oldpreference = get_user_preferences('message_showmessagewindow', -1, $user->id);
|
||||
//if they elected to see popups or the preference didnt exist
|
||||
$usepopups = (intval($oldpreference)==1 || intval($oldpreference)==-1);
|
||||
|
||||
$defaultonlineprocessor = 'none';
|
||||
$defaultofflineprocessor = 'none';
|
||||
|
||||
if ($useemail) {
|
||||
$defaultonlineprocessor = 'email';
|
||||
$defaultofflineprocessor = 'email';
|
||||
} else if ($usepopups) {
|
||||
$defaultonlineprocessor = 'popup';
|
||||
$defaultofflineprocessor = 'popup';
|
||||
}
|
||||
|
||||
$offlineprocessortouse = $onlineprocessortouse = null;
|
||||
|
||||
$providers = $DB->get_records('message_providers');
|
||||
$preferences = array();
|
||||
|
||||
foreach ($providers as $providerid => $provider) {
|
||||
|
||||
//force some specific defaults for IMs
|
||||
if ($provider->name=='instantmessage' && $usepopups && $useemail) {
|
||||
$onlineprocessortouse = 'popup';
|
||||
$offlineprocessortouse = 'email,popup';
|
||||
} else {
|
||||
$onlineprocessortouse = $defaultonlineprocessor;
|
||||
$offlineprocessortouse = $defaultofflineprocessor;
|
||||
}
|
||||
|
||||
$preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedin'] = $onlineprocessortouse;
|
||||
$preferences['message_provider_'.$provider->component.'_'.$provider->name.'_loggedoff'] = $offlineprocessortouse;
|
||||
}
|
||||
return set_user_preferences($preferences, $user->id);
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$DB->delete_records('message_processors', array('name' => $name));
|
||||
// delete permission preferences only, we do not care about loggedin/loggedoff
|
||||
// defaults, they will be removed on the next attempt to update the preferences
|
||||
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("{$name}_provider_%"));
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
@ -445,6 +445,7 @@ class page_requirements_manager {
|
||||
break;
|
||||
case 'core_message':
|
||||
$module = array('name' => 'core_message',
|
||||
'requires' => array('base', 'node', 'event', 'node-event-simulate'),
|
||||
'fullpath' => '/message/module.js');
|
||||
break;
|
||||
case 'core_flashdetect':
|
||||
|
@ -324,6 +324,9 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
|
||||
external_update_descriptions($component);
|
||||
events_update_definition($component);
|
||||
message_update_providers($component);
|
||||
if ($type === 'message') {
|
||||
message_update_processors($plug);
|
||||
}
|
||||
upgrade_plugin_mnet_functions($component);
|
||||
$endcallback($component, true, $verbose);
|
||||
}
|
||||
@ -357,6 +360,9 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
|
||||
external_update_descriptions($component);
|
||||
events_update_definition($component);
|
||||
message_update_providers($component);
|
||||
if ($type === 'message') {
|
||||
message_update_processors($plug);
|
||||
}
|
||||
upgrade_plugin_mnet_functions($component);
|
||||
|
||||
purge_all_caches();
|
||||
@ -387,6 +393,9 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
|
||||
external_update_descriptions($component);
|
||||
events_update_definition($component);
|
||||
message_update_providers($component);
|
||||
if ($type === 'message') {
|
||||
message_update_processors($plug);
|
||||
}
|
||||
upgrade_plugin_mnet_functions($component);
|
||||
|
||||
purge_all_caches();
|
||||
|
115
message/defaultoutputs.php
Normal file
115
message/defaultoutputs.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// Moodle 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/>.
|
||||
|
||||
/**
|
||||
* Default message outputs configuration page
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page
|
||||
admin_externalpage_setup('defaultmessageoutputs');
|
||||
|
||||
// Require site configuration capability
|
||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// Fetch processors
|
||||
$processors = get_message_processors(true);
|
||||
// Fetch message providers
|
||||
$providers = $DB->get_records('message_providers', null, 'name');
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$preferences = array();
|
||||
// Prepare default message outputs settings
|
||||
foreach ( $providers as $provider) {
|
||||
$componentproviderbase = $provider->component.'_'.$provider->name;
|
||||
foreach (array('permitted', 'loggedin', 'loggedoff') as $setting){
|
||||
$value = null;
|
||||
$componentprovidersetting = $componentproviderbase.'_'.$setting;
|
||||
if ($setting == 'permitted') {
|
||||
// if we deal with permitted select element, we need to create individual
|
||||
// setting for each possible processor. Note that this block will
|
||||
// always be processed first after entring parental foreach iteration
|
||||
// so we can change form values on this stage.
|
||||
foreach($processors as $processor) {
|
||||
$value = '';
|
||||
if (isset($form->{$componentprovidersetting}[$processor->name])) {
|
||||
$value = $form->{$componentprovidersetting}[$processor->name];
|
||||
}
|
||||
// Ensure that loggedin loggedoff options are set correctly
|
||||
// for this permission
|
||||
if ($value == 'forced') {
|
||||
$form->{$componentproviderbase.'_loggedin'}[$processor->name] = 1;
|
||||
$form->{$componentproviderbase.'_loggedoff'}[$processor->name] = 1;
|
||||
} else if ($value == 'disallowed') {
|
||||
// It might be better to unset them, but I can't figure out why that cause error
|
||||
$form->{$componentproviderbase.'_loggedin'}[$processor->name] = 0;
|
||||
$form->{$componentproviderbase.'_loggedoff'}[$processor->name] = 0;
|
||||
}
|
||||
// record the site preference
|
||||
$preferences[$processor->name.'_provider_'.$componentprovidersetting] = $value;
|
||||
}
|
||||
} else if (array_key_exists($componentprovidersetting, $form)) {
|
||||
// we must be processing loggedin or loggedoff checkboxes. Store
|
||||
// defained comma-separated processors as setting value.
|
||||
// Using array_filter eliminates elements set to 0 above
|
||||
$value = join(',', array_keys(array_filter($form->{$componentprovidersetting})));
|
||||
if (empty($value)) {
|
||||
$value = null;
|
||||
}
|
||||
}
|
||||
if ($setting != 'permitted') {
|
||||
// we have already recoded site preferences for 'permitted' type
|
||||
$preferences['message_provider_'.$componentprovidersetting] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update database
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
foreach ($preferences as $name => $value) {
|
||||
set_config($name, $value, 'message');
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
|
||||
// Redirect
|
||||
$url = new moodle_url('defaultoutputs.php');
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Page settings
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->requires->js_init_call('M.core_message.init_defaultoutputs');
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
|
||||
// Display the manage message outputs interface
|
||||
$preferences = get_message_output_default_preferences();
|
||||
$messageoutputs = $renderer->manage_defaultmessageoutputs($processors, $providers, $preferences);
|
||||
|
||||
// Display the page
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('defaultmessageoutputs', 'message'));
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
151
message/edit.php
151
message/edit.php
@ -23,7 +23,8 @@
|
||||
* @package message
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
|
||||
$userid = optional_param('id', $USER->id, PARAM_INT); // user id
|
||||
$course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
|
||||
@ -97,13 +98,13 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
|
||||
/// Set all the preferences for all the message providers
|
||||
$providers = message_get_my_providers();
|
||||
$possiblestates = array('loggedin', 'loggedoff');
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
foreach ($possiblestates as $state){
|
||||
foreach ($providers as $provider) {
|
||||
$componentproviderbase = $provider->component.'_'.$provider->name;
|
||||
foreach (array('loggedin', 'loggedoff') as $state) {
|
||||
$linepref = '';
|
||||
$componentproviderstate = $provider->component.'_'.$provider->name.'_'.$state;
|
||||
$componentproviderstate = $componentproviderbase.'_'.$state;
|
||||
if (array_key_exists($componentproviderstate, $form)) {
|
||||
foreach ($form->{$componentproviderstate} as $process=>$one){
|
||||
foreach (array_keys($form->{$componentproviderstate}) as $process){
|
||||
if ($linepref == ''){
|
||||
$linepref = $process;
|
||||
} else {
|
||||
@ -111,41 +112,25 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
|
||||
}
|
||||
}
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
foreach ($possiblestates as $state){
|
||||
$preferencekey = 'message_provider_'.$provider->component.'_'.$provider->name.'_'.$state;
|
||||
if (empty($preferences[$preferencekey])) {
|
||||
$preferences[$preferencekey] = 'none';
|
||||
if (empty($linepref)) {
|
||||
$linepref = 'none';
|
||||
}
|
||||
$preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
|
||||
}
|
||||
}
|
||||
|
||||
/// Set all the processor options as well
|
||||
$processors = $DB->get_records('message_processors');
|
||||
foreach ( $processors as $processorid => $processor){
|
||||
$processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/message_output_'.$processor->name.'.php';
|
||||
if ( is_readable($processorfile) ) {
|
||||
include_once( $processorfile );
|
||||
|
||||
$processclass = 'message_output_' . $processor->name;
|
||||
if ( class_exists($processclass) ){
|
||||
$pclass = new $processclass();
|
||||
$pclass->process_form($form, $preferences);
|
||||
} else{
|
||||
print_error('errorcallingprocessor', 'message');
|
||||
}
|
||||
}
|
||||
$processors = get_message_processors(true);
|
||||
foreach ($processors as $processor) {
|
||||
$processor->object->process_form($form, $preferences);
|
||||
}
|
||||
|
||||
//process general messaging preferences
|
||||
$preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts)?1:0;
|
||||
$preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts)?1:0;
|
||||
//$preferences['message_beepnewmessage'] = !empty($form->beepnewmessage)?1:0;
|
||||
|
||||
// Save all the new preferences to the database
|
||||
if (!set_user_preferences( $preferences, $user->id ) ){
|
||||
if (!set_user_preferences($preferences, $user->id)) {
|
||||
print_error('cannotupdateusermsgpref');
|
||||
}
|
||||
|
||||
@ -158,34 +143,25 @@ $preferences->userdefaultemail = $user->email;//may be displayed by the email pr
|
||||
|
||||
/// Get providers preferences
|
||||
$providers = message_get_my_providers();
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
foreach (array('loggedin', 'loggedoff') as $state){
|
||||
foreach ($providers as $provider) {
|
||||
foreach (array('loggedin', 'loggedoff') as $state) {
|
||||
$linepref = get_user_preferences('message_provider_'.$provider->component.'_'.$provider->name.'_'.$state, '', $user->id);
|
||||
if ($linepref == ''){
|
||||
continue;
|
||||
}
|
||||
$lineprefarray = explode(',', $linepref);
|
||||
$preferences->{$provider->component.'_'.$provider->name.'_'.$state} = array();
|
||||
foreach ($lineprefarray as $pref){
|
||||
foreach ($lineprefarray as $pref) {
|
||||
$preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$pref] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load all processors
|
||||
$processors = get_message_processors();
|
||||
/// For every processors put its options on the form (need to get function from processor's lib.php)
|
||||
$processors = $DB->get_records('message_processors');
|
||||
foreach ( $processors as $processorid => $processor){
|
||||
$processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/message_output_'.$processor->name.'.php';
|
||||
if ( is_readable($processorfile) ) {
|
||||
include_once( $processorfile );
|
||||
$processclass = 'message_output_' . $processor->name;
|
||||
if ( class_exists($processclass) ){
|
||||
$pclass = new $processclass();
|
||||
$pclass->load_data($preferences, $user->id);
|
||||
} else{
|
||||
print_error('errorcallingprocessor', 'message');
|
||||
}
|
||||
}
|
||||
foreach ($processors as $processor) {
|
||||
$processor->object->load_data($preferences, $user->id);
|
||||
}
|
||||
|
||||
//load general messaging preferences
|
||||
@ -203,84 +179,17 @@ if ($course->id != SITEID) {
|
||||
} else {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Start the form. We're not using mform here because of our special formatting needs ...
|
||||
echo '<form class="mform" method="post" action="'.$PAGE->url.'">';
|
||||
|
||||
/// Settings table...
|
||||
echo '<fieldset id="providers" class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('providers_config', 'message').'</legend>';
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
// Fetch message providers
|
||||
$providers = message_get_my_providers();
|
||||
$processors = $DB->get_records('message_processors', null, 'name DESC');
|
||||
$number_procs = count($processors);
|
||||
echo '<table cellpadding="2"><tr><td> </td>'."\n";
|
||||
foreach ( $processors as $processorid => $processor){
|
||||
echo '<th align="center">'.get_string('pluginname', 'message_'.$processor->name).'</th>';
|
||||
}
|
||||
echo '</tr>';
|
||||
// Fetch default (site) preferences
|
||||
$defaultpreferences = get_message_output_default_preferences();
|
||||
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
$providername = get_string('messageprovider:'.$provider->name, $provider->component);
|
||||
|
||||
echo '<tr><th align="right">'.$providername.'</th><td colspan="'.$number_procs.'"></td></tr>'."\n";
|
||||
foreach (array('loggedin', 'loggedoff') as $state){
|
||||
$state_res = get_string($state.'description', 'message');
|
||||
echo '<tr><td align="right">'.$state_res.'</td>'."\n";
|
||||
foreach ( $processors as $processorid => $processor) {
|
||||
if (!isset($preferences->{$provider->component.'_'.$provider->name.'_'.$state})) {
|
||||
$checked = '';
|
||||
} else if (!isset($preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$processor->name])) {
|
||||
$checked = '';
|
||||
} else {
|
||||
$checked = $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$processor->name]==1?" checked=\"checked\"":"";
|
||||
}
|
||||
echo '<td align="center"><input type="checkbox" name="'.$provider->component.'_'.$provider->name.'_'.$state.'['.$processor->name.']" '.$checked.' /></td>'."\n";
|
||||
}
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
}
|
||||
echo '</table>';
|
||||
echo '</fieldset>';
|
||||
|
||||
/// Show all the message processors
|
||||
$processors = $DB->get_records('message_processors');
|
||||
|
||||
$processorconfigform = null;
|
||||
foreach ($processors as $processorid => $processor) {
|
||||
$processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/message_output_'.$processor->name.'.php';
|
||||
if (is_readable($processorfile)) {
|
||||
include_once($processorfile);
|
||||
$processclass = 'message_output_' . $processor->name;
|
||||
|
||||
if (class_exists($processclass)) {
|
||||
$pclass = new $processclass();
|
||||
$processorconfigform = $pclass->config_form($preferences);
|
||||
|
||||
if (!empty($processorconfigform)) {
|
||||
echo '<fieldset id="messageprocessor_'.$processor->name.'" class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('pluginname', 'message_'.$processor->name).'</legend>';
|
||||
|
||||
echo $processorconfigform;
|
||||
|
||||
echo '</fieldset>';
|
||||
}
|
||||
} else{
|
||||
print_error('errorcallingprocessor', 'message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<fieldset id="messageprocessor_general" class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('generalsettings','admin').'</legend>';
|
||||
echo get_string('blocknoncontacts', 'message').': <input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?' checked="checked"':'');
|
||||
//get_string('beepnewmessage', 'message').': <input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' />';
|
||||
echo '</fieldset>';
|
||||
|
||||
echo '<div><input type="hidden" name="sesskey" value="'.sesskey().'" /></div>';
|
||||
echo '<div style="text-align:center"><input name="submit" value="'. get_string('updatemyprofile') .'" type="submit" /></div>';
|
||||
|
||||
echo "</form>";
|
||||
$messagingoptions = $renderer->manage_messagingoptions($processors, $providers, $preferences, $defaultpreferences);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $messagingoptions;
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
371
message/lib.php
371
message/lib.php
@ -53,6 +53,30 @@ define('MESSAGE_SEARCH_MAX_RESULTS', 200);
|
||||
define('MESSAGE_CONTACTS_PER_PAGE',10);
|
||||
define('MESSAGE_MAX_COURSE_NAME_LENGTH', 30);
|
||||
|
||||
/**
|
||||
* Define contants for messaging default settings population. For unambiguity of
|
||||
* plugin developer intentions we use 4-bit value (LSB numbering):
|
||||
* bit 0 - whether to send message when user is loggedin (MESSAGE_DEFAULT_LOGGEDIN)
|
||||
* bit 1 - whether to send message when user is loggedoff (MESSAGE_DEFAULT_LOGGEDOFF)
|
||||
* bit 2..3 - messaging permission (MESSAGE_DISALLOWED|MESSAGE_PERMITTED|MESSAGE_FORCED)
|
||||
*
|
||||
* MESSAGE_PERMITTED_MASK contains the mask we use to distinguish permission setting
|
||||
*/
|
||||
|
||||
define('MESSAGE_DEFAULT_LOGGEDIN', 0x01); // 0001
|
||||
define('MESSAGE_DEFAULT_LOGGEDOFF', 0x02); // 0010
|
||||
|
||||
define('MESSAGE_DISALLOWED', 0x04); // 0100
|
||||
define('MESSAGE_PERMITTED', 0x08); // 1000
|
||||
define('MESSAGE_FORCED', 0x0c); // 1100
|
||||
|
||||
define('MESSAGE_PERMITTED_MASK', 0x0c); // 1100
|
||||
|
||||
/**
|
||||
* Set default value for default outputs permitted setting
|
||||
*/
|
||||
define('MESSAGE_DEFAULT_PERMITTED', 'permitted');
|
||||
|
||||
if (!isset($CFG->message_contacts_refresh)) { // Refresh the contacts list every 60 seconds
|
||||
$CFG->message_contacts_refresh = 60;
|
||||
}
|
||||
@ -64,20 +88,21 @@ if (!isset($CFG->message_offline_time)) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the selector that allows the user to view their contacts, course participants, their recent
|
||||
* conversations etc
|
||||
* @param int $countunreadtotal how many unread messages does the user have?
|
||||
* @param int $viewing What is the user viewing? ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_SEARCH etc
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to
|
||||
* @param array $blockedusers an array of users blocked by $user1
|
||||
* @param array $onlinecontacts an array of $user1's online contacts
|
||||
* @param array $offlinecontacts an array of $user1's offline contacts
|
||||
* @param array $strangers an array of users who have messaged $user1 who aren't contacts
|
||||
* @param bool $showcontactactionlinks show action links (add/remove contact etc) next to the users in the contact selector
|
||||
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
|
||||
* @return void
|
||||
*/
|
||||
* Print the selector that allows the user to view their contacts, course participants, their recent
|
||||
* conversations etc
|
||||
*
|
||||
* @param int $countunreadtotal how many unread messages does the user have?
|
||||
* @param int $viewing What is the user viewing? ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_SEARCH etc
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to
|
||||
* @param array $blockedusers an array of users blocked by $user1
|
||||
* @param array $onlinecontacts an array of $user1's online contacts
|
||||
* @param array $offlinecontacts an array of $user1's offline contacts
|
||||
* @param array $strangers an array of users who have messaged $user1 who aren't contacts
|
||||
* @param bool $showcontactactionlinks show action links (add/remove contact etc) next to the users in the contact selector
|
||||
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
|
||||
* @return void
|
||||
*/
|
||||
function message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page=0) {
|
||||
global $PAGE;
|
||||
|
||||
@ -140,16 +165,17 @@ function message_print_contact_selector($countunreadtotal, $viewing, $user1, $us
|
||||
}
|
||||
|
||||
/**
|
||||
* Print course participants. Called by message_print_contact_selector()
|
||||
* @param object $context the course context
|
||||
* @param int $courseid the course ID
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of participants
|
||||
* @return void
|
||||
*/
|
||||
* Print course participants. Called by message_print_contact_selector()
|
||||
*
|
||||
* @param object $context the course context
|
||||
* @param int $courseid the course ID
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param int $page if there are so many users listed that they have to be split into pages what page are we viewing
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of participants
|
||||
* @return void
|
||||
*/
|
||||
function message_print_participants($context, $courseid, $contactselecturl=null, $showactionlinks=true, $titletodisplay=null, $page=0, $user2=null) {
|
||||
global $DB, $USER, $PAGE, $OUTPUT;
|
||||
|
||||
@ -183,12 +209,13 @@ function message_print_participants($context, $courseid, $contactselecturl=null,
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve users blocked by $user1
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to. If they are being blocked
|
||||
* they will have a variable called 'isblocked' added to their user object
|
||||
* @return array the users blocked by $user1
|
||||
*/
|
||||
* Retrieve users blocked by $user1
|
||||
*
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to. If they are being blocked
|
||||
* they will have a variable called 'isblocked' added to their user object
|
||||
* @return array the users blocked by $user1
|
||||
*/
|
||||
function message_get_blocked_users($user1=null, $user2=null) {
|
||||
global $DB, $USER;
|
||||
|
||||
@ -225,14 +252,15 @@ function message_get_blocked_users($user1=null, $user2=null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print users blocked by $user1. Called by message_print_contact_selector()
|
||||
* @param array $blockedusers the users blocked by $user1
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of blocked users
|
||||
* @return void
|
||||
*/
|
||||
* Print users blocked by $user1. Called by message_print_contact_selector()
|
||||
*
|
||||
* @param array $blockedusers the users blocked by $user1
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of blocked users
|
||||
* @return void
|
||||
*/
|
||||
function message_print_blocked_users($blockedusers, $contactselecturl=null, $showactionlinks=true, $titletodisplay=null, $user2=null) {
|
||||
global $DB, $USER;
|
||||
|
||||
@ -262,12 +290,13 @@ function message_print_blocked_users($blockedusers, $contactselecturl=null, $sho
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve $user1's contacts (online, offline and strangers)
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to. If they are a contact
|
||||
* they will have a variable called 'iscontact' added to their user object
|
||||
* @return array containing 3 arrays. array($onlinecontacts, $offlinecontacts, $strangers)
|
||||
*/
|
||||
* Retrieve $user1's contacts (online, offline and strangers)
|
||||
*
|
||||
* @param object $user1 the user whose messages are being viewed
|
||||
* @param object $user2 the user $user1 is talking to. If they are a contact
|
||||
* they will have a variable called 'iscontact' added to their user object
|
||||
* @return array containing 3 arrays. array($onlinecontacts, $offlinecontacts, $strangers)
|
||||
*/
|
||||
function message_get_contacts($user1=null, $user2=null) {
|
||||
global $DB, $CFG, $USER;
|
||||
|
||||
@ -342,18 +371,19 @@ function message_get_contacts($user1=null, $user2=null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print $user1's contacts. Called by message_print_contact_selector()
|
||||
* @param array $onlinecontacts $user1's contacts which are online
|
||||
* @param array $offlinecontacts $user1's contacts which are offline
|
||||
* @param array $strangers users which are not contacts but who have messaged $user1
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param int $minmessages The minimum number of unread messages required from a user for them to be displayed
|
||||
* Typically 0 (show all contacts) or 1 (only show contacts from whom we have a new message)
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of contacts
|
||||
* @return void
|
||||
*/
|
||||
* Print $user1's contacts. Called by message_print_contact_selector()
|
||||
*
|
||||
* @param array $onlinecontacts $user1's contacts which are online
|
||||
* @param array $offlinecontacts $user1's contacts which are offline
|
||||
* @param array $strangers users which are not contacts but who have messaged $user1
|
||||
* @param string $contactselecturl the url to send the user to when a contact's name is clicked
|
||||
* @param int $minmessages The minimum number of unread messages required from a user for them to be displayed
|
||||
* Typically 0 (show all contacts) or 1 (only show contacts from whom we have a new message)
|
||||
* @param bool $showactionlinks show action links (add/remove contact etc) next to the users
|
||||
* @param string $titletodisplay Optionally specify a title to display above the participants
|
||||
* @param object $user2 the user $user1 is talking to. They will be highlighted if they appear in the list of contacts
|
||||
* @return void
|
||||
*/
|
||||
function message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $contactselecturl=null, $minmessages=0, $showactionlinks=true, $titletodisplay=null, $user2=null) {
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
|
||||
@ -426,16 +456,17 @@ function message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a select box allowing the user to choose to view new messages, course participants etc.
|
||||
* Called by message_print_contact_selector()
|
||||
* @param int $viewing What page is the user viewing ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_RECENT_CONVERSATIONS etc
|
||||
* @param array $courses array of course objects. The courses the user is enrolled in.
|
||||
* @param array $coursecontexts array of course contexts. Keyed on course id.
|
||||
* @param int $countunreadtotal how many unread messages does the user have?
|
||||
* @param int $countblocked how many users has the current user blocked?
|
||||
* @param string $strunreadmessages a preconstructed message about the number of unread messages the user has
|
||||
* @return void
|
||||
*/
|
||||
* Print a select box allowing the user to choose to view new messages, course participants etc.
|
||||
*
|
||||
* Called by message_print_contact_selector()
|
||||
* @param int $viewing What page is the user viewing ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_RECENT_CONVERSATIONS etc
|
||||
* @param array $courses array of course objects. The courses the user is enrolled in.
|
||||
* @param array $coursecontexts array of course contexts. Keyed on course id.
|
||||
* @param int $countunreadtotal how many unread messages does the user have?
|
||||
* @param int $countblocked how many users has the current user blocked?
|
||||
* @param string $strunreadmessages a preconstructed message about the number of unread messages the user has
|
||||
* @return void
|
||||
*/
|
||||
function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages) {
|
||||
$options = array();
|
||||
$textlib = textlib_get_instance(); // going to use textlib services
|
||||
@ -482,10 +513,11 @@ function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the course contexts for all of the users courses
|
||||
* @param array $courses array of course objects. The courses the user is enrolled in.
|
||||
* @return array of course contexts
|
||||
*/
|
||||
* Load the course contexts for all of the users courses
|
||||
*
|
||||
* @param array $courses array of course objects. The courses the user is enrolled in.
|
||||
* @return array of course contexts
|
||||
*/
|
||||
function message_get_course_contexts($courses) {
|
||||
$coursecontexts = array();
|
||||
|
||||
@ -498,6 +530,7 @@ function message_get_course_contexts($courses) {
|
||||
|
||||
/**
|
||||
* strip off action parameters like 'removecontact'
|
||||
*
|
||||
* @param moodle_url/string $moodleurl a URL. Typically the current page URL.
|
||||
* @return string the URL minus parameters that perform actions (like adding/removing/blocking a contact).
|
||||
*/
|
||||
@ -511,6 +544,7 @@ function message_remove_url_params($moodleurl) {
|
||||
* Count the number of messages with a field having a specified value.
|
||||
* if $field is empty then return count of the whole array
|
||||
* if $field is non-existent then return 0
|
||||
*
|
||||
* @param array $messagearray array of message objects
|
||||
* @param string $field the field to inspect on the message objects
|
||||
* @param string $value the value to test the field against
|
||||
@ -528,6 +562,7 @@ function message_count_messages($messagearray, $field='', $value='') {
|
||||
|
||||
/**
|
||||
* Returns the count of unread messages for user. Either from a specific user or from all users.
|
||||
*
|
||||
* @param object $user1 the first user. Defaults to $USER
|
||||
* @param object $user2 the second user. If null this function will count all of user 1's unread messages.
|
||||
* @return int the count of $user1's unread messages
|
||||
@ -550,7 +585,9 @@ function message_count_unread_messages($user1=null, $user2=null) {
|
||||
|
||||
/**
|
||||
* Count the number of users blocked by $user1
|
||||
* @param $user1
|
||||
*
|
||||
* @param object $user1 user object
|
||||
* @return int the number of blocked users
|
||||
*/
|
||||
function message_count_blocked_users($user1=null) {
|
||||
global $USER, $DB;
|
||||
@ -569,6 +606,7 @@ function message_count_blocked_users($user1=null) {
|
||||
|
||||
/**
|
||||
* Print the search form and search results if a search has been performed
|
||||
*
|
||||
* @param boolean $advancedsearch show basic or advanced search form
|
||||
* @param object $user1 the current user
|
||||
* @return boolean true if a search was performed
|
||||
@ -627,6 +665,7 @@ function message_print_search($advancedsearch = false, $user1=null) {
|
||||
/**
|
||||
* Get the users recent conversations meaning all the people they've recently
|
||||
* sent or received a message from plus the most recent message sent to or received from each other user
|
||||
*
|
||||
* @param object $user the current user
|
||||
* @param int $limitfrom can be used for paging
|
||||
* @param int $limitto can be used for paging
|
||||
@ -718,6 +757,7 @@ function message_get_recent_conversations($user, $limitfrom=0, $limitto=100) {
|
||||
|
||||
/**
|
||||
* Sort function used to order conversations
|
||||
*
|
||||
* @param object $a A conversation object
|
||||
* @param object $b A conversation object
|
||||
* @return integer
|
||||
@ -732,6 +772,7 @@ function conversationsort($a, $b)
|
||||
|
||||
/**
|
||||
* Get the users recent event notifications
|
||||
*
|
||||
* @param object $user the current user
|
||||
* @param int $limitfrom can be used for paging
|
||||
* @param int $limitto can be used for paging
|
||||
@ -754,8 +795,10 @@ function message_get_recent_notifications($user, $limitfrom=0, $limitto=100) {
|
||||
|
||||
/**
|
||||
* Print the user's recent conversations
|
||||
*
|
||||
* @param object $user1 the current user
|
||||
* @param bool $showicontext flag indicating whether or not to show text next to the action icons
|
||||
* @return void
|
||||
*/
|
||||
function message_print_recent_conversations($user=null, $showicontext=false) {
|
||||
global $USER;
|
||||
@ -776,7 +819,9 @@ function message_print_recent_conversations($user=null, $showicontext=false) {
|
||||
|
||||
/**
|
||||
* Print the user's recent notifications
|
||||
*
|
||||
* @param object $user1 the current user
|
||||
* @return void
|
||||
*/
|
||||
function message_print_recent_notifications($user=null) {
|
||||
global $USER;
|
||||
@ -798,11 +843,13 @@ function message_print_recent_notifications($user=null) {
|
||||
|
||||
/**
|
||||
* Print a list of recent messages
|
||||
*
|
||||
* @staticvar type $dateformat
|
||||
* @param array $messages the messages to display
|
||||
* @param object $user the current user
|
||||
* @param bool $showotheruser display information on the other user?
|
||||
* @param bool $showicontext show text next to the action icons?
|
||||
* @return void
|
||||
*/
|
||||
function message_print_recent_messages_table($messages, $user=null, $showotheruser=true, $showicontext=false) {
|
||||
global $OUTPUT;
|
||||
@ -871,6 +918,7 @@ function message_print_recent_messages_table($messages, $user=null, $showotherus
|
||||
|
||||
/**
|
||||
* Add the selected user as a contact for the current user
|
||||
*
|
||||
* @param int $contactid the ID of the user to add as a contact
|
||||
* @param int $blocked 1 if you wish to block the contact
|
||||
* @return bool/int false if the $contactid isnt a valid user id. True if no changes made.
|
||||
@ -907,6 +955,7 @@ function message_add_contact($contactid, $blocked=0) {
|
||||
|
||||
/**
|
||||
* remove a contact
|
||||
*
|
||||
* @param type $contactid the user ID of the contact to remove
|
||||
* @return bool returns the result of delete_records()
|
||||
*/
|
||||
@ -917,6 +966,7 @@ function message_remove_contact($contactid) {
|
||||
|
||||
/**
|
||||
* Unblock a contact. Note that this reverts the previously blocked user back to a non-contact.
|
||||
*
|
||||
* @param int $contactid the user ID of the contact to unblock
|
||||
* @return bool returns the result of delete_records()
|
||||
*/
|
||||
@ -927,6 +977,7 @@ function message_unblock_contact($contactid) {
|
||||
|
||||
/**
|
||||
* block a user
|
||||
*
|
||||
* @param int $contactid the user ID of the user to block
|
||||
*/
|
||||
function message_block_contact($contactid) {
|
||||
@ -935,7 +986,9 @@ function message_block_contact($contactid) {
|
||||
|
||||
/**
|
||||
* Load a user's contact record
|
||||
*
|
||||
* @param int $contactid the user ID of the user whose contact record you want
|
||||
* @return array message contacts
|
||||
*/
|
||||
function message_get_contact($contactid) {
|
||||
global $USER, $DB;
|
||||
@ -944,9 +997,11 @@ function message_get_contact($contactid) {
|
||||
|
||||
/**
|
||||
* Print the results of a message search
|
||||
*
|
||||
* @param mixed $frm submitted form data
|
||||
* @param bool $showicontext show text next to action icons?
|
||||
* @param object $user1 the current user
|
||||
* @return void
|
||||
*/
|
||||
function message_print_search_results($frm, $showicontext=false, $user1=null) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
@ -1212,10 +1267,12 @@ function message_print_search_results($frm, $showicontext=false, $user1=null) {
|
||||
|
||||
/**
|
||||
* Print information on a user. Used when printing search results.
|
||||
*
|
||||
* @param object/bool $user the user to display or false if you just want $USER
|
||||
* @param bool $iscontact is the user being displayed a contact?
|
||||
* @param bool $isblocked is the user being displayed blocked?
|
||||
* @param bool $includeicontext include text next to the action icons?
|
||||
* @return void
|
||||
*/
|
||||
function message_print_user ($user=false, $iscontact=false, $isblocked=false, $includeicontext=false) {
|
||||
global $USER, $OUTPUT;
|
||||
@ -1259,6 +1316,7 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false, $i
|
||||
|
||||
/**
|
||||
* Print a message contact link
|
||||
*
|
||||
* @staticvar type $str
|
||||
* @param int $userid the ID of the user to apply to action to
|
||||
* @param string $linktype can be add, remove, block or unblock
|
||||
@ -1333,6 +1391,7 @@ function message_contact_link($userid, $linktype='add', $return=false, $script=n
|
||||
|
||||
/**
|
||||
* echo or return a link to take the user to the full message history between themselves and another user
|
||||
*
|
||||
* @staticvar type $strmessagehistory
|
||||
* @param int $userid1 the ID of the current user
|
||||
* @param int $userid2 the ID of the other user
|
||||
@ -1456,6 +1515,7 @@ function message_search_users($courseid, $searchtext, $sort='', $exceptions='')
|
||||
|
||||
/**
|
||||
* search a user's messages
|
||||
*
|
||||
* @param array $searchterms an array of search terms (strings)
|
||||
* @param bool $fromme include messages from the user?
|
||||
* @param bool $tome include messages to the user?
|
||||
@ -1597,6 +1657,7 @@ function message_search($searchterms, $fromme=true, $tome=true, $courseid='none'
|
||||
* Given a message object that we already know has a long message
|
||||
* this function truncates the message nicely to the first
|
||||
* sane place between $CFG->forum_longpost and $CFG->forum_shortpost
|
||||
*
|
||||
* @param string $message the message
|
||||
* @param int $minlength the minimum length to trim the message to
|
||||
* @return string the shortened message
|
||||
@ -1652,6 +1713,7 @@ function message_shorten_message($message, $minlength = 0) {
|
||||
* Given a string and an array of keywords, this function looks
|
||||
* for the first keyword in the string, and then chops out a
|
||||
* small section from the text that shows that word in context.
|
||||
*
|
||||
* @param string $message the text to search
|
||||
* @param array $keywords array of keywords to find
|
||||
*/
|
||||
@ -1699,6 +1761,7 @@ function message_get_fragment($message, $keywords) {
|
||||
|
||||
/**
|
||||
* Retrieve the messages between two users
|
||||
*
|
||||
* @param object $user1 the current user
|
||||
* @param object $user2 the other user
|
||||
* @param int $limitnum the maximum number of messages to retrieve
|
||||
@ -1754,6 +1817,7 @@ function message_get_history($user1, $user2, $limitnum=0, $viewingnewmessages=fa
|
||||
|
||||
/**
|
||||
* Print the message history between two users
|
||||
*
|
||||
* @param object $user1 the current user
|
||||
* @param object $user2 the other user
|
||||
* @param string $search search terms to highlight
|
||||
@ -1853,6 +1917,7 @@ function message_print_message_history($user1,$user2,$search='',$messagelimit=0,
|
||||
|
||||
/**
|
||||
* Format a message for display in the message history
|
||||
*
|
||||
* @param object $message the message object
|
||||
* @param string $format optional date format
|
||||
* @param string $keywords keywords to highlight
|
||||
@ -1893,6 +1958,7 @@ function message_format_message($message, $format='', $keywords='', $class='othe
|
||||
|
||||
/**
|
||||
* Format a the context url and context url name of a message for display
|
||||
*
|
||||
* @param object $message the message object
|
||||
* @return string the formatted string
|
||||
*/
|
||||
@ -1916,6 +1982,7 @@ function message_format_contexturl($message) {
|
||||
|
||||
/**
|
||||
* Send a message from one user to another. Will be delivered according to the message recipients messaging preferences
|
||||
*
|
||||
* @param object $userfrom the message sender
|
||||
* @param object $userto the message recipient
|
||||
* @param string $message the message
|
||||
@ -1968,6 +2035,7 @@ function message_post_message($userfrom, $userto, $message, $format) {
|
||||
* on large datasets?
|
||||
*
|
||||
* @todo: deprecated - to be deleted in 2.2
|
||||
* @return array
|
||||
*/
|
||||
function message_get_participants() {
|
||||
global $CFG, $DB;
|
||||
@ -1983,12 +2051,14 @@ function message_get_participants() {
|
||||
/**
|
||||
* Print a row of contactlist displaying user picture, messages waiting and
|
||||
* block links etc
|
||||
*
|
||||
* @param object $contact contact object containing all fields required for $OUTPUT->user_picture()
|
||||
* @param bool $incontactlist is the user a contact of ours?
|
||||
* @param bool $isblocked is the user blocked?
|
||||
* @param string $selectcontacturl the url to send the user to when a contact's name is clicked
|
||||
* @param bool $showactionlinks display action links next to the other users (add contact, block user etc)
|
||||
* @param object $selecteduser the user the current user is viewing (if any). They will be highlighted.
|
||||
* @return void
|
||||
*/
|
||||
function message_print_contactlist_user($contact, $incontactlist = true, $isblocked = false, $selectcontacturl = null, $showactionlinks = true, $selecteduser=null) {
|
||||
global $OUTPUT, $USER;
|
||||
@ -2048,6 +2118,7 @@ function message_print_contactlist_user($contact, $incontactlist = true, $isbloc
|
||||
|
||||
/**
|
||||
* Constructs the add/remove contact link to display next to other users
|
||||
*
|
||||
* @param bool $incontactlist is the user a contact
|
||||
* @param bool $isblocked is the user blocked
|
||||
* @param type $contact contact object
|
||||
@ -2072,6 +2143,7 @@ function message_get_contact_add_remove_link($incontactlist, $isblocked, $contac
|
||||
|
||||
/**
|
||||
* Constructs the block contact link to display next to other users
|
||||
*
|
||||
* @param bool $incontactlist is the user a contact
|
||||
* @param bool $isblocked is the user blocked
|
||||
* @param type $contact contact object
|
||||
@ -2096,12 +2168,13 @@ function message_get_contact_block_link($incontactlist, $isblocked, $contact, $s
|
||||
return $strblock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves messages from a particular user from the message table (unread messages) to message_read
|
||||
* This is typically only used when a user is deleted
|
||||
* @param object $userid User id
|
||||
* @return boolean success
|
||||
*/
|
||||
/**
|
||||
* Moves messages from a particular user from the message table (unread messages) to message_read
|
||||
* This is typically only used when a user is deleted
|
||||
*
|
||||
* @param object $userid User id
|
||||
* @return boolean success
|
||||
*/
|
||||
function message_move_userfrom_unread2read($userid) {
|
||||
global $DB;
|
||||
|
||||
@ -2115,11 +2188,12 @@ function message_move_userfrom_unread2read($userid) {
|
||||
}
|
||||
|
||||
/**
|
||||
* marks ALL messages being sent from $fromuserid to $touserid as read
|
||||
* @param int $touserid the id of the message recipient
|
||||
* @param int $fromuserid the id of the message sender
|
||||
* @return void
|
||||
*/
|
||||
* marks ALL messages being sent from $fromuserid to $touserid as read
|
||||
*
|
||||
* @param int $touserid the id of the message recipient
|
||||
* @param int $fromuserid the id of the message sender
|
||||
* @return void
|
||||
*/
|
||||
function message_mark_messages_read($touserid, $fromuserid){
|
||||
global $DB;
|
||||
|
||||
@ -2134,12 +2208,13 @@ function message_mark_messages_read($touserid, $fromuserid){
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a single message as read
|
||||
* @param message an object with an object property ie $message->id which is an id in the message table
|
||||
* @param int $timeread the timestamp for when the message should be marked read. Usually time().
|
||||
* @param bool $messageworkingempty Is the message_working table already confirmed empty for this message?
|
||||
* @return int the ID of the message in the message_read table
|
||||
*/
|
||||
* Mark a single message as read
|
||||
*
|
||||
* @param message an object with an object property ie $message->id which is an id in the message table
|
||||
* @param int $timeread the timestamp for when the message should be marked read. Usually time().
|
||||
* @param bool $messageworkingempty Is the message_working table already confirmed empty for this message?
|
||||
* @return int the ID of the message in the message_read table
|
||||
*/
|
||||
function message_mark_message_read($message, $timeread, $messageworkingempty=false) {
|
||||
global $DB;
|
||||
|
||||
@ -2159,11 +2234,131 @@ function message_mark_message_read($message, $timeread, $messageworkingempty=fal
|
||||
|
||||
/**
|
||||
* A helper function that prints a formatted heading
|
||||
*
|
||||
* @param string $title the heading to display
|
||||
* @param int $colspan
|
||||
* @return void
|
||||
*/
|
||||
function message_print_heading($title, $colspan=3) {
|
||||
echo html_writer::start_tag('tr');
|
||||
echo html_writer::tag('td', $title, array('colspan' => $colspan, 'class' => 'heading'));
|
||||
echo html_writer::end_tag('tr');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all message processors, validate corresponding plugin existance and
|
||||
* system configuration
|
||||
*
|
||||
* @param bool $ready only return ready-to-use processors
|
||||
* @return mixed $processors array of objects containing information on message processors
|
||||
*/
|
||||
function get_message_processors($ready = false) {
|
||||
global $DB, $CFG;
|
||||
|
||||
static $processors;
|
||||
|
||||
if (empty($processors)) {
|
||||
// Get all processors, ensure the name column is the first so it will be the array key
|
||||
$processors = $DB->get_records('message_processors', null, 'name DESC', 'name, id, enabled');
|
||||
foreach ($processors as &$processor){
|
||||
$processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/message_output_'.$processor->name.'.php';
|
||||
if (is_readable($processorfile)) {
|
||||
include_once($processorfile);
|
||||
$processclass = 'message_output_' . $processor->name;
|
||||
if (class_exists($processclass)) {
|
||||
$pclass = new $processclass();
|
||||
$processor->object = $pclass;
|
||||
$processor->configured = 0;
|
||||
if ($pclass->is_system_configured()) {
|
||||
$processor->configured = 1;
|
||||
}
|
||||
$processor->hassettings = 0;
|
||||
if (is_readable($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php')) {
|
||||
$processor->hassettings = 1;
|
||||
}
|
||||
$processor->available = 1;
|
||||
} else {
|
||||
print_error('errorcallingprocessor', 'message');
|
||||
}
|
||||
} else {
|
||||
$processor->available = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ready) {
|
||||
// Filter out enabled and system_configured processors
|
||||
$readyprocessors = $processors;
|
||||
foreach ($readyprocessors as $readyprocessor) {
|
||||
if (!($readyprocessor->enabled && $readyprocessor->configured)) {
|
||||
unset($readyprocessors[$readyprocessor->name]);
|
||||
}
|
||||
}
|
||||
return $readyprocessors;
|
||||
}
|
||||
|
||||
return $processors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get messaging outputs default (site) preferences
|
||||
*
|
||||
* @return object $processors object containing information on message processors
|
||||
*/
|
||||
function get_message_output_default_preferences() {
|
||||
$preferences = get_config('message');
|
||||
if (!$preferences) {
|
||||
$preferences = new stdClass();
|
||||
}
|
||||
return $preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate message default settings from binary value to the array of string
|
||||
* representing the settings to be stored. Also validate the provided value and
|
||||
* use default if it is malformed.
|
||||
*
|
||||
* @param int $plugindefault Default setting suggested by plugin
|
||||
* @param string $processorname The name of processor
|
||||
* @return array $settings array of strings in the order: $permitted, $loggedin, $loggedoff.
|
||||
*/
|
||||
function translate_message_default_setting($plugindefault, $processorname) {
|
||||
// Preset translation arrays
|
||||
$permittedvalues = array(
|
||||
0x04 => 'disallowed',
|
||||
0x08 => 'permitted',
|
||||
0x0c => 'forced',
|
||||
);
|
||||
|
||||
$loggedinstatusvalues = array(
|
||||
0x00 => null, // use null if loggedin/loggedoff is not defined
|
||||
0x01 => 'loggedin',
|
||||
0x02 => 'loggedoff',
|
||||
);
|
||||
|
||||
// define the default setting
|
||||
if ($processorname == 'email') {
|
||||
$default = MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF;
|
||||
} else {
|
||||
$default = MESSAGE_PERMITTED;
|
||||
}
|
||||
|
||||
// Validate the value. It should not exceed the maximum size
|
||||
if (!is_int($plugindefault) || ($plugindefault > 0x0f)) {
|
||||
$OUTPUT->notification(get_string('errortranslatingdefault', 'message'), 'notifyproblem');
|
||||
$plugindefault = $default;
|
||||
}
|
||||
// Use plugin default setting of 'permitted' is 0
|
||||
if (!($plugindefault & MESSAGE_PERMITTED_MASK)) {
|
||||
$plugindefault = $default;
|
||||
}
|
||||
|
||||
$permitted = $permittedvalues[$plugindefault & MESSAGE_PERMITTED_MASK];
|
||||
$loggedin = $loggedoff = null;
|
||||
|
||||
if (($plugindefault & MESSAGE_PERMITTED_MASK) == MESSAGE_PERMITTED) {
|
||||
$loggedin = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDIN];
|
||||
$loggedoff = $loggedinstatusvalues[$plugindefault & MESSAGE_DEFAULT_LOGGEDOFF];
|
||||
}
|
||||
|
||||
return array($permitted, $loggedin, $loggedoff);
|
||||
}
|
||||
|
@ -42,4 +42,49 @@ M.core_message.init_notification = function(Y, title, content, url) {
|
||||
return false;
|
||||
}, o);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
M.core_message.init_defaultoutputs = function(Y) {
|
||||
var defaultoutputs = {
|
||||
|
||||
init : function() {
|
||||
Y.all('#defaultmessageoutputs select').each(function(node) {
|
||||
// attach event listener
|
||||
node.on('change', defaultoutputs.changeState);
|
||||
// set initial layout
|
||||
node.simulate("change");
|
||||
}, this);
|
||||
},
|
||||
|
||||
changeState : function(e) {
|
||||
var value = e.target._node.options[e.target.get('selectedIndex')].value;
|
||||
var parentnode = e.target.ancestor('td');
|
||||
switch (value) {
|
||||
case 'forced':
|
||||
defaultoutputs.updateCheckboxes(parentnode, 1, 1);
|
||||
break;
|
||||
case 'disallowed':
|
||||
defaultoutputs.updateCheckboxes(parentnode, 1, 0);
|
||||
break;
|
||||
case 'permitted':
|
||||
defaultoutputs.updateCheckboxes(parentnode, 0, 0);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
updateCheckboxes : function(blocknode, disabled, checked) {
|
||||
blocknode.all('input[type=checkbox]').each(function(node) {
|
||||
node.removeAttribute('disabled');
|
||||
if (disabled) {
|
||||
node.setAttribute('disabled', 1)
|
||||
node.removeAttribute('checked');
|
||||
}
|
||||
if (checked) {
|
||||
node.setAttribute('checked', 1)
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
defaultoutputs.init();
|
||||
}
|
@ -23,5 +23,20 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Email';
|
||||
$string['allowusermailcharset'] = 'Allow user to select character set';
|
||||
$string['configallowusermailcharset'] = 'Enabling this, every user in the site will be able to specify his own charset for email.';
|
||||
$string['configmailnewline'] = 'Newline characters used in mail messages. CRLF is required according to RFC 822bis, some mail servers do automatic conversion from LF to CRLF, other mail servers do incorrect conversion from CRLF to CRCRLF, yet others reject mails with bare LF (qmail for example). Try changing this setting if you are having problems with undelivered emails or double newlines.';
|
||||
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
|
||||
$string['configsitemailcharset'] = 'All the emails generated by your site will be sent in the charset specified here. Anyway, every individual user will be able to adjust it if the next setting is enabled.';
|
||||
$string['configsmtphosts'] = 'Give the full name of one or more local SMTP servers that Moodle should use to send mail (eg \'mail.a.com\' or \'mail.a.com;mail.b.com\'). To specify a non-default port (i.e other than port 25), you can use the [server]:[port] syntax (eg \'mail.a.com:587\'. If you leave it blank, Moodle will use the PHP default method of sending mail.';
|
||||
$string['configsmtpmaxbulk'] = 'Maximum number of messages sent per SMTP session. Grouping messages may speed up the sending of emails. Values lower than 2 force creation of new SMTP session for each email.';
|
||||
$string['configsmtpuser'] = 'If you have specified an SMTP server above, and the server requires authentication, then enter the username and password here.';
|
||||
$string['email'] = 'Send email notifications to';
|
||||
$string['mailnewline'] = 'Newline characters in mail';
|
||||
$string['noreplyaddress'] = 'No-reply address';
|
||||
$string['pluginname'] = 'Email';
|
||||
$string['sitemailcharset'] = 'Character set';
|
||||
$string['smtphosts'] = 'SMTP hosts';
|
||||
$string['smtpmaxbulk'] = 'SMTP session limit';
|
||||
$string['smtppass'] = 'SMTP password';
|
||||
$string['smtpuser'] = 'SMTP username';
|
||||
|
@ -83,7 +83,7 @@ class message_output_email extends message_output {
|
||||
* @param array $preferences preferences array
|
||||
*/
|
||||
function process_form($form, &$preferences){
|
||||
if (isset($form->email_email)) {
|
||||
if (isset($form->email_email) && !empty($form->email_email)) {
|
||||
$preferences['message_processor_email_email'] = $form->email_email;
|
||||
}
|
||||
}
|
||||
|
44
message/output/email/settings.php
Normal file
44
message/output/email/settings.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// Moodle 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/>.
|
||||
|
||||
/**
|
||||
* Email configuration page
|
||||
*
|
||||
* @package message
|
||||
* @subpackage email
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'message_email'), get_string('configsmtphosts', 'message_email'), '', PARAM_RAW));
|
||||
$settings->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'message_email'), get_string('configsmtpuser', 'message_email'), '', PARAM_NOTAGS));
|
||||
$settings->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'message_email'), get_string('configsmtpuser', 'message_email'), ''));
|
||||
$settings->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'message_email'), get_string('configsmtpmaxbulk', 'message_email'), 1, PARAM_INT));
|
||||
$settings->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'message_email'), get_string('confignoreplyaddress', 'message_email'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
|
||||
|
||||
$charsets = get_list_of_charsets();
|
||||
unset($charsets['UTF-8']); // not needed here
|
||||
$options = array();
|
||||
$options['0'] = 'UTF-8';
|
||||
$options = array_merge($options, $charsets);
|
||||
$settings->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'message_email'), get_string('configsitemailcharset','message_email'), '0', $options));
|
||||
$settings->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'message_email'), get_string('configallowusermailcharset', 'message_email'), 0));
|
||||
$options = array('LF'=>'LF', 'CRLF'=>'CRLF');
|
||||
$settings->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'message_email'), get_string('configmailnewline','message_email'), 'LF', $options));
|
||||
}
|
@ -23,6 +23,16 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['pluginname'] = 'Jabber message';
|
||||
$string['configjabberhost'] = 'The server to connect to to send jabber message notifications';
|
||||
$string['configjabberserver'] = 'XMPP host ID (can be left empty if the same as Jabber host)';
|
||||
$string['configjabberusername'] = 'The user name to use when connecting to the Jabber server';
|
||||
$string['configjabberpassword'] = 'The password to use when connecting to the Jabber server';
|
||||
$string['configjabberport'] = 'The port to use when connecting to the Jabber server';
|
||||
$string['jabberhost'] = 'Jabber host';
|
||||
$string['jabberid'] = 'Jabber ID';
|
||||
$string['jabberserver'] = 'Jabber server';
|
||||
$string['jabberusername'] = 'Jabber user name';
|
||||
$string['jabberpassword'] = 'Jabber password';
|
||||
$string['jabberport'] = 'Jabber port';
|
||||
$string['notconfigured'] = 'The Jabber server hasn\'t been configured so Jabber messages cannot be sent';
|
||||
$string['pluginname'] = 'Jabber message';
|
||||
|
@ -44,46 +44,42 @@ class message_output_jabber extends message_output {
|
||||
function send_message($eventdata){
|
||||
global $CFG;
|
||||
|
||||
if (message_output_jabber::_jabber_configured()) {
|
||||
if (!empty($CFG->noemailever)) {
|
||||
// hidden setting for development sites, set in config.php if needed
|
||||
debugging('$CFG->noemailever active, no jabber message sent.', DEBUG_MINIMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
//hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
|
||||
static $jabberaddresses = array();
|
||||
|
||||
if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
|
||||
$jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', $eventdata->userto->email, $eventdata->userto->id);
|
||||
}
|
||||
$jabberaddress = $jabberaddresses[$eventdata->userto->id];
|
||||
|
||||
//calling s() on smallmessage causes Jabber to display things like < Jabber != a browser
|
||||
$jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;
|
||||
|
||||
if (!empty($eventdata->contexturl)) {
|
||||
$jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
|
||||
}
|
||||
|
||||
$jabbermessage .= "\n(".get_string('noreply','message').')';
|
||||
|
||||
$conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);
|
||||
|
||||
try {
|
||||
//$conn->useEncryption(false);
|
||||
$conn->connect();
|
||||
$conn->processUntil('session_start');
|
||||
$conn->presence();
|
||||
$conn->message($jabberaddress, $jabbermessage);
|
||||
$conn->disconnect();
|
||||
} catch(XMPPHP_Exception $e) {
|
||||
debugging($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
if (!empty($CFG->noemailever)) {
|
||||
// hidden setting for development sites, set in config.php if needed
|
||||
debugging('$CFG->noemailever active, no jabber message sent.', DEBUG_MINIMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
//note that we're reporting success if message was sent or if Jabber simply isnt configured
|
||||
//hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
|
||||
static $jabberaddresses = array();
|
||||
|
||||
if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
|
||||
$jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
|
||||
}
|
||||
$jabberaddress = $jabberaddresses[$eventdata->userto->id];
|
||||
|
||||
//calling s() on smallmessage causes Jabber to display things like < Jabber != a browser
|
||||
$jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;
|
||||
|
||||
if (!empty($eventdata->contexturl)) {
|
||||
$jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
|
||||
}
|
||||
|
||||
$jabbermessage .= "\n(".get_string('noreply','message').')';
|
||||
|
||||
$conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);
|
||||
|
||||
try {
|
||||
//$conn->useEncryption(false);
|
||||
$conn->connect();
|
||||
$conn->processUntil('session_start');
|
||||
$conn->presence();
|
||||
$conn->message($jabberaddress, $jabbermessage);
|
||||
$conn->disconnect();
|
||||
} catch(XMPPHP_Exception $e) {
|
||||
debugging($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,7 +90,7 @@ class message_output_jabber extends message_output {
|
||||
function config_form($preferences){
|
||||
global $CFG;
|
||||
|
||||
if (!message_output_jabber::_jabber_configured()) {
|
||||
if (!$this->is_system_configured()) {
|
||||
return get_string('notconfigured','message_jabber');
|
||||
} else {
|
||||
return get_string('jabberid', 'message_jabber').': <input size="30" name="jabber_jabberid" value="'.$preferences->jabber_jabberid.'" />';
|
||||
@ -107,7 +103,7 @@ class message_output_jabber extends message_output {
|
||||
* @param array $preferences preferences array
|
||||
*/
|
||||
function process_form($form, &$preferences){
|
||||
if (isset($form->jabber_jabberid)) {
|
||||
if (isset($form->jabber_jabberid) && !empty($form->jabber_jabberid)) {
|
||||
$preferences['message_processor_jabber_jabberid'] = $form->jabber_jabberid;
|
||||
}
|
||||
}
|
||||
@ -125,11 +121,25 @@ class message_output_jabber extends message_output {
|
||||
* Tests whether the Jabber settings have been configured
|
||||
* @return boolean true if Jabber is configured
|
||||
*/
|
||||
private function _jabber_configured() {
|
||||
function is_system_configured() {
|
||||
global $CFG;
|
||||
return (!empty($CFG->jabberhost) && !empty($CFG->jabberport) && !empty($CFG->jabberusername) && !empty($CFG->jabberpassword));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the Jabber settings have been configured on user level
|
||||
* @param object $user the user object, defaults to $USER.
|
||||
* @return bool has the user made all the necessary settings
|
||||
* in their profile to allow this plugin to be used.
|
||||
*/
|
||||
function is_user_configured($user = null) {
|
||||
global $USER;
|
||||
|
||||
if (is_null($user)) {
|
||||
$user = $USER;
|
||||
}
|
||||
return (bool)get_user_preferences('message_processor_jabber_jabberid', null, $user->id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
34
message/output/jabber/settings.php
Normal file
34
message/output/jabber/settings.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// Moodle 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/>.
|
||||
|
||||
/**
|
||||
* Jabber configuration page
|
||||
*
|
||||
* @package message
|
||||
* @subpackage jabber
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configtext('jabberhost', get_string('jabberhost', 'message_jabber'), get_string('configjabberhost', 'message_jabber'), '', PARAM_RAW));
|
||||
$settings->add(new admin_setting_configtext('jabberserver', get_string('jabberserver', 'message_jabber'), get_string('configjabberserver', 'message_jabber'), '', PARAM_RAW));
|
||||
$settings->add(new admin_setting_configtext('jabberusername', get_string('jabberusername', 'message_jabber'), get_string('configjabberusername', 'message_jabber'), '', PARAM_RAW));
|
||||
$settings->add(new admin_setting_configpasswordunmask('jabberpassword', get_string('jabberpassword', 'message_jabber'), get_string('configjabberpassword', 'message_jabber'), ''));
|
||||
$settings->add(new admin_setting_configtext('jabberport', get_string('jabberport', 'message_jabber'), get_string('configjabberport', 'message_jabber'), 5222, PARAM_INT));
|
||||
}
|
@ -39,6 +39,22 @@ abstract class message_output {
|
||||
public abstract function process_form($form, &$preferences);
|
||||
public abstract function load_data(&$preferences, $userid);
|
||||
public abstract function config_form($preferences);
|
||||
/**
|
||||
* @return bool have all the necessary config settings been
|
||||
* made that allow this plugin to be used.
|
||||
*/
|
||||
public function is_system_configured() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @param object $user the user object, defaults to $USER.
|
||||
* @return bool has the user made all the necessary settings
|
||||
* in their profile to allow this plugin to be used.
|
||||
*/
|
||||
public function is_user_configured($user = null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
346
message/renderer.php
Normal file
346
message/renderer.php
Normal file
@ -0,0 +1,346 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle 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.
|
||||
//
|
||||
// Moodle 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/>.
|
||||
|
||||
/**
|
||||
* Messaging libraries
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* message Renderer
|
||||
*
|
||||
* Class for rendering various message objects
|
||||
*
|
||||
* @package message
|
||||
* @copyright 2011 Lancaster University Network Services Limited
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_message_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Display the interface to manage message outputs
|
||||
*
|
||||
* @param mixed $processors array of objects containing message processors
|
||||
* @return string The text to render
|
||||
*/
|
||||
public function manage_messageoutputs($processors) {
|
||||
global $CFG;
|
||||
// Display the current workflows
|
||||
$table = new html_table();
|
||||
$table->attributes['class'] = 'generaltable';
|
||||
$table->data = array();
|
||||
$table->head = array(
|
||||
get_string('name'),
|
||||
get_string('enable'),
|
||||
get_string('settings'),
|
||||
);
|
||||
$table->colclasses = array(
|
||||
'displayname', 'availability', 'settings',
|
||||
);
|
||||
|
||||
foreach ($processors as $processor) {
|
||||
$row = new html_table_row();
|
||||
$row->attributes['class'] = 'messageoutputs';
|
||||
|
||||
// Name
|
||||
$name = new html_table_cell($processor->name);
|
||||
|
||||
// Enable
|
||||
$enable = new html_table_cell();
|
||||
$enable->attributes['class'] = 'mdl-align';
|
||||
if (!$processor->available) {
|
||||
$enable->text = html_writer::nonempty_tag('span', get_string('outputnotavailable', 'message'), array('class' => 'error'));
|
||||
} else if (!$processor->configured) {
|
||||
$enable->text = html_writer::nonempty_tag('span', get_string('outputnotconfigured', 'message'), array('class' => 'error'));
|
||||
} else if ($processor->enabled) {
|
||||
$url = new moodle_url('/admin/message.php', array('disable' => $processor->id, 'sesskey' => sesskey()));
|
||||
$enable->text = html_writer::link($url, html_writer::empty_tag('img',
|
||||
array('src' => $this->output->pix_url('i/hide'),
|
||||
'class' => 'icon',
|
||||
'title' => get_string('outputenabled', 'message'),
|
||||
'alt' => get_string('outputenabled', 'message'),
|
||||
)
|
||||
));
|
||||
} else {
|
||||
$name->attributes['class'] = 'dimmed_text';
|
||||
$url = new moodle_url('/admin/message.php', array('enable' => $processor->id, 'sesskey' => sesskey()));
|
||||
$enable->text = html_writer::link($url, html_writer::empty_tag('img',
|
||||
array('src' => $this->output->pix_url('i/show'),
|
||||
'class' => 'icon',
|
||||
'title' => get_string('outputdisabled', 'message'),
|
||||
'alt' => get_string('outputdisabled', 'message'),
|
||||
)
|
||||
));
|
||||
}
|
||||
// Settings
|
||||
$settings = new html_table_cell();
|
||||
if ($processor->available && $processor->hassettings) {
|
||||
$settingsurl = new moodle_url('settings.php', array('section' => 'messagesetting'.$processor->name));
|
||||
$settings->text = html_writer::link($settingsurl, get_string('settings', 'message'));
|
||||
}
|
||||
|
||||
$row->cells = array($name, $enable, $settings);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the interface to manage default message outputs
|
||||
*
|
||||
* @param mixed $processors array of objects containing message processors
|
||||
* @param mixed $providers array of objects containing message providers
|
||||
* @param mixed $preferences array of objects containing current preferences
|
||||
* @return string The text to render
|
||||
*/
|
||||
public function manage_defaultmessageoutputs($processors, $providers, $preferences) {
|
||||
global $CFG;
|
||||
|
||||
// Prepare list of options for dropdown menu
|
||||
$options = array();
|
||||
foreach (array('disallowed', 'permitted', 'forced') as $setting) {
|
||||
$options[$setting] = get_string($setting, 'message');
|
||||
}
|
||||
|
||||
$output = html_writer::start_tag('form', array('id'=>'defaultmessageoutputs', 'method'=>'post'));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
|
||||
// Display users outputs table
|
||||
$table = new html_table();
|
||||
$table->attributes['class'] = 'generaltable';
|
||||
$table->data = array();
|
||||
$table->head = array('');
|
||||
|
||||
// Populate the header row
|
||||
foreach ($processors as $processor) {
|
||||
$table->head[] = get_string('pluginname', 'message_'.$processor->name);
|
||||
}
|
||||
// Generate the matrix of settings for each provider and processor
|
||||
foreach ($providers as $provider) {
|
||||
$row = new html_table_row();
|
||||
$row->attributes['class'] = 'defaultmessageoutputs';
|
||||
$row->cells = array();
|
||||
|
||||
// Provider Name
|
||||
$providername = get_string('messageprovider:'.$provider->name, $provider->component);
|
||||
$row->cells[] = new html_table_cell($providername);
|
||||
|
||||
// Settings for each processor
|
||||
foreach ($processors as $processor) {
|
||||
$cellcontent = '';
|
||||
foreach (array('permitted', 'loggedin', 'loggedoff') as $setting) {
|
||||
// pepare element and preference names
|
||||
$elementname = $provider->component.'_'.$provider->name.'_'.$setting.'['.$processor->name.']';
|
||||
$preferencebase = $provider->component.'_'.$provider->name.'_'.$setting;
|
||||
// prepare language bits
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
$statename = get_string($setting, 'message');
|
||||
$labelparams = array(
|
||||
'provider' => $providername,
|
||||
'processor' => $processorname,
|
||||
'state' => $statename
|
||||
);
|
||||
if ($setting == 'permitted') {
|
||||
$label = get_string('sendingvia', 'message', $labelparams);
|
||||
// determine the current setting or use default
|
||||
$select = MESSAGE_DEFAULT_PERMITTED;
|
||||
$preference = $processor->name.'_provider_'.$preferencebase;
|
||||
if (array_key_exists($preference, $preferences)) {
|
||||
$select = $preferences->{$preference};
|
||||
}
|
||||
// dropdown menu
|
||||
$cellcontent = html_writer::label($label, $elementname, true, array('class' => 'accesshide'));
|
||||
$cellcontent .= html_writer::select($options, $elementname, $select, false, array('id' => $elementname));
|
||||
$cellcontent .= html_writer::tag('div', get_string('defaults', 'message'));
|
||||
} else {
|
||||
$label = get_string('sendingviawhen', 'message', $labelparams);
|
||||
// determine the current setting based on the 'permitted' setting above
|
||||
$checked = false;
|
||||
if ($select == 'forced') {
|
||||
$checked = true;
|
||||
} else if ($select == 'permitted') {
|
||||
$preference = 'message_provider_'.$preferencebase;
|
||||
if (array_key_exists($preference, $preferences)) {
|
||||
$checked = (int)in_array($processor->name, explode(',', $preferences->{$preference}));
|
||||
}
|
||||
}
|
||||
// generate content
|
||||
$cellcontent .= html_writer::start_tag('div');
|
||||
$cellcontent .= html_writer::label($label, $elementname, true, array('class' => 'accesshide'));
|
||||
$cellcontent .= html_writer::checkbox($elementname, 1, $checked, '', array('id' => $elementname));
|
||||
$cellcontent .= $statename;
|
||||
$cellcontent .= html_writer::end_tag('div');
|
||||
}
|
||||
}
|
||||
$row->cells[] = new html_table_cell($cellcontent);
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
$output .= html_writer::table($table);
|
||||
$output .= html_writer::start_tag('div', array('class' => 'form-buttons'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('savechanges','admin'), 'class' => 'form-submit'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('form');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the interface for messaging options
|
||||
*
|
||||
* @param mixed $processors array of objects containing message processors
|
||||
* @param mixed $providers array of objects containing message providers
|
||||
* @param mixed $preferences array of objects containing current preferences
|
||||
* @param mixed $defaultpreferences array of objects containing site default preferences
|
||||
* @return string The text to render
|
||||
*/
|
||||
public function manage_messagingoptions($processors, $providers, $preferences, $defaultpreferences) {
|
||||
// Filter out enabled, available system_configured and user_configured processors only.
|
||||
$readyprocessors = array_filter($processors, create_function('$a', 'return $a->enabled && $a->configured && $a->object->is_user_configured();'));
|
||||
|
||||
// Start the form. We're not using mform here because of our special formatting needs ...
|
||||
$output = html_writer::start_tag('form', array('method'=>'post', 'class' => 'mform'));
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
|
||||
|
||||
/// Settings table...
|
||||
$output .= html_writer::start_tag('fieldset', array('id' => 'providers', 'class' => 'clearfix'));
|
||||
$output .= html_writer::nonempty_tag('legend', get_string('providers_config', 'message'), array('class' => 'ftoggler'));
|
||||
|
||||
// Display the messging options table
|
||||
$table = new html_table();
|
||||
$table->attributes['class'] = 'generaltable';
|
||||
$table->data = array();
|
||||
$table->head = array('');
|
||||
|
||||
foreach ($readyprocessors as $processor) {
|
||||
$table->head[] = get_string('pluginname', 'message_'.$processor->name);
|
||||
}
|
||||
|
||||
$number_procs = count($processors);
|
||||
// Populate the table with rows
|
||||
foreach ( $providers as $provider) {
|
||||
$preferencebase = $provider->component.'_'.$provider->name;
|
||||
|
||||
$headerrow = new html_table_row();
|
||||
$providername = get_string('messageprovider:'.$provider->name, $provider->component);
|
||||
$providercell = new html_table_cell($providername);
|
||||
$providercell->header = true;
|
||||
$providercell->colspan = $number_procs + 1;
|
||||
$providercell->attributes['class'] = 'c0';
|
||||
$headerrow->cells = array($providercell);
|
||||
$table->data[] = $headerrow;
|
||||
|
||||
foreach (array('loggedin', 'loggedoff') as $state) {
|
||||
$optionrow = new html_table_row();
|
||||
$optionname = new html_table_cell(get_string($state.'description', 'message'));
|
||||
$optionname->attributes['class'] = 'c0';
|
||||
$optionrow->cells = array($optionname);
|
||||
foreach ($readyprocessors as $processor) {
|
||||
// determine the default setting
|
||||
$permitted = MESSAGE_DEFAULT_PERMITTED;
|
||||
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$permitted = $defaultpreferences->{$defaultpreference};
|
||||
}
|
||||
// If settings are disallowed, just display the message that
|
||||
// the setting is not permitted, if not use user settings or
|
||||
// force them.
|
||||
if ($permitted == 'disallowed') {
|
||||
if ($state == 'loggedoff') {
|
||||
// skip if we are rendering the second line
|
||||
continue;
|
||||
}
|
||||
$cellcontent = html_writer::nonempty_tag('div', get_string('notpermitted', 'message'), array('class' => 'dimmed_text'));
|
||||
$optioncell = new html_table_cell($cellcontent);
|
||||
$optioncell->rowspan = 2;
|
||||
$optioncell->attributes['class'] = 'disallowed';
|
||||
} else {
|
||||
// determine user preferences and use then unless we force
|
||||
// the preferences.
|
||||
$disabled = array();
|
||||
if ($permitted == 'forced') {
|
||||
$checked = true;
|
||||
$disabled['disabled'] = 1;
|
||||
} else {
|
||||
$checked = false;
|
||||
// See if hser has touched this preference
|
||||
if (isset($preferences->{$preferencebase.'_'.$state})) {
|
||||
// User have some preferneces for this state in the database, use them
|
||||
$checked = isset($preferences->{$preferencebase.'_'.$state}[$processor->name]);
|
||||
} else {
|
||||
// User has not set this preference yet, using site default preferences set by admin
|
||||
$defaultpreference = 'message_provider_'.$preferencebase.'_'.$state;
|
||||
if (isset($defaultpreferences->{$defaultpreference})) {
|
||||
$checked = (int)in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
|
||||
}
|
||||
}
|
||||
}
|
||||
$elementname = $preferencebase.'_'.$state.'['.$processor->name.']';
|
||||
// prepare language bits
|
||||
$processorname = get_string('pluginname', 'message_'.$processor->name);
|
||||
$statename = get_string($state, 'message');
|
||||
$labelparams = array(
|
||||
'provider' => $providername,
|
||||
'processor' => $processorname,
|
||||
'state' => $statename
|
||||
);
|
||||
$label = get_string('sendingviawhen', 'message', $labelparams);
|
||||
$cellcontent = html_writer::label($label, $elementname, true, array('class' => 'accesshide'));
|
||||
$cellcontent .= html_writer::checkbox($elementname, 1, $checked, '', array_merge(array('id' => $elementname), $disabled));
|
||||
$optioncell = new html_table_cell($cellcontent);
|
||||
$optioncell->attributes['class'] = 'mdl-align';
|
||||
}
|
||||
$optionrow->cells[] = $optioncell;
|
||||
}
|
||||
$table->data[] = $optionrow;
|
||||
}
|
||||
}
|
||||
$output .= html_writer::start_tag('div');
|
||||
$output .= html_writer::table($table);
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('fieldset');
|
||||
|
||||
foreach ($processors as $processor) {
|
||||
if (($processorconfigform = $processor->object->config_form($preferences)) && $processor->enabled) {
|
||||
$output .= html_writer::start_tag('fieldset', array('id' => 'messageprocessor_'.$processor->name, 'class' => 'clearfix'));
|
||||
$output .= html_writer::nonempty_tag('legend', get_string('pluginname', 'message_'.$processor->name), array('class' => 'ftoggler'));
|
||||
$output .= html_writer::start_tag('div');
|
||||
$output .= $processorconfigform;
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
}
|
||||
|
||||
$output .= html_writer::start_tag('fieldset', array('id' => 'messageprocessor_general', 'class' => 'clearfix'));
|
||||
$output .= html_writer::nonempty_tag('legend', get_string('generalsettings','admin'), array('class' => 'ftoggler'));
|
||||
$output .= html_writer::start_tag('div');
|
||||
$output .= get_string('blocknoncontacts', 'message').': ';
|
||||
$output .= html_writer::checkbox('blocknoncontacts', 1, $preferences->blocknoncontacts, '');
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('fieldset');
|
||||
$output .= html_writer::start_tag('div', array('class' => 'mdl-align'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('updatemyprofile'), 'class' => 'form-submit'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= html_writer::end_tag('form');
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
@ -84,6 +84,7 @@ $string['completionreplies'] = 'Student must post replies:';
|
||||
$string['completionrepliesgroup'] = 'Require replies';
|
||||
$string['completionreplieshelp'] = 'requiring replies to complete';
|
||||
$string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.';
|
||||
$string['configdigestmailtime'] = 'People who choose to have emails sent to them in digest form will be emailed the digest daily. This setting controls which time of day the daily mail will be sent (the next cron that runs after this hour will send it).';
|
||||
$string['configdisplaymode'] = 'The default display mode for discussions if one isn\'t set.';
|
||||
$string['configenablerssfeeds'] = 'This switch will enable the possibility of RSS feeds for all forums. You will still need to turn feeds on manually in the settings for each forum.';
|
||||
$string['configenabletimedposts'] = 'Set to \'yes\' if you want to allow setting of display periods when posting a new forum discussion (Experimental as not yet fully tested)';
|
||||
@ -110,6 +111,7 @@ $string['deletesureplural'] = 'Are you sure you want to delete this post and all
|
||||
$string['digestmailheader'] = 'This is your daily digest of new posts from the {$a->sitename} forums. To change your forum email preferences, go to {$a->userprefs}.';
|
||||
$string['digestmailprefs'] = 'your user profile';
|
||||
$string['digestmailsubject'] = '{$a}: forum digest';
|
||||
$string['digestmailtime'] = 'Hour to send digest emails';
|
||||
$string['digestsentusers'] = 'Email digests successfully sent to {$a} users.';
|
||||
$string['disallowsubscribe'] = 'Subscriptions not allowed';
|
||||
$string['disallowsubscribeteacher'] = 'Subscriptions not allowed (except for teachers)';
|
||||
|
@ -65,14 +65,17 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configcheckbox('forum_usermarksread', get_string('usermarksread', 'forum'),
|
||||
get_string('configusermarksread', 'forum'), 0));
|
||||
|
||||
// Default time (hour) to execute 'clean_read_records' cron
|
||||
$options = array();
|
||||
for ($i=0; $i<24; $i++) {
|
||||
$options[$i] = $i;
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$options[$i] = sprintf("%02d",$i);
|
||||
}
|
||||
// Default time (hour) to execute 'clean_read_records' cron
|
||||
$settings->add(new admin_setting_configselect('forum_cleanreadtime', get_string('cleanreadtime', 'forum'),
|
||||
get_string('configcleanreadtime', 'forum'), 2, $options));
|
||||
|
||||
// Default time (hour) to send digest email
|
||||
$settings->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'forum'),
|
||||
get_string('configdigestmailtime', 'forum'), 17, $options));
|
||||
|
||||
if (empty($CFG->enablerssfeeds)) {
|
||||
$options = array(0 => get_string('rssglobaldisabled', 'admin'));
|
||||
|
@ -444,3 +444,8 @@ table#tag-management-list {margin: 10px auto;width: 80%;}
|
||||
/* Portfolio */
|
||||
.path-portfolio .exportsummary {margin:0px auto 1em auto;}
|
||||
.portfolio-add-icon {margin-left:5px;}
|
||||
|
||||
/* Messaging options */
|
||||
#page-message-edit table.generaltable th.c0 {text-align: left;}
|
||||
#page-message-edit table.generaltable td.c0 {text-align: right;}
|
||||
#page-message-edit table.generaltable td.disallowed {text-align: center;vertical-align:middle;}
|
||||
|
@ -200,10 +200,6 @@ if ($usernew = $userform->get_data()) {
|
||||
|
||||
// trigger events
|
||||
if ($usercreated) {
|
||||
//set default message preferences
|
||||
if (!message_set_default_message_preferences( $usernew )){
|
||||
print_error('cannotsavemessageprefs', 'message');
|
||||
}
|
||||
events_trigger('user_created', $usernew);
|
||||
} else {
|
||||
events_trigger('user_updated', $usernew);
|
||||
|
@ -30,7 +30,8 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2011060500.03; // YYYYMMDD = weekly release date of this DEV branch
|
||||
|
||||
$version = 2011060800.00; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user