]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16267 done all items in list (html tidy, xhtml strict, plugins tidy)
authorlfrodrigues <lfrodrigues>
Fri, 29 Aug 2008 23:19:54 +0000 (23:19 +0000)
committerlfrodrigues <lfrodrigues>
Fri, 29 Aug 2008 23:19:54 +0000 (23:19 +0000)
lang/en_utf8/message.php
lang/en_utf8/messageprocessor_email.php [new file with mode: 0644]
lang/en_utf8/messageprocessor_jabber.php [new file with mode: 0644]
lang/en_utf8/messageprocessor_popup.php [new file with mode: 0644]
message/edit.php
message/edit_form.php [deleted file]
message/output/email/message_output_email.php
message/output/jabber/message_output_jabber.php
message/output/lib.php
message/output/popup/message_output_popup.php

index 2fcbb769d275d650dde79f7e5dbcb5fd7b4e8cc0..275ce4d33a64d56ae3abfc1fabb4466687fa1db9 100644 (file)
@@ -73,7 +73,7 @@ $string['guestnoeditmessage'] = 'Guest user can not edit messaging options';
 $string['guestnoeditmessageother'] = 'Guest user can not edit other user messaging options';
 $string['loggedin'] = 'Logged In: ';
 $string['loggedoff'] = 'Logged Off: ';
-$string['general_config'] = 'General Options';
+$string['private_config'] = 'Private Messaging Options';
 $string['providers_config'] = 'Message Sources';
 $string['processor_config'] = 'Destinations Configuration';
 $string['showmessagewindow'] = 'Popup window on new message';
diff --git a/lang/en_utf8/messageprocessor_email.php b/lang/en_utf8/messageprocessor_email.php
new file mode 100644 (file)
index 0000000..6fb3e1d
--- /dev/null
@@ -0,0 +1,3 @@
+<?PHP // $Id$ 
+$string['email'] = 'e-mail';
+?>
diff --git a/lang/en_utf8/messageprocessor_jabber.php b/lang/en_utf8/messageprocessor_jabber.php
new file mode 100644 (file)
index 0000000..84eb75b
--- /dev/null
@@ -0,0 +1,3 @@
+<?PHP // $Id$ 
+$string['jabber'] = 'Jabber Im';
+?>
diff --git a/lang/en_utf8/messageprocessor_popup.php b/lang/en_utf8/messageprocessor_popup.php
new file mode 100644 (file)
index 0000000..c2b27b7
--- /dev/null
@@ -0,0 +1,3 @@
+<?PHP // $Id$ 
+$string['popup'] = 'Html Im Window';
+?>
index 936c40b53189219ef0518cc5fef3a8736ff57cb5..ed57a42d09351fd8a280f58207c5beb943cf4d4a 100644 (file)
@@ -1,4 +1,4 @@
-<?php // $Id$
+<?php   // $Id$
 
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
@@ -32,9 +32,8 @@
  * @package
  */
 
-require_once('../config.php');
 
-require_once($CFG->dirroot.'/message/edit_form.php');
+require_once('../config.php');
 require_once($CFG->libdir.'/messagelib.php');
 
 
@@ -90,20 +89,65 @@ if ($user->id == $USER->id) {
     }
 }
 
+//save new preferences if data was submited
+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){
+        foreach (array('loggedin', 'loggedoff') as $state){
+            $linepref = '';
+            foreach ($form->{$provider->component.'_'.$provider->name.'_'.$state} as $process=>$one){                
+                if ($linepref == ''){ 
+                    $linepref = $process;
+                } else { 
+                    $linepref .= ','.$process;
+                }
+            }
+            $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{ 
+                error('Error calling defined processor');
+            }
+        }
+    }
+    /// Save all the new preferences to the database
+    if (!set_user_preferences( $preferences, $user->id ) ){
+        error('Error updating user message preferences');
+    }
+    
+    redirect("$CFG->wwwroot/message/edit.php?id=$user->id&course=$course->id");
+}
 
-//retrieve preferences from db
+//load preferences so show
 $preferences = new object();
-$preferences->id = $user->id;
 
 //get the message general preferences
 $preferences->showmessagewindow =  get_user_preferences( 'message_showmessagewindow', '', $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 all the known providers
+//get providers preferences
 $providers = message_get_my_providers();
-
 foreach ( $providers as $providerid => $provider){
     foreach (array('loggedin', 'loggedoff') as $state){
         $linepref = get_user_preferences('message_provider_'.$provider->component.'_'.$provider->name.'_'.$state, '', $user->id);
@@ -113,7 +157,7 @@ foreach ( $providers as $providerid => $provider){
         $lineprefarray = explode(',', $linepref);
         $preferences->{$provider->component.'_'.$provider->name.'_'.$state} = array();
         foreach ($lineprefarray as $pref){
-            $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$provider->component.'_'.$provider->name.'_'.$state.'_'.$pref] = 1;
+            $preferences->{$provider->component.'_'.$provider->name.'_'.$state}[$pref] = 1;
         }
     }
 }
@@ -134,65 +178,6 @@ foreach ( $processors as $processorid => $processor){
     }
 }
 
-
-//create form
-$userform = new user_edit_form();
-$userform->set_data($preferences);
-
-if ($messageconf = $userform->get_data()) {
-
-    add_to_log($course->id, 'message', 'update', "edit.php?id=$user->id&course=$course->id", '');
-
-    $preferences = array();
-
-/// Set the overall preferences
-    $preferences['message_showmessagewindow'] = $messageconf->showmessagewindow?1:0;
-    $preferences['message_blocknoncontacts']  = $messageconf->blocknoncontacts?1:0;
-    $preferences['message_beepnewmessage']    = $messageconf->beepnewmessage?1:0;
-    $preferences['message_noframesjs']        = $messageconf->noframesjs?1:0;
-
-/// Set all the preferences for all the message providers
-    foreach ( $providers as $providerid => $provider){
-        foreach (array('loggedin', 'loggedoff') as $state){
-            $linepref = '';
-            foreach ($messageconf->{$provider->component.'_'.$provider->name.'_'.$state} as $process=>$one){
-                $parray = explode( '_', $process);
-                if ($linepref == ''){ 
-                    $linepref = $parray[2];
-                } else { 
-                    $linepref .= ','.$parray[2];
-                }
-            }
-            $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.'/lib.php';
-        if ( is_readable($processorfile) ) {
-            include_once( $processorfile );
-            
-            $processclass = 'message_output_' . $processor->name;                
-            if ( class_exists($processclass) ){                    
-                $pclass = new $processclass();
-                $pclass->process_form($messageconf, $preferences);                    
-            } else{ 
-                error('Error calling defined processor');
-            }
-        }
-    }
-
-/// Save all the new preferences to the database
-    if (!set_user_preferences( $preferences, $user->id ) ){
-        error('Error updating user message preferences');
-    }
-
-    redirect("$CFG->wwwroot/message/edit.php?id=$user->id&course=$course->id");
-}
-
-
 /// Display page header
 $streditmymessage = get_string('editmymessage', 'message');
 $strparticipants  = get_string('participants');
@@ -219,12 +204,68 @@ $showroles = 1;
 $currenttab = 'editmessage';
 require('../user/tabs.php');
 
-notify('WARNING: This interface is still under construction!');
+echo '<form method="post" action="'.$CFG->wwwroot.'/message/edit.php">';
+echo '<table width="80%" class="userinfobox">';
+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>';
+
+//output settings table
+echo '<table width="80%" class="userinfobox">';
+echo '<tr><td><h3>Message Sources</h3></td></tr>'."\n";
+$providers = message_get_my_providers();
+$processors = $DB->get_records('message_processors');
+$number_procs = count($processors);
+echo '<tr><td>'; echo '<table cellpadding="2"><tr><td>&nbsp;</td>'."\n";
+foreach ( $processors as $processorid => $processor){
+    echo '<td align="center" style="width:120px">'.get_string($processor->name, 'messageprocessor_'.$processor->name).'</td>';
+}
+echo '</tr>';
+foreach ( $providers as $providerid => $provider){
+    $providername = get_string('messageprovider:'.$provider->name, $provider->component);
+    echo '<tr><td align="right">'.$providername.'</td><td colspan="'.$number_procs.'"></td></tr>'."\n";
+    foreach (array('loggedin', 'loggedoff') as $state){
+        $state_res = get_string($state, 'message');
+        echo '<tr><td align="right">'.$state_res.'</td>'."\n";
+        foreach ( $processors as $processorid => $processor){
+            $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 '</td></tr></table>';
 
-/// Finally display THE form
-$userform->display();
+//
+echo '<table width="80%" class="userinfobox">';
+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');
+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->config_form($preferences); 
+        } else{ 
+            error('Error calling defined processor');
+        }
+    }
+}
+echo '</table>';
+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>';
+
+echo "</form>";
 
 /// and proper footer
 print_footer($course);
 
 ?>
+
diff --git a/message/edit_form.php b/message/edit_form.php
deleted file mode 100644 (file)
index c7b1034..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards  Martin Dougiamas  http://moodle.com       //
-//                                                                       //
-// This program 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 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program 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:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-/**
- * Edit user message form
- *
- * @author Luis Rodrigues
- * @version  $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package
- */
-
-require_once($CFG->dirroot.'/lib/formslib.php');
-
-class user_edit_form extends moodleform {
-
-    // Define the form
-    function definition () {
-        global $CFG, $COURSE, $DB;
-
-        $mform =& $this->_form;
-        $strrequired = get_string('required');
-
-        /// Add some extra hidden fields
-        $mform->addElement('hidden', 'id'); //the userid
-        $mform->addElement('hidden', 'course', $COURSE->id); //courseid
-
-        //get a listing of all the message processors
-        $processors = $DB->get_records('message_processors');
-
-        //create the general config section
-        $mform->addElement('header', 'general_config',  get_string('general_config', 'message') );
-        $mform->addElement('checkbox', 'showmessagewindow', get_string('showmessagewindow', 'message') );
-        $mform->addElement('checkbox', 'blocknoncontacts', get_string('blocknoncontacts', 'message') );
-        $mform->addElement('checkbox', 'beepnewmessage', get_string('beepnewmessage', 'message') );
-        $mform->addElement('checkbox', 'noframesjs', get_string('noframesjs', 'message') );
-
-
-        //create the providers config section
-        $mform->addElement('header', 'providers_config',  get_string('providers_config', 'message') );
-        $providers = message_get_my_providers();
-        foreach ( $providers as $providerid => $provider){
-
-            $providername = get_string('messageprovider:'.$provider->name, $provider->component);
-
-            $mform->addElement('static', 'label'.$provider->component, $providername, '');
-
-            $test = array();
-            foreach ( $processors as $processorid => $processor){
-                $test[] = &$mform->createElement('checkbox', $provider->component.'_loggedin_'.$processor->name, $processor->name, $processor->name);
-            }
-            $mform->addGroup($test, $provider->component.'_loggedin', get_string('loggedin', 'message'));
-
-            $test = array();
-            foreach ( $processors as $processorid => $processor){
-                $test[] = &$mform->createElement('checkbox', $provider->component.'_loggedoff_'.$processor->name, $processor->name, $processor->name);
-            }
-            $mform->addGroup($test, $provider->component.'_loggedoff', get_string('loggedoff', 'message'));
-        }
-
-        //create the processors config section (need to get config items from processor's lib.php
-        $mform->addElement('header', 'processors_config',  get_string('processor_config', 'message') );
-        foreach ( $processors as $processorid => $processor){
-            $processorfile = $CFG->dirroot. '/message/output/'.$processor->name.'/lib.php';
-            if ( is_readable($processorfile) ) {
-                include_once( $processorfile );
-                $processfunc = $processor->name .'_config_form';
-                if ( function_exists($processfunc) ){
-                    $processfunc($mform);
-                }
-            }
-        }
-
-        $this->add_action_buttons(false, get_string('updatemyprofile'));
-    }
-
-    function definition_after_data() {
-      return true;
-    }
-
-    function validation ($messageconf) {
-      return true;
-    }
-
-}
-
-?>
index 91abaa78ffd52246b06b6d3512245b3e7c54f31f..36e8ef3f55ed9767a68ccc90da1fc2ea0ea802d1 100644 (file)
@@ -82,11 +82,11 @@ class message_output_email extends message_output {
      * Creates necessary fields in the messaging config form.
      * @param object $mform preferences form class
      */
-    function config_form(&$mform){
-        $mform->addElement('static', 'email_labelemail', get_string('processortag', 'message').'Email ', '');
-        $mform->addElement('text', 'email_email', get_string('email'));
-        $mform->setAdvanced('email_labelemail');
-        $mform->setAdvanced('email_email');
+    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;
     }
 
     /**
@@ -94,7 +94,7 @@ class message_output_email extends message_output {
      * @param object $mform preferences form class
      * @param array $preferences preferences array 
      */
-    function process_form(&$form, &$preferences){
+    function process_form($form, &$preferences){
         $preferences['message_processor_email_email'] = $form->email_email;
     }
 
index 26f28412132b47d030faee56d04671fa50bd1327..442a47b50afb06cb22e6afba54ddfbd73fb0a123 100644 (file)
@@ -110,11 +110,11 @@ class message_output_jabber extends message_output {
      * Creates necessary fields in the messaging config form.
      * @param object $mform preferences form class
      */
-    function config_form(&$mform){
-        $mform->addElement('static', 'jabber_labeljabber', get_string('processortag', 'message').'Jabber ', '');
-        $mform->addElement('text', 'jabber_jabberid', 'jabber ID');
-        $mform->setAdvanced('jabber_labeljabber');
-        $mform->setAdvanced('jabber_jabberid');
+    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;
     }
 
     /**
@@ -122,7 +122,7 @@ class message_output_jabber extends message_output {
      * @param object $mform preferences form class
      * @param array $preferences preferences array 
      */
-    function process_form(&$form, &$preferences){
+    function process_form($form, &$preferences){
         $preferences['message_processor_jabber_jabberid'] = $form->jabber_jabberid;
     }
 
index 46d22168617bede724c007f35112945b97338240..7e390a6b72c32ede586553954178ccf31ab60a79 100644 (file)
@@ -37,7 +37,7 @@
  */
 abstract class message_output {        
     public abstract function send_message($message);
-    public abstract function process_form(&$form, &$preferences);
+    public abstract function process_form($form, &$preferences);
     public abstract function load_data(&$preferences, $userid);
 }
 
index e22f6a34d3c7553305f9a7bbd5ba246a244b67a8..cfa1c8ef8c3c67e56beac416abb4f6733ab60efd 100644 (file)
@@ -62,7 +62,11 @@ class message_output_popup extends message_output{
         return true;
     }
     
-    public function process_form(&$form, &$preferences){
+    function config_form($preferences){
+        return true;
+    }
+    
+    public function process_form($form, &$preferences){
         return true;
     }
     public function load_data(&$preferences, $userid){