Download & Extend

Notify Assigned Users

Project:To do list
Version:6.x-1.x-dev
Component:User interface
Category:support request
Priority:minor
Assigned:AlexisWilke
Status:active

Issue Summary

Hi,

i tried to figure out how to notify assigned users about new tasks added by another users but couldnt figure it out. Would it be possible to send an notification e-mail to all assigned users? The possibility to automaticaly subscribe the users to the node created with the subscribe module would also be helpfull.

In short it should look like this:
A user "A" add a task and assign the task to users "B" and "C".
-> E-Mails "You have new Task" for users "B" and "C" will be send out with the next cron.
-> Users "B" and "C" have automatically been added to subscriptions on that node.

Is this possible to do? Or if this is allready implemented or somehow possible to realize please give me a hint.

Comments

#1

Would by nice, if it works with the subscirbtions-modul ;)
so that the users get compact email notifications :D

#2

Version:6.x-1.3» 6.x-1.4
Assigned to:Anonymous» AlexisWilke
Status:active» fixed

There is now support for the Rules module which has the capability of sending emails to anyone.

The support sends one event per assigned user so you can email each one.

If that module is capable of feeding data to the subscription module, then you got it Ragesoft...

Thank you,
Alexis Wilke

#3

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#4

Status:closed (fixed)» active

Hi,

I'm sorry to re-open this issue but I'm experiencing a problem using Rules for notifying assigned users.

I have created some ToDo items which deadlines are past and these two rules:

1. To do event deadline reached
Description: CRON detected that a deadline was reached.
Action: Send E-Mail to user "assigned user"

2. To do event past deadline
Description: CRON detected that To do task is past its deadline.
Action: Send E-Mail to user "assigned user"

Unfortunately no emails are sent when cron is running. The drupal protocol claims cron to be run successfully but nothing about executing these rules or rather sending out emails. Other rules successfully send emails on their execution; only these ToDo-specific rules do not.
For completeness: I'm using the SMTP Authentication module which is working normally.

Did I miss to set some preferences?
Hope somebody can help me to find out why no emails are sent to notify assigned users.

Thanks for reading
Vovo

#5

I don't think I detect that the deadline is past when you save a new To Do item... if I recall, I will only detect that specific case when the CRON process detects the deadline. But if it's already marked as dead on the save then the CRON process won't detect anything.

Thank you.
Alexis Wilke

#6

Hi Alexis,

thank you for you quick answer!

So, a ToDo item which has already reached its deadline will not be recognized by cron?
This means if I create a new ToDo and set the deadline e.g. to 20.12.2011 it should trigger the rules module to send out emails, right?
I'm gonna try this and report about success or failure, if I may.

Thank you again! :-)

#7

Yes, a date in the future will work.

There is a function called _to_do_fix_dates() which checks the deadline date and changes the status to TO_DO_STATUS_FINISHED if the current date is already larger than the deadline. This is not viewed as an event, it's just making sure the status is correct as you save a node (creating a new one or updating).

CRON will not do anything since the node is already marked as finished. CRON would detect a node that is marked as started and has to be moved to the finished state.

I'm not so sure we'd want an event to be triggered in the _to_do_fix_dates()... although I just added the Update and Create events (in 6.x-1.x). You could use those and check the status: if the status is FINISHED then you could send an email saying the deadline is passed already.

Thank you.
Alexis Wilke

#8

Hello again,

that's really good to know! :-)
I will check out the status events.

Unfortunately there seems to be a problem with CRON detecting ToDo items' status. Since I created new test items with deadlines in the future, CRON fails to run. After deleting the ToDo items CRON runs successfully again.

I guess, the assigning seems to fail. When I save a ToDo item it shows the following:
warning: Invalid argument supplied for foreach() in .../sites/all/modules/to_do/to_do_rules.module on line 7.
Line 7 is:
foreach ($node->assigned_users as $uid => $name)

This error has already been reported here and here but without a solution. :-(

But this does not explain why CRON is not running successfully..

Do you have any idea? :-(

#9

Version:6.x-1.4» 6.x-1.x-dev

Vovo,

Okay, checked in a few fixes that should take care of all of that.

If you don't mind to test the 6.x-1.x-dev version and I'll make it 1.6 if it works for you.

Thank you.
Alexis Wilke

#10

Hello Alexis,

thank you for the fixes!!
I just downloaded the dev-Version and created ToDo items with tomorrow as deadline.
Hope, I can report success tomorrow. ;-)

Thanks again!

#11

Hi again,

the good news: CRON runs successfully again. There are three test-ToDo items (one of each status "Not Started", "Started" and "In Progress") and their deadlines are reached today.

The bad news; No E-Mail was sent by the corresponding rules :-(
As I created the ToDo items yesterday they should not be marked as dead. At the moment I cannot see clearly why there are no E-Mails sent to noify the assigned users.

For now I wish you a merry christmas! Have fun in the snow and enjoy your holidays! :-)
Vovo

#12

Vovo,

Hmmm... I dunno. I've seen many problems raised because of emails not being sent by Rules.

This being said, you may want to try the email system with other events that you can reproduce quickly (with a click, as you create a new To Do item, etc.) so that way you make sure that you can indeed receive emails. Once that is out of the way, we can determine whether the To Do system has a problem with the deadline event.

Thank you.
Alexis Wilke

#13

Hi Alexis,

I've tested the Rules-Mail-Functions now and created the following rule for the ToDo module:

Title: ToDo Event created
Description: A user saved a new To do task.
Action: Send E-Mail to user "assigned user"

This works really fine! When a ToDo item is created this rule gets triggered and sends out an E-Mail to the assigned user. Both is logged in Drupal's system log and the E-Mail for the newly created ToDo item arrived in my mailbox.
So, there is no problem with sending and receiving E-Mails, I think.

As I tested many "Send E-Mail" functions in Drupal now, I recognized the ToDo reminder E-Mails are also not sent.
So, it seems to be an issue for time-triggered or time-dependent events.

Maybe the "mark as dead" function is not triggering rules?
I'm sorry to be so "pertinacious" about this.

Thank you very much!
Vovo

#14

Vovo,

Okay, it looks like a few things were wrong in the CRON implementation. I guess you're the first person who seriously tested that part of the code. 8-)

Let me know how the latest works for you. It should appear as Dec 30th or 31st.

Thank you.
Alexis Wilke

P.S. the code sets a variable that prevents the CRON code from running more than once a day, at least by default. So if you want to test many times within a day, you will have to change the following:

<?php
function to_do_cron() {
 
$now = (int)floor(time() / 86400); // what is today?
 
$last_update = variable_get('to_do_last_update', 0);
 
// Add the " || TRUE" to this if() statement and remove it once done testing
 
if ($last_update < $now || TRUE) {
   
variable_set('to_do_last_update', $now);
   
$now *= 86400;
    ...
?>

#15

Hello Alexis,

I've done extensive testing in the last few days and first and foremost: The function "to_do_cron()" ist called while CRON is running and successfully triggers Rules to send out E-Mails! :-)

Although there are three things I do not understand:
1. Drupal's dblog claims an error of an unknown table field when processing "to_do_cron()":
Unknown table field &#039;type&#039; in where clause query: SELECT nid FROM bv_to_do WHERE type = &#039;to_do&#039; AND 1328140800 &gt; date_finished AND n.status = 0 in /.../sites/all/modules/to_do/to_do.module in Zeile 608.
This occurs every time "to_do_cron()" is executed by CRON.

2. There seems to be something wrong with the date setting or rather check.
When creating a To Do node and setting its deadline (for example to 01. Februar 2012) this date is set to one day earlier on saving the node. So, after saving the To Do node its deadline is shown as 31. January 2012.

3. All assigned users get E-Mails on reminder events correctly. Corresponding to the settings for my tests I chose to remind assigned users 1 day before deadline. This works fine! Also assigned users got a reminder E-Mail (or rather a reminder event was triggered by CRON) on the deadline's day.

I think, the event "To do event deadline reached" should be triggered on the deadline's day, right?
Unfortunately this does not happen. I've created a rule to send out an E-Mail on this event but this never happened.

The next E-Mail to assigned users was sent on the event "To do event past deadline". This happened one day after the ToDo's deadline was reached. So, this also works fine.
Maybe as an enhancement, it could be a feature for a future version to trigger this event every day after a ToDo's deadline. So assigned users would get an E-Mail every day for a ToDo that is past deadline and not only once.

Conclusion
1. To Do list and rules are working together :-)
2. The "dead event" takes place and triggers corresponding rules
3. The "reminder event" is working correctly
--> CRON detects deadlines and reminders.

4. There seems to be a mismatch at a table field "'type&#039"
5. The deadline and start date are set to one day earlier when saving a to do node
6. The "deadline reached event" seems not to happen

Do you have an idea about the unknown table field or the date confusion?
I hope I could help and would be glad to support you with further testing.

#16

Point 1. is fixed, I updated 6.x-1.x-dev

Point 2. is a duplicate of #980478: wrong date it taken when select a day

Point 3. is probably related to Point 2.

In regard to sending an email every day until marked as Finished, it would be very simple. We just would have to skip the UPDATE in the database so the state doesn't prevent the email (this is done and checked in.) Note that the Global To Do settings include 3 boxes that can be used to send events 1 or more days before the deadline and since you mentioned the reminders, you already found those.

Now, I'm not too sure which event you are referring when talking about the deadline events. There are two of those:

  • To do event deadline reached
  • To do event past deadline

I suppose you are saying that the first one (To do event deadline reached) happens and the second one (To do event past deadline) is not. Is that correct?

Thank you.
Alexis Wilke

-- Addition: I implemented the send "To do event past deadline" until Todo is marked finished or canceled. The setting is in the global To Do Settings (Admin » Site Configuration » To do list).

#17

Hi Alexis,

Great! Thanks for your quick update! :-)

1. The error about an unknown table field is gone, but unfortunately there is a new one about an unknown table "n":
Unknown Table &#039;n&#039; in &#039;where clause&#039; query: SELECT nid FROM drupal_to_do WHERE 1328400000 &gt; date_finished AND n.status = 0 in /.../sites/all/modules/to_do/to_do.module in Zeile 610.
I think, this refers to the adressed field n.status when getting the $result in this function:

// Delete when 'delete after' is set
    // Note: We could run DELETE before UNPUBLISH, but some Rules could
    //       make use the the 'unpublished' event... that would otherwise
    //       to occur!
    $delete_after = variable_get('to_do_delete_after', '');
    if (is_numeric($delete_after) && $delete_after > 0) {
      $delete_after *= 86400;
      $sql = "SELECT nid FROM {to_do}"
        . " WHERE %d > date_finished";
      if (!variable_get('to_do_delete_any', 0)) {
        $sql .= " AND n.status = 0";
      }
      $result = db_query($sql, $now + $delete_after);
      while ($row = db_fetch_array($result)) {
        $node = node_load($row['nid']);
        module_invoke_all('to_do_deleting', 'to_do', $node);
        node_delete($row['nid']);
      }
    }

2. Okay, I compared with the described issue and fixed it that way. gmmktime() is working for me, too. :-)

3. I meant it right the other way. Sorry, that I expressed a little cumbersome. After afresh testing the result is:

  • "To do event deadline reachted" is not executed. At the deadlines day there seems to be already the "To do event past deadline" event, because the corresponding rule sends out E-Mails saying "ToDo XY is past deadline".
  • "To do event past deadline" happens correctly! Thank you also for implementing the setting whether this event should take place only once or should be repeated every day! This works fine and I like it very much! :-)

Edit:
I've experienced one more thing: If chosen that "any assigned user" can mark a todo item as finished, in fact any user seems to able to mark it as finished. I've created a todo that is assigned to myself and chose (as I set in the standards) that any assigned user is able to mark it as finished. But it is possible to mark this todo finished with another user account that is not assigned to this todo.

#18

Vovo,

Thank you for all the help! 8-)

1. Fixed. I removed the "{node} n" entry thinking it was not necessary missing the if() content!

2. I finally changed the mktime() into gmmktime() in the repository. I think that's the correct way of doing things here.

3. I used the == operator to determine whether the deadline was on that very date/time, but the value is in seconds, not in days so it will miss unless the timezone is zero. Actually, thinking about it my current fix is still wrong... if you allow each user to enter a different timezone for their account! I guess the only correct way is to compute the day. Hmmm...

Let me know how the latest checked in version works for you.

Thank you again.
Alexis Wilke

#19

Hi Alexis,

I like to help you and think I should thank you for developing this module! :-)

1. Great! But now another error occurs saying that the column "nid" is not distinct (or rather not well-defined. Sorry, I don't know the correct wording in English for this error):
Spalte &#039;nid&#039; in field list ist nicht eindeutig query: SELECT nid FROMto_do td, node n WHERE 1328835600 &gt; td.date_finished AND n.status = 0 in /.../sites/all/modules/to_do/to_do.module in Zeile 621.

2. Yes, works fine! :-)

3. I've tested again with the same result: The event "ToDo deadline reached" is not happening; "ToDo past deadline" happens on the deadlines day. CRON is run every hour by the way. With regard to user-chosen timezones maybe it would be better to calculate the day.
But at all there are E-Mails sent for reminder events, on the deadline's day and every day past deadline. I'm delighted! :-)

#20

Vovo,

Okay, I got #1 taken care of. There was another mistake in the SQL actually!

I'll check later for the deadline reached event as it will require testing to make sure it really happens / does not happen.

Thank you.
Alexis

#21

Alexis,

great, there are no more SQL errors! :-)
#1 is now finally fixed

Thank you!!

#22

Version:6.x-1.x-dev» 6.x-1.5
Component:Miscellaneous» User interface
Category:feature request» support request

Hi,

I want to do the same as IStyle, notify assigned users when the deadline is reached, or preferably one day before the deadline is reached.

I activated TO DO rules support, created a rule, chose event "TO DO event deadline reached" and now want to add an action which sends an e-mail to assigned users.

The problem I have is that I see no such action. The following actions concerning the sending of emails are available:
- system: send a mail to a user
- system: send a mail to all users of a role
- system: send a mail to an abitraray user

Which action should I use to send an e-mail to assigned users of a TO DO only? Where can I create such an action if it doesn't exist ? I tried "Manage Actions" -> "Make a new advanced action available" but this doesn't help either...

Thank you!
Lorenz

#23

You use the "system: send a mail to a user" and make sure you use the correct user in the list of users.

To send emails before the deadline (according to Vovo it doesn't yet work right on the deadline...) you want to use reminders instead.

Thank you.
Alexis

#24

Thanks for the quick reply. I will test it.

#25

Hi,

sorry for my english :)

In "Send a mail to a user - Arguments configuration - Recipient" I have only two options:
- content's author
- acting user

Only local images are allowed.

Where I find assigned users? Or how to get these users to the list?

Thank You
Radek

#26

Radek,

Assuming you installed the to_do_rules module (To do tasks rules extension) then when you create a "Send an HTML mail to a user" (or the non-HTML version) then in the "Arguments configuration" you see a dropdown named "Recipient". In that list I have 3 entries:

assigned user
to do author
acting user

What you're looking for is the "assigned user". Since Rules in Drupal 6.x doesn't have a way to loop through a list of any kind, I trigger the actions once per assigned user, hence the singular since the action really only applies to one assigned user at this point.

If you cannot see the "assigned user" and the "To do tasks rules extension" is installed, then I'm not too sure what to tell you... It could be that the option you use to send an email doesn't accept the users the standard way.

Thank you.
Alexis

#27

Version:6.x-1.5» 6.x-1.x-dev
Priority:normal» minor

Hi Alexis,

sending e-mails works fine. Thanks a lot!

Two issues:

1) I created a test TO DO which I edited and saved several times. It seems that the rule is triggered as many times as the TO DO is saved which results in several e-mail reminders for the same TO DO. Is there a way to send only one e-mail?

2) Some tokens do not work in the e-mail: [node:to-do-date-finished-d], [node:to-do-date-finished-m].[node:to-do-date-finished-yy].
Other tokens work: [node:title], [:global:site-url], [node:nid].

I am using 6.x-1.5+11-dev.

#28

lorenz,

How would I know that it is the last time you changed the To do? (and thus that I have to *finally* send the email.)

On my end I run cron at most once per hour. I guess we could mark the To do as "in need of sending an email" so on the next cron (or maybe the cron after next) sends the email instead of sending it immediately.

Thank you.
Alexis Wilke

nobody click here