Revision [4737]

This is an old revision of UserPagesAction made by NilsLindenberg on 2005-01-17 14:34:43.

 

UserPages Action


This is an upgraded version of the MyPages action. It allows not only to display pages owned by current user but also by any other registered user via a user GET variable

This action is meant as a module to integrate the MyPages action into the UserAdmin tool.
To use it as a standalone action simply add {{userpages}} in one of your pages.
 



Save the following code as actions/userpages.php.

-- DarTar



actions/userpages.php



<?php

// Shows pages owned by $_GET["user"] or, if this is not provided, by the current user.
// Adapted from actions/mypages.php written by Carlo Zottmann

$user = ($_GET["user"])? $_GET["user"] : $this->GetUserName();

if (!$user) {
        print("<em>No user specified</em>");
} else {

    echo $this->Format("== Pages owned by ".$user." == --- --- ");
    $user_pages_count = 0;
    if ($pages = $this->LoadAllPages()) {
        foreach ($pages as $page) {
            if ($user == $page["owner"]) {
                $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;
                }
                print($this->Link($page["tag"])."<br />\n");
                $user_pages_count++;
            }
        }
        if ($user_pages_count == 0) {
                print("<em>User doesn't own any pages.</em>");
        }
    } else {
        print("<em>No pages found.</em>");
    }
}
?>



CategoryDUserContributions
There are 9 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki