Skip to content

Commit

Permalink
message MDL-24562 made jabber message notifications work
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Davis committed Oct 18, 2010
1 parent 7d8e60f commit 90b4d59
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
10 changes: 10 additions & 0 deletions admin/settings/server.php
Expand Up @@ -72,6 +72,16 @@
$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'));
Expand Down
11 changes: 11 additions & 0 deletions lang/en/admin.php
Expand Up @@ -234,6 +234,11 @@
$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';
$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['configlangcache'] = 'Cache the language menu. Saves a lot of memory and processing power. If you enable this, the menu takes a few minutes to update after you have added or removed languages.';
Expand Down Expand Up @@ -597,6 +602,12 @@
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';
Expand Down
2 changes: 1 addition & 1 deletion lang/en/message.php
Expand Up @@ -46,7 +46,7 @@
$string['discussion'] = 'Discussion';
$string['editmymessage'] = 'Messaging';
$string['emailmessages'] = 'Email messages when I am offline';
$string['emailtagline'] = 'This email is a copy of a message sent to you at "{$a->sitename}". Go to {$a->url} to reply.';
$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['formorethan'] = 'For more than';
Expand Down
15 changes: 4 additions & 11 deletions message/output/jabber/message_output_jabber.php
Expand Up @@ -31,14 +31,6 @@
* @package
*/


define("JABBER_SERVER","jabber80.com");
define("JABBER_USERNAME","");
define("JABBER_PASSWORD","");
define("JABBER_PORT",5222);

define("RUN_TIME",15); // set a maximum run time of 15 seconds

require_once($CFG->dirroot.'/message/output/lib.php');
require_once($CFG->libdir.'/jabber/XMPP/XMPP.php');

Expand All @@ -50,7 +42,7 @@ class message_output_jabber extends message_output {
* @return true if ok, false if error
*/
function send_message($message){
global $DB;
global $DB, $CFG;

if (!$userfrom = $DB->get_record('user', array('id' => $message->useridfrom))) {
return false;
Expand All @@ -61,11 +53,12 @@ function send_message($message){
if (!$jabberaddress = get_user_preferences('message_processor_jabber_jabberid', $userto->email, $userto->id)) {
$jabberaddress = $userto->email;
}
$jabbermessage = fullname($userfrom).': '.$message->fullmessage;
$jabbermessage = fullname($userfrom).': '.$message->smallmessage;

$conn = new XMPPHP_XMPP(JABBER_SERVER, JABBER_PORT, JABBER_USERNAME, JABBER_PASSWORD, 'moodle', JABBER_SERVER);
$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();
Expand Down

0 comments on commit 90b4d59

Please sign in to comment.