From 48e79fd1469ea87d49a1a4c409d819a01aab91dc Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Thu, 20 Apr 2006 02:14:17 +0000 Subject: [PATCH] some clean up --- blog/edit.php | 27 +++++++++++++-------------- blog/header.php | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 00b3cffc4a7..39983d1bffb 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -22,8 +22,6 @@ if (isguest()) { error(get_string('noguestpost', 'blog'), $referrer); } -$userid = optional_param('userid', 0, PARAM_INT); - // make sure that the person trying to edit have access right if ($editid = optional_param('editid', 0, PARAM_INT)) { @@ -32,19 +30,21 @@ if ($editid = optional_param('editid', 0, PARAM_INT)) { if (!blog_user_can_edit_post($blogEntry)) { error( get_string('notallowedtoedit', 'blog'), $CFG->wwwroot .'/login/index.php'); } - } //check to see if there is a requested blog to edit if (isloggedin() && !isguest()) { - //the user is logged in and have not specified a blog - so they will be editing their own - //$tempBlogInfo = blog_user_bloginfo(); - $userid = $USER->id; //$tempBlogInfo->userid; - //unset($tempBlogInfo); //free memory from temp object - bloginfo will be created again in the included header + $userid = $USER->id; } else { error(get_string('noblogspecified', 'blog') .'' .get_string('viewentries', 'blog') .''); } +// if we are trying to delete an non-existing blog entry +if (isset($act) && ($act == 'del') && (empty($blogEntry))) { + error ('the entry you are trying to delete does not exist'); +} + + $pageNavigation = 'edit'; include($CFG->dirroot .'/blog/header.php'); @@ -72,9 +72,10 @@ if (isset($act) && ($act == 'del') && confirm_sesskey()) echo ' '; echo ''; print_footer($course); - die; + exit; } } + if ($usehtmleditor = can_use_richtext_editor()) { $defaultformat = FORMAT_HTML; $onsubmit = ''; @@ -111,7 +112,7 @@ if (($post = data_submitted( get_referer() )) && confirm_sesskey()) { } -if ($editid != '') { // User is editing a post +if ($editid) { // User is editing a post // ensure that editing is allowed first - admin users can edit any posts $blogEntry = get_record('post','id',$editid); @@ -126,9 +127,7 @@ if ($editid != '') { // User is editing a post } if (isset($post->postid) && ($post->postid != -1) ) { - $formHeading = get_string('updateentrywithid', 'blog'); - } else { $formHeading = get_string('addnewentry', 'blog'); } @@ -178,7 +177,7 @@ function do_delete($postid) { //record a log message of this entry deletion if ($site = get_site()) { - add_to_log($site->id, 'blog', 'delete', 'index.php?userid='. $bloginfo_arg->userid, 'deleted blog entry with entry id# '. $postid); + add_to_log($site->id, 'blog', 'delete', 'index.php?userid='. $blogEntry->userid, 'deleted blog entry with entry id# '. $postid); } } } @@ -253,7 +252,7 @@ function do_save($post) { } //record a log message of this entry addition 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); + add_to_log($site->id, 'blog', 'add', 'index.php?userid='. $blogEntry->userid .'&postid='. $entryID, 'created new blog entry with entry id# '. $entryID); } redirect($referrer); @@ -316,7 +315,7 @@ function do_update($post) { //record a log message of this entry update action 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); + add_to_log($site->id, 'blog', 'update', 'index.php?userid='. $blogEntry->userid .'&postid='. $post->postid, 'updated existing blog entry with entry id# '. $post->postid); } redirect($referrer); diff --git a/blog/header.php b/blog/header.php index 9b42f55c99c..b0250c792f4 100755 --- a/blog/header.php +++ b/blog/header.php @@ -94,7 +94,7 @@ if ($ME == 'http://yu.moodle.com/dev/blog/edit.php') { ///we are in edit mode, print_header("$site->shortname: $blogstring", "$site->fullname", ''.fullname($user).' -> - '.$blogstring.' -> '. $formHeading,'','',true,$PAGE->get_extra_header_string()); + '.$blogstring.' -> '. $formHeading,'','',true); } else { // else, we are in view mode