AddToWatchlist-Talk

Summary: Talk page for AddToWatchlist.
Maintainer: Petko
Users: +1 (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

New page creation attributes with AuthUser

I have an issue where when a new watch page needs to be created with a general user who only needs edit and publish rights to their own profile and watch list cannot have a watch list created because the attribute page for watchlist will not let them and requires a login first for a new watch list page which will not let them login of course. They are able to see and edit their own Profile page.

How can I make sure that edit and publish attributes include standard admin and moderator attributes in addition to the userID upon watch page creation so that the user has access to only their watch list and can actually see it?

The attributes format for edit and publish would be "@admins @moderators @UserID"
--Marcus 20171006, 17:10 CST

Sorry, this is not currently possible with this recipe, but there are at least two other ways to do it. One is to use the profile page as a watchlist trail, set to config.php such a line: $WatchlistTrailFmt = '{$FullName}'; # for Profiles.UserName. The other is to create a separate watchlist page at the same time, with the same function that creates the user page with the permissions you need. --Petko October 07, 2017, at 04:22 AM

New Page Creation Addendum

After reviewing functions like write($pagename,$page), SaveAttributes($pagename,&$page,&$new), HandlePostAttr($pagename, $auth = 'attr') and maybe a couple of others, I am still wondering if this can still easily be done. I am just unfamiliar enough with the pmwiki base code to be extremely effective. However, before I take a crack at this issue, I just wanted to invite any input of warnings, suggestions of operations with script or file handling, or see if anyone else has built anything similar for just such a situation as was first addressed above. Of course, I would need to read in the attributes of a user profile page and cache those rights before assigning them to the watchlist attributes, but I think that can be done with a simple page attributes read from the listed AuthUser name - which is simply the $Author variable which I also use as the profile page name for that author, if I am not mistaken.
Marcus 20171021, 11:45 CST

Here is how I'd do it: just add this to config.php: $WatchlistTrailFmt = '{$FullName}'; Then the watchlists will be included at the bottom of the profile pages with the same permissions (as long as the user can edit her own profile page). Then move any existing watchlists from their current separate pages into the owner's profile pages (edit page, copy from [[#AddToWatchlist]] to end of trail, paste in profile). If you absolutely must have a watchlist page separate from the profile, create it exactly the same way at the same time the profile page is created. See also an addon allowing you to easily copy a page with all permissions. In both cases, disable the automatic deletion feature we discussed earlier. --Petko October 21, 2017, at 12:39 PM


Delete empty watchlists

If the Watchlist page is empty, I see no need to retain the page. Would it be possible to modify the core script to remove the page on the last "Unwatch" entry execution? This would have the effect of allowing me to remove a header menu option for a watchlist page that does not exist as the empty page is was removed (because it was empty anyway).
--Marcus 20170909, 23:53 CST

Just add to config.php

if($action == "unwatch") $DeleteKeyPattern = "^[\\s\n]*\\[\\[#AddToWatchlist\\]\\][\\s\n]*$";

If you have added some header before the [[#AddToWatchlist]] anchor, use this instead:

if($action == "unwatch") $DeleteKeyPattern = "\\[\\[#AddToWatchlist\\]\\][\\s\n]*$";

--Petko September 10, 2017, at 12:42 AM


If other watch items are on the page, any remaining watched items need to stay. This seems as though a page deletion will be enacted on anything upon which "Unwatch" is selected. How do I make sure that only the last remaining item (which effectively clears the page) is the only thing that enacts the automatic deletion of the now-clear page?
After Testing, Page is Indeed Deleted Only After Last Item Remaining Has Been "UnWatched" From Page and Order is No Concern.

I would still appreciate clarification on the following:
I am also not sure if you mean a GroupHeader or some other header information. I do use the Profiles.GroupHeader for custom page selections based on pages-existence. Sorry if I seem dense.
--Marcus 20170910, 01:10 CST

I wrote about GroupHeaders earlier, see below, when you wanted to add some information on the users' watchlists. You can either add this information in the individual watchlist pages, or you can add it in a GroupHeader (same for all users), and hide it in a conditional so that it only shows on pages that end with "-watchlist". In my last reply about deleting the page, when I wrote "some header before the [[#AddToWatchlist]] anchor" I meant the information added inside the individual page, above the list of watched pages, not in the GroupHeader. --Petko September 11, 2017, at 08:32 AM


Watchlist end anchor?

I noticed that on new page creation, there is no ending anchor-tag created, only a beginning. Is the ending tag necessary to tell a pagelist where to stop? And, since this is a watchlist-for-changes, would it not also be beneficial to provide some configurable formats to display the watch-for-changes listings instead of just a page list actually on that page while comment-div'ing the pages being listed?
--Marcus 20170813, 00:01 CST

This anchor is where a new page will be added to the trail, and is intended to be at the top of the trail so the person who just added that page can see it immediately and return to it. No, an ending tag is not necessary. This list is not a PageList, it is a WikiTrail, and it is intended to be used for Notify, or for actual pagelists (with the trail= argument with a custom PageListTemplate). About automatically having content on all watchlists, you could use a GroupHeader with a conditional like (:if name *-Watchlist:)content shown on watchlists, eg (:pagelist order=-time trail={*$FullName} fmt=#customPLtemplate:) (:div99 style="display:none;":)(:ifend:) and the "div99" will actually hide the rest of the page where the trail is. --Petko August 13, 2017, at 02:27 AM


Watchlist page does not exist

If the watchlist page was not present, it was also not newly created and had to be created manually. I assume this is a script design issue.
Also, is there any reason why after creating a profile watchlist page and even some preliminary list information on it, that the script would not update the watchlist page just using the default information? The instructions were followed for adding the postconfig, the format variable (tried before and after script), and the page action - the watchlist page will not update.
--Marcus 20170808, 03:14 CST
v2.2.101 with config mod.

None of these is normal. If a watchlist page does not exist, it is created automatically. If such a page exists, with or without preliminary information, the newly watched item is added in it. In both cases, when you press the "watch" link, you are redirected to the watchlist page and see the newly added page -- what happens in your case? If you don't have an author name, or edit permissions for the watchlist, a form will appear to enter your name and/or password before continuing. --Petko August 08, 2017, at 09:06 PM

After reviewing your installation, the RequireSummary recipe was not compatible with this one and didn't allow the watchlist to be saved. This is fixed in the latest version. Additionally if the saving fails for some (other) reason, any messages about it will be shown. --Petko August 10, 2017, at 03:00 AM


Watchlists in separate group

This is a wonderful recipe. It could be even better with a few more configuration options.

It appears the watchlist can be kept on a page other than the author's Profiles page (or that page with a suffix). For example, I seem to be able to use in config $AuthorListPage="MyPrivateGroup.$Author";. Is that safe to do?

Yes, from version 20110322 you can use $WatchlistTrailFmt = 'MyPrivateGroup.{$Name}';, documentation updated. --Petko March 22, 2011, at 04:23 AM

FYI, I think you made a typo in your script. In version 20110322c I have to specify "Watchist" not "Watchlist" to get it to work. RandyB March 25, 2011, at 01:13 PM

Thanks, corrected. --Petko March 25, 2011, at 01:29 PM

English terminology

Is there a way to specify terminology other than "Watch" and "Unwatch" - for example "Star" and "UnStar" or "Remember" and "Forget"?

Yes, you can "set" the English "translations" like this:
XLSDV('en',array('Watch' => 'Star', 'Unwatch'=>'Forget')); --Petko March 21, 2011, at 02:40 PM

Custom redirect after "watching" a page

Is there a way to control where redirection goes after the post, for example, if I want the user to stay on the current page rather than go to the page where the list is stored?

Yes, you can add to the special link url &goto={*$FullName} like:
[[{*$FullName}?action={*$WatchlistAction}&goto={*$FullName} | {*$WatchlistText}]]
After some use I found that most often I prefer to see the watchlist, and if I want to stay on the current page, I'll middle-click the Watch link to open a new tab. --Petko March 21, 2011, at 02:40 PM

You can also redirect to a fixed page with &goto=Group.Page in the link or you can set a default redirect page with the variable $WatchlistRedirectFmt = "Group.Page"; in config.php. Petko March 22, 2011, at 04:44 AM

Customize the custom redirect

Is there a way to encode extra info in the target? For example, "&goto=Site.Watchlist?extrainfo=Preferences.{$Author}%23AddToWatchlist" won't work because the extrainfo would be dropped. - RandyB March 21, 2011, at 06:49 PM

How would you use this extra info? If I understand correctly, you want a single watchlist page for all users, which would construct pagelists based on the author name (brilliant idea)? In that case, I think it is better to use a page variable, either create one or use {$WatchlistTrail} added in version 20110322a. Petko March 22, 2011, at 04:44 AM

For example on my watchlist page I might have "[[{$?returnto}|Return to {$?returnto}]]" and the page might make use of "{$?MaxPagesToShow}". I use URL parameters for all sorts of things. RandyB March 22, 2011, at 06:00 AM

The "Return to Page" link can be done with something like (:pagelist trail={$WhachlistTrail} count=1 fmt=#my_return_fmt:). The max number could be set in a different way - preference, page variable for a different page, pagelist with request=1 parameter, etc.. In case you have to pass such and other things in the link url, you can write a custom $WatchRedirectFunction which can append these things to the url that this recipe returns. --Petko March 22, 2011, at 05:50 PM

Star picture instead of "Watch" word

You can probably anticipate my next question...

Can I use an image such as an uncolored star for Watch and colored star for UnWatch - thereby allowing the user to toggle the page on and off the list? ("Starred pages" are becoming common - for example in Google Docs.)

- RandyB March 21, 2011, at 12:43 PM

Great idea. You could do the same as with the English "translation", use the "★" star or ♡ ♥ hearts Unicode characters. You can use grey and gold colors if you like:
XLSDV('en',array('Watch' => '%gray%★%%', 'Unwatch'=>'%color=gold%★%%'));
There is a list with several special characters here [1] [2].

You could even set star icons, just use the url address like you would include a picture:

XLSDV('en',array(
  'Watch' => 'http://yoursite/pub/star-gray.png"Page not in your watchlist. Click to add it."',
  'Unwatch'=>'http://yoursite/pub/star-gold.png"Page in your watchlist. Click to remove it."'));

It is probably a good idea to add "tooltip titles" to the icons (see PmWiki:Images) so that your users know what the icons do. --Petko March 21, 2011, at 03:21 PM

Bug report

Found a problem: "Watching" or "unwatching" a page eliminates the history for the target page where I keep my list. RandyB March 21, 2011, at 01:42 PM

Nice catch, thanks, fixed in 20110321a (just released). --Petko March 21, 2011, at 02:40 PM

Comment lier cette recette avec notify ?

Les membres peuvent choisir les pages à suivre, mais les mails ne sont pas envoyé... Pourtant, j'ai bien ajouté $EnableNotify = 1; dans config.php

Il y a un truc que je ne comprend pas !

Merci d'avance !Manu February 22, 2012, at 02:55 PM

Pour chaque utilisateur, il faut ajouter dans SiteAdmin.NotifyList une telle ligne:
notify=adresse@domaine.fr trail=Profiles.Petko-Watchlist
où après notify= c'est l'adresse de l'utilisateur, et après trail= c'est sa propre page avec sa liste de suivi, définie avec $WatchlistTrailFmt. Effectivement, le module fonctionne comme les listes de suivi sur Wikipédia, avec une page spéciale à chaque utilisateur; pour des envois avec Notify il faut bidouiller un peu. --Petko February 22, 2012, at 04:21 PM

Merci ! Je vais tester ça ! Je vais utiliser une requête SQL via php pour le faire automatiquement dans config.php

 
$EnableNotify = 1;		
	include_once("$FarmD/cookbook/adodb/adodb.inc.php");
	$DB['mysql'] = NewADOConnection('mysql');  
	if (!$DB['mysql']) die("Connection failed"); 
	$DB['mysql']->Connect('mysqlxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxx');
	$rs = $DB['mysql']->Execute("SELECT email,username FROM pmwiki_users");
	if ($rs){
        while ($arr = $rs->FetchRow()) {
		$monMail=$arr['email'];
		$monPseudo=$arr['username'];
		$NotifyList[] = 'notify='.$monMail.' trail=Watchlists.'.$monPseudo.'';  
        } 
	}

Manu? February 22, 2012, at 11:47 PM

Watching Talk Pages

Does AddToWatchlist automatically watch associated Talk pages? If not, can it be configured to do so? Calion? February 16, 2018, at 12:47 PM

No, it doesn't, but it is a good idea. I'll try to add it soon. --Petko February 19, 2018, at 01:10 AM

Added for version 20180221. --Petko February 21, 2018, at 01:01 AM

Talk page for the AddToWatchlist recipe (users).