public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
A post's creator can now view his post even if it's set to a group that
is not his own. A helpful message will be displayed when they view the
post to inform them.
vito (author)
Sun Nov 02 08:20:43 -0800 2008
commit  1f9bb11a28799baa28aeaddab88550c066da1918
tree    7992e77704a1594977821fb2bd55dae61901159d
parent  3db2031326534389c121e17525740d0844a5a590
...
386
387
388
 
 
 
389
390
391
...
386
387
388
389
390
391
392
393
394
0
@@ -386,6 +386,9 @@
0
             if ($post->status == "draft")
0
                 Flash::message(__("This post is a draft."));
0
 
0
+            if ($post->groups() and !substr_count($post->status, "{".Visitor::current()->group->id."}"))
0
+                Flash::message(_f("This post is only visible by the following groups: %s.", $post->groups()));
0
+
0
             $this->display(array("pages/view", "pages/index"),
0
                            array("post" => $post, "posts" => array($post)),
0
                            $post->title());
...
721
722
723
724
 
725
726
727
...
744
745
746
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747
...
721
722
723
 
724
725
726
727
...
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
0
@@ -721,7 +721,7 @@
0
             if ($visitor->group->can("view_private"))
0
                 $statuses[] = "private";
0
 
0
-            return "posts.status IN ('".implode("', '", $statuses)."') OR posts.status LIKE '%{".$visitor->group->id."}%'";
0
+            return "posts.status IN ('".implode("', '", $statuses)."') XOR (posts.status LIKE '%{".$visitor->group->id."}%' OR posts.user_id = ".$visitor->id.")";
0
         }
0
 
0
         /**
0
@@ -744,4 +744,25 @@
0
 
0
             return new User($this->user_id);
0
         }
0
+
0
+        /**
0
+         * Function: groups
0
+         * Lists the groups who can view the post if the post's status is specific to certain groups.
0
+         */
0
+        public function groups() {
0
+            if ($this->no_results)
0
+                return false;
0
+
0
+            preg_match_all("/\{([0-9]+)\}/", $this->status, $groups, PREG_PATTERN_ORDER);
0
+            if (empty($groups[1]))
0
+                return false;
0
+
0
+            $names = array();
0
+            foreach ($groups[1] as $group_id) {
0
+                $group = new Group($group_id);
0
+                $names[] = $group->name;
0
+            }
0
+
0
+            return list_notate($names);
0
+        }
0
     }

Comments