Wiki source for Mod031fSmarterLinking


Show raw source

==== Wikka Mod 031 ====
Type: Feature Addition
----
===Credit:===
**[[http://web.archive.org/web/20040603201849/http://www.wakkawiki.com/NickK | NickK]]** -- Credit for the idea. http://wakka.netdome.biz/WakkaChangelog
**[[JsnX | 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)
<?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)
<?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)."⇒".$this->Format($page["user"])." ".$note."<br />");
}
else {
print("(".$page["time"].")(".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."⇒".$page["user"]." ".$note."<br />");
}
} else {
if ($this->HasAccess("read", $page["user"])) {
print("(".$page["time"].")(history) ".$page["tag"]."⇒".$this->Format($page["user"])." ".$note."<br />");
}
else {
print("(".$page["time"].")(history) ".$page["tag"]."⇒".$page["user"]." ".$note."<br />");
}
}
}
}
print "</p>\n";
}
?>
%%
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki