UserPages Action


See also:
AdminModules
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

Changes:

To do:



<?php

/**
 * 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 http://web.archive.org/web/20040616194824/http://www.wakkawiki.com/CarloZottmann Carlo Zottmann} (original code)
 * @author      {@link http://wikka.jsnx.com/DarTar 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'];
    break;

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

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

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");
                $user_pages_count++;
            }
        }
        if ($user_pages_count == 0) {
                print("<em>User doesn't own any pages.</em>");
        }
    } else {
        print("<em>No pages found.</em>");
    }
}
?>



CategoryDevelopmentActions CategoryDevelopmentAdmin
Comments
Comment by GmBowen
2004-12-06 04:03:14
Hiya DarTar. I've developed some code that can be copied as a block into the textsearch.php file and will provide a list of owned pages if a search is done using a username.....see my personal page for the code. I think your action is pretty useful...I'm going to put it as part of my developing site....so that students working together on one project can "lump" all the pages they own together into one spot. I think the code I developed complements yours. Cheers,
Comment by DarTar
2004-12-06 08:18:39
Mike, I'll have a look at your code, thanks for the hint.
Comment by GeorgePetsagourakis
2004-12-19 22:37:13
There is another action i have put up that you might be interested in ... it is called DescribeUsers. basically it does the same thing in essence but gives a lot more info on every user ..
Comment by MasinAlDujaili
2006-05-29 12:57:45
How about multi-col output as in category action? Or a more general page filter action that checks for
* category
* owner
* recently changed
and so on?
Comment by DarTar
2006-05-29 15:42:10
Masin, I'd like to implement a general-purpose action with a number of filters like: http://wush.net/trac/wikka/ticket/143
More flexibility and less actions.
Comment by DevNet
2006-07-19 09:41:48
Was this action removed for 1.1.6.2? I'm getting an error on this when calling a specific user....
Comment by WazoO
2006-07-20 16:57:20
Actually, this was not 'included' with 1.1.6.2 .. it is still a function that must be "added" to your existing install ....
Comment by HansEric
2007-09-26 02:11:14
I would like some changes made to this action.
I would like to be able to specify the owner and the category to be listed.
Comment by DarTar
2007-09-27 05:30:43
The more I look at a few suggestions that have been made recently (including http://wikkawiki.org/RegexpindexActionInfo), the more I think we would need a flexible action to query the DB for pages matching specific criteria.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki