Skip to content

Commit

Permalink
MDL-16267 and MDL-10107
Browse files Browse the repository at this point in the history
I did some further work tidying up the form.  I also just treat the popup like another plugin and moved all the config into the plugin.
This still needs help buttons everywhere now!
  • Loading branch information
moodler committed Sep 23, 2008
1 parent d583bff commit f3d095f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 43 deletions.
1 change: 1 addition & 0 deletions lang/en_utf8/messageprocessor_jabber.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?PHP // $Id$
$string['jabber'] = 'Jabber message';
$string['jabberid'] = 'Jabber ID';
?>
35 changes: 5 additions & 30 deletions message/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@
if ( ($form = data_submitted()) && confirm_sesskey()) {
$preferences = array();

/// Set the overall 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;

/// Set all the preferences for all the message providers
$providers = message_get_my_providers();
foreach ( $providers as $providerid => $provider){
Expand All @@ -114,6 +108,7 @@
$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){
Expand Down Expand Up @@ -141,11 +136,6 @@
//load preferences so show
$preferences = new object();

//get the message general preferences
$preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $user->id);
$preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $user->id);
$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $user->id);
$preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $user->id);
//get providers preferences
$providers = message_get_my_providers();
foreach ( $providers as $providerid => $provider){
Expand Down Expand Up @@ -204,22 +194,12 @@
$currenttab = 'editmessage';
require('../user/tabs.php');

echo '<form method="post" action="'.$CFG->wwwroot.'/message/edit.php">';

echo '<div class="generalbox">';
echo '<table>';
echo '<tr><td colspan="2"><h3>'.get_string('private_config', 'message').'</h3></td></tr>';
echo '<tr><td>'.get_string('showmessagewindow', 'message').'</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('blocknoncontacts', 'message').'</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('beepnewmessage', 'message').'</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('noframesjs', 'message').'</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>';
echo '</table>';
echo '</div>';
echo '<form class="mform" method="post" action="'.$CFG->wwwroot.'/message/edit.php">';

//output settings table
echo '<div class="generalbox">';
echo '<fieldset id="providers" class="clearfix">';
echo '<legend class="ftoggler">'.get_string('providers_config', 'message').'</legend>';
echo '<table>';
echo '<tr><td><h3>'.get_string('providers_config', 'message').'</h3></td></tr>'."\n";
$providers = message_get_my_providers();
$processors = $DB->get_records('message_processors');
$number_procs = count($processors);
Expand Down Expand Up @@ -254,11 +234,8 @@
}
echo '</table>';
echo '</td></tr></table>';
echo '</div>';
echo '</fieldset>';

echo '<div class="generalbox">';
echo '<table>';
echo '<tr><td colspan="2"><h3>'.get_string('processor_config', 'message').'</h3></td></tr>'."\n";
//get a listing of all the message processors
$processors = $DB->get_records('message_processors');

Expand All @@ -278,8 +255,6 @@
}
}
}
echo '</table>';
echo '</div>';

echo '<p><input type="hidden" name="sesskey" value="'.sesskey().'" /> </p>';
echo '<div style="text-align:center"><input name="submit" value="'. get_string('updatemyprofile') .'" type="submit" /></div>';
Expand Down
8 changes: 4 additions & 4 deletions message/output/email/message_output_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function send_message($message) {
* @param object $mform preferences form class
*/
function config_form($preferences){
$dest = get_string('email', 'messageprocessor_email');
echo '<tr><td colspan="2"><b>'.get_string('processortag', 'message').$dest.'</b></td></tr>'."\n";
echo '<tr><td align="right">'.get_string('email').'</td><td><input name="email_email" value="'.$preferences->email_email.'" /></td></tr>'."\n";
return true;
echo '<fieldset id="messageprocessor_email" class="clearfix">';
echo '<legend class="ftoggler">'.get_string('email', 'messageprocessor_email').'</legend>';
echo get_string('email').': <input name="email_email" value="'.$preferences->email_email.'" />';
echo '</fieldset>';
}

/**
Expand Down
8 changes: 4 additions & 4 deletions message/output/jabber/message_output_jabber.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ function send_message($message){
* @param object $mform preferences form class
*/
function config_form($preferences){
$dest = get_string('jabber', 'messageprocessor_jabber');
echo '<tr><td colspan="2"><b>'.get_string('processortag', 'message').$dest.'</b></td></tr>'."\n";
echo '<tr><td align="right">Jabber ID</td><td><input name="jabber_jabberid" value="'.$preferences->jabber_jabberid.'" /></td></tr>'."\n";
return true;
echo '<fieldset id="messageprocessor_email" class="clearfix">';
echo '<legend class="ftoggler">'.get_string('jabber', 'messageprocessor_jabber').'</legend>';
echo get_string('jabberid', 'messageprocessor_jabber').': <input name="jabber_jabberid" value="'.$preferences->jabber_jabberid.'" />';
echo '</fieldset>';
}

/**
Expand Down
1 change: 1 addition & 0 deletions message/output/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract class message_output {
public abstract function send_message($message);
public abstract function process_form($form, &$preferences);
public abstract function load_data(&$preferences, $userid);
public abstract function config_form($preferences);
}


Expand Down
26 changes: 21 additions & 5 deletions message/output/popup/message_output_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class message_output_popup extends message_output{
* @param object $message the message to be sent
* @return true if ok, false if error
*/
public function send_message($message){
public function send_message($message) {
global $DB;

//put the process record into db
Expand All @@ -62,14 +62,30 @@ public function send_message($message){
return true;
}

function config_form($preferences){
return true;
function config_form($preferences) {
echo '<fieldset id="messageprocessor_popup" class="clearfix">';
echo '<legend class="ftoggler">'.get_string('popup', 'messageprocessor_popup').'</legend>';
echo '<table>';
echo '<tr><td>'.get_string('showmessagewindow', 'message').'</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('blocknoncontacts', 'message').'</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('beepnewmessage', 'message').'</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>';
echo '<tr><td>'.get_string('noframesjs', 'message').'</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>';
echo '</table>';
echo '</fieldset>';
}

public function process_form($form, &$preferences){
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;
return true;
}
public function load_data(&$preferences, $userid){
public function load_data(&$preferences, $userid) {
$preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $user->id);
$preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $user->id);
$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $user->id);
$preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $user->id);
return true;
}
}
Expand Down
4 changes: 4 additions & 0 deletions theme/standard/styles_layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -2569,6 +2569,10 @@ body#message-send td.fixeditor {
text-align:center;
}

body#message-edit fieldset {
padding: 20px;
}

/***
*** Notes
***/
Expand Down

0 comments on commit f3d095f

Please sign in to comment.