Revision history for WikiPageWatch


Revision [23625]

Last edited on 2018-07-13 10:48:51 by IanHayhurst
Additions:
##WikiRoot
   \-- unpagewatch.php##
Deletions:
WikiRoot
   \-- unpagewatch.php


Revision [23624]

Edited on 2018-07-13 10:48:34 by IanHayhurst
Additions:
| |-- watchlink
Deletions:
| |-- watchlink


Revision [23623]

Edited on 2018-07-13 10:48:16 by IanHayhurst
Additions:
| |-- watchlink
Deletions:
  | |-- watchlink


Revision [23622]

Edited on 2018-07-13 10:48:04 by IanHayhurst
Additions:
  | |-- watchlink
Deletions:
  | |-- watchlink


Revision [23621]

Edited on 2018-07-13 10:08:53 by IanHayhurst
Additions:
-Create pagewatch.php in ##//wikiroot///plugins/handlers/pagewatch##
%%(php;;pagewatch.php)
<?php
* This handler will add the current user to the watch list for the
* page he is currently on
*
* @author <chumang.sango@syngenta.com>
*
* Date: 09 Decemeber 2009
* CHANGES
* 20180710 Ian M. Hayhurst wrap in check for logged on user
*/
$redirectmessage = "";
if ($this->GetUser())
$watch_cmd = "
insert into wikka_page_watch (user_name, page_tag)
values ('".$user."', '".$tag."') ";
$success = mysql_query($watch_cmd, $this->dblink);
$redirectmessage = "You are now watching this page.";
{$redirectmessage = "You need to be logged in!";
// redirect to parent page
$this->Redirect($this->Href(), $redirectmessage);
-Create upagewatch.php in ##//wikiroot///plugins/handlers/unpagewatch##
%%(php;;unpagewatch.php)
<?php
* This handler will remove the current user from the watch list for the
* page he is currently on
*
* @author <chumang.sango@syngenta.com>
*
* Date: 09 Decemeber 2009
*/
$redirectmessage = "";
$unwatch_cmd = "
delete from wikka_page_watch
where user_name = '".$user."'
and page_tag = '".$tag."' ";
$success = mysql_query($unwatch_cmd, $this->dblink);
$redirectmessage = "You are no longer watching this page.";
// redirect to parent page
$this->Redirect($this->Href(), $redirectmessage);


Revision [23620]

Edited on 2018-07-13 09:59:05 by IanHayhurst
Additions:
* 09/12/2009 | C.Sango | Created
* @package Actions
* @subpackage Menulets
Deletions:
* 09/12/2009 | C.Sango | Created
* @package Actions
* @subpackage Menulets


Revision [23619]

Edited on 2018-07-13 09:57:49 by IanHayhurst
Additions:
-Edit the plugin version of addcomment.php to include our notify line ##$this->NotifyWatchers($this->tag, 'comment');## at the point where the comment is ready to be stored (about line 58)
%%(php;53;addcomment.php)
Deletions:
-Edit the plugin version of addcomment.php to include our notify line ##$this->NotifyWatchers($this->tag, 'comment');## at the point where the comment or edit is ready to be stored
%% (php;53;addcomment.php)


Revision [23618]

Edited on 2018-07-13 09:55:50 by IanHayhurst
Additions:
-This will make wiki check the plugin version of any action / handler etc. before the supplied one
-Add menu action ""{{watchlink}}"" to ##//wikiroot///plugin/config/option_menu.inc, option_menu.user.inc and option_menu.admin.inc## Which need to be copied from##//wikiroot///config/## to ##//wikiroot///plugin/config##
-Copy file from ##//wikiroot///handlers/addcomment/addcomment.php## to ##//wikiroot///plugin/handlers/addcomment/addcomment.php##
-Copy file from ##//wikiroot///handlers/edit/edit.php## to ##//wikiroot///plugin/handlers/edit/edit.php##
-Edit the plugin version of addcomment.php to include our notify line ##$this->NotifyWatchers($this->tag, 'comment');## at the point where the comment or edit is ready to be stored
%% (php;53;addcomment.php)
// all is kosher: store new comment
else
{
$body = nl2br($this->htmlspecialchars_ent($body));
$this->SaveComment($this->GetPageTag(), $body, $parent_id);
// notify watchers of new content
$this->NotifyWatchers($this->tag, 'comment');
-Edit the plugin version of editt.php to include our notify line ##$this->NotifyWatchers($this->tag, 'edit');
## at the point where the edit is ready to be stored about line 155
%%(php;138;edit.php)
{
// only save if new body differs from old body
if ($body != $this->page['body']) {
// add page (revisions)
$this->SavePage($this->GetPageTag(), $body, $note);
// now we render it internally so we can write the updated link table.
// if we no longer do link tracking for header and footer why are we creating dummy output?
$this->ClearLinkTable();
$dummy = $this->Header(); // @@@
$this->StartLinkTracking();
$dummy .= $this->Format($body);
$this->StopLinkTracking();
$dummy .= $this->Footer(); // @@@
$this->WriteLinkTable();
$this->ClearLinkTable();
}
// notify page watchers of recent change
$this->NotifyWatchers($this->tag, 'edit');
// forward
$this->Redirect($this->Href());
Deletions:
-Add menu action ""{{watchlink}}"" to ##//wikiroot///plugin/config/option_menu.inc, option_menu.user.inc and option_menu.admin.inc##
-Copy


Revision [23617]

Edited on 2018-07-13 09:38:13 by IanHayhurst [update action]
Additions:
%%(php;;AppendTo-Wakka.class.php)
%%(php;;watchlink.php)
The ##addcomment.php## and## edit.php## handlers are modified to include a call to the Notify Watchers function of the main class. This is necessary to ensure that watchers are notified of changes the moment they are made.
Deletions:
%%(php)
%%(php)
The addcomment.php and edit.php handlers are modified to include a call to the Notify Watchers function of the main class. This is necessary to ensure that watchers are notified of changes the moment they are made.


Revision [23616]

Edited on 2018-07-13 09:33:47 by IanHayhurst [update action]
Additions:
===Database===
===Functions===
===Plugin Integration===
==Actions==
==Config==
==Handlers==
Deletions:
==Database==
==Functions==
==Plugin Integration==


Revision [23615]

Edited on 2018-07-13 09:31:09 by IanHayhurst [update action]
Additions:
::c::
==Database==
==Functions==
==Plugin Integration==
-Enable wiki for use of plugins //detailed here:// InstallingPlugins
-Add menulet action to the ##//wikiroot///plugin/actions/watchlink/watchlink.php##
-Displays Watch Page link or Un Watch page as appropriate
* Watch / Unwatch link menulet
*
* Displays a link to watch / unwatch the current page (depending on user privileges).
*
* Syntax: {{watchlink}}
*
* @package Actions
* @subpackage Menulets
* @name Watch link
*
* @author {@link Chumang Sango, Ian Hayhurst}
*/
if ($this->WatchWiki()){
echo '<a href="'.$this->Href('unpagewatch').'" title="'.T_("Click to stop receiving email on page edits or comments").'">'.T_("[Unwatch this page]").'</a>'; #i18n
else {
echo '<a href="'.$this->Href('pagewatch').'" title="'.T_("Click to receive email on page edits or comments").'">'.T_("[Watch this page]").'</a>'; #i18n
-Add menu action ""{{watchlink}}"" to ##//wikiroot///plugin/config/option_menu.inc, option_menu.user.inc and option_menu.admin.inc##
-Copy
----
Deletions:
//destructions section//''draft''
Enable wiki for use of plugins //detailed here:// InstallingPlugins
Add menu action ""{{watchlink}}"" config/option_menu.inc
Create new table// (mention table prefix)//
Fix with: %%setsebool -P httpd_can_sendmail=1%%
---


Revision [23614]

Edited on 2018-07-13 09:11:46 by IanHayhurst [update action]
Additions:
==ToDo:==
-Functions in Wikka.class.php not really in a plugin friendly place not sure what best practice should be here
Fix with: %%setsebool -P httpd_can_sendmail=1%%>>
Append the following functions to## //wikiroot///libs/Wakka.class.php ##just before the final closing } (which you can delete as it is included in the insert )
Deletions:
ToDo:
-Functions in Wikka.class.php not really in a plugin friendly place not sure what best practice should be here >>
Append the following functions to //wikiroot///libs/Wakka.class.php just before the final closing } (which you can delete as it is included in the insert )


Revision [23613]

Edited on 2018-07-13 09:10:01 by IanHayhurst [update action]

No Differences

Revision [23612]

Edited on 2018-07-13 09:09:29 by IanHayhurst [update action]
Additions:
- code assumes table prefix wikka_ in parts and needs ##$prefix = $this->GetConfigValue('table_prefix');## inserting in some of the sql
-Functions in Wikka.class.php not really in a plugin friendly place not sure what best practice should be here >>
Append the following functions to //wikiroot///libs/Wakka.class.php just before the final closing } (which you can delete as it is included in the insert )
%%(php)
/**
* Function to produce a module that allows a user to watch/unwatch a wiki.
* Watching a wiki involves subscribing to receive email notifications when
* the wiki changes i.e. page edits and comments
*
* @name WatchWiki
* @param None
* @author <chumang.sango@syngenta.com> Chumang Sango
* @access public
* @return string
* @version 0.0.2 Beta
*
* History
* ---------------------------------------------------------------------
* Date | Changed By | Description
* ---------------------------------------------------------------------
* 09/12/2009 | C.Sango | Created
* 12/07/2018 | I.Hayhurst | Return changed to bool. Handler redirect moved to watchlink menu action
*
*/
function WatchWiki()
{
$user = $this->GetUserName();
$tag = $this->GetPageTag();
$url = $this->Href();
$table = "page_watch";
$where = "user_name = '".$user."'
and page_tag = '".$tag."' ";
$count = $this->getCount($table, $where);
if($count == 0) {return false;}
else {return true;}
}
/**
* Function to send an email to the list of all the users watching a particular wiki
* This function should be used in handlers and actions that modify a page i.e. page edits and comments
*
* @name NotifyWatchers
* @@param string $tag The tag of the page whose watchers you want to notify
* @author <chumang.sango@syngenta.com> Chumang Sango
* @access public
* @version 0.0.1 Beta
* @@return void
*
* History
* ---------------------------------------------------------------------
* Date | Changed By | Description
* ---------------------------------------------------------------------
* 09/12/2009 | C.Sango | Created
* 15/12/2009 | C.Sango | Added code to set sender's email
*/
function NotifyWatchers($tag, $type=''){
$url = $this->Href();
$subject = "WikiWatch Alert for $tag";
// Load the email of the person sending the email
$senderQuery = "
select u.email
from wikka_users u
where u.name = '".$this->GetUserName()."'";
$res = $this->LoadSingle($senderQuery);
$sender = $res['email'];
// construct email message based on change type
switch($type){
case 'comment': {
$message = '
<div id="mail" style="font-family: Calibri;">
<p> Hi </p>
<p>
<span style="width: 100%"> A new comment was made on the <strong>'.$tag.'</strong> wiki.</span>
<span> Follow the link below to view it. </span>
</p>
<p>     '.$url.'</p>
</div>';
break;
}
case 'edit': {
$message = '
<div id="mail" style="font-family: Calibri;">
<p> Hi </p>
<p>
<span> The wiki page <strong>'.$tag.'</strong> has been recently edited. </br></span>
<span> Follow the link below to view the new content. </span>
</p>
<p>     '.$url.'</p>
</div>';
break;
}
default: {
$message = '
<div id="mail" style="font-family: Calibri;">
<p> Hi </p>
<p>
<span> Content on the <strong>'.$tag.'</strong> wiki has been recently updated. </br></span>
<span> Follow the link below to view it. </span>
</p>
<p>      '.$url.'</p>
</div>';
}
}
// select watch list of page from database
$watchListQuery = "
select u.email
from wikka_users u,
wikka_page_watch w
where w.user_name = u.name
and w.page_tag = '".$tag."' ";
$result = $this->LoadAll($watchListQuery);
// send email to list
for ($i = 0; $i < sizeof($result); ++$i) {
$email = $result[$i]['email'];
$headers = "From: WikiWatch <$sender>\r\n";
$headers .= "Content-type: text/html\r\n";
mail($email, $subject, $message, $headers);
}
}
}
?>
Deletions:
code assumes table prefix wikka_ in parts and needs
##$prefix = $this->GetConfigValue('table_prefix');## inserting in some of the sql >>


Revision [23611]

Edited on 2018-07-13 08:57:30 by IanHayhurst [update action]
Additions:
Ported IanHayhurst 2018 for V1.3.7 pluginsystem
ToDo:
code assumes table prefix wikka_ in parts and needs
##$prefix = $this->GetConfigValue('table_prefix');## inserting in some of the sql >>
My table Prefix was ##wikka_## The table is referred to in the code
Deletions:
Ported IanHayhurst 2018 for V1.3.7 pluginsystem>>


Revision [23610]

Edited on 2018-07-13 08:49:17 by IanHayhurst [update action]
Additions:
>>{{image url="https:////c1.staticflickr.com/2/1823/43330485912_490c6b6a57_m.jpg"}}>>
Deletions:
{{image url="https:////c1.staticflickr.com/2/1823/43330485912_3891941b18_m.jpg"}}


Revision [23609]

Edited on 2018-07-13 08:44:33 by IanHayhurst [update action]
Additions:
{{image url="https:////c1.staticflickr.com/2/1823/43330485912_3891941b18_m.jpg"}}
Deletions:
{{image url="https://drive.google.com/file/d/1tuWZNyIM7zxRboDFttMhd6FksO2bhd9S/view?usp=sharing"}}


Revision [23608]

Edited on 2018-07-13 08:29:39 by IanHayhurst [update action]
Additions:
{{image url="https://drive.google.com/file/d/1tuWZNyIM7zxRboDFttMhd6FksO2bhd9S/view?usp=sharing"}}


Revision [23607]

Edited on 2018-07-13 08:23:09 by IanHayhurst [update action]
Additions:
WikiRoot
Deletions:
WikiRoot/


Revision [23606]

Edited on 2018-07-13 07:38:44 by IanHayhurst [update action]
Additions:
|-- actions
  | |-- watchlink
|   \-- watchlink.php
Deletions:
|-- actions
   | |-- watchlink
|   \-- watchlink.php


Revision [23605]

Edited on 2018-07-13 07:37:34 by IanHayhurst [update action]
Additions:
|   \-- watchlink.php
Deletions:
|   \-- watchlink.php


Revision [23604]

Edited on 2018-07-13 07:37:18 by IanHayhurst [update action]
Additions:
|-- actions
   | |-- watchlink
|   \-- watchlink.php
Deletions:
\-- actions
   |-- watchlink
|   \-- watchlink.php


Revision [23603]

Edited on 2018-07-12 16:35:28 by IanHayhurst [update action]
Additions:
Enable wiki for use of plugins //detailed here:// InstallingPlugins
Deletions:
Enable wiki for use of plugins InstallingPlugins


Revision [23602]

Edited on 2018-07-12 16:34:49 by IanHayhurst [update action]
Additions:
Enable wiki for use of plugins InstallingPlugins
Deletions:
Enable wiki for use of pluginsInstallingPlugins


Revision [23601]

Edited on 2018-07-12 16:33:03 by IanHayhurst [update action]
Additions:
CREATE TABLE 'wikka_page_watch' (
'page_tag' varchar(75) NOT NULL,
'user_name' varchar(75) NOT NULL,
PRIMARY KEY ('page_tag','user_name') )
ENGINE=MyISAM DEFAULT CHARSET utf8 COLLATE utf8_unicode_ci;
Deletions:
CREATE TABLE `wikka_page_watch` ( `page_tag` varchar(75) NOT NULL, `user_name` varchar(75) NOT NULL, PRIMARY KEY (`page_tag`,`user_name`) ) ENGINE=MyISAM DEFAULT CHARSET utf8 COLLATE utf8_unicode_ci;


Revision [23600]

Edited on 2018-07-12 16:30:55 by IanHayhurst [update action]
Additions:
A new table was added to the underlying database. The table name is wikka_page_watch and it will serve as the watch list. The structure of the table is shown below:
|=|Field |=|Type |=|Null|=|
||page_tag ||VARCHAR(75) ||No||
||user_name ||VARCHAR(75) ||No||
The PRIMARY key for the table is a combination of page_tag and user_name. Examples of page_tag values include WelcomePage, RecentChanges, etc. Examples of user_name values include JohnSmith, JohnDoe, etc. When a user subscribes to a page, his name and the tag of the page will be added to this table. The opposite happens when a user decides to unsubscribe.
The addcomment.php and edit.php handlers are modified to include a call to the Notify Watchers function of the main class. This is necessary to ensure that watchers are notified of changes the moment they are made.
----
//destructions section//''draft''
Enable wiki for use of pluginsInstallingPlugins

Add menu action ""{{watchlink}}"" config/option_menu.inc
Create new table// (mention table prefix)//
%%(mysql)
CREATE TABLE `wikka_page_watch` ( `page_tag` varchar(75) NOT NULL, `user_name` varchar(75) NOT NULL, PRIMARY KEY (`page_tag`,`user_name`) ) ENGINE=MyISAM DEFAULT CHARSET utf8 COLLATE utf8_unicode_ci;
%%

==Troubleshooting:==
SELinux Http can't send mail
var/log/maillog shows:
##postfix/sendmail[29013]: fatal: open /etc/postfix/main.cf: Permission denied##
Fix with: %%setsebool -P httpd_can_sendmail=1%%


Revision [23599]

Edited on 2018-07-12 16:16:04 by IanHayhurst [update action]
Additions:
**""NotifyWatchers ($tag, $type='')""**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used when page content is changed). The $type parameter is option, and a generic change message will be generated if it is not specified.
Deletions:
**""NotifyWatchers"" ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used when page content is changed). The $type parameter is option, and a generic change message will be generated if it is not specified.


Revision [23598]

Edited on 2018-07-12 16:15:26 by IanHayhurst [update action]
Additions:
**""WatchWiki"" ( )**: This function constructs a module that will be displayed on a wiki page. This module has a link in it which will allow a user to watch the page (if the user does not already exist in the watch list of the page), or to stop watching a page (if the user is already watching the page). //altered just to return bool if page is watched or not//
**""NotifyWatchers"" ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used when page content is changed). The $type parameter is option, and a generic change message will be generated if it is not specified.
Deletions:
**WatchWiki ( )**: This function constructs a module that will be displayed on a wiki page. This module has a link in it which will allow a user to watch the page (if the user does not already exist in the watch list of the page), or to stop watching a page (if the user is already watching the page). //altered just to return bool if page is watched or not//
**NotifyWatchers ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used when page content is changed). The $type parameter is option, and a generic change message will be generated if it is not specified.


Revision [23597]

Edited on 2018-07-12 16:14:55 by IanHayhurst [update action]
Additions:
Two new functions are added to the Wakka.Class.php file. These functions are :
**NotifyWatchers ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used when page content is changed). The $type parameter is option, and a generic change message will be generated if it is not specified.
Deletions:
3. Two new functions are added to the Wakka.Class.php file. These functions are :
**NotifyWatchers ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used


Revision [23596]

Edited on 2018-07-12 16:12:34 by IanHayhurst [update action]
Additions:
3. Two new functions are added to the Wakka.Class.php file. These functions are :
**WatchWiki ( )**: This function constructs a module that will be displayed on a wiki page. This module has a link in it which will allow a user to watch the page (if the user does not already exist in the watch list of the page), or to stop watching a page (if the user is already watching the page). //altered just to return bool if page is watched or not//
**NotifyWatchers ($tag, $type='')**: This function will send out an email message to all users that are on the watch list of a page when a change is made on the page. The $tag parameter is used to specify the tag of the page whose watchers need to be notified. The $type parameter is used to specify the type of notification. There are currently two types of notification – ‘comment’ (used when a new comment is made on a page) and ‘edit’ (used


Revision [23595]

Edited on 2018-07-12 16:11:02 by IanHayhurst [update action]
Deletions:
|


Revision [23594]

Edited on 2018-07-12 16:09:56 by IanHayhurst [update action]
Additions:
|-- libs
|   \-- Wakka.class.php
|
|-- plugins
\-- actions
   |-- watchlink
|   \-- watchlink.php
|-- config
| \-- options_menu.inc
| |-- options_menu.user.inc
| |-- options_menu.admin.inc
|-- handlers
   \-- addcomment
       | \--addcomment.php
   |--edit
      | \-- edit.php
   |--pagewatch
   | \--pagewatch.php
   |-- unpagewatch
   \-- unpagewatch.php
Deletions:
??? libs
?   ??? Wakka.class.php
??? plugins
??? actions
?   ??? watchlink
?   ??? watchlink.php
??? config
?   ??? options_menu.inc
?   ??? options_menu.user.inc
?   ??? options_menu.admin.inc
??? handlers
   ??? addcomment
    ?   ??? addcomment.php
   ??? edit
   ?   ??? edit.php
   ??? pagewatch
   ?   ??? pagewatch.php
   ??? unpagewatch
   ??? unpagewatch.php


Revision [23593]

The oldest known version of this page was created on 2018-07-12 15:53:58 by IanHayhurst [update action]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki