New module 'Watcher'

This commit is contained in:
Manuel Cillero 2017-07-26 13:57:55 +02:00
parent 1dd3176f21
commit ec3462121f
18 changed files with 5862 additions and 0 deletions

View file

@ -0,0 +1,104 @@
Note: CHANGELOG is no longer being updated. See the commit history at
drupal.org/project/watcher for a list of changes.
2009-02-26
- Fixed #384388 by J-Chance: Autowatching of nodes you make doesn't work.
2009-02-14
- Added: Caches 'from' header so it's only generated once.
- #371506: Fixed: Removed apostrophes in permission strings as it seems to cause illegal form
error with some modules enabled.
2009-02-10
- Fixed: Improved caching of user's watched posts list, significantly reducing the number of
queries needed.
2009-02-08
- Fixed: An issue with mismatching variable names causing some templates not to be editable.
- Refactored form code.
- Added: Introduced a theme function to display the "default settings" message on a user's
settings page. Added an icon to spruce things up a bit :)
- Fixed: Watcher now uses Drupal.behaviors.
2009-02-07
- Fixed: #369910 by Sebo: Anonynous notifications are received even for non-watched posts
- Fixed: README file contents not rendered properly on help page.
- Fixed: The current user, not the node's author, is now excluded from receiving
notifications when a node is updated since many users may edit a node and the current
user isn't necessarily author of the node.
2009-01-30
- Committing BETA1.
2009-01-29
- Fixed bug causing send to fail when time limit set to "unlimited" (to be backported to 5.x branch)
- Bug #361753: Fixed bug causing messages and subjects to be empty
- Fixed not setting correct headers and footers for anonymous users
- Added a template to the settings page for setting notification message footer for anonymous recipients
- Fixed issue with wrong argument passed to function watcher_db_user_set_watching()
2009-01-18
- #358709: Fixed.
- #359471: Fixed.
- #360612: Fixed.
- More options for anonymous users, watch for comments, updates or both.
- Introduced watch_for column in the watcher_nodes table.
- Fixed a number of not reported bugs.
- Binder/other users' watcher posts lists now work as they should.
- Statistics page now also shows the number of anonymous users watching nodes.
- Removed hook_user op: view implementation, a menu tab now serves as the link
to a user's list of watched posts
2009-01-10
- Removed customization of "My Watched Posts", translation is now handled through the
the translation system. Changes to its title can be made from admin/build/menu.
- Removed cache clearing menu callback.
- Implemented support for letting anonymous users watch posts.
2009-01-09
- First working version of 6.x branch.
- Added notice to user settings page indicating whether the settings are default or custom.
- Included cache clearing menu callback.
- A number of minor improvements.
2008-12-12
- #319048: Improved fix, filters out RFC2047 especials from site name string
before used as sender name in email messages
- Refactoring.
2008-11-09
- #319048: Fixing issue for users using "site name <email@site.com>" for site email
- Refactoring of code to improve compliance with coding guidelines
2008-09-07
- Improvements to CSS and Javascript.
- #263139: Fix - Implemented workaround for issue with SMTP module
- #268439: Doc - Added additional information about theming to README file.
- Feature - Watcher now adds a log entry to Watchdog every time cron notifications
are successfully sent.
2008-09-06
- #299605: Fix - Fixed a bug stopping excerpt length from being changed.
- #263978: Fix - Fixed a bug making uid 0 being notified when anonymous
comment posting is allowed.
2008-08-19
- Clicking buttons on the testing page now works.
2008-04-26
- #251367: Fix -Fixed a bug that manifested itself when posting comments.
- Cosmetic fix, added margin below the start watching link so that the link
to the user's binder is displayed nicely.
- #251367: Fix - handles hook_comment being passed comments as arrays *and* objects.
2008-04-23
- Fixed bug with quotes in comment text being encoded as HTML
character entity tags
- Fixed bug that caused a PHP error referring to array_flip()
- Updated .pot file
(These changes were carried out over the course of several weeks but
the changelog was lost in a hard drive crash, and they're therefore
noted here.)
(Dates are YYYY-MM-DD)

View file

@ -0,0 +1,274 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
verbatim copies of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to
share and change it. By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change free software--to
make sure the software is free for all its users. This General Public License
applies to most of the Free Software Foundation's software and to any other
program whose authors commit to using it. (Some other Free Software
Foundation software is covered by the GNU Library General Public License
instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the
freedom to distribute copies of free software (and charge for this service if
you wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for
a fee, you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must show
them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems
introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such
program or work, and a "work based on the Program" means either the
Program or any derivative work under copyright law: that is to say, a work
containing the Program or a portion of it, either verbatim or with
modifications and/or translated into another language. (Hereinafter, translation
is included without limitation in the term "modification".) Each licensee is
addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program is
not restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made
by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the
Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such
modifications or work under the terms of Section 1 above, provided that you
also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in
part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print such
an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you distribute
them as separate works. But when you distribute the same sections as part
of a whole which is a work based on the Program, the distribution of the
whole must be on the terms of this License, whose permissions for other
licensees extend to the entire whole, and thus to each and every part
regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to
work written entirely by you; rather, the intent is to exercise the right to
control the distribution of derivative or collective works based on the
Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of a
storage or distribution medium does not bring the other work under the scope
of this License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1
and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above
on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for
noncommercial distribution and only if you received the program in object
code or executable form with such an offer, in accord with Subsection b
above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source code
means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and
installation of the executable. However, as a special exception, the source
code distributed need not include anything that is normally distributed (in
either source or binary form) with the major components (compiler, kernel,
and so on) of the operating system on which the executable runs, unless that
component itself accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with the
object code.
4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy,
modify, sublicense or distribute the Program is void, and will automatically
terminate your rights under this License. However, parties who have received
copies, or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it.
However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the
Program (or any work based on the Program), you indicate your acceptance
of this License to do so, and all its terms and conditions for copying,
distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms and
conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution
of the Program by all those who receive copies directly or indirectly through
you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In such
case, this License incorporates the limitation as if written in the body of this
License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will be
similar in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that
version or of any later version published by the Free Software Foundation. If
the Program does not specify a version number of this License, you may
choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of
preserving the free status of all derivatives of our free software and of
promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,253 @@
Watcher Module for Drupal 6.x
Feature overview
* Lets users watch nodes for changes or new comments being posted without
having to post themselves.+
* Uses AJAX to toggle watching for a smooth user experience.
* Allows both anonymous and registered users to watch nodes.
* Supports email notifications being sent when both or either of the
above occurs.
* Template-based notification messages using the Token module - edit the
templates to your liking!
* Provides a binder with an overview of the nodes you watch. From the
binder you can also toggle email notifications for each node you watch.
* Users may choose to publish the binder so that other users can see what
they're watching, providing a form of social bookmarking.
* Uses a queue-based email dispatcher to handle large numbers of notifications.
* Users can opt to automatically watch nodes they create or comment on.
* User settings can have default values, set by the site owner, that can be
customized and overridden by the user.
* Highly customizable, configurable user interface and themeable.
* Designed with usability and exceptional user experience as a high priority.
Watcher was developed to fill a gap that has existed for a long time. Even
though there are several subscription and notification modules out there,
none is both easy to use or particularly specialized and allows instant
(or near instant) notifications. Watcher is not a general solution to
notifications but caters to the needs of community sites.
+Added in the Drupal 6 version.
Requirements
------------
To install this version of Watcher you need:
* Drupal 6.x
* Comments module (included in Drupal)
* Node module (included in Drupal)
* Token module (http://drupal.org/project/token)
There's a version for Drupal 5 as well, available from:
http://drupal.org/project/watcher
Installation
------------
To install Watcher, do the following:
1. Download, install and configure the Token module, follow the
instructions for that module.
2. Download the latest stable version of Watcher from its project
page: http://drupal.org/project/watcher
3. Unpack the file you downloaded into sites/all/modules or the
modules directory of your site.
4. Go to Administer » Site building » Modules and enable the module.
5. Go to Administer » Site configuration » Watcher and select at least
one content type for the module.
NOTE: The module will not work and users will not be able to watch
posts unless you select at least *one* content type.
Click "Save configuration" to save your changes.
Upgrading from Drupal 5
-----------------------
If you've been using a previous version of Watcher, make sure you go to update.php
and run the update script after uploading the new module files.
Issues
------
In case Watcher does not appear to work for anonymous users even though the
role Anonymous has been granted the necessary permissions, your users table
may be missing the anonymous user.
To fix this, first empty your site's cache. You can do that by going to
Administration » Site Settings » Performance
Secondly, make sure there's a row with uid 0 in your site's users table.
You can confirm that by executing this SQL query:
SELECT * FROM `users` WHERE uid = 0;
The query should return exactly one row. If no row is returned, the row is
missing and must be restored. Execute this query to add the row:
INSERT INTO `users` VALUES (0, '', '', '', 0, 0, 0, '', '', 0, 0, 0, 0, NULL, '', '', '', NULL);
See: http://drupal.org/node/370459
CAPTCHA support and preventing spam
-----------------------------------
Since Watcher now supports anonymous users watching nodes, CAPTCHA support has
been added to help prevent spam submissions. Download CAPTCHA module:
http://www.drupal.org/project/captcha
Watcher is known to work with CAPTCHA 6.x-1.0-rc2 and probably also all subsequent
6.x-1.0 release. Compatibility with 6.x-2.0 and later is not confirmed at this point.
Install CAPTCHA and set up its permissions as needed. Then go to:
admin/user/captcha/captcha/captcha_point
Enter "_watcher_watch_toggle_anonymous_form" (quotation marks omitted) in the
"Form ID" field. Select a challenge type and save the form. CAPTCHA will now display
the challenge you selected when anonymous users want to start watching a node.
To implement a first line of defense against spambots you can use the Bad Behavior
module. It uses heuristics to determine whether the browser is a genuine
human-controlled software application or an automated spambot:
http://drupal.org/project/badbehavior
Configuration
-------------
The module can be configured by going to:
Administer » Site configuration » Watcher
You can customize a wide range of options. Most of this is quite straight-forward
however some things may require an explanation.
Under "Settings for Email Notifications" you can choose what method to use for
sending emails. This will have an impact on how many messages are sent at once.
Watcher stores notifications to be sent in a message queue and every time messages
are sent they're taken off the queue. The method affects when the queue messages are
actually sent, it can either happen when cron and cron.php is being run or when a
user posts a comment.
If there are many messages in the queue, the best setting to use is cron and making
sure cron is run frequently enough that the entire queue is being processed. You can
change the time limit for message sending. The server will send as many messages as
possible during this interval. Any messages left unsent will remain in the queue
until it is processed again.
You may also modify the notification message templates that are used to generate the
notification messages. You can use placeholder tokens to insert the content that
changes, such as recipient name and comment excerpt.
Watcher also allows every user on your site to customize how the module works for them.
Users may enable or disable email notifications and make it so that they automatically
watch every post they make or comment on. Users who have not yet altered these settings
will be affected by the user settings defaults. These default settings apply until a
user goes to his or her settings page for Watcher and clicks "Save".
The page titled Statistics shows some basic statistics about the module which may be of
interest to you as a site owner. If there are unsent messages in the message queue,
these can be viewed here as well.
The Testing page allows you to do testing in case notification messages are not being
delivered. You can create test messages that are sent to your own email address.
Retroactively add existing posts
--------------------------------
If you have a large site and a large quantity of nodes/posts you may want to add the
existing nodes your users have made or commented on to their watched posts lists.
You can do this by running the SQL queries below. The queries below will do the
following:
- add all posts a user has created to his/her watched posts list
- add the nodes belonging to every comment a user has made to his/her watched posts list
CAUTION: Make a database dump to keep as a backup copy before attempting this!
CAUTION: The following has only been tested with MySQL 5!
INSERT IGNORE INTO watcher_nodes (uid, nid, send_email, added) SELECT uid, nid, 1, UNIX_TIMESTAMP() FROM node;
INSERT IGNORE INTO watcher_nodes (uid, nid, send_email, added) SELECT uid, nid, 1, UNIX_TIMESTAMP() FROM comments;
Theming
-------
Watcher is entirely themable. Open watcher.module in your editor to see what
theme functions are available to be overridden. The functions are documented in
detail in the code.
Themable functions of interest:
* watcher_binder($intro_text, $posts_table_header, $posts_table_body)
* watcher_binder_email_icon($t, $type, $url, $dest)
* watcher_binder_stop_watching_icon($url, $dest)
* watcher_node_toggle_watching_link($uid, $nid, $dest, $user_is_watching)
* watcher_help_page($content)
Watcher outputs the watcher link at the end of the node's body by default. A future
feature will be to make this configurable, allowing the link to be output in the
node's links section, at the beginning or end of body or in a separate template
variable. Until then, you can use the following method to separate the watcher link
from the node's body.
In node.tpl.php, to display the watcher link:
<?php if($node->content['watcher']['#value']): ?>
<div class="node_watcher">
<?php print $node->content['watcher']['#value']; ?>
</div>
<?php endif; ?>
And the node's body:
<div class="content">
<div class="content_description"><?php print $node->content['body']['#value']; ?></div>
</div>
For more info, please see: http://drupal.org/node/11816
Terminology
-----------
I have tried to consistently use the term "post" in the parts of the module that
the end users see as it makes way more sense to non-Drupallers than the word "node".
In the code comments and documentation, I've used the word "node" where I talk
about nodes.
The word "binder", is used interchangeable with the term "watched posts list". They're
exactly the same thing, "binder" is a term Hans Dekker of Wordsy.com suggested and it's
stayed in the module since its first versions.
Author
------
The module was developed by Jakob Persson <http://drupal.org/user/37564> of
NodeOne, Sweden's leading Drupal consulting firm. Our goal is to empower the
user by building usable, powerful and effective web solutions for our clients.
Visit us at http://www.nodeone.se
I am a developer that considers usability and user experience to be some of the
defining properties of successful software applications as well as devices and
appliances. I have a background in cognitive science and HCI and I work with
user experience and usability at NodeOne, building beautiful, usable
web sites and intranet applications for our clients.
The author can be contacted for paid customizations of this module as well as
Drupal consulting, installation, development and customizations.
Sponsors
--------
The development of this module has been sponsored by
* Wordsy <http://www.wordsy.com>
* NodeOne <http://www.nodeone.se>
Thanks
------
To Hans Dekker <http://www.hansdekker.com> for the idea as well as suggestions
and feedback.
Some of the icons were either taken directly from the Tango Icon Library or were
derived from Tango icons.
http://tango.freedesktop.org/

View file

@ -0,0 +1,127 @@
@CHARSET "UTF-8";
/**
* Intro text in binder
*/
#watcher_binder_intro {
margin: 1em 0;
}
/**
* Email notification status link in binder
*/
.watcher_binder_send_email_status_icon {
background-image: url(../images/send_email_disabled.gif);
background-repeat: no-repeat!important;
width: 47px;
height: 24px;
display: block;
padding-left: 47px;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 10px;
line-height: 1.2em;
}
.watcher_binder_send_email_status_icon_disabled {
background-image: url(../images/send_email_disabled.gif);
color: #c00!important;
}
.watcher_binder_send_email_status_icon_enabled {
background-image: url(../images/send_email_enabled.gif);
color: #0b0!important;
}
/*
Must be on hover or firefox will not play the animated GIFs asynchronously,
instead they'll all sync and loop at the same time.
The last frame of the GIFs lasts for 10 seconds to handle long latencies.
*/
.watcher_binder_send_email_status_icon_from_enabled_to_disabled:hover {
background-image: url(../images/send_email_from_enabled_to_disabled_ani.gif)!important;
}
.watcher_binder_send_email_status_icon_from_disabled_to_enabled:hover {
background-image: url(../images/send_email_from_disabled_to_enabled_ani.gif)!important;
}
/**
* Stop watching link in binder (watch list)
*/
.watcher_binder_stop_watching_icon {
background-image: url(../images/stop_watching.png);
background-repeat: no-repeat!important;
width: 100%;
height: 22px;
display: block;
text-indent: -300em;
}
/**
* Toggle watching link on nodes
*/
.watcher_node {
background-image: url(../images/unwatch.gif);
background-repeat: no-repeat!important;
background-position: 0% 50%;
padding-left: 22px;
padding-top: 0px;
padding-bottom: 3px;
margin: 0;
font-size: 13px;
height: 18px;
}
.watcher_node_watched {
background-image: url(../images/watch.gif)!important;
}
.watcher_node_toggle_watching_link {
display: block;
color: #5F5F5F!important;
}
.watcher_node_toggle_watching_link_watched {
color: #0c0!important;
font-weight: bold;
}
.watcher_node_toggle_watching_link_with_link_to_binder {
margin-bottom: 1.5em;
}
/** mini link, not currently used */
.watcher_node_toggle_watching_link_mini {
background-image: url(../images/watch.gif);
background-repeat: no-repeat!important;
font-size: 14px;
width: 16px;
height: 16px;
display: inline;
margin: 0 0 0 .5em;
}
.watcher_node_help_link_to_binder {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
margin-top: 15px;
}
/**
* Watcher Help Page
*/
#watcher_help_page dl dt {
font-weight: bold!important;
}
/**
* Defaults notice on user's settings page
*/
.watcher_settings_defaults_notice {
font-weight: bold;
padding: 1em 1em 1em 54px;
background: url(../images/important.png) no-repeat 8px 50%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 B

View file

@ -0,0 +1,166 @@
/**
* Watcher JavaScript
*
* By Jakob Persson of NodeOne
*/
/**
* Register Watcher behavior
*/
Drupal.behaviors.watcher = function (context) {
$('.watcher_binder_send_email_status_icon:not(.watcher-processed)', context)
.click( function () {
ajaxToggleEmailNotifications(this, this.href);
return false;
})
.addClass('watcher-processed');
$('.watcher_node_toggle_watching_link:not(.watcher-processed)', context)
.click( function () {
ajaxToggleWatchFade(this, this.href);
return false;
})
.addClass('watcher-processed');
}
/********************************************************************
* EMAIL NOTIFICATION TOGGLE
********************************************************************/
/**
* Handles the AJAX toggle request for email notifications
* @param {Object} el The element that triggered the request.
* @param {Object} url The URL to call.
*/
function ajaxToggleEmailNotifications(el, url) {
toggleEmailIconStatusAni(el, false);
$.ajax({
url: url,
type: 'GET',
data: { async : 'true' },
dataType: 'json',
timeout: 4000, //set very high to prevent time outs for users with high latency connections
success: function (json) {
toggleNotificationStatus(el, json);
},
complete: function (json) {
toggleEmailIconStatusAni(el, true);
}
});
}
/**
* Toggle email notification status icon
*
* @param {Object} el The element to modify
* @param {Object} rdata A JSON object containing the results of the AJAX request
*/
function toggleNotificationStatus(el, rdata) {
var string_text_enabled = Drupal.settings.watcher.binder_notif_text_enabled;
var string_text_disabled = Drupal.settings.watcher.binder_notif_text_disabled;
var string_title_enabled = Drupal.settings.watcher.binder_notif_title_enabled;
var string_title_disabled = Drupal.settings.watcher.binder_notif_title_disabled;
if (rdata['status'] == 'enabled') {
$(el).empty().append(string_text_enabled).attr('email_status','enabled').attr('title', string_title_enabled);
} else {
$(el).empty().append(string_text_disabled).attr('email_status','disabled').attr('title', string_title_disabled);
}
}
/**
* Display an animation to convey to the user that the action has not gone unnoticed
*
* @param {Object} el The element to modify
*/
function toggleEmailIconStatusAni(el, stop) {
if(stop) {
$(el).removeClass('watcher_binder_send_email_status_icon_from_disabled_to_enabled');
$(el).removeClass('watcher_binder_send_email_status_icon_from_enabled_to_disabled');
if($(el).attr('email_status')=='enabled') {
$(el).addClass('watcher_binder_send_email_status_icon_enabled');
$(el).removeClass('watcher_binder_send_email_status_icon_disabled');
} else {
$(el).addClass('watcher_binder_send_email_status_icon_disabled');
$(el).removeClass('watcher_binder_send_email_status_icon_enabled');
}
return true;
}
if($(el).attr('email_status')=='enabled') {
$(el).addClass('watcher_binder_send_email_status_icon_from_enabled_to_disabled');
} else {
$(el).addClass('watcher_binder_send_email_status_icon_from_disabled_to_enabled');
}
}
/********************************************************************
* WATCH TOGGLE
********************************************************************/
/**
* Handles the AJAX toggle request for watching
* @param {Object} el The element that triggered the request.
* @param {Object} url The URL to call.
*/
function ajaxToggleWatchFade(el, url) {
// Fade out the element
$(el).fadeTo(400, 0.01, function(){
ajaxToggleWatch(el, url)
});
}
/**
* Handles the AJAX toggle request for email notifications
* @param {Object} el The element that triggered the request.
* @param {Object} url The URL to call.
*/
function ajaxToggleWatch(el, url) {
$.ajax({
url: url,
type: 'GET',
data: { async : 'true' },
dataType: 'json',
timeout: 4000, //set very high to prevent time outs for users with high latency connections
success: function (json) {
toggleWatch(el, json);
},
error: function(json){
$(el).fadeTo(400, 1);
}
});
}
/***
* Toggle the watching of a node
*/
function toggleWatch(el, rdata) {
var string_text_enabled = Drupal.settings.watcher.watch_toggle_enabled;
var string_title_enabled = Drupal.settings.watcher.watch_toggle_enabled_title;
var string_text_disabled = Drupal.settings.watcher.watch_toggle_disabled;
var string_title_disabled = Drupal.settings.watcher.watch_toggle_disabled_title;
var string_watched_posts_link = Drupal.settings.watcher.watch_watched_posts_link;
if (rdata['status'] == 'enabled') {
$(el).empty().append(string_text_enabled).attr('title', string_title_enabled).addClass('watcher_node_toggle_watching_link_watched');
$(el).parent().addClass('watcher_node_watched');
}
else if (rdata['status'] == 'disabled') {
$(el).empty().append(string_text_disabled).attr('title', string_title_disabled).removeClass('watcher_node_toggle_watching_link_watched');
$(el).parent().removeClass('watcher_node_watched');
}
else {
$(el).parent().fadeOut('fast').replaceWith(rdata['data']).fadeIn('fast');
}
//Append link to user's list of watched posts if it doesn't already exist
var parent = $(el).parent();
if ($(parent).find('a.watcher_node_help_link_to_binder').length == 0) {
$(parent).addClass('watcher_node_toggle_watching_link_with_link_to_binder').append(string_watched_posts_link);
}
// Fade in, display the element again
$(el).fadeTo(400, 1);
}

View file

@ -0,0 +1,775 @@
# $Id: watcher.pot,v 1.1.2.4 2009/02/07 19:30:12 solipsist Exp $
#
# LANGUAGE translation of Drupal (general)
# Copyright YEAR NAME <EMAIL@ADDRESS>
# Generated from files:
# watcher.module,v 1.2.2.6.2.14 2009/01/30 11:07:32 solipsist
# watcher.info,v 1.2.4.1 2009/01/09 19:19:22 solipsist
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2009-02-07 19:05+0100\n"
"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: watcher.module:126
msgid "Stop watching"
msgstr ""
#: watcher.module:132
msgid "Stop watching this post."
msgstr ""
#: watcher.module:630
msgid "Watchable Content Types"
msgstr ""
#: watcher.module:631
msgid "Select the content types that may be watched."
msgstr ""
#: watcher.module:639
msgid "You haven't selected any watchable content types. This module will not work until you do so."
msgstr ""
#: watcher.module:653
msgid "Watch Toggle Link"
msgstr ""
#: watcher.module:660
msgid "Display \"watch this post\" toggle link in teasers."
msgstr ""
#: watcher.module:661
msgid "Determines whether or not to show the \"watch this post\" toggle link in node teasers (used on front page and content listings). Teasers are the shortened down version of a node, often shown on a site's frontpage or on pages that summarize content. If disabled, link will only be shown when nodes are shown as pages (full view)."
msgstr ""
#: watcher.module:669
msgid "Display Settings for Personal Binder"
msgstr ""
#: watcher.module:675
msgid "Click here to view your personal binder"
msgstr ""
#: watcher.module:680
msgid "Text at the top of the Personal Binder page"
msgstr ""
#: watcher.module:681
msgid "You are recommended to use this space to display <strong>brief</strong> information about what this page does and how it works to the user."
msgstr ""
#: watcher.module:688
msgid "Settings for the table of posts"
msgstr ""
#: watcher.module:693
msgid "Display Node Type Column"
msgstr ""
#: watcher.module:699
msgid "Display Last Updated Column"
msgstr ""
#: watcher.module:705
msgid "Display Post Author Column"
msgstr ""
#: watcher.module:713
msgid "Settings for Email Notifications"
msgstr ""
#: watcher.module:724
msgid "Enable Email Notifications"
msgstr ""
#: watcher.module:734
msgid "Messages are sent"
msgstr ""
#: watcher.module:735
msgid "You can select when messages are sent. Using \"on cron\", messages are sent when cron is being run, usually every hour depending on how you have configured crontab, this is preferred for large sites with hundreds of users or more. Using the second method, messages are sent right away for the time limit set (see below). Any messages that remain unsent will be sent next time messages are sent. The second method won't affect loading times since messages are sent after the page has been delivered to the user's browser."
msgstr ""
#: watcher.module:738
msgid "on cron (recommended for large sites)"
msgstr ""
#: watcher.module:739
msgid "instantaneously and for limited number of seconds (recommended for small to medium sites)"
msgstr ""
#: watcher.module:751
msgid "unlimited"
msgstr ""
#: watcher.module:756
msgid "Time limit for sending messages in seconds"
msgstr ""
#: watcher.module:757
msgid "This setting lets you specify for how many seconds messages should be sent and it applies to both methods. Any messages that remain unsent after this interval will be sent next time messages are sent. This setting will not make your site seem slower to visitors. The maximum value is the max execution time in your PHP configuration."
msgstr ""
#: watcher.module:765
msgid "Limit length of comment excerpt in notification email to"
msgstr ""
#: watcher.module:766
msgid "It may be wise not to send the entire comment as doing so will tease the user to go to your site to view it which results in traffic. Here you can select how much of the comment you want to include in the email. Percentages refer to the length of the comment. \"Nothing\" means no excerpt will be included in the message."
msgstr ""
#: watcher.module:769
msgid "nothing"
msgstr ""
#: watcher.module:770
msgid "25% of comment"
msgstr ""
#: watcher.module:771
msgid "50% of comment"
msgstr ""
#: watcher.module:772
msgid "75% of comment"
msgstr ""
#: watcher.module:773
msgid "100 characters of comment"
msgstr ""
#: watcher.module:774
msgid "200 characters of comment"
msgstr ""
#: watcher.module:775
msgid "300 characters of comment"
msgstr ""
#: watcher.module:776
msgid "400 characters of comment"
msgstr ""
#: watcher.module:777
msgid "entire comment"
msgstr ""
#: watcher.module:783
msgid "Notification Message Templates"
msgstr ""
#: watcher.module:784
msgid "These message templates are used for notifications and confirmation messages. You may edit them if you like. Tokens are in [brackets] and act as placeholders for variables, such as URLs, usernames and email addresses, and will be replaced when the email is sent. <strong>You cannot use HTML code in your message templates.</strong>"
msgstr ""
#: watcher.module:793
msgid "Message Header"
msgstr ""
#: watcher.module:795
msgid "<p>The text above will be prepended to every message sent. The following tokens are available:</p><ul><li>[recipient-username]</li><li>[recipient-user-settings-url]</li><li>[stop-watching-url]</li></ul>"
msgstr ""
#: watcher.module:800
msgid "Additional Tokens for Header"
msgstr ""
#: watcher.module:813
msgid "Message Footer"
msgstr ""
#: watcher.module:815
msgid "<p>The text above will be appended to every message sent. The following tokens are available:</p><ul><li>[recipient-username]</li><li>[recipient-user-settings-url]</li><li>[stop-watching-url]</li></ul>"
msgstr ""
#: watcher.module:820
msgid "Message Footer for Anonymous Users"
msgstr ""
#: watcher.module:822
msgid "<p>The text above will be appended to notification messages messages sent to anonymous users. The following tokens are available:</p><ul><li>[stop-watching-url]</li><li>[stop-watching-url]</li><li>[stop-watching-all-url]</li></ul>"
msgstr ""
#: watcher.module:827
msgid "Message Footer in Confirmation Messages"
msgstr ""
#: watcher.module:829
msgid "<p>The text above will be appended to confirmation messages sent to anonymous users when they start watching a node. Links for stopping watching this or every node the user watches and user's IP address are automatically prepended to this text.</p><ul><li>[user-ip]</li><li>[stop-watching-url]</li><li>[stop-watching-all-url]</li></ul>"
msgstr ""
#: watcher.module:834
msgid "Additional Tokens for Footers"
msgstr ""
#: watcher.module:847
msgid "Message Body for Node Updates"
msgstr ""
#: watcher.module:849
msgid "<p>The following tokens are available:</p><ul><li>[node-url]</li></ul>"
msgstr ""
#: watcher.module:854
msgid "Additional Tokens for Nodes"
msgstr ""
#: watcher.module:867
msgid "Message Body for New Comments"
msgstr ""
#: watcher.module:869
msgid "<p>The following tokens are available:</p><ul><li>[comment-excerpt]</li><li>[node-url]</li><li>[comment-url]</li><li>[comment-reply-url]</li></ul>"
msgstr ""
#: watcher.module:874
msgid "Additional Tokens for Comments"
msgstr ""
#: watcher.module:887
msgid "Message Body for Confirmation Messages"
msgstr ""
#: watcher.module:889
msgid "<p>The text above will be included in confirmation messages sent to anonymous users when they start watching a node.:</p><p>The following tokens are available:</p><ul><li>[node-url]</li></ul>"
msgstr ""
#: watcher.module:899
msgid "Default User Settings"
msgstr ""
#: watcher.module:900
msgid "These will set the defaults in every user's personal settings. Settings you make here will affect the settings of every user that hasn't customized his or her settings. This setting will currently affect <strong>!numusers</strong> users who have not customized their settings."
msgstr ""
#: watcher.module:909;1394
msgid "Automatically enable email notifications for posts that I start watching"
msgstr ""
#: watcher.module:910;1404
msgid "Send email notification when a post is updated or edited"
msgstr ""
#: watcher.module:911;1410
msgid "Send email notification when a post receives a new comment"
msgstr ""
#: watcher.module:912;1425
msgid "Automatically watch posts that I comment on"
msgstr ""
#: watcher.module:913;1431
msgid "Automatically watch posts that I make"
msgstr ""
#: watcher.module:914;1445
msgid "Share my list of watched posts"
msgstr ""
#: watcher.module:922
msgid "Help Page"
msgstr ""
#: watcher.module:923
msgid "This help text is displayed if the user clicks the Help link in the list of watched posts. You can customize it below. To apply your own CSS rules to this page you can use the <code>#watcher_help_page</code> selector."
msgstr ""
#: watcher.module:930
msgid "Text on Help Page"
msgstr ""
#: watcher.module:936
msgid "Preview help page"
msgstr ""
#: watcher.module:958
msgid "Notification Queue Table"
msgstr ""
#: watcher.module:963
msgid "Number of notifications in queue"
msgstr ""
#: watcher.module:964
msgid "Notification counter (some kind of indication of how many notifications that have been sent)"
msgstr ""
#: watcher.module:974
msgid "Table Content"
msgstr ""
#: watcher.module:975
msgid "This is the content of the notification queue table."
msgstr ""
#: watcher.module:985
msgid "There are no notifications in the queue."
msgstr ""
#: watcher.module:994
msgid "Watched Nodes Table"
msgstr ""
#: watcher.module:998
msgid "Number of registered users that watch nodes"
msgstr ""
#: watcher.module:999
msgid "Number of anonymous users that watch nodes"
msgstr ""
#: watcher.module:1013
msgid "User Settings Table"
msgstr ""
#: watcher.module:1017
msgid "Number of users that have changed their user settings"
msgstr ""
#: watcher.module:1018
msgid "Number of users that use default user settings"
msgstr ""
#: watcher.module:1041
msgid "Email notifications are NOT enabled. You can use the diagnostics tools anyway but regular notifications will not be sent."
msgstr ""
#: watcher.module:1046
msgid "If you're experiencing problems with the module such as messages not being delivered et c, you can use the diagnostic tools on this page to send test notifications. The <a href=\"!statpage\">statistics page</a> also contains valuable information for troubleshooting."
msgstr ""
#: watcher.module:1051
msgid "Create a Test Notification"
msgstr ""
#: watcher.module:1052
msgid "Click the buttons below to add a notification to the queue. A notification for a new comment will use content from the newest comment on the site. A notification for a node update will contain a link to the newest node on the site. Notifications will be sent to your email account (!usermail)."
msgstr ""
#: watcher.module:1057
msgid "Create test notification for node update"
msgstr ""
#: watcher.module:1063
msgid "Create test notification for new comment"
msgstr ""
#: watcher.module:1069
msgid "Send Notifications in Queue"
msgstr ""
#: watcher.module:1070
msgid "Notifications are stored in a queue. Depending on what method you have chosen in the <a href=\"!settings\">settings</a>, notifications are either delivered instantaneously (when a comment is posted or a node updated) or when cron is run."
msgstr ""
#: watcher.module:1076
msgid "Your currently selected method for sending notifications in queue is <strong>!method</strong>."
msgstr ""
#: watcher.module:1082
msgid "There are currently <strong>!num</strong> !notification_plural in the queue."
msgstr ""
#: watcher.module:1088
msgid "Click here to run cron manually and SEND messages in queue"
msgstr ""
#: watcher.module:1094
msgid "Click here to SEND messages in queue"
msgstr ""
#: watcher.module:1105
msgid "Click here to EMPTY queue"
msgstr ""
#: watcher.module:1125
msgid "TEST: Post has been updated"
msgstr ""
#: watcher.module:1127
msgid "A test notification (node update) has been created."
msgstr ""
#: watcher.module:1131
msgid "No nodes exist. You need to create at least one."
msgstr ""
#: watcher.module:1147
msgid "TEST: New comment posted"
msgstr ""
#: watcher.module:1149
msgid "A test notification (new comment) has been created."
msgstr ""
#: watcher.module:1153
msgid "No comments exist. You need to make at least one."
msgstr ""
#: watcher.module:1162
msgid "Notifications have been sent using instant method."
msgstr ""
#: watcher.module:1170
msgid "Watcher Notification Queue has been emptied."
msgstr ""
#: watcher.module:1200
msgid "!username's Watched Posts"
msgstr ""
#: watcher.module:1205
msgid "Click to Disable"
msgstr ""
#: watcher.module:1206
msgid "Click to Enable"
msgstr ""
#: watcher.module:1207
msgid "Email notifications for this post are ENABLED, click to disable"
msgstr ""
#: watcher.module:1208
msgid "Email notifications for this post are DISABLED, click to enable"
msgstr ""
#: watcher.module:1224
msgid "Type"
msgstr ""
#: watcher.module:1229
msgid "Post"
msgstr ""
#: watcher.module:1236
msgid "Author"
msgstr ""
#: watcher.module:1243
msgid "Post Added"
msgstr ""
#: watcher.module:1251
msgid "Last updated"
msgstr ""
#: watcher.module:1257
msgid "Comments"
msgstr ""
#: watcher.module:1261
msgid "Notifications"
msgstr ""
#: watcher.module:1266
msgid "Remove"
msgstr ""
#: watcher.module:1301;1305
msgid "!time ago"
msgstr ""
#: watcher.module:1331
msgid "No posts in the list - you should add some!"
msgstr ""
#: watcher.module:1331
msgid "!username's watched posts list is empty"
msgstr ""
#: watcher.module:1366
msgid "Settings for Watching Posts"
msgstr ""
#: watcher.module:1375
msgid "Your settings are currently defaults, as set by the site owner. Save these settings to customize them."
msgstr ""
#: watcher.module:1387
msgid "Email Notification Settings"
msgstr ""
#: watcher.module:1418
msgid "Watch Automatically"
msgstr ""
#: watcher.module:1437
msgid "Sharing"
msgstr ""
#: watcher.module:1438
msgid "By sharing your list of watched posts, other users can see it but they cannot remove or add posts or change it in any way."
msgstr ""
#: watcher.module:1456
msgid "Save my settings"
msgstr ""
#: watcher.module:1471
msgid "Help on Watching Posts"
msgstr ""
#: watcher.module:1539
msgid "%ntitle previously watched by %email is no longer being watched."
msgstr ""
#: watcher.module:1556
msgid "Are you sure you want to STOP watching all posts %email currently watches on this site? This action cannot be undone."
msgstr ""
#: watcher.module:1575
msgid "All posts on this site previously watched by %email are no longer being watched."
msgstr ""
#: watcher.module:1604
msgid "You are no longer watching <em>!ntitle</em>. <strong><a href=\"!undo\">Undo</a></strong>"
msgstr ""
#: watcher.module:1608;1617
msgid "We're sorry but you may not watch this type of post."
msgstr ""
#: watcher.module:1613
msgid "You are now watching <em>!ntitle</em>. <strong><a href=\"!undo\">Undo</a></strong>"
msgstr ""
#: watcher.module:1729
msgid "Post!nodetitlehas been updated!sitename"
msgstr ""
#: watcher.module:1802
msgid " about \"!nodetitle\""
msgstr ""
#: watcher.module:1804
msgid "New comment posted!aboutnodetitle!sitename"
msgstr ""
#: watcher.module:1875
msgid "for updates and new comments"
msgstr ""
#: watcher.module:1876
msgid "for new comments"
msgstr ""
#: watcher.module:1877
msgid "for updates"
msgstr ""
#: watcher.module:1880
msgid " \"!nodetitle\""
msgstr ""
#: watcher.module:1882
msgid "You are now watching!aboutnodetitle!forwhat!sitename"
msgstr ""
#: watcher.module:2064
msgid "You are watching this post, click to stop watching"
msgstr ""
#: watcher.module:2065
msgid "This post is being watched. You can track and change email notification setting for this post in your watched posts list (see your user profile)"
msgstr ""
#: watcher.module:2066
msgid "You are not watching this post, click to start watching"
msgstr ""
#: watcher.module:2067
msgid "Watch posts to be notified when other users comment on them or the posts are changed"
msgstr ""
#: watcher.module:2070
msgid "Go to your list of watched posts"
msgstr ""
#: watcher.module:2114
msgid "Settings saved."
msgstr ""
#: watcher.module:2843
msgid "The confirmation message contains your IP address so that in case of abuse the owner of the email account can identify who submitted the form."
msgstr ""
#: watcher.module:2851
msgid "Stop watching %title"
msgstr ""
#: watcher.module:2853
msgid "Enter your email address below to stop watching %title. The form will remember the email you enter until next time."
msgstr ""
#: watcher.module:2858
msgid "Watch %title"
msgstr ""
#: watcher.module:2860
msgid "Enter your email address below to start watching %title. The form will remember the email you enter until next time. Once you submit the form, a confirmation message will be sent to the email address entered. %ipinfo"
msgstr ""
#: watcher.module:2870
msgid "Your email address"
msgstr ""
#: watcher.module:2882
msgid "What to watch for"
msgstr ""
#: watcher.module:2884
msgid "Updates and new comments"
msgstr ""
#: watcher.module:2885
msgid "Only new comments"
msgstr ""
#: watcher.module:2886
msgid "Only updates"
msgstr ""
#: watcher.module:2889
msgid "Choose to be informed about new comments, updates (this post being changed) or both."
msgstr ""
#: watcher.module:2897
msgid "Watch"
msgstr ""
#: watcher.module:2897
msgid "Unwatch"
msgstr ""
#: watcher.module:3025
msgid "You are no longer watching %ntitle. <strong><a href=\"!undo\">Undo</a></strong>"
msgstr ""
#: watcher.module:3036
msgid "That email address is not associated with any user watching %ntitle"
msgstr ""
#: watcher.module:3044
msgid "updates and new comments"
msgstr ""
#: watcher.module:3045
msgid "new comments"
msgstr ""
#: watcher.module:3046
msgid "updates"
msgstr ""
#: watcher.module:3048
msgid "You are now watching %ntitle for !what. A message will be sent to the email address you entered (%email) to confirm this action."
msgstr ""
#: watcher.module:3081
msgid "You must enter a valid e-mail address."
msgstr ""
#: watcher.module:587;2715;2718;368 watcher.info:0
msgid "Watcher"
msgstr ""
#: watcher.module:587
msgid "Notifications were sent on cron."
msgstr ""
#: watcher.module:2715
msgid "Watcher has successfully sent !notifications using the !method method."
msgstr ""
#: watcher.module:2718
msgid "Watcher failed to send notifications using the !method method."
msgstr ""
#: watcher.module:1082
msgid "notification"
msgid_plural "notifications"
msgstr[0] ""
msgstr[1] ""
#: watcher.module:2430
msgid "1 new"
msgid_plural "@count new"
msgstr[0] ""
msgstr[1] ""
#: watcher.module:2715
msgid "1 notification"
msgid_plural "@count notifications"
msgstr[0] ""
msgstr[1] ""
#: watcher.module:253
msgid "administer watcher"
msgstr ""
#: watcher.module:253
msgid "use watcher"
msgstr ""
#: watcher.module:253
msgid "access others' lists of watched posts"
msgstr ""
#: watcher.module:287;402
msgid "My Watched Posts"
msgstr ""
#: watcher.module:296
msgid "Watched Posts"
msgstr ""
#: watcher.module:306;377
msgid "Settings"
msgstr ""
#: watcher.module:316
msgid "Help"
msgstr ""
#: watcher.module:327
msgid "Watcher Toggle Watching Post"
msgstr ""
#: watcher.module:336
msgid "Watcher Toggle Email Notifications"
msgstr ""
#: watcher.module:369
msgid "Modify the settings for Watcher module."
msgstr ""
#: watcher.module:385
msgid "Statistics"
msgstr ""
#: watcher.module:393
msgid "Testing"
msgstr ""
#: watcher.module:0
msgid "watcher"
msgstr ""
#: watcher.info:0
msgid "Watcher enables your site's users to watch nodes for changes and new comments and be notified about them."
msgstr ""
#: watcher.info:0
msgid "Other"
msgstr ""

View file

@ -0,0 +1,659 @@
<?php
// $Id: watcher.db.inc,v 1.1.2.1.2.10 2009/07/10 15:58:06 solipsist Exp $
/**
* Watcher Module
* by Jakob Persson of NodeOne <jakob@nodeone.se>
* With ideas and feedback from Hans Dekker of Wordsy.com
*
* are updated or commented on.
*
* Sponsored by
* Wordsy - www.wordsy.com
* NodeOne - www.nodeone.se
*/
/***************************************************************************************
* DECLARATION OF CONSTANTS
***************************************************************************************/
// Values for "watch_for" column in database
define('WATCHER_WATCH_FOR_ALL', 1);
define('WATCHER_WATCH_FOR_COMMENTS', 2);
define('WATCHER_WATCH_FOR_UPDATES', 3);
/***************************************************************************************
* DATABASE FUNCTIONS
***************************************************************************************/
/**
* Returns a wealth of information on the nodes a user is watching
* Results are pageable
*
* @param $user
* User object of the user whose binder we want posts for
* @param $header
* The table header array, used for table sorting
* @return
* A paged database result resource
*/
function _watcher_db_get_watched_nodes_full($user = false, $header = null) {
// Taken from tracker.module
// TODO: These queries are very expensive, see http://drupal.org/node/105639
if ($user->uid) {
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, wn.send_email, wn.added, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {watcher_nodes} wn ON n.nid = wn.nid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND wn.uid = %d';
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) INNER JOIN {watcher_nodes} wn ON n.nid = wn.nid WHERE n.status = 1 AND wn.uid = %d AND wn.uid = %d';
if ($header) {
$sql .= tablesort_sql($header);
}
$sql = db_rewrite_sql($sql);
$sql_count = db_rewrite_sql($sql_count);
$result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $user->uid, $user->uid, $user->uid);
return $result;
}
}
/**
* Returns minimal information on the nodes a user is watching
*
* @param $user
* User object of the user whose watched posts we want
*
* @return
* A database result resource
*/
function _watcher_db_get_watched_nodes_mini($user) {
if ($user->uid) {
$sql = 'SELECT DISTINCT(nid) FROM {watcher_nodes} WHERE uid = %d';
}
else {
$sql = "SELECT DISTINCT(nid) FROM {watcher_nodes} WHERE mail = '%s'";
}
$result = db_query($sql, ( $user->uid ? $user->uid : $user->mail ));
return $result;
}
/**
* Get NIDs by UID
* see what posts a user is watching
*
* @param $uid
* UID - a user id.
* @return
* A database result set of matching table rows.
*/
function _watcher_db_get_nids_by_uid($uid) {
$sql = 'SELECT nid FROM {watcher_nodes} WHERE uid = %d';
$result = db_query($sql, $uid);
while($row = db_fetch_object($result)) {
return $result;
}
return false;
}
/**
* Get UIDs by NID
* see what users are watching a post
*
* @param $nid
* NID - a node id.
* @return
* A database result set of matching table rows.
*/
function _watcher_db_get_uids_by_nid($nid) {
$sql = 'SELECT uid FROM {watcher_nodes} WHERE nid = %d';
$result = db_query($sql, $nid);
while ($row = db_fetch_object($result)) {
return $result;
}
return false;
}
/**
* Get NIDs by user
* see what posts a user is watching
*
* @param $user
* A user object
* @return
* An array of NIDs with NIDs as keys and values
*/
function _watcher_db_get_nids_by_user($user) {
if ($user->uid) {
$sql = 'SELECT nid FROM {watcher_nodes} WHERE uid = %d';
$result = db_query($sql, $user->uid);
}
else {
$sql = "SELECT nid FROM {watcher_nodes} WHERE mail = '%s'";
$result = db_query($sql, $user->mail);
}
while ($row = db_fetch_object($result)) {
$nids[$row->nid] = $row->nid;
}
return $nids;
}
/**
* Is user watching NID
* check if a specific user is watching the given node
*
* @param $user
* A user object.
* @param $nid
* A node NID
*
* @return
* A database result set of matching table rows.
*/
function _watcher_db_get_user_nid($user, $nid) {
if (!$user->uid) {
$sql = "SELECT mail FROM {watcher_nodes} WHERE mail = '%s' AND nid = %d";
$result = db_query($sql, $user->mail, $nid);
}
else {
$sql = 'SELECT uid FROM {watcher_nodes} WHERE uid = %d AND nid = %d';
$result = db_query($sql, $user->uid, $nid);
}
while($row = db_fetch_object($result)) {
return $result;
}
return false;
}
/**
* Add NID to UID's watch list, enable email notifications if desired
*
* @param $nid
* The nid of the node the users is going to watch
* @param $user
* A user object
* @param $what
* A string indicating what an anonymous user watches for: all, comments, updates
*
* @return
* Boolean true on success
*/
function _watcher_db_set_nid_user($nid, $user, $what = null) {
if (!$user->uid) {
// If the user is anonymous, we first remove any already existing rows and replace
// them to allow the user to alter previously set watches
$sql = "DELETE FROM {watcher_nodes} WHERE nid = %d AND uid = %d AND mail = '%s'";
db_query($sql, $nid, $user->uid, $user->mail);
}
if ($what) {
// Mapping integers to strings
$for['all'] = WATCHER_WATCH_FOR_ALL;
$for['comments'] = WATCHER_WATCH_FOR_COMMENTS;
$for['updates'] = WATCHER_WATCH_FOR_UPDATES;
$sql = "INSERT INTO {watcher_nodes} (uid, mail, nid, added, watch_for) VALUES(%d, '%s', %d, %d, %d)";
$res = db_query($sql, $user->uid, $user->mail, $nid, time(), $for[$what]);
}
else {
$sql = "INSERT INTO {watcher_nodes} (uid, nid, added) VALUES(%d, %d, %d)";
$res = db_query($sql, $user->uid, $nid, time());
}
return $res;
}
/**
* Remove NIDs from the UID's watch list
* @param $nids
* Array of node NIDs
* @param $user
* A user object.
*
* @return
* A boolean indicating success/failure
*/
function _watcher_db_delete_nids_user($nids, $user) {
if (!count($nids)) {
return;
}
$sql_in = implode(',', $nids);
if (!$user->uid) {
$sql = "DELETE FROM {watcher_nodes} WHERE mail = '%s' AND nid IN(%s)";
$res = db_query($sql, $user->mail, $sql_in);
}
else {
$sql = 'DELETE FROM {watcher_nodes} WHERE uid = %d AND nid IN(%s)';
$res = db_query($sql, $user->uid, $sql_in);
}
return (bool) db_affected_rows();
}
/**
* Delete a node from the watch list
* @param $nid
* NID of node to delete
* @return
* Boolean of success or failure
*/
function _watcher_db_delete_nid($nid) {
$sql = 'DELETE FROM {watcher_nodes} WHERE nid = %d';
$res = db_query($sql, $nid);
return (bool) $res;
}
/**
* Remove all NIDs on UID's watch list
* @param $uid
* UID - a user id.
* @return
* A boolean indicating success/failur
*/
function _watcher_db_delete_uid($uid) {
$sql = 'DELETE FROM {watcher_nodes} WHERE uid = %d';
$res = db_query($sql, $uid);
return (bool) $res;
}
/**
* Get email notification status given UID and NID
*
* @param $uid
* UID - a user id.
* @param $nid
* NID - a node id.
* @return
* Boolean True if email notifications are enabled for this user and node
*/
function _watcher_db_get_send_email_status($nid, $uid) {
$sql = 'SELECT send_email FROM {watcher_nodes} WHERE uid = %d AND nid = %d';
$result = db_query($sql, $uid, $nid);
$row = db_fetch_object($result);
if ($row->send_email) return true;
return false;
}
/**
* Set email notification status given NID and UID
*
* @param $nid
* NID - a node id
* @param $user
* A user object
* @param $send_email
* A boolean integer, 1 or 0
* @return
* Boolean denoting success/failure.
*/
function _watcher_db_set_send_email_status($nid, $user, $send_email = 0) {
if ($user->uid) {
$sql = 'UPDATE {watcher_nodes} SET send_email = %d WHERE uid = %d AND nid = %d';
$res = db_query($sql, $send_email, $user->uid, $nid);
}
else {
$sql = "UPDATE {watcher_nodes} SET send_email = %d WHERE mail = '%s' AND nid = %d";
$res = db_query($sql, $send_email, $user->mail, $nid);
}
return ((bool) $res);
}
/**
* Save user settings to database
*
* @param $uid
* A user UID
* @param $settings
* An associative array of user settings
* @return
* Boolean true on success
*/
function _watcher_db_set_user_settings($uid, $settings) {
//Add custom field to mark these user settings as custom
$settings['custom'] = 1;
//Serialize settings
$fields = implode(', ', array_keys($settings));
$values = implode(', ', array_values($settings));
// First delete existing settings
$sql = 'DELETE FROM {watcher_user_settings} WHERE uid = %d';
db_query($sql, $uid);
// Insert new settings
$sql = 'INSERT INTO {watcher_user_settings} (uid, %s) VALUES (%d, %s)';
$res = db_query($sql, $fields, $uid, $values);
return (bool) $res;
}
/**
* Delete user settings for given UID
*
* @param $uid
* A user UID
* @return
* Boolean True on success
*/
function _watcher_db_delete_user_settings($uid) {
$sql = 'DELETE FROM {watcher_user_settings} WHERE uid = %d';
$res = db_query($sql, $uid);
return (bool) $res;
}
/**
* Load user settings from database
*
* @param $uid
* A user UID
* @return
* An assoc array of user settings
*/
function _watcher_db_get_user_settings($uid) {
// Cache settings
static $settings;
if (!isset($settings)) {
$sql = 'SELECT * FROM {watcher_user_settings} WHERE uid = %d';
$result = db_query($sql, $uid);
while($row = db_fetch_array($result)) {
unset($row['uid']);
$settings = $row;
return $settings;
}
$settings = false;
}
return $settings;
}
/**
* Updates the default settings for all users who haven't customized their settings
*
* @param $settings
* An associative array of settings
* @return
* A boolean true on success
*/
function _watcher_db_user_settings_update_defaults($settings) {
// Users may have registered and not had settings set yet so add rows for any users that are "missing"
$sql = 'INSERT INTO {watcher_user_settings} (uid) SELECT u.uid FROM {users} u LEFT JOIN {watcher_user_settings} wus ON u.uid = wus.uid WHERE ISNULL(custom)';
$res = db_query($sql);
// If defaults are set, apply them, otherwise return
if (is_array($settings)) {
// Format settings array as string
foreach ($settings as $setting => $value) {
$insert_array[] = $setting .'='. $value;
}
$insert_string = implode(', ', $insert_array);
// Update all users who haven't customized their settings yet
$sql = 'UPDATE {watcher_user_settings} SET %s WHERE custom <> 1';
$res = db_query($sql, $insert_string);
}
return (bool) $res;
}
/**
* Has UID customized his/her user settings?
*
* @param $uid
* A user UID
* @return
* A boolean true if given UID has customized his/her user settings
*/
function _watcher_db_user_settings_uid_custom($uid) {
$sql = 'SELECT custom FROM {watcher_user_settings} WHERE uid = %d AND custom = 1';
$res = db_query($sql, $uid);
while($row = db_fetch_object($res)) {
return true;
}
return false;
}
/**
* Return a list of users that want to get notified about node updates for given NID
*
* @param $nid
* The NID of the node that has been updated
* @param $uid_exclude
* A UID we want to exclude from our set of users, normally the user that updated the node.
* @return
* An array of objects with uid as key representing users, with attributes uid, mail and name
*/
function _watcher_db_get_users_notify_node_update($nid, $uid_exclude) {
$sql = "SELECT wn.uid, wn.mail wnmail, u.mail umail, u.name FROM {watcher_nodes} wn LEFT JOIN {watcher_user_settings} wus ON wus.uid = wn.uid LEFT JOIN {users} u ON u.uid = wus.uid WHERE nid = %d AND ((wn.uid <> 0 AND wn.uid <> %d AND notifications_updates = 1 AND send_email = 1) OR (wn.uid = 0 AND (watch_for = 1 OR watch_for = 3)))";
$res = db_query($sql, $nid, $uid_exclude);
$users = array();
while ($row = db_fetch_object($res)) {
$users[$row->uid] = $row;
}
return $users;
}
/**
* Return a list of users that want to get notified about new comments for given NID
*
* @param $nid
* The nid of the node the comment belongs to
* @param $uid_exclude
* A uid we want to exclude from our set of users, normally the user that wrote the comment,
* what's the point in being notified about your own comments, eh?
*
* @return
* An array of objects with uid as key representing users, with attributes uid, mail and name
*/
function _watcher_db_get_users_notify_comment_insert($nid, $uid_exclude) {
$sql = 'SELECT wn.uid, wn.mail wnmail, u.mail umail, u.name FROM {watcher_nodes} wn LEFT JOIN {watcher_user_settings} wus ON wus.uid = wn.uid LEFT JOIN {users} u ON u.uid = wus.uid WHERE nid = %d AND ((wn.uid <> 0 AND wn.uid <> %d AND notifications_new_comments = 1 AND send_email = 1) OR (wn.uid = 0 AND (watch_for = 1 OR watch_for = 2)))';
$res = db_query($sql, $nid, $uid_exclude);
$users = array();
while ($row = db_fetch_object($res)) {
$users[] = $row;
}
return $users;
}
/**
* Return a list of users that want to get notified about node updates or new comments
* for a given NID
*
* @param $nid
* The nid of the node that has been updated
* @param $uid_exclude
* A uid we want to exclude from our set of users, normally the user that updated the node.
*
* @return
* An array of objects with uid as key representing users, with attributes uid, mail and name
*/
function _watcher_db_get_users_notify_about_node($nid, $uid_exclude) {
$sql = 'SELECT wn.uid, wn.mail wnmail, u.mail umail, u.name FROM {watcher_nodes} wn LEFT JOIN {users} u ON u.uid = wn.uid WHERE nid = %d AND ((wn.uid <> 0 AND wn.uid <> %d AND send_email = 1) OR (NOT ISNULL(watch_for)))';
$res = db_query($sql, $nid, $uid_exclude);
$users = array();
while ($row = db_fetch_object($res)) {
$users[$row->uid] = $row;
}
return $users;
}
/**
* Add a message to the notification queue table
*
* @param $qid
* A qid (table pk) generated by db_next_id()
* @param $r_uid
* Recipient uid
* @param $r_email
* Recipient email address
* @param $subject
* The message subject
* @param $message
* Message to be sent
* @return
* A database result resource
*/
function _watcher_db_insert_users_notification_queue($r_uid, $r_email, $subject, $message) {
$sql = "INSERT INTO {watcher_notify_queue} (uid, mail, subject, message) VALUES (%d, '%s', '%s', '%s')";
$res = db_query($sql, $r_uid, $r_email, $subject, $message);
return (bool) $res;
}
/**
* Delete all rows in notification queue table
*
* @return
* A boolean denoting whether any rows were deleted, false if none, true if one or more
*/
function _watcher_db_delete_users_notification_queue_all() {
$sql = "DELETE FROM {watcher_notify_queue}";
$res = db_query($sql);
return (bool) $res;
}
/**
* Get messages from the notification queue table
*/
function _watcher_db_get_users_notification_queue() {
$sql = "SELECT * FROM {watcher_notify_queue}";
$res = db_query($sql);
while ($qmsg = db_fetch_object($res)) {
$qmsgs[] = $qmsg;
}
return $qmsgs;
}
/**
* Delete a set of rows from the notification queue table
*
* @param $rows
* An array of qids (queue id)
*/
function _watcher_db_delete_users_notification_queue($qids) {
// Database managers can only handle *finite* (gulp!) SQL queries
// so we gotta limit the fun
$limit = 4096; //2^12 elements
$offset = 0;
for ($i = 1; $offset < count($qids); $i++) {
$batch = array_slice($qids, $offset, $limit);
$in = implode(',', $batch);
$sql = "DELETE FROM {watcher_notify_queue} WHERE qid IN (%s)";
db_query($sql, $in);
$offset = (($i * $limit) - 1);
}
}
/**
* Statistics for Notification Queue Table
*
* @return
* An assoc array with keys num_rows and num_sent
*/
function _watcher_db_stats_notification_queue() {
$sql = 'SELECT * FROM {watcher_notify_queue}';
$sql2 = 'SELECT MAX(qid) FROM {watcher_notify_queue}';
$sql3 = 'SELECT COUNT(*) FROM {watcher_notify_queue}';
// Obtain number of rows
$res = db_query($sql3);
$stat['num_rows'] = db_result($res);
// Obtain the contents of the queue table
$res = db_query($sql);
while ($row = db_fetch_object($res)) {
// Load fields
$data['qid'] = $row->qid;
$data['uid'] = $row->uid;
$data['mail'] = $row->mail;
$data['subject'] = $row->subject;
$data['message'] = '<pre>'. $row->message .'</pre>';
// Add to data array
$stat['data']['content'][] = $data;
}
// Add header
$stat['data']['header'] = array('qid', 'uid', 'mail', 'subject', 'message');
// Obtain the number of notifications sent - this is not 100% accurate since we cannot
// entirely trust the increment counter
$res2 = db_query($sql2);
$num_sent = db_result($res2);
$stat['num_sent'] = ( $num_sent = db_result($res2) ? $num_sent : 0 );
if ($res) {
return $stat;
}
return false;
}
/**
* Statistics for Watched Nodes Table
* Numbers of users that watch nodes
*
* @return
* An assoc array with key num_users
*/
function _watcher_db_stats_watched_nodes_users() {
$sql = 'SELECT COUNT(DISTINCT(uid)) FROM {watcher_nodes} WHERE uid <> 0';
$sql2 = 'SELECT COUNT(DISTINCT(mail)) FROM {watcher_nodes} WHERE uid = 0';
// Obtain number of rows
$res = db_query($sql);
$stat['num_users_reg'] = db_result($res);
$res2 = db_query($sql2);
$stat['num_users_anon'] = db_result($res2);
if ($res && $res2) return $stat;
return false;
}
/**
* Statistics for User Settings Table
*
* @return
* An assoc array with key num_users_with_settings, num_users and num_users_no_settings
*/
function _watcher_db_stats_user_settings() {
// Users with custom settings
$sql = 'SELECT COUNT(uid) FROM {watcher_user_settings} WHERE custom = 1';
// Total number of users on the site
$sql2 = 'SELECT COUNT(uid) FROM {users} WHERE uid <> 0';
// Obtain number of users with settings
$res = db_query($sql);
$stat['num_users_with_settings'] = db_result($res);
// Obtain number of users without setting
$res2 = db_query($sql2);
$stat['num_users'] = db_result($res2);
$stat['num_users_no_settings'] = $stat['num_users'] - $stat['num_users_with_settings'];
if ($res) return $stat;
return false;
}
/**
* Return the newest node
*/
function _watcher_db_get_newest_node() {
$sql = 'SELECT nid FROM {node} ORDER BY created DESC LIMIT 0,1';
$res = db_query($sql);
if ($nid = db_result($res)) {
return $nid;
}
return false;
}
/**
* Return the newest comment
*/
function _watcher_db_get_newest_comment() {
$sql = 'SELECT cid FROM {comments} ORDER BY timestamp DESC LIMIT 0,1';
$res = db_query($sql);
if ($cid = db_result($res)) {
return $cid;
}
return false;
}

View file

@ -0,0 +1,14 @@
; $Id: watcher.info,v 1.2.4.2 2009/02/26 17:03:48 solipsist Exp $
name = "Watcher"
description = "Watcher enables your site's users to watch nodes for changes and new comments and be notified about them."
package = Other
core = 6.x
dependencies[] = node
dependencies[] = token
dependencies[] = comment
; Information added by drupal.org packaging script on 2010-10-26
version = "6.x-1.4"
core = "6.x"
project = "watcher"
datestamp = "1288126235"

View file

@ -0,0 +1,250 @@
<?php
// $Id: watcher.install,v 1.1.2.1.2.11 2009/07/13 12:19:32 solipsist Exp $
/**
* @file
* Watcher module installer.
*
* Watcher Module
* by Jakob Persson of NodeOne <jakob@nodeone.se>
* With ideas and feedback from Hans Dekker of Wordsy.com
*
* Module allows users to watch nodes and receive notifications when nodes
* are updated or commented on.
*
* Sponsored by
* Wordsy - www.wordsy.com
* NodeOne - www.nodeone.se
*/
/**
* Implementation of hook_install()
*/
function watcher_install() {
if (db_table_exists('watcher_nodes') && db_table_exists('watcher_notify_queue') && db_table_exists('watcher_user_settings')) {
drupal_set_message("Watcher's tables already exist in the database, this indicates Watcher has been installed previously. You can probably go ahead and use Watcher without any further actions.");
return;
}
if (drupal_install_schema('watcher')) {
drupal_set_message('Watcher was successfully installed.');
}
}
/**
* Implementation of hook_uninstall()
*/
function watcher_uninstall() {
// Uninstall schemas
drupal_uninstall_schema('watcher');
// Empty site cache
cache_clear_all('*', 'cache', true);
cache_clear_all('*', 'cache_filter', true);
cache_clear_all('*', 'cache_menu', true);
cache_clear_all('*', 'cache_page', true);
// Clear variables
db_query("DELETE FROM {variable} WHERE name LIKE('%s%%') ", 'watcher_');
cache_clear_all('variables', 'cache');
}
/**
* Updates 5.x -> 6.x-1.0
*/
function watcher_update_6000() {
$ret = array();
db_add_field($ret, 'watcher_nodes', 'mail', array('type' => 'varchar', 'length' => 128, 'default' => null));
db_drop_primary_key($ret, 'watcher_nodes');
db_add_primary_key($ret, 'watcher_nodes', array('uid', 'nid', 'mail'));
return $ret;
}
function watcher_update_6001() {
$ret = array();
db_add_field($ret, 'watcher_nodes', 'watch_for', array('type' => 'int', 'size' => 'tiny', 'default' => null));
return $ret;
}
function watcher_update_6002() {
$ret = array();
$schema = watcher_schema();
foreach ($schema as $table => $table_definition) {
if ($table == 'watcher_user_settings') {
foreach ($table_definition as $property => $property_definition) {
if ($property == 'fields') {
foreach ($property_definition as $field => $field_definition) {
if ($field != 'uid') {
// We cannot set default value to integer 0 for these fields using
// db_field_set_default() due to a bug
// See: http://drupal.org/node/517642
// db_field_set_default($ret, $table, $field, 0);
$ret[] = update_sql('ALTER TABLE {'. $table .'} ALTER COLUMN '. $field .' SET DEFAULT '. 0);
}
}
}
}
}
}
return $ret;
}
/**
* Implementation of hook_schema()
*/
function watcher_schema() {
$schema['watcher_nodes'] = array(
'description' => 'Holds what users are watching what nodes',
'fields' => array(
'uid' => array(
'description' => 'Holds UID of user',
'type' => 'int',
'not null' => true,
'disp-width' => '10'
),
'nid' => array(
'description' => 'Holds NID of node',
'type' => 'int',
'not null' => true,
'disp-width' => '10'
),
'mail' => array(
'description' => 'Holds email address of user (if user is anonymous)',
'type' => 'varchar',
'length' => 128,
'default' => null
),
'send_email' => array(
'description' => 'Whether the user wants to be notified by email or not',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'default' => 0,
'disp-width' => '1'
),
'added' => array(
'description' => 'Timestamp of when row was added',
'type' => 'int',
'not null' => true,
'disp-width' => '11'
),
'watch_for' => array(
'description' => 'What the user is watching for (anonymous users): 1 = all, 2 = comments, 3 = updates',
'type' => 'int',
'size' => 'tiny',
'default' => null
),
),
'primary key' => array('uid', 'nid', 'mail'),
);
$schema['watcher_notify_queue'] = array(
'description' => 'Holds the queue of notifications',
'fields' => array(
'qid' => array(
'description' => 'Queue item ID',
'type' => 'serial',
'not null' => true,
'disp-width' => '32'
),
'uid' => array(
'description' => 'Recipient UID',
'type' => 'int',
'not null' => true,
'disp-width' => '10'
),
'mail' => array(
'description' => 'Recipient email address',
'type' => 'varchar',
'length' => '64',
'not null' => true
),
'subject' => array(
'description' => 'Message subject',
'type' => 'varchar',
'length' => '192',
'not null' => true
),
'message' => array(
'description' => 'Notification message',
'type' => 'text',
'not null' => true
)
),
'primary key' => array('qid'),
);
$schema['watcher_user_settings'] = array(
'description' => 'Holds personal user settings',
'fields' => array(
'uid' => array(
'description' => 'User UID',
'type' => 'int',
'not null' => true,
'disp-width' => '10',
),
'automatic_enable_notifications' => array(
'description' => 'Automatically enable notifications for the post when a user starts watching a post',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'notifications_updates' => array(
'description' => 'User will be notified about updates of posts the user watches',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'notifications_new_comments' => array(
'description' => 'User will be notified about new comments on posts the user watches',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'autowatch_commented_on' => array(
'description' => 'User will automatically watch nodes the user comments on',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'autowatch_posted' => array(
'description' => 'User will automatically watch nodes the user creates',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'share_binder' => array(
'description' => 'Whether the user\'s list of watched posts should be viewable by others',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
),
'custom' => array(
'description' => 'Whether the user has customized the settings or whether they were derived from the defaults',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
'disp-width' => '1',
'default' => 0
)
),
'primary key' => array('uid'),
);
return $schema;
}

File diff suppressed because it is too large Load diff