# 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.29)
+++ moodle/blocks/messages/block_messages.php Locally Modified (Based On 1.29)
@@ -29,7 +29,10 @@
             return $this->content;
         }
 
-        $this->content->footer = '<a href="'.$CFG->wwwroot.'/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'</a>...';
+        $link = '/message/index.php';
+        $action = new popup_action('click', $link, 'message');
+        $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>...';
 
         $users = $DB->get_records_sql("SELECT m.useridfrom AS id, COUNT(m.useridfrom) AS count,
                                               u.firstname, u.lastname, u.picture, u.imagealt, u.lastaccess
@@ -47,8 +50,15 @@
                 $this->content->text .= '<li class="listentry"><div class="user"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.SITEID.'" title="'.$timeago.'">';
                 $this->content->text .= $OUTPUT->user_picture($user, array('courseid'=>SITEID)); //TODO: user might not have capability to view frontpage profile :-(
                 $this->content->text .= fullname($user).'</a></div>';
-                $this->content->text .= '<div class="message"><a href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\'; return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count.'</a>';
-                $this->content->text .= '</div></li>';
+
+                //<a href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\'; return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count.'</a>'
+                $link = '/message/discussion.php?id='.$user->id;
+                $anchortagcontents = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="" />&nbsp;'.$user->count;
+                
+                $action = new popup_action('click', $link, 'message_'.$user->id);
+                $anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
+
+                $this->content->text .= '<div class="message">'.$anchortag.'</div></li>';
             }
             $this->content->text .= '</ul>';
         } else {
Index: moodle/blocks/online_users/block_online_users.php
--- moodle/blocks/online_users/block_online_users.php Base (1.74)
+++ moodle/blocks/online_users/block_online_users.php Locally Modified (Based On 1.74)
@@ -155,8 +155,14 @@
                     $this->content->text .= $user->fullname.'</a></div>';
                 }
                 if ($canshowicon and ($USER->id != $user->id) and  $user->username != 'guest') {  // Only when logged in and messaging active etc
-                    $this->content->text .= '<div class="message"><a title="'.get_string('messageselectadd').'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\';return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'
-                        .'<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" /></a></div>';
+                    //<a title="'.get_string('messageselectadd').'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\';return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">
+                    $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);
+                    $anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>get_string('messageselectadd')));
+
+                    $this->content->text .= '<div class="message">'.$anchortag.'</div>';
                 }
                 $this->content->text .= "</li>\n";
             }
Index: moodle/filter/algebra/filter.php
--- moodle/filter/algebra/filter.php Base (1.29)
+++ moodle/filter/algebra/filter.php Locally Modified (Based On 1.29)
@@ -61,23 +61,23 @@
   }
   $style .= '"';
   if ($imagefile) {
-    if (!file_exists("$CFG->dataroot/filter/algebra/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
-      $output .= "<a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">";
+    $anchorcontents .= "<img $title alt=\"".s($origtex)."\" src=\"";
+    if ($CFG->slasharguments) {        // Use this method if possible for better caching
+      $anchorcontents .= "$CFG->wwwroot/filter/algebra/pix.php/$imagefile";
     } else {
-      $output .= "<a target=\"popup\" title=\"TeX\" href=";
-      $output .= "\"$CFG->wwwroot/filter/algebra/displaytex.php?";
-      $output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/algebra/displaytex.php?";
-      $output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,";
-      $output .= "resizable,width=300,height=240', 0);\">";
+      $anchorcontents .= "$CFG->wwwroot/filter/algebra/pix.php?file=$imagefile";
     }
-    $output .= "<img $title alt=\"".s($origtex)."\" src=\"";
-    if ($CFG->slasharguments) {        // Use this method if possible for better caching
-      $output .= "$CFG->wwwroot/filter/algebra/pix.php/$imagefile";
+    $anchorcontents .= "\" $style />";
+
+    $link = $action = null;
+    if (!file_exists("$CFG->dataroot/filter/algebra/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+        $link = '/filter/algebra/algebradebug.php';
     } else {
-      $output .= "$CFG->wwwroot/filter/algebra/pix.php?file=$imagefile";
+        $link = '/filter/algebra/displaytex.php?'.urlencode($tex);
+        $action = new popup_action('click', $link, 'popup', array('height'=>300,'width'=>240));
     }
-    $output .= "\" $style />";
-    $output .= "</a>";
+    $output .= $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>'TeX'));
+    
   } else {
     $output .= "Error: must pass URL or course";
   }
Index: moodle/filter/tex/filter.php
--- moodle/filter/tex/filter.php Base (1.32)
+++ moodle/filter/tex/filter.php Locally Modified (Based On 1.32)
@@ -78,23 +78,22 @@
     // Build the output.
     $output = "";
     if ($imagefile) {
-        if (!file_exists("$CFG->dataroot/filter/tex/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
-          $output .= "<a href=\"$CFG->wwwroot/filter/tex/texdebug.php\">";
+        $anchorcontents = "<img class=\"texrender\" $title alt=\"$alt\" src=\"";
+        if ($CFG->slasharguments) {        // Use this method if possible for better caching
+            $anchorcontents .= "$CFG->wwwroot/filter/tex/pix.php/$imagefile";
         } else {
-          $output .= "<a target=\"popup\" title=\"TeX\" href=";
-          $output .= "\"$CFG->wwwroot/filter/tex/displaytex.php?";
-          $output .= urlencode($tex) . "\" onclick=\"return openpopup('/filter/tex/displaytex.php?";
-          $output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,";
-          $output .= "resizable,width=300,height=240', 0);\">";
+            $anchorcontents .= "$CFG->wwwroot/filter/tex/pix.php?file=$imagefile";
         }
-        $output .= "<img class=\"texrender\" $title alt=\"$alt\" src=\"";
-        if ($CFG->slasharguments) {        // Use this method if possible for better caching
-            $output .= "$CFG->wwwroot/filter/tex/pix.php/$imagefile";
+        $anchorcontents .= "\" $style/>";
+
+        $link = $action = null;
+        if (!file_exists("$CFG->dataroot/filter/tex/$imagefile") && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+            $link = '/filter/tex/texdebug.php';
         } else {
-            $output .= "$CFG->wwwroot/filter/tex/pix.php?file=$imagefile";
+            $link = '/filter/tex/displaytex.php?'.urlencode($tex);
+            $action = new popup_action('click', $link, 'popup', array('height'=>300,'width'=>240));
         }
-        $output .= "\" $style/>";
-        $output .= "</a>";
+        $output .= $OUTPUT->action_link($link, $anchortagcontents, $action, array('title'=>'TeX'));
     } else {
         $output .= "Error: must pass URL or course";
     }
Index: moodle/lib/form/choosecoursefile.php
--- moodle/lib/form/choosecoursefile.php Base (1.6)
+++ moodle/lib/form/choosecoursefile.php Locally Modified (Based On 1.6)
@@ -83,18 +83,21 @@
         $choose = 'id_'.str_replace(array('[', ']'), array('_', ''), $this->getElementName(0));
         $url="/files/index.php?id=$courseid&choose=".$choose;
 
-        if ($this->_options['options'] == 'none') {
-            $options = 'menubar=0,location=0,scrollbars,resizable,width='. $this->_options['width'] .',height='. $this->_options['height'];
-        }else{
-            $options = $this->_options['options'];
-        }
         $fullscreen = 0;
 
-        $buttonattributes = array('title'=>get_string("chooseafile", "resource"),
-                  'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
+        $buttonattributes = array('title'=>get_string("chooseafile", "resource"));
 
         $button->updateAttributes($buttonattributes);
+
+        //attach the onclick event
+        if ($this->_options['options'] == 'none') {
+            $options = array('height'=>$this->_options['height'],'width'=>$this->_options['width']);
+        }else{
+            $options = $this->_options['options'];
     }
+        $action = new popup_action('click', $url, $button->getName(), $options);
+        $OUTPUT->add_action_handler($action, $button->id);
+    }
 
     /**
      * Output a timestamp. Give it the name of the group.
Index: moodle/lib/form/choosecoursefileorimsrepo.php
--- moodle/lib/form/choosecoursefileorimsrepo.php Base (1.5)
+++ moodle/lib/form/choosecoursefileorimsrepo.php Locally Modified (Based On 1.5)
@@ -88,19 +88,25 @@
         }
         $fullscreen = 0;
 
-        $buttonattributes = array('title'=>get_string("chooseafile", "resource"),
-                  'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
+        $buttonattributes = array('title'=>get_string("chooseafile", "resource"));
 
         $button->updateAttributes($buttonattributes);
 
+        //attach the onclick event
+        $action = new popup_action('click', $url, $button->getName(), $options);
+        $OUTPUT->add_action_handler($action, $button->id);
+
         /// With repository active, show the button to browse it
         if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
             $this->_elements[2] =& MoodleQuickForm::createElement('button', 'imsrepo', get_string('browserepository', 'resource'));
             $imsbutton =& $this->_elements[2];
             $url = "/mod/resource/type/ims/finder.php?directory=&choose=".$choose;
-            $buttonattributes = array('title'=>get_string("browserepository", "resource"),
-                  'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', $fullscreen);");
+            $buttonattributes = array('title'=>get_string("browserepository", "resource"));
             $imsbutton->updateAttributes($buttonattributes);
+
+            //attach the onclick event
+            //$action = new popup_action('click', $url, $button->getName(), $options);
+            $OUTPUT->add_action_handler($action, $imsbutton->id);
         }
     }
     /**
Index: moodle/message/refresh.php
--- moodle/message/refresh.php Base (1.29)
+++ moodle/message/refresh.php Locally Modified (Based On 1.29)
@@ -27,6 +27,7 @@
 define('MESSAGE_DEFAULT_REFRESH', 5);
 
 require_login();
+echo('refresh.php');
 
 if (isguestuser()) {
     redirect($CFG->wwwroot);
Index: moodle/mod/chat/chatd.php
--- moodle/mod/chat/chatd.php Base (1.44)
+++ moodle/mod/chat/chatd.php Locally Modified (Based On 1.44)
@@ -278,11 +278,18 @@
             $userinfo = $this->sets_info[$usersessionid];
 
             $lastping = $timenow - $userinfo['chatuser']->lastmessageping;
-            $popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&amp;course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\'';
+            //$popuppar = '\'/user/view.php?id='.$userinfo['user']->id.'&amp;course='.$userinfo['courseid'].'\',\'user'.$userinfo['chatuser']->id.'\',\'\'';
             echo '<tr><td width="35">';
-            echo '<a target="_new" onclick="return openpopup('.$popuppar.');" href="'.$CFG->wwwroot.'/user/view.php?id='.$userinfo['chatuser']->id.'&amp;course='.$userinfo['courseid'].'">';
-            echo $OUTPUT->user_picture($userinfo['user'], array('courseid'=>$userinfo['courseid']));
-            echo "</a></td><td valign=\"center\">";
+
+            //echo '<a target="_new" onclick="return openpopup('.$popuppar.');" href="'.$CFG->wwwroot.'/user/view.php?id='.$userinfo['chatuser']->id.'&amp;course='.$userinfo['courseid'].'">';
+            $link = '/user/view.php?id='.$userinfo['user']->id.'&course='.$userinfo['courseid'];
+            $anchortagcontents = $OUTPUT->user_picture($userinfo['user'], array('courseid'=>$userinfo['courseid']));
+            
+            $action = new popup_action('click', $link, 'user'.$userinfo['chatuser']->id);
+            $anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
+
+            echo $anchortag;
+            echo "</td><td valign=\"center\">";
             echo "<p><font size=\"1\">";
             echo fullname($userinfo['user'])."<br />";
             echo "<font color=\"#888888\">$str->idle: ".format_time($lastping, $str)."</font> ";
Index: moodle/mod/data/preset.php
--- moodle/mod/data/preset.php Base (1.52)
+++ moodle/mod/data/preset.php Locally Modified (Based On 1.52)
@@ -360,11 +360,16 @@
 echo '<input type="hidden" name="d" value="'.$data->id.'" />';
 echo '<input type="hidden" name="action" value="importzip" />';
 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-echo '<input name="file" size="20" value="" id="fromfile" type="text" /><input name="coursefiles" value="'.$strchooseorupload.'" onclick="return openpopup('."'/files/index.php?id={$course->id}&amp;choose=uploadpreset.file', 'coursefiles', 'menubar=0,location=0,scrollbars,resizable,width=750,height=500', 0".');" type="button" />';
+echo '<input name="file" size="20" value="" id="fromfile" type="text" /><input name="coursefiles" value="'.$strchooseorupload.'" type="button" />';
 echo '<input type="submit" value="'.$strimport.'" />';
 echo '</fieldset></form>';
 echo '</td></tr>';
 
+//attach the onclick event to fromfile button
+$link = '/files/index.php?id={$course->id}&amp;choose=uploadpreset.file';
+$action = new popup_action('click', $link, 'coursefiles', array('height'=>750,'width'=>500));
+$OUTPUT->add_action_handler($action, 'fromfile');
+
 echo '<tr valign="top"><td><label>'.$strusestandard.'</label>';
 echo $OUTPUT->help_icon('usestandard', 'data');
 echo '</td><td>';
Index: moodle/mod/glossary/filter.php
--- moodle/mod/glossary/filter.php Base (1.39)
+++ moodle/mod/glossary/filter.php Locally Modified (Based On 1.39)
@@ -128,12 +128,15 @@
                     $encodedconcept = urlencode($concept->concept);
                     $title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
                 }
-                $href_tag_begin = '<a class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
+                $randid = html_writer::random_id($title);
+                $href_tag_begin = '<a id="'.$randid.'" class="glossary autolink glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
                                   'href="'.$CFG->wwwroot.'/mod/glossary/showentry.php?courseid='.$courseid.
-                                  '&amp;concept='.$encodedconcept.'" '.
-                                  'onclick="return openpopup(\'/mod/glossary/showentry.php?courseid='.$courseid.
-                                  '\&amp;concept='.$encodedconcept.'\', \'entry\', '.
-                                  '\'menubar=0,location=0,scrollbars,resizable,width=600,height=450\', 0);">';
+                                  '&amp;concept='.$encodedconcept.'" >';
+
+                //attach the onclick event
+                $link = '/mod/glossary/showentry.php?courseid='.$courseid.'\&amp;concept='.$encodedconcept;
+                $action = new popup_action('click', $link, 'entry', array('height'=>600,'width'=>450));
+                $OUTPUT->add_action_handler($action, $randid);
             }
 
 
Index: moodle/mod/glossary/formats/entrylist/entrylist_format.php
--- moodle/mod/glossary/formats/entrylist/entrylist_format.php Base (1.20)
+++ moodle/mod/glossary/formats/entrylist/entrylist_format.php Locally Modified (Based On 1.20)
@@ -1,7 +1,7 @@
 <?php
 
 function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $aliases=true) {
-    global $USER;
+    global $USER, $OUTPUT;
 
     $return = false;
 
@@ -11,9 +11,15 @@
     echo '<td class="entry">';
     if ($entry) {
         glossary_print_entry_approval($cm, $entry, $mode);
-        echo "<div class=\"concept\"><a href=\"showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary\" target=\"_blank\" onclick=\"return openpopup('/mod/glossary/showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">";
-        glossary_print_entry_concept($entry);
-        echo '</a></div> ';
+
+        //<a href=\"showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary\" target=\"_blank\" onclick=\"return openpopup('/mod/glossary/showentry.php?courseid=$course->id&amp;eid=$entry->id&amp;displayformat=dictionary', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">
+        $link = "/mod/glossary/showentry.php?courseid={$course->id}&eid={$entry->id}&displayformat=dictionary";
+        $anchortagcontents = glossary_print_entry_concept($entry);
+        
+        $action = new popup_action('click', $link, 'entry',array('title'=>'entry','width'=>600,'height'=>450));
+        $anchor = $OUTPUT->action_link($link, $anchortagcontents, $action);
+
+        echo "<div class=\"concept\">$anchor</div> ";
         echo '</td><td align="right" class="entrylowersection">';
         if ($printicons) {
             glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,'print');
Index: moodle/mod/glossary/lib.php
--- moodle/mod/glossary/lib.php Base (1.296)
+++ moodle/mod/glossary/lib.php Locally Modified (Based On 1.296)
@@ -1655,7 +1655,7 @@
  * @param string $sortorder
  */
 function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     $asc    = get_string("ascending","glossary");
     $desc   = get_string("descending","glossary");
Index: moodle/mod/glossary/sql.php
--- moodle/mod/glossary/sql.php Base (1.48)
+++ moodle/mod/glossary/sql.php Locally Modified (Based On 1.48)
@@ -149,10 +149,10 @@
 
             $searchcond = array();
             $alcond     = array();
-            $params     = array();
+            //$params     = array();
             $i = 0;
 
-            $concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition',"' '", "COALESCE(al.alial, '')");
+            $concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition',"' '", "COALESCE(al.alias, '')");
 
             $searchterms = explode(" ",$hook);
 
Index: moodle/mod/hotpot/mod_form.php
--- moodle/mod/hotpot/mod_form.php Base (1.13)
+++ moodle/mod/hotpot/mod_form.php Locally Modified (Based On 1.13)
@@ -102,12 +102,14 @@
         if ($choosefile_button) {
             $wdir = "'+getDir(this.form.reference.value)+'";
             $url="/files/index.php?id=$id&wdir=$wdir&choose=id_reference";
-            $options = 'menubar=0,location=0,scrollbars,resizable,width=750,height=500';
             $attributes = array(
-                'title'=>get_string('chooseafile', 'resource'),
-                'onclick'=>"return openpopup('$url', '".$choosefile_button->getName()."', '$options', 0);"
+                'title'=>get_string('chooseafile', 'resource')
             );
             $choosefile_button->updateAttributes($attributes);
+
+            //attach the onclick event
+            $action = new popup_action('click', $url, $choosefile_button->getName(), array('title'=>$choosefile_button->getName(),'width'=>750,'height'=>500));
+            $OUTPUT->add_action_handler($action, $choosefile_button->id);
         }
         $mform->setType('reference', PARAM_TEXT);
 
Index: moodle/search/documents/glossary_document.php
--- moodle/search/documents/glossary_document.php Base (1.16)
+++ moodle/search/documents/glossary_document.php Locally Modified (Based On 1.16)
@@ -112,7 +112,9 @@
     // Suggestion : bounce on popup within the glossarie's showentry page
     // preserve glossary pop-up, be careful where you place your ' and "s
     //this function is meant to return a url that is placed between href='[url here]'
-    return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid={$entry_id}\", \"entry\", DEFAULT_POPUP_SETTINGS, 0);";
\ No newline at end of file
+    $jsondata = array('url'=>'/mod/glossary/showentry.php?eid='.$entry_id,'name'=>'entry','options'=>DEFAULT_POPUP_SETTINGS);
+    $jsondata = json_encode($jsondata);
+    return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(null, $jsondata);";
\ No newline at end of file
 } 
 
 /**
Index: moodle/user/view.php
--- moodle/user/view.php Base (1.235)
+++ moodle/user/view.php Locally Modified (Based On 1.235)
@@ -525,18 +525,31 @@
         } else {
             $messagebuttonname = get_string("messages", "message");
         }
+        $messagebuttonid = html_writer::random_id($messagebuttonname);
         echo "<form onclick=\"this.target='message'\" action=\"../message/index.php\" method=\"get\">";
         echo "<div>";
-        echo "<input type=\"submit\" value=\"$messagebuttonname\" onclick=\"return openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
+        echo "<input type=\"submit\" id=\"$messagebuttonid\" value=\"$messagebuttonname\" />";
         echo "</div>";
         echo "</form>";
+
+        //attach the onclick event
+        $link = '/message/index.php';
+        $action = new popup_action('click', $link, 'message');
+        $OUTPUT->add_action_handler($action, $messagebuttonid);
     } else {
+        $sendmessage = get_string("sendmessage", "message");
+        $messagebuttonid = html_writer::random_id($sendmessage);
         echo "<form onclick=\"this.target='message$user->id'\" action=\"../message/discussion.php\" method=\"get\">";
         echo "<div>";
         echo "<input type=\"hidden\" name=\"id\" value=\"$user->id\" />";
-        echo "<input type=\"submit\" value=\"".get_string("sendmessage", "message")."\" onclick=\"return openpopup('/message/discussion.php?id=$user->id', 'message_$user->id', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
+        echo "<input type=\"submit\" id=\"$messagebuttonid\" value=\"".$sendmessage."\" />";
         echo "</div>";
         echo "</form>";
+
+        //attach the onclick event
+        $link = "/message/discussion.php?id={$user->id}";
+        $action = new popup_action('click', $link, 'message_'.$user->id);
+        $OUTPUT->add_action_handler($action, $messagebuttonid);
     }
 }
 
