Revision [1982]

This is an old revision of UserChangesAction made by NilsLindenberg on 2004-10-25 18:16:24.

 

UserChanges Action


This is an upgraded version of the MyChanges action. It allows not only to display pages edited 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 MyChanges action into the UserAdmin tool.
To use it as a standalone action simply add {{userchanges}} in one of your pages.
 



Save the following code as actions/userchanges.php.

-- DarTar



actions/userchanges.php



<?php

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

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

if ($user)
{
    $user_edits_count = 0;

    if ($_GET["alpha"] == 1)
    {
        echo $this->Format("== Pages modified by [[".$user."]] == --- --- ");
        print("<strong>This is a list of pages edited by ".$this->Link($user).", along with the time of the last edit (<a
href=\""
.$page."?user=".$user."&date=1&action=changes\">order by date</a>).</strong><br /><br />\n");

        if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user =
'"
.mysql_real_escape_string($user)."' ORDER BY tag ASC, time DESC"))
        {
            foreach ($pages as $page)
            {
                if ($last_tag != $page["tag"]) {
                    $last_tag = $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;
                    }
   
                    // print entry
                    print("&nbsp;&nbsp;&nbsp;(".$page["time"].") (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");
   
                    $user_edits_count++;
                }
            }
           
            if ($user_edits_count == 0)
            {
                print("<em>User has not edited any pages yet.</em>");
            }
        }
        else
        {
            print("<em>No pages found.</em>");
        }
    }
    else
    {

                echo $this->Format("== Pages modified by [[".$user."]] == --- --- ");
                print("<strong>This is a list of pages edited by ".$this->Link($user).", ordered by the time of last edit (<a
href=\""
.$page."?user=".$user."&alpha=1&action=changes\">order alphabetically</a>).</strong><br /><br />\n");

        if ($pages = $this->LoadAll("SELECT tag, time FROM ".$this->config["table_prefix"]."pages WHERE user =
'"
.mysql_real_escape_string($user)."' ORDER BY time ASC, tag ASC"))
        {
            foreach ($pages as $page)
            {
                $edited_pages[$page["tag"]] = $page["time"];
            }

            $edited_pages = array_reverse($edited_pages);

            foreach ($edited_pages as $page["tag"] => $page["time"])
            {
                // day header
                list($day, $time) = explode(" ", $page["time"]);
                if ($day != $curday)
                {
                    if ($curday) print("<br />\n");
                    print("<strong>$day:</strong><br />\n");
                    $curday = $day;
                }

                // print entry
                print("&nbsp;&nbsp;&nbsp;($time) (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)."<br />\n");

                $user_edits_count++;
            }
           
            if ($user_edits_count == 0)
            {
                print("<em>User has not edited any pages yet.</em>");
            }
        }
        else
        {
            print("<em>No pages found.</em>");
        }
    }
}
else
{
    print("<em>No user specified</em>");
}

?>




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