Page 1 of 27

Board watch

Posted: Fri Mar 27, 2009 5:15 pm
by Extensions Robot
Modification name: Board watch
Author: asinshesq
Modification description: This mod gives users a 'board watch' option to receive notifications for posts made anywhere on the site (analogous to forum watch but for the entire board). Each user can choose between two ways for board watch to work: (1) send notification of the first post since the user's last visit and send no further notifications until the user revisits the site (analogous to the way forum watch and topic watch work) or (2) send notifications of all posts. In addition, each user can choose whether forum watch and topic watch work in the normal phpbb3 way (analogous to (1) above) or instead send notifications of all posts or replies in the subscribed forums or topics. The ability to choose between these two ways of working for boardwatch. forum watch and topic watch can be turned off in the acp. This mod also slightly changes the wording of the regular phpbb3 notifications to let recipients know how to change their notification settings, and it changes the post links in those notifications so that they lead to the earliest unread post in the topic in question (which I think is a more logical destination than the most recent post in the topic).
Modification version: 1.0.5
Tested on phpBB version: 3.0.12

Download file: boardwatch_1-0-5.zip
File size: 196.42 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extensions Team may not be able to provide support.

-->Modification support<--

Board watch

Posted: Fri Mar 27, 2009 5:15 pm
by Paul
Modification validated/released

Notes:

Board watch

Posted: Fri Mar 27, 2009 5:15 pm
by asinshesq
[edit: when you are done with the installation, please make the additional change I describe here: http://www.phpbb.com/community/viewtopi ... #p11536505 ]

Thanks for doing the work to validate this, Paul and DavidIQ.

Before installing this mod, I strongly suggest you read the file in the contrib folder for this mod called "changing_default_settings.html" and think about what default options you want your users to have.

The default if you don't change anything is that every user will get an email for every single post that gets posted in any forum where the user is allowed to read the post. Although that's how I have my board set, that can be a LOT of emails, and that may annoy your users. Moreover, if you have a lot of users, your board may get weighed down by sending out huge numbers of emails. (Incidentally, I would be interested in hearing from people about how that default works - and how much that default weighs down the site - on a large board.)

A compromise would be to set the default so that a user gets an email about a post and then does not get another email until the user goes back to the site (analogous to the way plain vanilla phpbb3 deals with topic watch).

And when you run the install_boardwatch.php script after making the file edits, please do not ignore the big red warning it gives you that reads:
Warning

New permission settings have been added. Be sure to check your permission settings and see that they are as you would like them.
That tells you that you have to give people permissions allowing them to change their boardwatch settings. If you forget to do that, no one will have permission to see the boardwatch module that allows them to change their settings so they all get stuck with whatever default you provided. Go here for more detail on how to set permissions: http://www.phpbb.com/community/viewtopi ... #p10575065

Some people have asked how to get the mod to include the text of the post in the email notice. I don't like doing that on my own board (I would rather encourage users to come to the site), but for people who want to do that I have posted the necessary code here: http://www.phpbb.com/community/viewtopi ... 5#p9334935

For those of you who have an earlier version installed, I have listed the changes in a file called code_changes_since_1-0-0.txt that appears in the contrib folder.

Re: Board watch

Posted: Fri Mar 27, 2009 6:16 pm
by thesecret
nice mod :)

Re: Board watch

Posted: Mon Mar 30, 2009 11:45 am
by Greylock3491
Thank you for your hard work on this mod :D

After installing the mod I have a small issue - when I click on the Users And Groups Tab, I get the following text at the top of the page:

Code: Select all

Warning: Call-time pass-by-reference has been deprecated in \includes\acp\acp_users.php on line 1345
In my file this points to the 3rd line below:

Code: Select all

	// start mod boardwatch
	include($phpbb_root_path . 'includes/functions_boardwatch.' . $phpEx);
	boardwatch_draw_acp_prefs(&$data, $user_row);
	// end mod boardwatch
Is there a quick fix for this?

Thanks in advance

Re: Board watch

Posted: Mon Mar 30, 2009 12:46 pm
by RMcGirr83
change this

Code: Select all

&$data,
to this

Code: Select all

$data,

Re: Board watch

Posted: Mon Mar 30, 2009 1:16 pm
by asinshesq
Thanks, Rich. How did I let that slip through :oops:
Just one more reason for me to submit an updated version for validation.

Re: Board watch

Posted: Mon Mar 30, 2009 1:22 pm
by RMcGirr83
asinshesq wrote:Thanks, Rich. How did I let that slip through :oops:
Bigger question is how did the validation Team let it slip through? ;)

Re: Board watch

Posted: Mon Mar 30, 2009 2:03 pm
by asinshesq
RMcGirr83 wrote:
asinshesq wrote:Bigger question is how did the validation Team let it slip through? ;)
I was very very very careful not to say that, rich ;)
Seriously, the validation team does an amazing job but can't be expected to find every needle in a haystack. The error was all mine.
I just updated the link in http://www.phpbb.com/community/viewtopi ... 5#p9075535 so that it points to a revised version that fixes this problem, so once again if you want to install a version that already has the various fixes referred to above you can use that link.

Re: Board watch

Posted: Mon Apr 06, 2009 4:38 pm
by shott
Board Watch community:

I seem to have fouled up my attempt to install the board watch module. While I thought that I had carefully followed all instructions, I must have missed something. For starters, I don't seem to see the Edit Boardwatch Options under the User Control Panel -> Board Preferences even though I think that I have the appropriate INCLUDE statement in acp_users_prefs.html and also have acp_boardwatch.html in the adm/styles directory. I do, however have BOARDWATCH_EDIT_OPTIONS under ACP -> System -> Module Management -> UCP -> Board Preferences.

Also, when I post a reply to a message I get the following error message:

Code: Select all

SQL ERROR [ postgres ]

ERROR: invalid input syntax for integer: " . BOARDWATCH_YES . " []

SQL

SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber, u.user_boardwatchf FROM phpbb_forums_watch fw, phpbb_users u WHERE fw.forum_id = 5 AND fw.user_id NOT IN (1, 2, 62, 66, 54, 57, 58, 64, 53, 55, 63, 61, 60, 56, 65, 54, 57, 58, 64, 53, 55, 63, 61, 60, 56, 65) AND (fw.notify_status = 0 OR u.user_boardwatchf = ' . BOARDWATCH_YES . ') AND u.user_type IN (0, 3) AND u.user_id = fw.user_id

BACKTRACE

FILE: includes/db/postgres.php
LINE: 177
CALL: dbal->sql_error()

FILE: includes/functions_posting.php
LINE: 1195
CALL: dbal_postgres->sql_query()

FILE: includes/functions_posting.php
LINE: 2491
CALL: user_notification()

FILE: posting.php
LINE: 1001
CALL: submit_post()
Note: I'm running phpBB3 version 3.0.4 against a Postgresql 8.1.11 database running under RHEL5.

Does anyone have a suggestion as to go about finding what I did wrong? Or are there log files that I can check that might give me a better idea? Or is it easier to tear it all out and try again? Note: I'm a new phpBB3 administrator and this is my first attempt to add a module so some sort of pilot error is likely ...

Thanks,

John

Re: Board watch

Posted: Mon Apr 06, 2009 8:23 pm
by asinshesq
shott wrote:...While I thought that I had carefully followed all instructions, I must have missed something. For starters, I don't seem to see the Edit Boardwatch Options under the User Control Panel -> Board Preferences even though I think that I have the appropriate INCLUDE statement in acp_users_prefs.html and also have acp_boardwatch.html in the adm/styles directory. I do, however have BOARDWATCH_EDIT_OPTIONS under ACP -> System -> Module Management -> UCP -> Board Preferences...
Are you sure you granted the user in question (e.g. yourself or a group of which you are a member) permission to use boardwatch? The boardwatch options will only show up for a user that has permissions to use boardwatch.

Also, are you sure that you 'enabled' the module? When you go to ACP -> System -> Module Management -> UCP -> Board Preferences does it say 'disable' (which means it is already eenabled) right next to 'edit post notification options' the way the other options do?
shott wrote:...Also, when I post a reply to a message I get the following error message:

Code: Select all

SQL ERROR [ postgres ]

ERROR: invalid input syntax for integer: " . BOARDWATCH_YES . " []...[/quote]
I know nothing about postgres (I only use mysql), but it looks like maybe it doesn't realize that BOARDWATCH_YES is a constant that means 0.  And that could happen if you either (a) forgot to upload the includes/boardwatch constants.php file that comes iwth the mod (or uploaded it to the wrong folder) or (b) forgot to make the first change to includes/functi0ons_posting.php that this mod has you make (that's the one that includes the boardwatch_constants.php file) or made that change in the wrong place.

Let me know what you figure out.

Re: Board watch

Posted: Tue Apr 07, 2009 2:53 am
by shott
Are you sure you granted the user in question (e.g. yourself or a group of which you are a member) permission to use boardwatch? The boardwatch options will only show up for a user that has permissions to use boardwatch.
Alan .... Bingo!!! That's what I had forgotten to do. I had enabled the module but not allowed anyone to use it.
Duh!!! Thanks for pointing that out to me .... it makes perfect sense.

I'm still checking into the Postgresql portion to see if I can figure out what is going on with the SQL error I reported. I believe that I have the constants_boardwatch.php file in the proper location and have double-checked and also believe that I'm including that file. While I believe that Posgresql only supports the smallint rather than the tinyint(1) option, I believe that I was successfully able to add the appropriate 4 columns to the phpbb_users
tables with:

ALTER TABLE phpbb_users
ADD user_boardwatchb SMALLINT DEFAULT '0' NOT NULL;

and similar syntax for the other three columns.

I'll let you know what I learn however.

Thank you for your work on the mod and for your timely response,

John

Re: Board watch

Posted: Tue Apr 07, 2009 8:05 pm
by TheLuBu
Is there an SQL code to set board notification to off? I have set permissions only to administrator but about 30-40 People get the email notification! I don´t now how to turn it off!

lease help me quick, board is getting flooded :D

TheLuBu

----
Did it, set boardwatch for the whole forum to never for everyone. Could you set boardwatch for the complete forum to "No" as standard from the beginnning?

I´m sorry for my bad english ;)

Re: Board watch

Posted: Tue Apr 07, 2009 10:05 pm
by asinshesq
TheLuBu wrote:Is there an SQL code to set board notification to off? I have set permissions only to administrator but about 30-40 People get the email notification! I don´t now how to turn it off!

lease help me quick, board is getting flooded :D

TheLuBu

----
Did it, set boardwatch for the whole forum to never for everyone. Could you set boardwatch for the complete forum to "No" as standard from the beginnning?

I´m sorry for my bad english ;)
If you are trying to turn boardwatch off for all existing users, try this:

Code: Select all

UPDATE phpbb_users
SET user_boardwatchb = 2
WHERE 1 = 1;
That sets boardwatch to 'no' for everyone but leaves forum watch and topic watch choices at whatever settings the user has selected. And if you want brand new users to start with 'no' for boardwatch by default, try this:

Code: Select all

ALTER TABLE phpbb_users
MODIFY user_boardwatchb TINYINT(1) UNSIGNED DEFAULT '2' NOT NULL;
That sets boardwatch at no for future users but allows anyone who has boardwatch permission to turn it on in the future.

Re: Board watch

Posted: Wed Apr 08, 2009 4:59 pm
by shott
Alan .... and BoardWatch fans:

I am still getting the following error when I post replies (phpBB 3.0.4 on Linux with a Postgresql database ....):
General Error
SQL ERROR [ postgres ]

ERROR: invalid input syntax for integer: " . BOARDWATCH_YES . " []

SQL

SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber, u.user_boardwatchf FROM phpbb_forums_watch fw, phpbb_users u WHERE fw.forum_id = 5 AND fw.user_id NOT IN (1, 2, 62, 66, 54, 57, 58, 64, 55, 63, 60, 56, 65, 61, 53, 54, 57, 58, 64, 55, 63, 60, 56, 65, 61, 53) AND (fw.notify_status = 0 OR u.user_boardwatchf = ' . BOARDWATCH_YES . ') AND u.user_type IN (0, 3) AND u.user_id = fw.user_id

BACKTRACE

FILE: includes/db/postgres.php
LINE: 177
CALL: dbal->sql_error()

FILE: includes/functions_posting.php
LINE: 1195
CALL: dbal_postgres->sql_query()

FILE: includes/functions_posting.php
LINE: 2491
CALL: user_notification()

FILE: posting.php
LINE: 1001
CALL: submit_post()
I believe that I do have the contstants_boardwatch.php file included properly .... in fact, it seems to be interpreting the constant BOARDWATCH_YES appropriately in the $sql statement that follows "// -- get forum_userids || topic_userids", but then does not get interpreted properly in the "if ($topic_notification)" $sql statement that follows about 20 lines later.

When I look at it closely, it appears to me that there are differences in the two $sql queries as to whether the BOARDWATCH_YES is unquoted (as I think that it is in the first $sql statement) or quoted by single quotes (as I think that it is in the second $sql statement).

Here is the first post-boardwatch-modification query:

Code: Select all

        // -- get forum_userids || topic_userids
        $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_
notify_type, u.user_jabber, u.user_boardwatch' . (($topic_notification) ? 't' : 
'f') . '
                FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WA
TCH_TABLE) . ' w, ' . USERS_TABLE . ' u
                WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . 
' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
                        AND w.user_id NOT IN ($sql_ignore_users)
                        AND (w.notify_status = 0 OR u.user_boardwatch" . (($topi
c_notification) ? 't' : 'f') . ' = ' . BOARDWATCH_YES . ")
                        AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDE
R . ')
                        AND u.user_id = w.user_id';
and here is the second one that appears in the "if ($topic_notification)" block:

Code: Select all

                $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang,
 u.user_notify_type, u.user_jabber, u.user_boardwatchf
                        FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " 
u
                        WHERE fw.forum_id = $forum_id
                                AND fw.user_id NOT IN ($sql_ignore_users)
                                AND (fw.notify_status = 0 OR u.user_boardwatchf 
= ' . BOARDWATCH_YES . ')
                                AND u.user_type IN (" . USER_NORMAL . ', ' . USE
R_FOUNDER . ')
                                AND u.user_id = fw.user_id';
In the second query, it appears to me as if the double quoted section (that starts after USERS_TABLE and
end before USER_NORMAL) contains the single quoted section that surrounds BOARDWATCH_YES. My guess is that this confuses things so that BOARDWATCH_YES is not interpreted as a constant.

Note: to make sure that I didn't screw up the original placement of single- and double quotes, I've included the original, unaltered statements from the phpBB3 file that I downloaded. In particular, I'm not sure whether this file is guaranteed to be the same on a Linux platform as that downloaded on a Windows platform, for example.

The unaltered first query has:

Code: Select all

        // -- get forum_userids || topic_userids
        $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_
notify_type, u.user_jabber
                FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WA
TCH_TABLE) . ' w, ' . USERS_TABLE . ' u
                WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . 
' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
                        AND w.user_id NOT IN ($sql_ignore_users)
                        AND w.notify_status = 0
                        AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDE
R . ')
                        AND u.user_id = w.user_id';
And the unaltered "if ($topic_notification)" query is:

Code: Select all

                $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang,
 u.user_notify_type, u.user_jabber
                        FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " 
u
                        WHERE fw.forum_id = $forum_id
                                AND fw.user_id NOT IN ($sql_ignore_users)
                                AND fw.notify_status = 0
                                AND u.user_type IN (" . USER_NORMAL . ', ' . USE
R_FOUNDER . ')
                                AND u.user_id = fw.user_id';
Although I have not yet tested it, I believe that the second $sql query would work properly (that is, will interpret the BOARDWATCH_YES constant properly) if the single quotes that precede and follow BOARDWATCH_YES are each changed to double quotes. In this way, the $forum_id and $sql_ignore_users variables will be interpreted properly and the BOARDWATCH_YES (which will no longer be quoted) will be interpreted as a constant.

Code: Select all

                $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang,
 u.user_notify_type, u.user_jabber, u.user_boardwatchf
                        FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " 
u
                        WHERE fw.forum_id = $forum_id
                                AND fw.user_id NOT IN ($sql_ignore_users)
                                AND (fw.notify_status = 0 OR u.user_boardwatchf 
= " . BOARDWATCH_YES . ")
                                AND u.user_type IN (" . USER_NORMAL . ', ' . USE
R_FOUNDER . ')
                                AND u.user_id = fw.user_id';
You experts may think that I'm barking up the wrong tree, that that is what I believe to be the cause of the Postgresql error that I am seeing.

Thanks for your consideration,

John