From: toyomoyo Date: Wed, 12 Apr 2006 03:02:53 +0000 (+0000) Subject: various small things X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9ffcd15f3aacb7f4ed30048eba885121ee1a0f9c;p=moodle.git various small things --- diff --git a/blog/edit.html b/blog/edit.html index 91f7479bb3..d71a2dfe0b 100755 --- a/blog/edit.html +++ b/blog/edit.html @@ -19,8 +19,8 @@
enctype="multipart/form-data"> - - + + diff --git a/blog/edit.php b/blog/edit.php index 4ac9568cf7..2ad0277e6a 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -9,10 +9,12 @@ $courseid = optional_param('courseid', SITEID, PARAM_INT); $act = optional_param('act','',PARAM_ALPHA); // detemine where the user is coming from in case we need to send them back there -if (isset($_SERVER['HTTP_REFERER'])) { - $referrer = $_SERVER['HTTP_REFERER']; -} else { - $referrer = $CFG->wwwroot; +if (!$referrer = optional_param('referrer','', PARAM_URL)) { + if (isset($_SERVER['HTTP_REFERER'])) { + $referrer = $_SERVER['HTTP_REFERER']; + } else { + $referrer = $CFG->wwwroot; + } } //first verify that user is not a guest @@ -166,7 +168,7 @@ include($CFG->dirroot .'/blog/footer.php'); * also takes the postid - the id of the entry to be removed */ function do_delete($postid) { - global $CFG, $USER; + global $CFG, $USER, $referrer; // make sure this user is authorized to delete this entry. // cannot use $post->pid because it may not have been initialized yet. Also the pid may be in get format rather than post. // check ownership @@ -192,6 +194,7 @@ function do_delete($postid) { } //comment out this redirect to debug the deletion of entries + redirect($CFG->wwwroot .'/blog/index.php?userid='. $post->userid); } @@ -202,7 +205,7 @@ function do_delete($postid) { * @param object $bloginfo_arg argument is reference to a blogInfo object. */ function do_save($post) { - global $USER, $CFG; + global $USER, $CFG, $referrer; // echo 'Debug: Post object in do_save function of edit.php
'; //debug // print_object($post); //debug @@ -259,12 +262,15 @@ function do_save($post) { if ($site = get_site()) { add_to_log($site->id, 'blog', 'add', 'archive.php?userid='. $bloginfo_arg->userid .'&postid='. $entryID, 'created new blog entry with entry id# '. $entryID); } + + redirect($referrer); + /* //to debug this save function comment out the following redirect code if ($courseid == SITEID || $courseid == 0 || $courseid == '') { redirect($CFG->wwwroot .'/blog/index.php?userid='. $blogEntry->userid); } else { redirect($CFG->wwwroot .'/course/view.php?id='. $courseid); - } + }*/ } } @@ -275,7 +281,7 @@ function do_save($post) { */ function do_update($post) { // here post = data_submitted(); - global $CFG, $USER; + global $CFG, $USER, $referrer; $blogEntry = get_record('post','id',$post->postid); // echo "id id ".$post->postid; // print_object($blogentry); //debug @@ -319,8 +325,15 @@ function do_update($post) { if ($site = get_site()) { add_to_log($site->id, 'blog', 'update', 'archive.php?userid='. $bloginfo->userid .'&postid='. $post->postid, 'updated existing blog entry with entry id# '. $post->postid); } - - redirect($CFG->wwwroot .'/blog/index.php?userid='. $blogEntry->userid); + + redirect($referrer); + //to debug this save function comment out the following redirect code +/* + if ($courseid == SITEID || $courseid == 0 || $courseid == '') { + redirect($CFG->wwwroot .'/blog/index.php?userid='. $blogEntry->userid); + } else { + redirect($CFG->wwwroot .'/course/view.php?id='. $courseid); + }*/ } else { // get_string('', 'blog') //Daryl Hawes note: localize this line $post->error = 'There was an error updating this post in the database: '. $error; diff --git a/blog/lib.php b/blog/lib.php index 0958167978..fc88074a01 100755 --- a/blog/lib.php +++ b/blog/lib.php @@ -200,8 +200,11 @@ $template['author'] = fullname(get_record('user','id',$blogEntry->userid)); $template['lastmod'] = userdate($blogEntry->lastmodified); $template['created'] = userdate($blogEntry->created); - $template['publishtomenu'] = get_publish_to_menu($blogEntry, true, true); - //forum style printing of blogs + + /// preventing user to browse blogs that they aren't supposed to see + if (!blog_user_can_view_user_post($template['userid'])) { + error ('you can not view this post'); + } blog_print_entry_content ($template, $blogEntry->id, $filtertype, $filterselect, $mode); } @@ -257,11 +260,11 @@ echo '
'; if (isset($USER->id)) { - if (($template['userid'] == $USER->id) or isteacher($course->id)) { + if (($template['userid'] == $USER->id) or isadmin()) { echo ''.$stredit.''; } - if (($template['userid'] == $USER->id) or isteacher($course->id)) { + if (($template['userid'] == $USER->id) or isadmin()) { echo '| '.$strdelete.''; } }