Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2.  
  3. function vozmob_og_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  4. switch ($op) {
  5. // when in view mode as opposed to edit, delete, etc.
  6. case 'view':
  7.  
  8.  
  9. break;
  10. }
  11. }
  12.  
  13. /**
  14. * Implementation of hook_mailhandler()
  15. * Check incoming mail to see if it needs to be associated with a
  16. * group. This uses the to address (to@domain.com)
  17. */
  18. function vozmob_og_mailhandler(&$node, $result, $i, $header, $mailbox) {
  19.  
  20. $to_address = $header->toaddress;
  21. $split_address = split("@", $to_address);
  22. $email_name = $split_address[0];
  23.  
  24. // Get the full user object.
  25. $user = user_load($node->uid);
  26.  
  27. // Load group node object, so we can get the path of the group
  28. $group = node_load($user->og_groups[$group->nid]);
  29. $group_path = $group->path;
  30.  
  31. // Get the group's path, which we presume the user has set as a path alia with only one path argument
  32. // TODO - make this smarter
  33. $group_path = $group->path;
  34.  
  35. // We need to make sure this user is a member
  36. // @TODO This should hook into OG's check if a user can post to a group
  37. if (! $user->og_groups[$group->nid]) {
  38. watchdog('vozmob_og', 'User !user attempted to post to !group that they are not a member of.',
  39. array(
  40. '!user' => l($user->name, 'user/' . $user->uid),
  41. '!group' => l($group->title, 'node/' . $group->nid)
  42. ),
  43. 'warning');
  44. return;
  45. }
  46.  
  47. // Does email address match path of a group?
  48. if ($email_name == $group_path) {
  49. watchdog('vozmob_og', 'This email address matches the path of a group.');
  50. $node->og_groups[$group->nid] = $group->nid;
  51. }
  52.  
  53. // return the modified node
  54. return $node;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement