]> git.mjollnir.org Git - moodle.git/commitdiff
various small changes
authortoyomoyo <toyomoyo>
Tue, 18 Apr 2006 01:59:13 +0000 (01:59 +0000)
committertoyomoyo <toyomoyo>
Tue, 18 Apr 2006 01:59:13 +0000 (01:59 +0000)
blog/edit.html
blog/edit.php
blog/header.php
blog/index.php
blog/lib.php

index d71a2dfe0bd96764b9c96d153308c987c072760a..6bc848742d35a8be94af7bf7613dfcd480cb4834 100755 (executable)
     </strong><br /><br />
     <small><small>
     <?php
-        helpbutton('reading', get_string('helpreading'), 'moodle', true, true);
-        echo '<br />';
         helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
         echo '<br />';
-        helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
-        echo '<br />';
         if ($usehtmleditor) {
            helpbutton('richtext', get_string('helprichtext'), 'moodle', true, true);
         } else {
index 9f40803858145728f356598fa4ac969bae8f668a..00b3cffc4a7a09fdbf7c4a8e507930bcb0ec78dc 100755 (executable)
@@ -167,7 +167,7 @@ function do_delete($postid) {
     // check ownership
     $blogEntry = get_record('post','id',$postid);
 
-    if (blog_user_can_edit($blogEntry)) {
+    if (blog_user_can_edit_post($blogEntry)) {
         
         if (delete_records('post','id',$postid)) {
             //echo "bloginfo_arg:"; //debug
@@ -188,7 +188,7 @@ function do_delete($postid) {
 
     //comment out this redirect to debug the deletion of entries
 
-    redirect($CFG->wwwroot .'/blog/index.php?userid='. $post->userid);
+    redirect($CFG->wwwroot .'/blog/index.php?userid='. $blogEntry->userid);
 }
 
 /**
index dd2430630ffd36e245272f687df6621269ad8bdc..9b42f55c99ce5ce8d551273a02b02ada5cc44170 100755 (executable)
@@ -72,97 +72,123 @@ if (!isset($filtertype)) {
 /// course blogs - sitefullname -> course fullname ->blogs ->(?tag)
 /// group blogs - sitefullname -> course fullname ->group ->(?tag)
 /// user blogs - sitefullname -> (?coursefullname) -> participants -> blogs -> (?tag)
+
 $blogstring = get_string('blogs','blog');
 $tagstring = get_string('tag');
 
-switch ($filtertype) {
-    case 'site':
-        if ($tagid || !empty($tag)) {
-            print_header("$site->shortname: $blogstring", "$site->fullname",
-                        '<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
-        } else {
-            print_header("$site->shortname: $blogstring", "$site->fullname",
-                        "$blogstring",'','',true,$PAGE->get_extra_header_string());
-        }
-    break;
-
-    case 'course':
-        if ($tagid || !empty($tag)) {
-            print_header("$course->shortname: $blogstring", "$course->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$filterselect.'">'.$course->shortname.'</a> ->
-                        <a href="index.php?filtertype=course&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
-        } else {
-            print_header("$site->shortname: $blogstring", "$site->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$filterselect.'">'.$course->shortname."</a> ->
-                        $blogstring",'','',true,$PAGE->get_extra_header_string());
-        }
-    break;
+if ($ME == 'http://yu.moodle.com/dev/blog/edit.php') {  ///we are in edit mode, print editting header
 
-    case 'group':
+    // first we need to identify the user
+    if ($editid) {  // if we are editting a post
+        $blogEntry = get_record('post','id',$editid);
+        $user = get_record('user','id',$blogEntry->userid);
+    } else {
+        $user = get_record('user','id',$filterselect);
+    }
 
-        $thisgroup = get_record('groups', 'id', $filterselect);
+    if ($editid) {
+        $formHeading = get_string('updateentrywithid', 'blog');
+    } else {
+        $formHeading = get_string('addnewentry', 'blog');
+    }
+    
+    print_header("$site->shortname: $blogstring", "$site->fullname",
+                        '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
+                        <a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.$blogstring.'</a> -> '.               $formHeading,'','',true,$PAGE->get_extra_header_string());
 
-        if ($tagid || !empty($tag)) {
-            print_header("$course->shortname: $blogstring", "$course->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name.'</a> ->
-                        <a href="index.php?filtertype=group&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
-        } else {
-            print_header("$course->shortname: $blogstring", "$course->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name."</a> ->
-                        $blogstring",'','',true,$PAGE->get_extra_header_string());
+} else {  // else, we are in view mode
 
-        }
-    
-    break;
+/// This is very messy atm.
 
-    case 'user':
-        $user = get_record('user', 'id', $filterselect);
-        $participants = get_string('participants');
+    switch ($filtertype) {
+        case 'site':
+            if ($tagid || !empty($tag)) {
+                print_header("$site->shortname: $blogstring", "$site->fullname",
+                            '<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+            } else {
+                print_header("$site->shortname: $blogstring", "$site->fullname",
+                            "$blogstring",'','',true,$PAGE->get_extra_header_string());
+            }
+        break;
 
-        if (isset($course->id) && $course->id && $course->id != SITEID) {
+        case 'course':
             if ($tagid || !empty($tag)) {
                 print_header("$course->shortname: $blogstring", "$course->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
-                        <a href="index.php?courseid='.optional_param('courseid', 0, PARAM_INT).'&amp;filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$filterselect.'">'.$course->shortname.'</a> ->
+                            <a href="index.php?filtertype=course&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+            } else {
+                print_header("$site->shortname: $blogstring", "$site->fullname",
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$filterselect.'">'.$course->shortname."</a> ->
+                            $blogstring",'','',true,$PAGE->get_extra_header_string());
+            }
+        break;
+
+        case 'group':
 
+            $thisgroup = get_record('groups', 'id', $filterselect);
+
+            if ($tagid || !empty($tag)) {
+                print_header("$course->shortname: $blogstring", "$course->fullname",
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name.'</a> ->
+                            <a href="index.php?filtertype=group&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
             } else {
                 print_header("$course->shortname: $blogstring", "$course->fullname",
-                        '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
-                        <a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
-                        '.$blogstring,'','',true,$PAGE->get_extra_header_string());
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name."</a> ->
+                            $blogstring",'','',true,$PAGE->get_extra_header_string());
 
             }
 
-        }
-        //in top view
-        else {
+        break;
 
-            if ($tagid || !empty($tag)) {
-                print_header("$site->shortname: $blogstring", "$site->fullname",
-                        '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
-                        <a href="index.php?filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+        case 'user':
+            $user = get_record('user', 'id', $filterselect);
+            $participants = get_string('participants');
 
-            } else {
-                print_header("$site->shortname: $blogstring", "$site->fullname",
-                        '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
-                        '.$blogstring,'','',true,$PAGE->get_extra_header_string());
+            if (isset($course->id) && $course->id && $course->id != SITEID) {
+                if ($tagid || !empty($tag)) {
+                    print_header("$course->shortname: $blogstring", "$course->fullname",
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
+                            <a href="index.php?courseid='.optional_param('courseid', 0, PARAM_INT).'&amp;filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+
+                } else {
+                    print_header("$course->shortname: $blogstring", "$course->fullname",
+                            '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
+                            <a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
+                            '.$blogstring,'','',true,$PAGE->get_extra_header_string());
+                }
 
             }
-           
-        }
-    break;
+            //in top view
+            else {
 
-    default:    //user click on add from block
-        print_header("$site->shortname: $blogstring", "$site->fullname",
-                        '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&amp;course='.$course->id.'">'.fullname($user).'</a> ->
-                        '.$blogstring,'','',true,$PAGE->get_extra_header_string());
-    break;
-}
+                if ($tagid || !empty($tag)) {
+                    print_header("$site->shortname: $blogstring", "$site->fullname",
+                            '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
+                            <a href="index.php?filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
+
+                } else {
+                    print_header("$site->shortname: $blogstring", "$site->fullname",
+                            '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
+                            '.$blogstring,'','',true,$PAGE->get_extra_header_string());
+
+                }
+
+            }
+        break;
+
+        default:    //user click on add from block
+            print_header("$site->shortname: $blogstring", "$site->fullname",
+                            '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
+                            <a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.$blogstring.'</a> -> '.get_string('addentry','blog'),'','',true,$PAGE->get_extra_header_string());
+        break;
+    }
+
+} /// close switch
 
 $editing = false;
 if ($PAGE->user_allowed_editing()) {
index 7c5617d7241516946d45cd04ba727d652308aa4d..271da130a1c908a9501fca40bf1977c12baaecbb 100755 (executable)
@@ -118,11 +118,15 @@ switch ($filtertype) {
         if ($CFG->bloglevel < BLOG_USER_LEVEL) {
             error ('Blogs is not enabled');
         }
-
-        blog_user_can_view_user_post($filterselect);
+        
+        if ($CFG->bloglevel == BLOG_USER_LEVEL and $USER->id != $filterselect and !isadmin()) {
+            error ('Under this setting, you can only view your own blogs');
+        }
 
         /// check to see if the viewer is sharing no_group, visible group course.
         /// if not , check if the viewer is in any spg group as the user
+        blog_user_can_view_user_post($filterselect);
+
     break;
     default:
     break;
@@ -133,8 +137,6 @@ if ($limit == 'none') {
     $limit = get_user_preferences('blogpagesize',10);
 }
 
-//$blogFilter =& new BlogFilter($userid, $postid, $limit, $start,$filtertype, $filterselect, $tagid, $tag);
-
 include($CFG->dirroot .'/blog/header.php');
 
 //prints the tabs
index ef6376c29a76a2b7f281d9adc4b924cb356a0506..f8b8b9e798db2327e23f2fe599e52fce685ce2a3 100755 (executable)
 
         echo '</td><td class="content">'."\n";
 
+        switch ($template['publishstate']) {
+            case 'draft':
+                $blogtype = get_string('publishtonoone', 'blog');
+            break;
+            case 'site':
+                $blogtype = get_string('publishtosite', 'blog');
+            break;
+            case 'public':
+                $blogtype = get_string('publishtoworld', 'blog');
+            break;
+            default:
+            break;
+
+        } 
+
+        echo '<div class="">'.$blogtype.'</div>';  /// martin please fill in the class and css
+
         // Print whole message
         echo format_text($template['body']);