Revision history for PageWatches


Revision [23240]

Last edited on 2016-05-20 07:38:47 by JavaWoman [Replaces old-style internal links with new pipe-split links.]
Additions:
This patch is based on the code [[http://web.archive.org/web/20040823065854/http://www.wakkawiki.com/NodeWatching | published at wakkawiki]] by [[http://web.archive.org/web/20040823065833/http://www.wakkawiki.com/MattPeperell | MattPeperell]] and [[http://web.archive.org/web/20040823064948/http://www.wakkawiki.com/SilBaer | SilBaer]].
Deletions:
This patch is based on the code [[http://web.archive.org/web/20040823065854/http://www.wakkawiki.com/NodeWatching published at wakkawiki]] by [[http://web.archive.org/web/20040823065833/http://www.wakkawiki.com/MattPeperell MattPeperell]] and [[http://web.archive.org/web/20040823064948/http://www.wakkawiki.com/SilBaer SilBaer]].


Revision [19257]

Edited on 2008-01-28 00:14:44 by JavaWoman [Modified links pointing to docs server]

No Differences

Revision [17137]

Edited on 2007-07-07 03:42:47 by JavaWoman [web.archive.org links for wakkawiki]
Additions:
This patch is based on the code [[http://web.archive.org/web/20040823065854/http://www.wakkawiki.com/NodeWatching published at wakkawiki]] by [[http://web.archive.org/web/20040823065833/http://www.wakkawiki.com/MattPeperell MattPeperell]] and [[http://web.archive.org/web/20040823064948/http://www.wakkawiki.com/SilBaer SilBaer]].
Deletions:
This patch is based on the code ++[[http://www.wakkawiki.com/nodewatching published at wakkawiki]]++ by matt peperell and silBaer.


Revision [16979]

Edited on 2007-05-31 23:27:32 by BrianKoontz [Reverted]
Additions:
This patch is based on the code ++[[http://www.wakkawiki.com/nodewatching published at wakkawiki]]++ by matt peperell and silBaer.
if ($watcher != $user && preg_match("/^.+@.+$/", $email)) {
$subject = $this->config["wakka_name"].": watched page ".$tag." changed";
$message = "Hello ". $watcher."\n\n";
$message .= "The following page has been changed: ".$this->Href("",$tag)."\n\n";
$message .= "You can remove this page from your watchlist with the following link:\n\n";
$message .= $this->Href("watch", $tag)."\n\n";
$message .= "Regards\n\nYour Wikka watchdog";
$headers = "From: Wikka watchdog <".$this->config["admin_mail"].">\n";
mail($email, $subject, $message, $headers);
}
?>%%
the watchlist itself is designed as an action. every user will see another list that contains only his own watches.
**actions/watches.php**
%%(php)<?php
$p = $this->config["table_prefix"]."pages";
$w = $this->config["table_prefix"]."watches";
$sql = "select $p.tag, $w.user, $p.time, $p.user, $p.changelog from $p, $w ".
"where $p.tag = $w.tag and $p.latest='Y' and $w.user='".$this->GetUserName()."' ".
"order by $p.time desc";
if ($pages = $this->LoadAll($sql)) {
$s = ""; $cur = "";
foreach ($pages as $page) {
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday) {
print("<br />\n<b>".$day."</b><br />\n");
$curday = $day;
print("<span class='indent'>".$time." (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)." ⇒ ".$this->Link($page["user"], "", "", 0)." (".$page["note"].")</span><br />\n");
} else print("<i>None</i><br>\n");
?>%%
the handler controls the watchlist and toggles page watching when called.
**handlers/page/watch.php**
%%(php)<?php
$tag = $this->GetPageTag();
$mail = $_POST["mail"] == "Y" ? "Y" : "N";
if ($this->GetUser()) {
$user = $this->GetUserName();
if ($this->IsWatched($user, $tag)) {
return $this->Query("delete from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'");
$this->Redirect($this->href("", $tag));
} else {
if ($_POST) {
if ($_POST["submit"] == "watch") {
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user)."', tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");
}
$this->Redirect($this->href("", $tag));
} else {
print("<div class='page'>".$this->FormOpen("watch"));
print($this->Format("You have chosen to put the page **".$tag."** onto your [[watchlist]].\n"));
print("If you don't want to watch this page, hit cancel\n");
print("<p>Aditionally you can be notified by mail every time this page is changed until you put it off your watchlist.<br />");
print("<input type='checkbox' name='mail' value='Y' /> send mail on changes<br />");
print("<input type='submit' name='submit' value='watch' /><input type='submit' name='submit' value='cancel' />\n");
print($this->FormClose()."</div>");
}
} else $this->Redirect($this->href("", $tag));
?>%%
finally hook in the notify feature in the savepage() function by calling
%%<? $this->NotifyWatchers($tag); ?>%%
at the end of that function and place a call to
%%<? $this->WatchLink(); ?>%%
wherever you want in the header or footer.
Back Links
----
{{backlinks}}
----
CategoryDevelopmentActions CategoryDevelopmentHandlers
Deletions:
This patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.
if ($watcher != $user


Revision [16778]

Edited on 2007-05-31 10:47:33 by Td5Mni [Reverted]
Additions:
This patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.
if ($watcher != $user
Deletions:
This patch is based on the code ++[[http://www.wakkawiki.com/nodewatching published at wakkawiki]]++ by matt peperell and silBaer.
if ($watcher != $user && preg_match("/^.+@.+$/", $email)) {
$subject = $this->config["wakka_name"].": watched page ".$tag." changed";
$message = "Hello ". $watcher."\n\n";
$message .= "The following page has been changed: ".$this->Href("",$tag)."\n\n";
$message .= "You can remove this page from your watchlist with the following link:\n\n";
$message .= $this->Href("watch", $tag)."\n\n";
$message .= "Regards\n\nYour Wikka watchdog";
$headers = "From: Wikka watchdog <".$this->config["admin_mail"].">\n";
mail($email, $subject, $message, $headers);
}
?>%%
the watchlist itself is designed as an action. every user will see another list that contains only his own watches.
**actions/watches.php**
%%(php)<?php
$p = $this->config["table_prefix"]."pages";
$w = $this->config["table_prefix"]."watches";
$sql = "select $p.tag, $w.user, $p.time, $p.user, $p.changelog from $p, $w ".
"where $p.tag = $w.tag and $p.latest='Y' and $w.user='".$this->GetUserName()."' ".
"order by $p.time desc";
if ($pages = $this->LoadAll($sql)) {
$s = ""; $cur = "";
foreach ($pages as $page) {
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday) {
print("<br />\n<b>".$day."</b><br />\n");
$curday = $day;
print("<span class='indent'>".$time." (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)." ⇒ ".$this->Link($page["user"], "", "", 0)." (".$page["note"].")</span><br />\n");
} else print("<i>None</i><br>\n");
?>%%
the handler controls the watchlist and toggles page watching when called.
**handlers/page/watch.php**
%%(php)<?php
$tag = $this->GetPageTag();
$mail = $_POST["mail"] == "Y" ? "Y" : "N";
if ($this->GetUser()) {
$user = $this->GetUserName();
if ($this->IsWatched($user, $tag)) {
return $this->Query("delete from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'");
$this->Redirect($this->href("", $tag));
} else {
if ($_POST) {
if ($_POST["submit"] == "watch") {
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user)."', tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");
}
$this->Redirect($this->href("", $tag));
} else {
print("<div class='page'>".$this->FormOpen("watch"));
print($this->Format("You have chosen to put the page **".$tag."** onto your [[watchlist]].\n"));
print("If you don't want to watch this page, hit cancel\n");
print("<p>Aditionally you can be notified by mail every time this page is changed until you put it off your watchlist.<br />");
print("<input type='checkbox' name='mail' value='Y' /> send mail on changes<br />");
print("<input type='submit' name='submit' value='watch' /><input type='submit' name='submit' value='cancel' />\n");
print($this->FormClose()."</div>");
}
} else $this->Redirect($this->href("", $tag));
?>%%
finally hook in the notify feature in the savepage() function by calling
%%<? $this->NotifyWatchers($tag); ?>%%
at the end of that function and place a call to
%%<? $this->WatchLink(); ?>%%
wherever you want in the header or footer.
Back Links
----
{{backlinks}}
----
CategoryDevelopmentActions CategoryDevelopmentHandlers


Revision [15265]

Edited on 2006-09-09 11:18:47 by BrianKoontz [Dead link]
Additions:
This patch is based on the code ++[[http://www.wakkawiki.com/nodewatching published at wakkawiki]]++ by matt peperell and silBaer.
Deletions:
This patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.


Revision [9811]

Edited on 2005-07-05 16:03:05 by DarTar [adding seealso box]
Additions:
>>**See also:** UserAccountModules>>::c::
Deletions:
>>**See also:** UserAdminModules>>::c::


Revision [9810]

Edited on 2005-07-05 16:02:51 by DarTar [adding seealso box]
Additions:
>>**See also:** UserAdminModules>>::c::
This patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.
Deletions:
this patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.


Revision [8605]

Edited on 2005-05-28 17:22:39 by JavaWoman [move to two subcategories]
Additions:
=====Watchlist for Wikka Pages=====
this patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.
registered users can put any page on a watchlist and can optionally choose to get an email on changes.
first we need a separate database table that holds the watches:
%%CREATE TABLE `wikka_watches` (
`user` varchar(80) NOT NULL default '',
`tag` varchar(50) NOT NULL default '',
`mail` enum('N','Y') NOT NULL default 'N',
`time` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`user`, `tag`)
) TYPE=MyISAM;%%
additional functions to be used when saving pages (notifywatchers()) and in the page footer... or header, of course (watchlink())
**wikka.php** inside ##class Wakka {##
%%(php)<?
// WATCHES
function IsWatched($user, $tag) { return $this->LoadSingle("select * from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'"); }
function WatchLink($delimiter = "::", $unwatch = "unwatch", $watch = "watch") {
if ($this->GetUser()) {
echo ($this->IsWatched($this->GetUserName(), $this->tag) ?
$delimiter." <a href='".$this->href("watch")."'>".$unwatch."</a>" :
$delimiter.":: <a href='".$this->href("watch")."'>".$watch."</a>");
}
}
function NotifyWatchers($tag) {
$w = $this->config["table_prefix"]."watches";
$u = $this->config["table_prefix"]."users";
$sql = "select $w.user, $u.email from $w, $u".
" where $w.user = $u.name and $w.mail = 'Y'".
" and $w.tag = '".mysql_real_escape_string($tag)."'";
$notify = $this->LoadAll($sql);
foreach ($notify as $watcher) $watchers[$notify["user"]] = $notify["email"];
//needs group management
//add chief editors, a group that always will be notified
// if ($chiefeditors = $this->GetMembers($this->config["always_notify"]) {
// foreach ($chiefeditors as $chiefeditor) {
// if ($editor = $this->LoadSingle("select * from $u where user='".mysql_real_escape_string($chiefeditor)."'")) {
// $watchers[$editor["user"]] = $editor["email"];
// }
// }
// }
foreach ($watchers as $watcher => $email) {
if ($watcher != $user && preg_match("/^.+@.+$/", $email)) {
$subject = $this->config["wakka_name"].": watched page ".$tag." changed";
$message = "Hello ". $watcher."\n\n";
$message .= "The following page has been changed: ".$this->Href("",$tag)."\n\n";
$message .= "You can remove this page from your watchlist with the following link:\n\n";
$message .= $this->Href("watch", $tag)."\n\n";
$message .= "Regards\n\nYour Wikka watchdog";
$headers = "From: Wikka watchdog <".$this->config["admin_mail"].">\n";
mail($email, $subject, $message, $headers);
}
}
}
?>%%
the watchlist itself is designed as an action. every user will see another list that contains only his own watches.
**actions/watches.php**
%%(php)<?php
$p = $this->config["table_prefix"]."pages";
$w = $this->config["table_prefix"]."watches";
$sql = "select $p.tag, $w.user, $p.time, $p.user, $p.changelog from $p, $w ".
"where $p.tag = $w.tag and $p.latest='Y' and $w.user='".$this->GetUserName()."' ".
"order by $p.time desc";
if ($pages = $this->LoadAll($sql)) {
$s = ""; $cur = "";
foreach ($pages as $page) {
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday) {
print("<br />\n<b>".$day."</b><br />\n");
$curday = $day;
}
print("<span class='indent'>".$time." (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)." ⇒ ".$this->Link($page["user"], "", "", 0)." (".$page["note"].")</span><br />\n");
}
} else print("<i>None</i><br>\n");
?>%%
the handler controls the watchlist and toggles page watching when called.
**handlers/page/watch.php**
%%(php)<?php
$tag = $this->GetPageTag();
$mail = $_POST["mail"] == "Y" ? "Y" : "N";
if ($this->GetUser()) {
$user = $this->GetUserName();
if ($this->IsWatched($user, $tag)) {
return $this->Query("delete from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'");
$this->Redirect($this->href("", $tag));
} else {
if ($_POST) {
if ($_POST["submit"] == "watch") {
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user)."', tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");
}
$this->Redirect($this->href("", $tag));
} else {
print("<div class='page'>".$this->FormOpen("watch"));
print($this->Format("You have chosen to put the page **".$tag."** onto your [[watchlist]].\n"));
print("If you don't want to watch this page, hit cancel\n");
print("<p>Aditionally you can be notified by mail every time this page is changed until you put it off your watchlist.<br />");
print("<input type='checkbox' name='mail' value='Y' /> send mail on changes<br />");
print("<input type='submit' name='submit' value='watch' /><input type='submit' name='submit' value='cancel' />\n");
print($this->FormClose()."</div>");
}
}
} else $this->Redirect($this->href("", $tag));
?>%%
finally hook in the notify feature in the savepage() function by calling
%%<? $this->NotifyWatchers($tag); ?>%%
at the end of that function and place a call to
%%<? $this->WatchLink(); ?>%%
wherever you want in the header or footer.
Back Links
----
{{backlinks}}
----
CategoryDevelopmentActions CategoryDevelopmentHandlers
Deletions:
=====Watchlist for Wikka Pages=====
this patch is based on the code [[http://www.wakkawiki.com/nodewatching published at wakkawiki]] by matt peperell and silBaer.

registered users can put any page on a watchlist and can optionally choose to get an email on changes.

first we need a separate database table that holds the watches:
%%CREATE TABLE `wikka_watches` (
`user` varchar(80) NOT NULL default '',
`tag` varchar(50) NOT NULL default '',
`mail` enum('N','Y') NOT NULL default 'N',
`time` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`user`, `tag`)
) TYPE=MyISAM;%%

additional functions to be used when saving pages (notifywatchers()) and in the page footer... or header, of course (watchlink())
**wikka.php** inside ##class Wakka {##
%%(php)<?
// WATCHES
function IsWatched($user, $tag) { return $this->LoadSingle("select * from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'"); }
function WatchLink($delimiter = "::", $unwatch = "unwatch", $watch = "watch") {
if ($this->GetUser()) {
echo ($this->IsWatched($this->GetUserName(), $this->tag) ?
$delimiter." <a href='".$this->href("watch")."'>".$unwatch."</a>" :
$delimiter.":: <a href='".$this->href("watch")."'>".$watch."</a>");
}
}
function NotifyWatchers($tag) {
$w = $this->config["table_prefix"]."watches";
$u = $this->config["table_prefix"]."users";
$sql = "select $w.user, $u.email from $w, $u".
" where $w.user = $u.name and $w.mail = 'Y'".
" and $w.tag = '".mysql_real_escape_string($tag)."'";
$notify = $this->LoadAll($sql);
foreach ($notify as $watcher) $watchers[$notify["user"]] = $notify["email"];

//needs group management
//add chief editors, a group that always will be notified
// if ($chiefeditors = $this->GetMembers($this->config["always_notify"]) {
// foreach ($chiefeditors as $chiefeditor) {
// if ($editor = $this->LoadSingle("select * from $u where user='".mysql_real_escape_string($chiefeditor)."'")) {
// $watchers[$editor["user"]] = $editor["email"];
// }
// }
// }

foreach ($watchers as $watcher => $email) {
if ($watcher != $user && preg_match("/^.+@.+$/", $email)) {
$subject = $this->config["wakka_name"].": watched page ".$tag." changed";

$message = "Hello ". $watcher."\n\n";
$message .= "The following page has been changed: ".$this->Href("",$tag)."\n\n";
$message .= "You can remove this page from your watchlist with the following link:\n\n";
$message .= $this->Href("watch", $tag)."\n\n";
$message .= "Regards\n\nYour Wikka watchdog";

$headers = "From: Wikka watchdog <".$this->config["admin_mail"].">\n";
mail($email, $subject, $message, $headers);
}
}
}
?>%%

the watchlist itself is designed as an action. every user will see another list that contains only his own watches.

**actions/watches.php**
%%(php)<?php
$p = $this->config["table_prefix"]."pages";
$w = $this->config["table_prefix"]."watches";

$sql = "select $p.tag, $w.user, $p.time, $p.user, $p.changelog from $p, $w ".
"where $p.tag = $w.tag and $p.latest='Y' and $w.user='".$this->GetUserName()."' ".
"order by $p.time desc";

if ($pages = $this->LoadAll($sql)) {
$s = ""; $cur = "";
foreach ($pages as $page) {
list($day, $time) = explode(" ", $page["time"]);
if ($day != $curday) {
print("<br />\n<b>".$day."</b><br />\n");
$curday = $day;
}
print("<span class='indent'>".$time." (".$this->Link($page["tag"], "revisions", "history", 0).") ".$this->Link($page["tag"], "", "", 0)." ⇒ ".$this->Link($page["user"], "", "", 0)." (".$page["note"].")</span><br />\n");
}
} else print("<i>None</i><br>\n");
?>%%

the handler controls the watchlist and toggles page watching when called.

**handlers/page/watch.php**
%%(php)<?php
$tag = $this->GetPageTag();
$mail = $_POST["mail"] == "Y" ? "Y" : "N";
if ($this->GetUser()) {
$user = $this->GetUserName();
if ($this->IsWatched($user, $tag)) {
return $this->Query("delete from ".$this->config["table_prefix"]."watches where user = '".mysql_real_escape_string($user)."' and tag = '".mysql_real_escape_string($tag)."'");
$this->Redirect($this->href("", $tag));
} else {
if ($_POST) {
if ($_POST["submit"] == "watch") {
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user)."', tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");
}
$this->Redirect($this->href("", $tag));
} else {
print("<div class='page'>".$this->FormOpen("watch"));
print($this->Format("You have chosen to put the page **".$tag."** onto your [[watchlist]].\n"));
print("If you don't want to watch this page, hit cancel\n");
print("<p>Aditionally you can be notified by mail every time this page is changed until you put it off your watchlist.<br />");
print("<input type='checkbox' name='mail' value='Y' /> send mail on changes<br />");
print("<input type='submit' name='submit' value='watch' /><input type='submit' name='submit' value='cancel' />\n");
print($this->FormClose()."</div>");
}
}
} else $this->Redirect($this->href("", $tag));
?>%%

finally hook in the notify feature in the savepage() function by calling

%%<? $this->NotifyWatchers($tag); ?>%%

at the end of that function and place a call to

%%<? $this->WatchLink(); ?>%%

wherever you want in the header or footer.

Back Links
----
{{backlinks}}


----
CategoryDevelopment


Revision [2063]

Edited on 2004-11-02 09:30:21 by NilsLindenberg [header+category added]
Additions:
=====Watchlist for Wikka Pages=====
{{backlinks}}
CategoryDevelopment
Deletions:
{{backlinks}}


Revision [2060]

Edited on 2004-11-01 20:08:37 by WinFried [corrected SQL of watch.php, added hint for main PHP block]
Additions:
**wikka.php** inside ##class Wakka {##
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user)."', tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");
Deletions:
return $this->Query("insert into ".$this->config["table_prefix"]."watches set user='".mysql_real_escape_string($user).", tag='".mysql_real_escape_string($tag)."', mail='".$mail."'");


Revision [1325]

Edited on 2004-09-18 19:43:15 by AherdfTurtles [corrected SQL of watch.php, added hint for main PHP block]
Additions:
wherever you want in the header or footer.
Back Links
----
{{backlinks}}
Deletions:
wherever you want in the header or footer.


Revision [1046]

The oldest known version of this page was created on 2004-08-26 21:37:05 by DreckFehler [corrected SQL of watch.php, added hint for main PHP block]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki