]> git.mjollnir.org Git - moodle.git/commitdiff
blocks editing ui: MDL-19398 give users a path back after assigning block roles
authortjhunt <tjhunt>
Wed, 15 Jul 2009 06:33:13 +0000 (06:33 +0000)
committertjhunt <tjhunt>
Wed, 15 Jul 2009 06:33:13 +0000 (06:33 +0000)
admin/roles/assign.php
admin/roles/check.php
admin/roles/override.php
admin/roles/tabs.php
lang/en_utf8/moodle.php
lib/blocklib.php

index 54625a2619020b2d6e6e2289a10e6bbb88e3a806..3025499cdad1516b5dd815d2036dca7a928da55a 100755 (executable)
@@ -42,6 +42,7 @@
     $hidden         = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
     $extendperiod   = optional_param('extendperiod', 0, PARAM_INT);
     $extendbase     = optional_param('extendbase', 3, PARAM_INT);
+    $returnurl      = optional_param('returnurl', null, PARAM_LOCALURL);
 
     $urlparams = array('contextid' => $contextid);
     if (!empty($userid)) {
@@ -50,6 +51,9 @@
     if ($courseid && $courseid != SITEID) {
         $urlparams['courseid'] = $courseid;
     }
+    if ($returnurl) {
+        $urlparams['returnurl'] = $returnurl;
+    }
     $PAGE->set_url($CFG->admin . '/roles/assign.php', $urlparams);
     $baseurl = $PAGE->url->out();
 
         if (!$isfrontpage && ($url = get_context_url($context))) {
             echo '<div class="backlink"><a href="' . $url . '">' .
                 get_string('backto', '', $contextname) . '</a></div>';
+        } else if ($returnurl) {
+            echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
+                get_string('backtopageyouwereon') . '</a></div>';
         }
     }
 
-    if ($context->contextlevel == CONTEXT_SYSTEM || $isfrontpage) {
-        admin_externalpage_print_footer();
-    } else {
-        print_footer();
-    }
-?>
+    print_footer();
index 4153ae8db55ea87d8e5af5b359a4c5b792a333f6..ae6a14d742a6d66dd2b59f27624e27f2080e2adf 100755 (executable)
@@ -36,6 +36,7 @@
     $contextid = required_param('contextid',PARAM_INT);
     $userid = optional_param('userid', 0, PARAM_INT); // needed for user tabs
     $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
+    $returnurl      = optional_param('returnurl', null, PARAM_LOCALURL);
 
     $urlparams = array('contextid' => $contextid);
     if (!empty($userid)) {
@@ -44,6 +45,9 @@
     if ($courseid && $courseid != SITEID) {
         $urlparams['courseid'] = $courseid;
     }
+    if ($returnurl) {
+        $urlparams['returnurl'] = $returnurl;
+    }
     $PAGE->set_url($CFG->admin . '/roles/check.php', $urlparams);
 
     if (! $context = get_context_instance_by_id($contextid)) {
     if (!$isfrontpage && ($url = get_context_url($context))) {
         echo '<div class="backlink"><a href="' . $url . '">' .
             get_string('backto', '', $contextname) . '</a></div>';
+        } else if ($returnurl) {
+            echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
+                get_string('backtopageyouwereon') . '</a></div>';
     }
 
     print_footer();
index 85ce08860cff80344e4f46a99d490a938f17ab6e..c8cf6ee85bc52108f04a17fab3668e3663a121c7 100755 (executable)
@@ -37,6 +37,7 @@
     $roleid = optional_param('roleid', 0, PARAM_INT);   // requested role id
     $userid = optional_param('userid', 0, PARAM_INT);   // needed for user tabs
     $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
+    $returnurl      = optional_param('returnurl', null, PARAM_LOCALURL);
 
 /// Get the base URL for this and related pages into a convenient variable.
     $urlparams = array('contextid' => $contextid);
@@ -46,6 +47,9 @@
     if ($courseid && $courseid != SITEID) {
         $urlparams['courseid'] = $courseid;
     }
+    if ($returnurl) {
+        $urlparams['returnurl'] = $returnurl;
+    }
     $PAGE->set_url($CFG->admin . '/roles/override.php', $urlparams);
     $baseurl = $PAGE->url->out();
 
         if (!$isfrontpage && ($url = get_context_url($context))) {
             echo '<div class="backlink"><a href="' . $url . '">' .
                 get_string('backto', '', $contextname) . '</a></div>';
+        } else if ($returnurl) {
+            echo '<div class="backlink"><a href="' . $CFG->wwwroot . '/' . $returnurl . '">' .
+                get_string('backtopageyouwereon') . '</a></div>';
         }
     }
 
     print_footer();
-?>
\ No newline at end of file
index 0d106bb60b2c3674a0b94b6c0666d41016b8a858..569dac303eec49a9e0f074c2083bb234f13ae12b 100755 (executable)
@@ -169,6 +169,12 @@ $activetwo = array();
 
 if ($context->contextlevel != CONTEXT_SYSTEM) {    // Print tabs for anything except SYSTEM context
 
+    if (!empty($returnurl)) {
+        $returnurlparam = '&amp;returnurl=' . $returnurl;
+    } else {
+        $returnurlparam = '';
+    }
+
     if ($context->contextlevel == CONTEXT_MODULE) {  // Only show update button if module
         $toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
                         $context->instanceid.'&amp;return=true&amp;sesskey='.sesskey(), get_string('settings'));
@@ -176,20 +182,20 @@ if ($context->contextlevel != CONTEXT_SYSTEM) {    // Print tabs for anything ex
 
     if (!empty($assignableroles) || $currenttab=='assign') {
         $toprow[] = new tabobject('assign',
-                $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
+                $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.$returnurlparam,
                 get_string('localroles', 'role'), '', true);
     }
 
     if (!empty($overridableroles)) {
         $toprow[] = new tabobject('override',
-                $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
+                $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id.$returnurlparam,
                 get_string('overridepermissions', 'role'), '', true);
     }
 
     if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
             'moodle/role:override', 'moodle/role:assign'), $context)) {
         $toprow[] = new tabobject('check',
-                $CFG->wwwroot.'/'.$CFG->admin.'/roles/check.php?contextid='.$context->id,
+                $CFG->wwwroot.'/'.$CFG->admin.'/roles/check.php?contextid='.$context->id.$returnurlparam,
                 get_string('checkpermissions', 'role'));
     }
 
index 799660494e03804df379b051ff9d318a85a14ba8..0ddc7820ad30a5c1042b79f48baefa001d66d89c 100644 (file)
@@ -140,6 +140,7 @@ $string['backtoparticipants'] = 'Back to participants list';
 $string['back'] = 'Back';
 $string['backto'] = 'Back to $a';
 $string['backtocourselisting'] = 'Back to course listing';
+$string['backtopageyouwereon'] = 'Back to the page you were on';
 $string['backup'] = 'Backup';
 $string['backupactivehelp'] = 'Choose whether or not to do automated backups.';
 $string['backupcancelled'] = 'Backup Cancelled';
index 46baf109482f20e5e89d173716e6d441d11871a5..a6d9433d86b788007c7e1e927212247f8f047f59 100644 (file)
@@ -851,10 +851,12 @@ function block_edit_controls($block, $page) {
 
     $controls = array();
     $actionurl = $page->url->out_action();
+    $returnurlparam = '&amp;returnurl=' . urlencode($page->url->out_returnurl());
 
     // Assign roles icon.
     if (has_capability('moodle/role:assign', $block->context)) {
-        $controls[] = array('url' => $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$block->context->id,
+        $controls[] = array('url' => $CFG->wwwroot . '/' . $CFG->admin .
+                '/roles/assign.php?contextid=' . $block->context->id . $returnurlparam,
                 'icon' => 'i/roles', 'caption' => get_string('assignroles', 'role'));
     }
 
@@ -874,7 +876,7 @@ function block_edit_controls($block, $page) {
             if (!empty($block->instance->blockpositionid)) {
                 $editurl .= '&amp;positionid=' . $block->instance->blockpositionid;
             }
-            $controls[] = array('url' => $editurl . '&amp;returnurl=' . urlencode($page->url->out_returnurl()),
+            $controls[] = array('url' => $editurl . $returnurlparam,
                     'icon' => 't/edit', 'caption' => get_string('configuration'));
         }