Wikka Mod 031

Type: Feature Addition

Credit:

NickK -- Credit for the idea. http://wakka.netdome.biz/WakkaChangelog
Jason Tourtelotte -- Credit for the coding.


Don't link to pages that the viewing user is not allowed to read in PageIndex and RecentChanges.

actions/pageindex.php
<?php

if ($pages = $this->LoadAllPages())
{
    foreach ($pages as $page)
    {
        if (!preg_match("/^Comment/", $page["tag"])) {
            $firstChar = strtoupper($page["tag"][0]);
            if (!preg_match("/[A-Z,a-z]/", $firstChar)) {
                $firstChar = "#";
            }

            if ($firstChar != $curChar) {
                if ($curChar) print("<br />\n");
                print("<strong>$firstChar</strong><br />\n");
                $curChar = $firstChar;
            }

            if ($this->HasAccess("read", $page["tag"])) {
                print($this->Link($page["tag"]));
                }
            else {
                print($page["tag"]);
            }
            if ($page['owner'] != '')
                {                      
                if ($this->UserName() == $page['owner'])
                    print(" . . . . one of your pages.");
                    else {
                    if ($this->HasAccess("read", $page["owner"])) {
                            print(" . . . . Owner: ".$this->Format($page['owner']));
                        }
                    else {
                        print(" . . . . Owner: ".$page['owner']);
                    }
                }
                }

                print("<br />\n"); 
        }
    }
}
else
{
    print("<em>No pages found.</em>");
}

?>


actions/recentchanges.php
<?php
if ($pages = $this->LoadRecentlyChanged())
{
    print("<p><a href=\"".$this->href("", "xml/recentchanges_".preg_replace("/[^a-zA-Z0-9]/", "", strtolower($this->GetConfigValue("wakka_name"))).".xml")."\"><img src=\"".$this->href("", "images/xml.png")."\" width=\"36\" height=\"14\" alt=\"XML\" /></a></p>\n");
    if ($user = $this->GetUser())
    {
        $max = $user["changescount"];
    }
    else
    {
        $max = 50;
    }

    foreach ($pages as $i => $page)
    {
        if (($i < $max) || !$max)
        {
            // day header
            list($day, $time) = explode(" ", $page["time"]);
            if ($day != $curday)
            {
                if ($curday) print("</p>\n");
                print("<p><strong>$day:</strong><br /></p>\n<p class=\"recentchanges\">");
                $curday = $day;
            }

            // print entry
            if ($page[note]) $note=" <span class=\"pagenote\">[".$page["note"]."]</span>"; else $note ="";
            if ($this->HasAccess("read", $page["tag"])) {
                if ($this->HasAccess("read", $page["user"])) {
                    print("(".$page["time"].")(".$this->Link($page["tag"], "revisions", "history", 0).")  ".$this->Link($page["tag"], "", "", 0)."&rArr;".$this->Format($page["user"])." ".$note."<br />");
                }
                else {
                    print("(".$page["time"].")(".$this->Link($page["tag"], "revisions", "history", 0).")  ".$this->Link($page["tag"], "", "", 0)."&rArr;".$page["user"]." ".$note."<br />");
                }  
        } else {
                if ($this->HasAccess("read", $page["user"])) {
                    print("(".$page["time"].")(history) ".$page["tag"]."&rArr;".$this->Format($page["user"])." ".$note."<br />");
                }
                else {
                    print("(".$page["time"].")(history) ".$page["tag"]."&rArr;".$page["user"]." ".$note."<br />");
                }              
            }
        }
    }
    print "</p>\n";
}
?>
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki