# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/blog/edit.php
--- moodle/blog/edit.php Base (1.87)
+++ moodle/blog/edit.php Locally Modified (Based On 1.87)
@@ -65,6 +65,16 @@
 
 require_login($courseid);
 
+/**
+ * Moodle.org hack.... BEWARE!
+ * This is to prevent people signing up and immediatly spamming blogs.
+ * Users must first enrol in at least one course before they can blog
+ * or register external blogs.
+ */
+if (!moodle_dot_org_user_can_blog()) {
+    print_error('You need to be an active member of the Moodle community to use this feature.');
+}
+
 if ($action == 'edit') {
     $id = required_param('entryid', PARAM_INT);
 }
Index: moodle/blog/external_blog_edit.php
--- moodle/blog/external_blog_edit.php Base (1.8)
+++ moodle/blog/external_blog_edit.php Locally Modified (Based On 1.8)
@@ -35,6 +35,16 @@
 $context = get_context_instance(CONTEXT_SYSTEM);
 require_capability('moodle/blog:manageexternal', $context);
 
+/**
+ * Moodle.org hack.... BEWARE!
+ * This is to prevent people signing up and immediatly spamming blogs.
+ * Users must first enrol in at least one course before they can blog
+ * or register external blogs.
+ */
+if (!moodle_dot_org_user_can_blog()) {
+    print_error('You need to be an active member of the Moodle community to use this feature.');
+}
+
 // TODO redirect if $CFG->useexternalblogs is off, $CFG->maxexternalblogsperuser == 0, or if user doesn't have caps to manage external blogs
 
 $id = optional_param('id', null, PARAM_INT);
Index: moodle/blog/lib.php
--- moodle/blog/lib.php Base (1.154)
+++ moodle/blog/lib.php Locally Modified (Based On 1.154)
@@ -364,6 +364,24 @@
 }
 
 /**
+ * Moodle.org hack.... BEWARE!
+ * This is to prevent people signing up and immediatly spamming blogs.
+ * Users must first enrol in at least one course before they can blog
+ * or register external blogs.
+ */
+function moodle_dot_org_user_can_blog() {
+    global $SESSION, $USER;
+    
+    if (!isset($SESSION->moodledotorgusercanblog) || 1==1) {
+        $courses = enrol_get_users_courses($USER->id);
+        $SESSION->moodledotorgusercanblog = (!empty($courses));
+    }
+    
+    return $SESSION->moodledotorgusercanblog;
+
+}
+
+/**
  * Get all of the blog options that relate to the passed user.
  *
  * If no user is passed the current user is assumed.
@@ -405,7 +423,7 @@
             'string' => get_string('viewuserentries', 'blog', fullname($user)),
             'link' => new moodle_url('/blog/index.php', array('userid'=>$user->id))
         );
-    } else {
+    } else if (moodle_dot_org_user_can_blog()) {
         // It's the current user
         if ($canview) {
             // We can view our own blogs .... BIG surprise
Index: moodle/lib/navigationlib.php
--- moodle/lib/navigationlib.php Base (1.209)
+++ moodle/lib/navigationlib.php Locally Modified (Based On 1.209)
@@ -3441,9 +3441,10 @@
 
         // Blogs
         if ($currentuser && !empty($CFG->bloglevel)) {
+            require_once($CFG->dirroot.'/blog/lib.php');
             $blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs');
             $blog->add(get_string('preferences', 'blog'), new moodle_url('/blog/preferences.php'), navigation_node::TYPE_SETTING);
-            if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', get_context_instance(CONTEXT_SYSTEM))) {
+            if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', get_context_instance(CONTEXT_SYSTEM)) && moodle_dot_org_user_can_blog()) {
                 $blog->add(get_string('externalblogs', 'blog'), new moodle_url('/blog/external_blogs.php'), navigation_node::TYPE_SETTING);
                 $blog->add(get_string('addnewexternalblog', 'blog'), new moodle_url('/blog/external_blog_edit.php'), navigation_node::TYPE_SETTING);
             }
