It would great if the case tracker integrated with the rules module by providing a context for it. Case Tracker fields could then be used as they are used now in views. Users assigned to a case could for example be mailed a day before the case ends, but much more is possible.

I have read the rules integrations help page (http://drupal.org/node/298639), but don't know where to start.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

buzink’s picture

Something like this?

<?php
/**
* Implementation of hook_rules_data_type_info().
*/
function casetracker_rules_data_type_info() {
  return array(
    'casetracker' => array(
      'label' => t('Case'),
      'class' => 'rules_data_type_casetracker',
      'savable' => TRUE,
      'identifiable' => TRUE,
      'uses_input_form' => FALSE,
      'module' => 'Case Tracker',
    ),
  );
}

/**
* Defines the rules node data type.
*/
class rules_data_type_casetracker extends rules_data_type {

//  function save() {
//    $node = &$this->get();
//    node_save($node);
//    return TRUE;
//  }

  function load($nid) {
  
  $casetracker = db_fetch_object(db_query('SELECT pid, case_priority_id, case_type_id, assign_to, case_status_id FROM {casetracker_case} WHERE nid = %d AND vid = %d', $nid, $nid));
    
    return $casetracker;
  }

  function get_identifier() {
    $node = &$this->get();
    return $node->nid;
  }
}
?>
dagmar’s picture

Title: Rules integration » Case Tracker - Rules integration
Version: master » 6.x-1.x-dev
Status: Active » Needs review
FileSize
7.79 KB

I have created an initial patch to provide rules integration for casetracker:

It's provides:

Actions:

  • Change a value of a case (Project, Assign to, Priority, Department, Status)

Conditions:

  • Realm have value (i.e Status = Open)
  • Realm have changed (i.e Priority is different after update a case)
  • Content is case
  • Content is project

It still needs some works, as an example, multiple values for a realm are not supported, so users cannot create a rule to check if a case status is Closed or Duplicated.

I'm leaving this issue as needs reviews to get some feedback if a new condition or actions should be included.

Grayside’s picture

function casetracker_rules_action_change_realm() has a dsm() floating in the middle.

function casetracker_rules_condition_is_project_label has the string "@node's is case". Should that not be "@node's is project"?

Also, CT's current actions support is in a submodule. This should most likely be bundled with CT Actions, and possibly have tighter integration with it.

dagmar’s picture

Thanks Grayside

I have reviewed the patch, this were the changes:

Removed the dsm call
Fixed the label for is_project.
Department is not a valid realm, changed to fixed.
Now a realm can be checked against multiple values (example: status is Duplicated or Closed)

Related to:

Also, CT's current actions support is in a submodule. This should most likely be bundled with CT Actions, and possibly have tighter integration

Rules fetch all the *.rules.inc files. So, if rules module is missing, this file doesn't do nothing, in my opinion this should not be included as part of action submodule, rules and actions are different modules.

It is true that casetracker_actions includes a lot a functions that could be reused, however most of these actions were implemented in a single function in this patch, and the others functions just provides conditions.

And as a final thought, I never used actions from Drupal core, Rules is a more powerful module and I don't see the reason to require to enable Actions in order to use Rules.

Thanks again Grayside, new patch attached.

Grayside’s picture

They are both kind of a Case Tracker Workflow sub-functionality. But point taken about rules being separate. It does create two versions of similarly purposed code, and it would be nice to unite them.

zeezhao’s picture

subscribing

Boobaa’s picture

Subscribing - would love to have it, since it would be the best (I mean the most flexible) solution to replace the now-have-dropped CT Mail module, IMHO.

As far as I know CT Mail had a routine to send a mail to the assigned user even when s/he is not subscribed to anything (using Notifications & Messaging). By dropping CT Mail, I could not find a way to achieve this - that's why I'd love to see Rules integration in CT.

UPDATE: I've just given the patch a go, and had to find out that I cannot send a mail (not to mention a Notification, which completely lacks Rules integration as of now) to the _assigned_ user - all my choices are the node author, the comment author and the current user who saved the comment. So it seems that there's quite a bunch of work to do, but I don't know where to step in with a helping hand (for now).

zeezhao’s picture

In notifications 6.x-4.x-dev, used with messaging 6.x-4.x-dev, there is a means of using cck fields and/or cck types, and also a "Custom Subscriptions" functionality. You might want to look at that to see if it can be made to work. I have not tried it myself as the last dev version I downloaded a couple of weeks ago had some other bugs, so I decided to wait...

Boobaa’s picture

Given that I should use it for a "live" system, I'd rather wait for at least a (supported) beta release of them myself, too. If we have to wait too much for it, we are going to look into it ourselves, when time permits.

dagmar’s picture

Status: Needs review » Needs work

UPDATE: I've just given the patch a go, and had to find out that I cannot send a mail (not to mention a Notification, which completely lacks Rules integration as of now) to the _assigned_ user - all my choices are the node author, the comment author and the current user who saved the comment. So it seems that there's quite a bunch of work to do, but I don't know where to step in with a helping hand (for now).

So, probably needs works.

Thanks for testing this Booba, could you explain a little better what kind of tests did you made, and how it isn't working? It would be very useful to fix this patch.

zeezhao’s picture

Fyi - a related link that may be of interest:

http://drupal.org/node/547680

Boobaa’s picture

@dagmar in #10:
1. Applied the patch in #10.
2. Installed rules.module, added a rule: ON event After saving a new comment.
3. Added some conditions: IF commented content's is a case AND NOT commented content's assigned to has value (of "Unassigned").
4. Tried to add an action to send a notification to the assigned user, but I had to find out that:
4a. there is no such an action: ”send a notification", since notification.module (or whatever should provide it) completely lacks Rules integration (see #212865: Rules integration: adding an action, which I didn't have the time for to check);
4b. so tried to continue with core's "Send a mail to a user" action, where I was shown only three choices: "created comment author" (which is mostly not the assigned one, as usually the boss is the one who assigns cases to other users), "commented content author" (which is mostly not the assigned one either, as usually the help desk monkey adds those case nodes), and "acting user" (which is mostly the same as the created comment author).

Did I miss something, or misunderstand your request to describe what and how I tried? (Actually I've been thinking about a simple module which hooks into comment forms of cases, and sends a mail if the case will have an assignee after saving the comment - this should do the trick for me and shouldn't take more than a couple of hours to implement, but it's not quite the solution to solve the issue, but only a specific workaround, which completely ignores notifications/messaging and targets other than email.)

dagmar’s picture

Status: Needs work » Needs review
FileSize
8.95 KB

Here is a new patch.

I have noticed that behavior described in #12 can be solved using this set of actions:

Load a user by Id (use the token [assigned_to] provided by the last Token integration committed into beta7)
Send email to a user...

However, if token is not enabled (which isn't probable if you are using rules) you cannot load the assigned user.

So, this new version includes an action to load the assigned user to a case. Like User Reference from CCK does.

Please, review the strings of this patch, I'm not sure if they are grammatically correct.

Then, sent an email to the user assigned to the case, just load the user using the action "Load the user assigned to the case" and create another action to send the email to this loaded user.

skessler’s picture

subscribe

Boobaa’s picture

OK, OK, I should have reviewed the patch in #13, but I desperately needed the functionality, so I forged a tiny little module for that (available on repo.or.cz for the time being). I don't plan to create a new project for it on d.o, though, since I hope it will lose its reason to exist if and when this issue gets resolved.

dzepol’s picture

subscribe. I've applied the patch in #13 will report if I find any issues.

zeezhao’s picture

I applied the #13 patch, and it works fine. Thanks!

thebuckst0p’s picture

Subscribe. This would be very helpful for a project I'm working on and would be great to see in the next release.

Yuki’s picture

subscribe

SocialNicheGuru’s picture

subscribing

Scenario. I am using mailhandler and a few other modules to email in cases.
They come in unassigned.
I would like to have a project automatically created in a group if no project exists as a default or "Misc. project" and assign the new case to it

or if the project can't be created, assign a case to any project

or send an email to the sender to assign a case.

how can I use this to
1. create a project in a group if no case is present. I am not sure if that can currently be done.
2. can i check if the realm value is null or unassigned for a case? right now, it looks like I have to select an option for a realm no matter what.

There doesn't seem to be any php options. Thanks for your help.

langworthy’s picture

subscribe

Anonymous’s picture

Patch #13 work well for me too : Drupal 6.19

Thank you

JordiTR’s picture

Patch #13 also works well for me too under Drupal 6.17. And very well in fact, nice notification of user assigniment changes via email without subscriptions or notifications modules :-)

Thanks. JordiTR

eighthourlunch’s picture

Patch on #13 worked for me as well, thank you. Using it with Drupal 6.19 & PHP 5.3. Thanks, dagmar. Nice work.

Fidelix’s picture

I'm using OpenAtrium beta 8 and the user does not get loaded.

I'm creating an action to load a case's assigned user and then mail him. But the token to load the user does not seem to work.
I just get an error message saying the system was unable to mail, and in the logs: Error sending e-mail (from mysite@mysite.com to ).

I tried patch #13

dagmar’s picture

@Fidelix, It would be nice to see your rule export here.

Fidelix’s picture

FileSize
3.01 KB
2.91 KB

I tried in two ways.
Each rule is attached.

royerd’s picture

What condition(s) in the rule sequence might one add that say--if this ticket has not been updated or changed in the last 7 days . . .

If I knew how to create that condition, then I could have the action be to send an email to the creator of that node (ticket) and ask them to update or close the ticket.

But I can't see what conditions could be messed with here. Can someone suggest something for me?

Dan

Fidelix’s picture

I would like to know that also...

I dont know if the $node->updated (or something like this) actually gets modified by casetracker, so if it is, this would be easy to do.

Grayside’s picture

Node->Updated is not modified by casetracker. There are two ways to update case info-by updating the node, which does modify the update date, or to update via a comment, which registers the state change in a special database table.

Chetan Sharma’s picture

Issue summary: View changes

this Patch is not working for me.

zeezhao’s picture

@dagmar - again, thanks for your patch. Please is there a D7 version of this?

metzlerd’s picture

New maintainer... am starting to look at this patch and will try and roll a 7.x version. Assuming people would still like to see the 6.x-1.x version committed.

mywebmasteruk’s picture

Are we any closer to seeing rules integration for Drupal 7?

Thanks