UserPages Action

See also:
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 user="UserName"}} in the page body.

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 specified either via a user action parameter or via a user GET variable.

Save the code below as actions/userpages.php.

The action

Current version: 0.4


To do:


 * Display an alphabetical list of pages owned by a user.
 * This action can be used to display a list of pages owned by a specific user. It
 * accepts a user value both as an action parameter and as a GET parameter. The
 * specified user must be an existing user. If no user parameter is specified
 * or the specified user is invalid, an error message is printed. If no user parameter
 * is specified or the specified user is invalid, and the current user is logged in,
 * the action will display a list of pages owned by the current user.
 * @package     Actions
 * @name        Userpages
 * @author      {@link Carlo Zottmann} (original code)
 * @author      {@link Dario Taraborelli} (modified action)
 * @version     0.4
 * @since       Wikka 1.1.X.X
 * @output      list of pages owned by the specified user
 * @input       string  $user  optional: a valid user name;
 *              default: current user, if user is logged in;
 *              the default can be overridden by providing a URL parameter 'user';
 * @todo
 *              - (Optionally) create a config option allowing admins to decide whether users can
 *              display pages owned by other users;

$owner =''; #initializing variable

switch(true) {
    case (isset($_GET['user']) && $this->LoadUser($_GET['user'])): # a valid user is specified as an URL parameter
    $owner = $_GET['user'];

    case (isset($user) && $this->LoadUser($user)): # a valid user parameter is used
    $owner = $user;

    case ($this->GetUser()):
    $owner = $this->GetUserName();

if (strlen($owner) == 0) {
        print("<em>Sorry, no valid user is specified</em>");
} else {

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

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