When a user submits a new issue, and someone else creates a follow-up on that issue, then I believe that an email notification should be sent to the user who submitted the issue. But unfortunately, he only gets an email if the submitter has used the "subscribe" form, which is not likely because the form is pretty difficult to find.
To fix this, I automatically subscribe the issue author to "own issues".
I have patched the "issue.inc" code and added an "autosubscribe" function:
/**
* Automatically subscribe user to "own issues" in the specified project. Called when user creates an issue, because
* without this subscription he won't receive an email when someone else posts a follow-up on his issue.
*
* @param $uid
* userid
* @param $pid
* projectid, or actually nid for the node where nodetype = "project", not "issue"
*/
function project_autosubscribe($uid, $pid) {
$level = db_result(db_query('SELECT level FROM {project_subscriptions} WHERE nid = %d AND uid = %d', $pid, $uid));
if ((1==$level) || (2==$level)) {
// no action required, this user is already subscribed to this project
}
else {
db_query('DELETE FROM {project_subscriptions} WHERE nid = %d AND uid = %d', $pid, $uid);
db_query('INSERT INTO {project_subscriptions} (nid, uid, level) VALUES (%d, %d, %d)', $pid, $uid, 1);
}
}
... and this new function is called from functions "project_issue_insert" and "project_issue_update" just before calling mail_notify :
project_autosubscribe($node->uid, $node->pid);
if ($node->assigned)
project_autosubscribe($node->assigned, $node->pid);
project_mail_notify($node);
I hope this makes sense, and also hope that it will be added to the CVS repository for future releases?
Comments
Comment #1
dwwyay, someone else posts a patch for project* ;)
and yeah, i agree the subscribe stuff is too hard to find, as it currently exists.
however, i'd be *extremely* opposed to having project_issue *always* subscribe me via email to my own issues. *especially* on drupal.org. ;)
so, if i was going to commit something like this, it'd have to have a reasonable way to allow users to opt-in if they wanted it. not quite sure what that would look like, just yet.
perhaps a different approach to solving this problem is to figure out how to make the "subscribe via email to your own issues" stuff more visible. for example, put a checkbox or something in the user profile form, when a user edits their own account...
anyway, thanks for taking the time to actually find the code to do what you want, and i look forward to committing *something* as a result of this issue. we just have to make it reasonable and flexible enough to work on drupal.org and the other sites trying to use project*.
cheers,
-derek
Comment #2
jurjen commentedOk, I see now why you are opposed to my solution. You sure submit a lot of issues :-)
A checkbox in the user profile form, well, I don't know. In my humble experience, people don't seem to use their profile forms very well: they only see it once when they create a new account, and since they are new at that time they don't understand the consequences of the various options yet. Plus, it would still be a site-wide setting.
A more fine-grained alternative solution might be a checkbox in the issue form, saying "notify me by email when someone responds to this issue". A similar checkbox in the follow-up form would also be nice.
I understand this would require a new approach in function "project_mail_notify" where the $uids array is checked against the project_subscriptions table.
Thanks for looking into it,
Jurjen.
Comment #3
dwwsubscribe to a single issue is a long-term wish-list item: http://drupal.org/node/34496
that's obviously the best solution, but involves a lot of work.
however, now that i look at it, this issue is turning into an exact duplicate of http://drupal.org/node/16014 ;)
-derek