1

I'm trying to figure out if it's possible/advisable to create URLs that get sent out in user notification emails which, when clicked, carry out actions like changing a CCK field value.

So for example - say you have an issue tracking system. There's no activity on one issue for a week, so the system sends an email to the person who posted the issue asking if they consider the issue closed. And if so, please click here to close the issue.

They click on the "close the issue" link in their email, the CCK status field for the issue is changed to "closed," and they're taken to some arbitrary page on the site.

Is something like that doable?

In Drupal 6?

6
  • how secure do you want this? – iStryker Jul 19 '11 at 2:20
  • Pretty secure. But! - I actually just found a module that more or less does what I'm after. drupal.org/project/node_update_from_url – chriscaple Jul 19 '11 at 10:47
  • put your update as your answer. If no one supplies a better answer then expect your own answer in a few days or so. – iStryker Jul 19 '11 at 11:46
  • I did, right after I posted that comment... – chriscaple Jul 19 '11 at 11:52
  • @reallyordinary post your update as an answer to your own question instead of putting a solution inside the question. Then you can accept your own answer if it is most suitable to you. – Laxman13 Jul 19 '11 at 14:23
1

It's feasible but not advisable. Drupal's standard for changing data via URLs: 1) Use _GET variables (or simple URL paths) to _access_data 2) Use _POST variables to change data

Along with using _POST, you would want to use Drupal's Form API so that tokens and fields are generated and validated.

Options you could do to change the data via URL (e.g. link) is to: 1) Add a token to URL to validate it's only used once (or other validation necessary) 2) Ensure user is logged in (and maybe ensure he is owner of that ticket, etc.) Hope this helps.

1

You will have to install and setup rules to email 1 week after inactivity.

For the menu link, create a custom module

/**
 * Implements hook_menu()
 */
function MYMODULE_menu()  {
  $items['issue/close/%'] = array(
    'page callback' => '_MYMODULE_close_issue',
    'page arguement' => array(2),
    'access callback' => TRUE,
  );
}

function _MYMODULE_close_issue($nid = NULL) {
  if ($nid) {
    $node = node_load($nid);
    $node['field_issue_closed'][0][value] = TRUE;
    node_save($node);
  }
}

Problems:

  • This gives access to anyone
  • No control to get users to login
  • No validation on array(3). User could pass anything

The way you really want to do this is how Drupal does user password resets, where it emails the user a hashed link that is good for a one time login. Except you have a predefine action to this link, which is to close the issue.

I know someone from my Local Community Drupal Meetup that is creating a module that creates these hash links. I believe its still in a sandbox. I'll try to track him down to see where his project is at.

1
  • I second this. Can we not put a user login check, say, global $users; if($users->uid) // user is logged in else... ? save the destination url so it redirects after log in? – jan Jul 19 '11 at 5:46
0

I found a module that does more or less what I want -

http://drupal.org/project/node_update_from_url

It lets you create URLs that a user can click to update any CCK field, provided the user has permission to edit their own content. Takes the user to a confirmation page where they have to click on "update"... and then the action is carried out.

I'm just testing it. Seems to work. Should probably suit my requirements for now. But! - the other answers are pretty interesting & I'll probably explore them as well.

1
  • Just a note - if you want to use this module with a user reference field you'll need to add else if($result['type'] == 'userreference'){$node->$key = array(array('uid' => $value)); to the node_update_from_url_confirm_submit function around line 49 }` – user2014 Nov 3 '11 at 19:05
0

For Drupal 7, there is another module which allows to change values from anchor link. It's called Rules Link and it's much more popular. It's connection with rules allows to do more - activate any rule you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.