MDL-6805 Fix redirects in blog - edit button now properly redirects to self
authorskodak <skodak>
Tue, 3 Oct 2006 21:07:13 +0000 (21:07 +0000)
committerskodak <skodak>
Tue, 3 Oct 2006 21:07:13 +0000 (21:07 +0000)
blog/blogpage.php
blog/index.php
blog/set_session_vars.php [deleted file]

index 7801307..f6db6db 100644 (file)
@@ -170,9 +170,10 @@ class page_blog extends page_base {
             } else {
                 $editingString = get_string('turneditingon');
             }
-            $editformstring = '<form target="'. $CFG->framename .'" method="get" action="'. $CFG->wwwroot .'/blog/set_session_vars.php">'.
-                '<input type="hidden" name="referrer" value="'. me() .'" />'.
-                '<input type="hidden" name="var" value="showediting" />'.
+            $url = $this->url_get_full(); 
+            $editval = empty($SESSION->blog_editing_enabled) ? 1 : 0;
+            $editformstring = '<form target="'. $CFG->framename .'" method="get" action="'.$url.'/blog/index.php">'.
+                '<input type="hidden" name="edit" value="'.$editval.'" />'.
                 '<input type="submit" value="'. $editingString .'" /></form>';
         }
 
index e27f05d..ec3dec7 100755 (executable)
@@ -15,22 +15,34 @@ require_once('../config.php');
 require_once($CFG->dirroot .'/blog/lib.php');
 require_once($CFG->libdir .'/blocklib.php');
 
-$id = optional_param('id', 0, PARAM_INT);
-$limit = optional_param('limit', 0, PARAM_INT);
-$start = optional_param('formstart', 0, PARAM_INT);
-$userid = optional_param('userid',0,PARAM_INT);
-$courseid = optional_param('courseid',SITEID,PARAM_INT);
-$tag = optional_param('tag', '', PARAM_NOTAGS);
-$tagid = optional_param('tagid', 0, PARAM_INT);
-$postid = optional_param('postid',0,PARAM_INT);
-$filtertype = optional_param('filtertype', '', PARAM_ALPHA);
+$id           = optional_param('id', 0, PARAM_INT);
+$limit        = optional_param('limit', 0, PARAM_INT);
+$start        = optional_param('formstart', 0, PARAM_INT);
+$userid       = optional_param('userid',0,PARAM_INT);
+$courseid     = optional_param('courseid',SITEID,PARAM_INT);
+$tag          = optional_param('tag', '', PARAM_NOTAGS);
+$tagid        = optional_param('tagid', 0, PARAM_INT);
+$postid       = optional_param('postid',0,PARAM_INT);
+$filtertype   = optional_param('filtertype', '', PARAM_ALPHA);
 $filterselect = optional_param('filterselect', 0, PARAM_INT);
+$edit         = optional_param('edit', -1, PARAM_BOOL);
 
 if (empty($CFG->bloglevel)) {
     error('Blogging is disabled!');
 }
 
 
+// Blogs are only global for now.
+// 'post' table will have to be changed to use contextid instead of courseid,
+// modileid, etc. because they are obsolete now.
+$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+
+
+// change block edit staus if not guest and logged in
+if (isloggedin() and !isguest() and $edit != -1) {
+    $SESSION->blog_editing_enabled = $edit;
+}
+
 /// overwrite filter code here
 
 if ($filtertype) {
diff --git a/blog/set_session_vars.php b/blog/set_session_vars.php
deleted file mode 100644 (file)
index 1cad1ef..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/// inspired/taken from moodle calendar module's set.php file
-
-    require_once('../config.php');
-
-    if (empty($CFG->bloglevel)) {
-        error('Blogging is disabled!');
-    }
-
-    $referrer = required_param('referrer', PARAM_URL);
-
-    if (isset($SESSION->blog_editing_enabled)) {
-         $SESSION->blog_editing_enabled = !$SESSION->blog_editing_enabled;
-    } else {
-         $SESSION->blog_editing_enabled = true;
-    }
-
-    redirect($referrer);
-?>