# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/blocks/messages/block_messages.php
--- moodle/blocks/messages/block_messages.php Base (1.30)
+++ moodle/blocks/messages/block_messages.php Locally Modified (Based On 1.30)
@@ -30,7 +30,7 @@
         }
 
         $link = '/message/index.php';
-        $action = new popup_action('click', $link, 'message');
+        $action = new popup_action('click', $link, 'message', array('width'=>400,'height'=>500));
         $this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action);
         //$this->content->footer = '<a href="'.$CFG->wwwroot.'/message/index.php" onclick="this.target=\'message\'; return openpopup_old(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'</a>...';
 
Index: moodle/blocks/online_users/block_online_users.php
--- moodle/blocks/online_users/block_online_users.php Base (1.76)
+++ moodle/blocks/online_users/block_online_users.php Locally Modified (Based On 1.76)
@@ -158,7 +158,7 @@
                     $link = '/message/discussion.php?id='.$user->id;
                     $anchortagcontents = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" />';
 
-                    $action = new popup_action('click', $link, 'message_'.$user->id);
+                    $action = new popup_action('click', $link, 'message_'.$user->id, array('width'=>800,'height'=>600));
                     $anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>get_string('messageselectadd')));
 
                     $this->content->text .= '<div class="message">'.$anchortag.'</div>';
Index: moodle/lib/navigationlib.php
--- moodle/lib/navigationlib.php Base (1.109)
+++ moodle/lib/navigationlib.php Locally Modified (Based On 1.109)
@@ -1284,6 +1284,9 @@
             }
         }
 
+        $url = new moodle_url('/message/view.php',array());
+        $usernode->add(get_string('messages', 'message'), $url);
+
         // Add a node to view the users notes if permitted
         if (!empty($CFG->enablenotes) && has_any_capability(array('moodle/notes:manage', 'moodle/notes:view'), $coursecontext)) {
             $url = new moodle_url('/notes/index.php',array('user'=>$user->id));
Index: moodle/message/discussion.php
--- moodle/message/discussion.php Base (1.38)
+++ moodle/message/discussion.php Locally Modified (Based On 1.38)
@@ -74,7 +74,7 @@
        <title><?php echo get_string('discussion', 'message').': '.fullname($user) ?></title>
        <link rel="shortcut icon" href="<?php echo $CFG->wwwroot.'/theme/'.$PAGE->theme->name; ?>/pix/favicon.ico" />
      </head>
-     <frameset rows="110,*,0,220">
+     <frameset rows="110,*,0,420">
        <noframes><body><?php
            echo '<a href="discussion.php?id='.$userid.'&amp;noframesjs=1">'.get_string('noframesjs', 'message').'</a>';
        ?></body></noframes>
Index: moodle/message/edit.php
--- moodle/message/edit.php Base (1.28)
+++ moodle/message/edit.php Locally Modified (Based On 1.28)
@@ -95,13 +95,16 @@
     foreach ( $providers as $providerid => $provider){
         foreach (array('loggedin', 'loggedoff') as $state){
             $linepref = '';
-            foreach ($form->{$provider->component.'_'.$provider->name.'_'.$state} as $process=>$one){
+            $componentproviderstate = $provider->component.'_'.$provider->name.'_'.$state;
+            if (array_key_exists($componentproviderstate, $form)) {
+                foreach ($form->{$componentproviderstate} as $process=>$one){
                 if ($linepref == ''){
                     $linepref = $process;
                 } else {
                     $linepref .= ','.$process;
                 }
             }
+            }
             $preferences['message_provider_'.$provider->component.'_'.$provider->name.'_'.$state] = $linepref;
         }
     }
Index: moodle/message/index.php
--- moodle/message/index.php Base (1.32)
+++ moodle/message/index.php Locally Modified (Based On 1.32)
@@ -112,8 +112,8 @@
                            get_string('contacts', 'message'));
 $tabrow[] = new tabobject('search', $CFG->wwwroot.'/message/index.php?tab=search',
                            get_string('search', 'message'));
-$tabrow[] = new tabobject('settings', $CFG->wwwroot.'/message/index.php?tab=settings',
-                           get_string('settings', 'message'));
+//$tabrow[] = new tabobject('settings', $CFG->wwwroot.'/message/index.php?tab=settings',
+//                           get_string('settings', 'message'));
 $tabrows = array($tabrow);
 
 print_tabs($tabrows, $tab);
@@ -129,7 +129,7 @@
 /// a print function is associated with each tab
 $tabprintfunction = 'message_print_'.$tab;
 if (function_exists($tabprintfunction)) {
-    $tabprintfunction();
+    $tabprintfunction('index.php');
 }
 
 echo '</td> </tr> </table>';
Index: moodle/message/lib.php
--- moodle/message/lib.php Base (1.108)
+++ moodle/message/lib.php Locally Modified (Based On 1.108)
@@ -29,6 +29,9 @@
 define ('MESSAGE_SHORTLENGTH', 300);
 define ('MESSAGE_WINDOW', true);          // We are in a message window (so don't pop up a new one!)
 
+define ('MESSAGE_DISCUSSION_WIDTH',600);
+define ('MESSAGE_DISCUSSION_HEIGHT',500);
+
 if (!isset($CFG->message_contacts_refresh)) {  // Refresh the contacts list every 60 seconds
     $CFG->message_contacts_refresh = 60;
 }
@@ -40,7 +43,7 @@
 }
 
 
-function message_print_contacts() {
+function message_print_contacts($refresh=true) {
     global $USER, $CFG, $DB, $PAGE, $OUTPUT;
 
     $timetoshowusers = 300; //Seconds default
@@ -115,7 +118,7 @@
         print_string('contactlistempty', 'message');
         echo '</div>';
         echo '<div class="note">';
-        print_string('addsomecontacts', 'message', $CFG->wwwroot.'/message/index.php?tab=search');
+        print_string('addsomecontacts', 'message', message_remove_url_params($PAGE->url).'?tab=search');
         echo '</div>';
     }
 
@@ -168,18 +171,29 @@
 
     echo '<br />';
 
+    if ($refresh) {
     $PAGE->requires->js_init_call('M.core_message.init_refresh_page', array(60*1000, $PAGE->url->out(false)));
 
     echo $OUTPUT->container_start('messagejsautorefresh note center');
     echo get_string('pagerefreshes', 'message', $CFG->message_contacts_refresh);
     echo $OUTPUT->container_end();
+    }
 
     echo $OUTPUT->container_start('messagejsmanualrefresh aligncenter');
-    echo $OUTPUT->single_button('index.php', get_string('refresh'));
+    echo $OUTPUT->single_button(message_remove_url_params($PAGE->url), get_string('refresh'));
     echo $OUTPUT->container_end();
 }
 
+function message_remove_url_params($moodleurl) {
+    //this should work but doesnt for some reason
+    //return $PAGE->url->out(true);
 
+    $newurl = new moodle_url($moodleurl);
+    $newurl->remove_params('addcontact','removecontact','blockcontact','unblockcontact');
+    return $newurl->out();
+}
+
+
 /// $messagearray is an array of objects
 /// $field is a valid property of object
 /// $value is the value $field should equal to be counted
@@ -200,10 +214,14 @@
 function message_print_search() {
     global $USER, $OUTPUT;
 
-    if ($frm = data_submitted()) {
+    $frm = data_submitted();
+    $doingsearch = false;
+    if ($frm) {
+        $doingsearch = !empty($frm->keywordssubmit) || (!empty($frm->personsubmit) and !empty($frm->name));
+    }
 
+    if ($doingsearch) {
         message_print_search_results($frm);
-
     } else {
 /*
 /// unfinished buggy code disabled in search.html anyway
@@ -239,7 +257,7 @@
 
         set_user_preferences($pref);
 
-        redirect('index.php', get_string('settingssaved', 'message'), 1);
+        redirect(message_remove_url_params($PAGE->url), get_string('settingssaved', 'message'), 1);
     }
 
     $cbshowmessagewindow = (get_user_preferences('message_showmessagewindow', 1) == '1') ? 'checked="checked"' : '';
@@ -310,7 +328,7 @@
 
 
 function message_print_search_results($frm) {
-    global $USER, $CFG, $DB, $OUTPUT;
+    global $USER, $CFG, $DB, $OUTPUT, $PAGE;
 
     echo '<div class="mdl-align">';
 
@@ -353,8 +371,8 @@
                 echo '</td>';
                 echo '<td class="contact">';
                 $popupoptions = array(
-                        'height' => 500,
-                        'width' => 500,
+                        'height' => MESSAGE_DISCUSSION_HEIGHT,
+                        'width' => MESSAGE_DISCUSSION_WIDTH,
                         'menubar' => false,
                         'location' => false,
                         'status' => true,
@@ -512,7 +530,7 @@
     }
 
     echo '<br />';
-    echo $OUTPUT->single_button(new moodle_url('index.php', array('tab' => 'search')), get_string('newsearch', 'message'));
+    echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('tab' => 'search')), get_string('newsearch', 'message'));
 
     echo '</div>';
 }
@@ -524,7 +542,7 @@
     if ($user === false) {
         echo $OUTPUT->user_picture($USER, array('size'=>20, 'courseid'=>SITEID));
     } else {
-        echo $OUTPUT->user_picture($USE, array('size'=>20, 'courseid'=>SITEID));
+        echo $OUTPUT->user_picture($USER, array('size'=>20, 'courseid'=>SITEID));
         echo '&nbsp;';
         if ($iscontact) {
             message_contact_link($user->id, 'remove');
@@ -540,8 +558,8 @@
         echo '<br />';
 
         $popupoptions = array(
-                'height' => 500,
-                'width' => 500,
+                'height' => MESSAGE_DISCUSSION_HEIGHT,
+                'width' => MESSAGE_DISCUSSION_WIDTH,
                 'menubar' => false,
                 'location' => false,
                 'status' => true,
@@ -557,11 +575,16 @@
 
 
 /// linktype can be: add, remove, block, unblock
-function message_contact_link($userid, $linktype='add', $return=false, $script="index.php?tab=contacts", $text=false) {
-    global $USER, $CFG, $OUTPUT;
+function message_contact_link($userid, $linktype='add', $return=false, $script=null, $text=false) {
+    global $USER, $CFG, $OUTPUT, $PAGE;
 
     static $str;
 
+    if (empty($script)) {
+        //$script = "index.php?tab=contacts";
+        $script = message_remove_url_params($PAGE->url).'?tab=contacts';
+    }
+
     if (empty($str->blockcontact)) {
        $str->blockcontact   =  get_string('blockcontact', 'message');
        $str->unblockcontact =  get_string('unblockcontact', 'message');
@@ -1063,8 +1086,8 @@
     echo '<td class="contact">';
 
     $popupoptions = array(
-            'height' => 500,
-            'width' => 500,
\ No newline at end of file
+            'height' => MESSAGE_DISCUSSION_HEIGHT,
+            'width' => MESSAGE_DISCUSSION_WIDTH,
\ No newline at end of file
             'menubar' => false,
             'location' => false,
             'status' => true,
Index: moodle/message/module.js
--- moodle/message/module.js Base (1.2)
+++ moodle/message/module.js Locally Modified (Based On 1.2)
@@ -5,7 +5,6 @@
 }
 
 M.core_message.init_refresh_parent_frame = function(Y, msgcount, msg) {
-
 	var add_message = function (messagestr) {
 	    var messageblock = parent.messages.document.getElementById('messages');
 	    var message = document.createElement('div');
Index: moodle/message/output/jabber/message_output_jabber.php
--- moodle/message/output/jabber/message_output_jabber.php Base (1.7)
+++ moodle/message/output/jabber/message_output_jabber.php Locally Modified (Based On 1.7)
@@ -82,7 +82,7 @@
      * @param object $mform preferences form class
      */
     function config_form($preferences){
-        return get_string('jabberid', 'messageprocessor_jabber').': <input size="30" name="jabber_jabberid" value="'.$preferences->jabber_jabberid.'" />';
+        return get_string('jabberid', 'message_jabber').': <input size="30" name="jabber_jabberid" value="'.$preferences->jabber_jabberid.'" />';
     }
 
     /**
Index: moodle/message/output/popup/message_output_popup.php
--- moodle/message/output/popup/message_output_popup.php Base (1.9)
+++ moodle/message/output/popup/message_output_popup.php Locally Modified (Based On 1.9)
@@ -56,22 +56,42 @@
                '<tr><td align="right">'.get_string('showmessagewindow', 'message').':</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>'.
                '<tr><td align="right">'.get_string('blocknoncontacts', 'message').':</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>'.
                '<tr><td align="right">'.get_string('beepnewmessage', 'message').':</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>'.
+               '<tr><td align="right">'.get_string('htmleditor').':</td><td><input type="checkbox" name="usehtmleditor" '.($preferences->usehtmleditor==1?" checked=\"checked\"":"").' /></td></tr>'.
                '<tr><td align="right">'.get_string('noframesjs', 'message').':</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>'.
+               '<tr><td align="right">'.get_string('emailmessages', 'message').':</td><td><input type="checkbox" name="emailmessages" '.($preferences->emailmessages==1?" checked=\"checked\"":"").' /></td></tr>'.
+               '<tr><td align="right">'.get_string('formorethan', 'message').':</td><td><input type="text" name="emailtimenosee" id="emailtimenosee" size="2" value="'.$preferences->emailtimenosee.'" /> '.get_string('mins').'</td></tr>'.
+               '<tr><td align="right">'.get_string('email').':</td><td><input type="text" name="emailaddress" id="emailaddress" size="20" value="'.$preferences->emailaddress.'" /></td></tr>'.
+               '<tr><td align="right">'.get_string('format').':</td><td>'.$preferences->formatselect.'</td></tr>'.
                '</table>';
     }
 
     public function process_form($form, &$preferences) {
-        $preferences['message_showmessagewindow'] = $form->showmessagewindow?1:0;
-        $preferences['message_blocknoncontacts']  = $form->blocknoncontacts?1:0;
-        $preferences['message_beepnewmessage']    = $form->beepnewmessage?1:0;
-        $preferences['message_noframesjs']        = $form->noframesjs?1:0;
+        $preferences['message_showmessagewindow'] = !empty($form->showmessagewindow)?1:0;
+        $preferences['message_blocknoncontacts']  = !empty($form->blocknoncontacts)?1:0;
+        $preferences['message_beepnewmessage']    = !empty($form->beepnewmessage)?1:0;
+        $preferences['message_usehtmleditor']     = !empty($form->usehtmleditor)?1:0;
+        $preferences['message_noframesjs']        = !empty($form->noframesjs)?1:0;
+        $preferences['message_emailmessages']     = !empty($form->emailmessages)?1:0;
+        $preferences['message_emailtimenosee']    = $form->emailtimenosee;
+        $preferences['message_emailaddress']      = $form->emailaddress;
+        $preferences['message_emailformat']       = $form->emailformat;
+
         return true;
     }
     public function load_data(&$preferences, $userid) {
+        global $USER;
         $preferences->showmessagewindow =  get_user_preferences( 'message_showmessagewindow', 1, $userid);
         $preferences->blocknoncontacts  =  get_user_preferences( 'message_blocknoncontacts', '', $userid);
         $preferences->beepnewmessage    =  get_user_preferences( 'message_beepnewmessage', '', $userid);
+        $preferences->usehtmleditor     =  get_user_preferences( 'message_usehtmleditor', '', $userid);
         $preferences->noframesjs        =  get_user_preferences( 'message_noframesjs', '', $userid);
+        $preferences->emailmessages     =  get_user_preferences( 'message_emailmessages', 1, $userid);
+        $preferences->emailtimenosee    =  get_user_preferences( 'message_emailtimenosee', 10, $userid);
+        $preferences->emailaddress      =  get_user_preferences( 'message_emailaddress', $USER->email, $userid);
+        $preferences->formatselect      =  html_writer::select(array(FORMAT_PLAIN => get_string('formatplain'),
+                                                                FORMAT_HTML  => get_string('formathtml')),
+                                                                'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN));
+
\ No newline at end of file
         return true;
     }
 }
Index: moodle/message/refresh.php
--- moodle/message/refresh.php Base (1.31)
+++ moodle/message/refresh.php Locally Modified (Based On 1.31)
@@ -76,7 +76,7 @@
     }
 }
 
-$PAGE->requires->js_init_call('M.core_message.init_refresh_parent_frame', array($jsmessages, $jsmessages));
+$PAGE->requires->js_init_call('M.core_message.init_refresh_parent_frame', array(count($jsmessages), $jsmessages));
 
 echo $OUTPUT->header();
 if (!empty($playbeep)) {
Index: moodle/message/search.html
--- moodle/message/search.html Base (1.17)
+++ moodle/message/search.html Locally Modified (Based On 1.17)
@@ -1,4 +1,4 @@
-<form id="personsearch" action="index.php" method="post">
+<form id="personsearch" method="post">
 <div><input type="hidden" name="tab" value="search" /></div>
 
 
Index: moodle/message/send.php
--- moodle/message/send.php Base (1.45)
+++ moodle/message/send.php Locally Modified (Based On 1.45)
@@ -102,7 +102,7 @@
                    '<span class="time">['.$time.']</span>: '.
                    '<span class="content">'.$message.'</span></div>';
         //$PAGE->requires->js_function_call('parent.messages.document.write', Array($message));
-        $PAGE->requires->js_function_call('add_message', Array($message));
\ No newline at end of file
+        $PAGE->requires->js_function_call('parent.refresh.add_message', Array($message));
\ No newline at end of file
         $PAGE->requires->js_function_call('parent.messages.scroll', Array(1,5000000));
 
         add_to_log(SITEID, 'message', 'write', 'history.php?user1='.$user->id.'&amp;user2='.$USER->id.'#m'.$messageid, $user->id);
Index: moodle/message/view.php
--- moodle/message/view.php No Base Revision
+++ moodle/message/view.php Locally New
@@ -0,0 +1,116 @@
+<?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/>.
+
+/**
+ * A page displaying the user's contacts. Similar to index.php but not a popup.
+ *
+ * @package   moodlecore
+ * @copyright 2010 Andrew Davis
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require('../config.php');
+require('lib.php');
+
+require_login(0, false);
+
+if (isguestuser()) {
+    redirect($CFG->wwwroot);
+}
+
+if (empty($CFG->messaging)) {
+    print_error('disabled', 'message');
+}
+
+/// Optional variables that may be passed in
+//$tab            = optional_param('tab', 'contacts', PARAM_ALPHA); // current tab - default to contacts
+$addcontact     = optional_param('addcontact',     0, PARAM_INT); // adding a contact
+$removecontact  = optional_param('removecontact',  0, PARAM_INT); // removing a contact
+$blockcontact   = optional_param('blockcontact',   0, PARAM_INT); // blocking a contact
+$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
+//$popup          = optional_param('popup', false, PARAM_ALPHANUM);    // If set then starts a new popup window
+
+$url = new moodle_url('/message/view.php');
+if ($addcontact !== 0) {
+    $url->param('addcontact', $addcontact);
+}
+if ($removecontact !== 0) {
+    $url->param('removecontact', $removecontact);
+}
+if ($blockcontact !== 0) {
+    $url->param('blockcontact', $blockcontact);
+}
+if ($unblockcontact !== 0) {
+    $url->param('unblockcontact', $unblockcontact);
+}
+$PAGE->set_url($url);
+
+
+$context = get_context_instance(CONTEXT_SYSTEM);
+
+
+/// Process any contact maintenance requests there may be
+if ($addcontact and confirm_sesskey()) {
+    add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
+    message_add_contact($addcontact);
+}
+if ($removecontact and confirm_sesskey()) {
+    add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
+    message_remove_contact($removecontact);
+}
+if ($blockcontact and confirm_sesskey()) {
+    add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
+    message_block_contact($blockcontact);
+}
+if ($unblockcontact and confirm_sesskey()) {
+    add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
+    message_unblock_contact($unblockcontact);
+}
+
+//$PAGE->blocks->add_region('content');
+$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
+$PAGE->navigation->extend_for_user($USER);
+
+$strmessage = get_string('messages', 'message');
+//$PAGE->navbar->add($strmessage);
+
+$PAGE->set_pagelayout('course');
+$PAGE->set_title(fullname($USER) . ': ' . $strmessage);
+$PAGE->set_heading($strmessage);
+
+//not the page contents
+echo $OUTPUT->header();
+echo $OUTPUT->heading(fullname($USER).': '.$strmessage);
+
+echo $OUTPUT->box_start();
+message_print_search('view.php');
+echo $OUTPUT->box_end();
+
+echo $OUTPUT->box_start();
+$refresh = false;
+message_print_contacts($refresh);
+echo $OUTPUT->box_end();
+
+
+//echo $OUTPUT->blocks_for_region('content');
+
+echo $OUTPUT->footer();
+
+
+function print_row($left, $right) {
+    echo "\n<tr><td class=\"label c0\">$left</td><td class=\"info c1\">$right</td></tr>\n";
+}
