Revision history for UserCommentsAction


Revision [19296]

Last edited on 2008-01-28 00:14:45 by JavaWoman [Modified links pointing to docs server]

No Differences

Revision [17223]

Edited on 2007-07-07 15:18:27 by JavaWoman [updated Carlo Zottmann link in **code**]
Additions:
* @author {@link http://web.archive.org/web/20040616194824/http://www.wakkawiki.com/CarloZottmann Carlo Zottmann} (original code)
print("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&alpha=1&action=comments")."\">order alphabetically</a>).<br /><br />\n");
Deletions:
* @author {@link http://www.wakkawiki.de/CarloZottmann Carlo Zottmann} (original code)
print("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&alpha=1&action=comments")."\">order alphabetically</a>).<br /><br />\n");


Revision [17032]

Edited on 2007-05-31 23:27:49 by DarTar [Reverted]
Additions:
case (isset($_GET['user']) && $this->LoadUser($_GET['user'])): # a valid user is specified as an URL parameter
$author = $_GET['user'];
break;
case (isset($user) && $this->LoadUser($user)): # a valid user parameter is used
$author = $user;
break;
case ($this->GetUser()):
$author = $this->GetUserName();
break;
}
$page = $this->GetPageTag();
if ($author)
{
$user_comments_count = 0;
if ($_GET["alpha"] == 1)
{
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", along with the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&date=1&action=comments")."\">order by date</a>).<br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY page_tag ASC, time DESC"))
{
foreach ($comments as $comment)
{
if ($last_tag != $comment["page_tag"]) {
$last_tag = $comment["page_tag"];
$firstChar = strtoupper($comment["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("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
else
{
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&alpha=1&action=comments")."\">order alphabetically</a>).<br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY time ASC, page_tag ASC"))
{
foreach ($comments as $comment)
{
$commented_pages[$comment["page_tag"]] = $comment["time"];
}
$commented_pages = array_reverse($commented_pages);
foreach ($commented_pages as $comment["page_tag"] => $comment["time"])
{
// day header
list($day, $time) = explode(" ", $comment["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print("   (".$time.") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
}
else
{
print("<em>No user specified</em>");
}
?>
%%
CategoryDevelopmentActions CategoryDevelopmentAdmin
Deletions:
case (isset($_GET['user'])


Revision [16831]

Edited on 2007-05-31 10:53:25 by RskQrs [Reverted]
Additions:
case (isset($_GET['user'])
Deletions:
case (isset($_GET['user']) && $this->LoadUser($_GET['user'])): # a valid user is specified as an URL parameter
$author = $_GET['user'];
break;
case (isset($user) && $this->LoadUser($user)): # a valid user parameter is used
$author = $user;
break;
case ($this->GetUser()):
$author = $this->GetUserName();
break;
}
$page = $this->GetPageTag();
if ($author)
{
$user_comments_count = 0;
if ($_GET["alpha"] == 1)
{
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", along with the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&date=1&action=comments")."\">order by date</a>).<br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY page_tag ASC, time DESC"))
{
foreach ($comments as $comment)
{
if ($last_tag != $comment["page_tag"]) {
$last_tag = $comment["page_tag"];
$firstChar = strtoupper($comment["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("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
else
{
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&alpha=1&action=comments")."\">order alphabetically</a>).<br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY time ASC, page_tag ASC"))
{
foreach ($comments as $comment)
{
$commented_pages[$comment["page_tag"]] = $comment["time"];
}
$commented_pages = array_reverse($commented_pages);
foreach ($commented_pages as $comment["page_tag"] => $comment["time"])
{
// day header
list($day, $time) = explode(" ", $comment["time"]);
if ($day != $curday)
{
if ($curday) print("<br />\n");
print("<strong>$day:</strong><br />\n");
$curday = $day;
}
// print entry
print("   (".$time.") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
}
else
{
print("<em>No user specified</em>");
}
?>
%%
CategoryDevelopmentActions CategoryDevelopmentAdmin


Revision [9772]

Edited on 2005-07-05 08:13:57 by DarTar [adding link]
Additions:
>>**See also:**
AdminModules
>><<This action is meant as a module for the **UserAdmin** tool.
Deletions:
<<This action is meant as a module for the **UserAdmin** tool.


Revision [8697]

Edited on 2005-05-29 12:26:28 by JavaWoman [new categories]
Additions:
CategoryDevelopmentActions CategoryDevelopmentAdmin
Deletions:
CategoryUserContributions


Revision [7346]

Edited on 2005-04-18 08:30:45 by DarTar [UserComments v.0.4]
Additions:
===== ""UserComments"" Action =====
{{lastedit}}

<<This action is meant as a module for the **UserAdmin** tool.
To use it as a standalone action simply add: ##""{{usercomments user="UserName"}}""## in the page body.<< ::c::


This action displays a list of pages commented by the current user or by any other registered user specified either via a ##user## action parameter of via a ##user## GET variable . If no user is specified and the current user is logged in it displays a list of comments by the current user.

Save the code below as ##actions/usercomments.php##.

=== The action ===
Current version: 0.4

Changes:
~-Added documentation header;
~-Initialized variables;
~-User is checked in the following order: GET parameter, action parameter, current user;

To do:
~-(Optionally) create a config option allowing admins to decide whether users can display a list of comments posted by other users;

----

<<##actions/usercomments.php##<<


%%(php)
<?php

/**
* Display a list of recent comments posted by a user.
*
* This action can be used to display a list of comments posted 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 comments recently posted by the current user.
*
* @package Actions
* @name Usercomments
*
* @author {@link http://www.wakkawiki.de/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 comments recently posted 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 a list of comments by other users;
*/

$author =''; #initializing variable

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

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

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


$page = $this->GetPageTag();

if ($author)
{
$user_comments_count = 0;

if ($_GET["alpha"] == 1)
{
echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", along with the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&date=1&action=comments")."\">order by date</a>).<br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY page_tag ASC, time DESC"))

{
foreach ($comments as $comment)
{
if ($last_tag != $comment["page_tag"]) {
$last_tag = $comment["page_tag"];
$firstChar = strtoupper($comment["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("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
else
{

echo $this->Format("== Pages commented by [[".$author."]] == --- --- ");
print("This is a list of pages commented by ".$this->Link($author).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$author."&alpha=1&action=comments")."\">order alphabetically</a>).<br /><br />\n");

if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($author)."' ORDER BY time ASC, page_tag ASC"))
{
foreach ($comments as $comment)
{
$commented_pages[$comment["page_tag"]] = $comment["time"];
}

$commented_pages = array_reverse($commented_pages);

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

// print entry
print("   (".$time.") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}

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

?>


%%


----
Deletions:
===== ""UserComments"" Action =====
''Last Updated: 2004-11-23 - ""RewriteRules"" bug fixed''


This action displays a list of pages commented by the current user or by any other registered user specified via a ##user## GET variable

<<This action is meant as a module for the **UserAdmin** tool.
To use it as a standalone action simply add ##""{{usercomments}}""## in one of your pages.<< ::c::

Save the following code as ##actions/usercomments.php##.

-- DarTar

----

<<##actions/usercomments.php##<<


%%(php)
<?php

// Shows pages commented 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_comments_count = 0;

if ($_GET["alpha"] == 1)
{
echo $this->Format("== Pages commented by [[".$user."]] == --- --- ");
print("<strong>This is a list of pages commented by ".$this->Link($user).", along with the time of the comment (<a href=\"".$this->Href("", "", "user=".$user."&date=1&action=comments")."\">order by date</a>).</strong><br /><br />\n");
if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($user)."' ORDER BY page_tag ASC, time DESC"))

{
foreach ($comments as $comment)
{
if ($last_tag != $comment["page_tag"]) {
$last_tag = $comment["page_tag"];
$firstChar = strtoupper($comment["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("   (".$comment["time"].") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}
}

if ($user_comments_count == 0)
{
print("<em>User has not commented any pages yet.</em>");
}
}
else
{
print("<em>No comments found.</em>");
}
}
else
{

echo $this->Format("== Pages commented by [[".$user."]] == --- --- ");
print("<strong>This is a list of pages commented by ".$this->Link($user).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$user."&alpha=1&action=comments")."\">order alphabetically</a>).</strong><br /><br />\n");

if ($comments = $this->LoadAll("SELECT id, page_tag, time FROM ".$this->config["table_prefix"]."comments WHERE user =
'".mysql_real_escape_string($user)."' ORDER BY time ASC, page_tag ASC"))
{
foreach ($comments as $comment)
{
$commented_pages[$comment["page_tag"]] = $comment["time"];
}

$commented_pages = array_reverse($commented_pages);

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

// print entry
print("   (".$time.") <a href=\"".$this->href("", $comment["page_tag"], "show_comments=1")."#".$comment["id"]."\">".$comment["page_tag"]."</a><br />\n");

$user_comments_count++;
}

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

?>

%%


----


Revision [4732]

Edited on 2005-01-17 14:31:27 by NilsLindenberg [cat. added]
Additions:
CategoryUserContributions
Deletions:
CategoryDevelopment


Revision [2379]

Edited on 2004-11-23 08:56:53 by DarTar [RewriteRules bug fixed]
Additions:
''Last Updated: 2004-11-23 - ""RewriteRules"" bug fixed''
print("<strong>This is a list of pages commented by ".$this->Link($user).", along with the time of the comment (<a href=\"".$this->Href("", "", "user=".$user."&date=1&action=comments")."\">order by date</a>).</strong><br /><br />\n");
print("<strong>This is a list of pages commented by ".$this->Link($user).", ordered by the time of the comment (<a href=\"".$this->Href("", "", "user=".$user."&alpha=1&action=comments")."\">order alphabetically</a>).</strong><br /><br />\n");
Deletions:
print("<strong>This is a list of pages commented by ".$this->Link($user).", along with the time of the comment (<a href=\"".$page."?user=".$user."&date=1&action=comments\">order by date</a>).</strong><br /><br />\n");
print("<strong>This is a list of pages commented by ".$this->Link($user).", ordered by the time of the comment (<a href=\"".$page."?user=".$user."&alpha=1&action=comments\">order alphabetically</a>).</strong><br /><br />\n");


Revision [1983]

Edited on 2004-10-25 18:16:53 by NilsLindenberg [category added]
Additions:
%%
CategoryDevelopment
Deletions:
%%


Revision [1268]

Edited on 2004-09-16 09:41:04 by DarTar [category added]
Additions:
<<This action is meant as a module for the **UserAdmin** tool.
To use it as a standalone action simply add ##""{{usercomments}}""## in one of your pages.<< ::c::
Deletions:
<<(This action is meant as a module for the UserAdmin tool).<<


Revision [1257]

Edited on 2004-09-16 09:27:41 by DarTar [category added]
Additions:
This action displays a list of pages commented by the current user or by any other registered user specified via a ##user## GET variable
Deletions:
This action allowing displays a list of pages commented by the current user or by any other registered user specified via a ##user## GET variable


Revision [1256]

Edited on 2004-09-16 09:27:23 by DarTar [category added]
Additions:
----
<<##actions/usercomments.php##<<


Revision [1245]

The oldest known version of this page was created on 2004-09-16 09:14:51 by DarTar [category added]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki