]> git.mjollnir.org Git - moodle.git/commitdiff
added cancel button to forms in login/ directory MDL-7778
authorskodak <skodak>
Tue, 5 Dec 2006 09:30:18 +0000 (09:30 +0000)
committerskodak <skodak>
Tue, 5 Dec 2006 09:30:18 +0000 (09:30 +0000)
login/change_password.php
login/change_password_form.php
login/forgot_password.php
login/forgot_password_form.php
login/signup.php
login/signup_form.php

index 8045551adc6be0906c5918b86b70225b9eb79381..cc4c7c25705e2c7fe6e28352d1bdfde7029e7d53 100644 (file)
@@ -31,7 +31,9 @@
     $mform = new change_password_form('change_password.php');
     $mform->set_defaults(array('id'=>$course->id, 'username'=>$USER->username));
 
-    if ($data = $mform->data_submitted()) {
+    if ($mform->is_cancelled()) {
+        redirect($CFG->wwwroot.'/user/view.php?id='.$USER->id.'&amp;course='.$course->id);
+    } else if ($data = $mform->data_submitted()) {
 
         if (!has_capability('moodle/user:update', $sitecontext)) {
             //ignore submitted username - the same is done in form validation
@@ -86,7 +88,7 @@
 
         print_header($strpasswordchanged, $strpasswordchanged, $navstr);
 
-        if (empty($SESSION->wantsurl)) {
+        if (empty($SESSION->wantsurl) or $SESSION->wantsurl == $CFG->httpswwwroot.'/login/change_password.php') {
             $returnto = "$CFG->wwwroot/user/view.php?id=$USER->id&amp;course=$id";
         } else {
             $returnto = $SESSION->wantsurl;
index 93c185ac309015edc9631bad408686443e8ce88e..0f9d6b3f0790a1db5cbb523bae1fecc1164e4cc1 100644 (file)
@@ -46,9 +46,15 @@ class change_password_form extends moodleform {
         $mform->setType('id', PARAM_INT);
 
         // buttons
-        $mform->addelement('submit', 'submitbutton', get_string('changepassword'));
-
-        $renderer->addStopFieldsetElements('submitbutton');
+        if (empty($USER->preference['auth_forcepasswordchange'])) {
+            $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
+            $buttonarray[] = &$mform->createElement('cancel');
+            $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+            $renderer->addStopFieldsetElements('buttonar');
+        } else {
+            $mform->addElement('submit', 'submitbutton', get_string('savechanges'));
+            $renderer->addStopFieldsetElements('submitbutton');
+        }
     }
 
 /// perform extra password change validation
index e1ba047bc79d58751573b4eb1d7f632871cc721e..aed470673538f87dae9d52fbc7867b5c77e6aac4 100644 (file)
@@ -58,6 +58,10 @@ if (!empty($CFG->changepassword)) {
 
 $mform = new forgot_password_form('forgot_password.php');
 
+if ($mform->is_cancelled()) {
+    redirect($CFG->httpswwwroot.'/login/index.php');
+}
+
 if ($action == 'find' and $param = $mform->data_submitted()) {
 ///=====================
 /// find the user in the database and mail info
index 5ad355296d14a100b56e375f0cce7091991a13e5..31038629cc2e56b296303e10d4ec763f1e9394dc 100644 (file)
@@ -21,9 +21,11 @@ class forgot_password_form extends moodleform {
         $mform->setType('action', PARAM_ALPHA);
 
         // buttons
-        $mform->addelement('submit', 'submitbutton', get_string('ok'));
+        $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('ok'));
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
 
-        $renderer->addStopFieldsetElements('submitbutton');
+        $renderer->addStopFieldsetElements('buttonar');
     }
 }
 
index 71dab6d594e9610905c4cf11d8296a7f98c3b7f4..2f0a1e9cc0767186620be2a38e512b03accd5388 100644 (file)
@@ -7,13 +7,15 @@
     //HTTPS is potentially required in this page
     httpsrequired();
 
-    $mform_signup = new login_signup_form('signup.php');
-
     if ($CFG->auth != 'email' and (empty($CFG->auth_user_create) or !(function_exists('auth_user_create'))) ) {
         error("Sorry, you may not use this page.");
     }
 
-    if ($user = $mform_signup->data_submitted()) {
+    $mform_signup = new login_signup_form('signup.php');
+
+    if ($mform_signup->is_cancelled()) {
+        redirect($CFG->httpswwwroot.'/login/index.php');
+    } else if ($user = $mform_signup->data_submitted()) {
 
         $plainpass = $user->password;
         $user->password    = hash_internal_user_password($plainpass);
index 0d6cc9711464a39c76e20a7311942eae9ffc3d1f..6e76e1bff82468633b554204a20217af894bcd55 100644 (file)
@@ -49,9 +49,12 @@ class login_signup_form extends moodleform {
                $mform->addRule('country', get_string('missingcountry'), 'required', null, 'client');
         $mform->setDefault('country', '');
 
-               $mform->addElement('submit', 'submitbutton', get_string('createaccount'));
+        // buttons
+        $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('createaccount'));
+        $buttonarray[] = &$mform->createElement('cancel');
+        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
 
-               $renderer->addStopFieldsetElements('submitbutton');
+        $renderer->addStopFieldsetElements('buttonar');
        }
 
        function definition_after_data(){