DennisSkov

Untitled

Oct 11th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2. use WHMCS\Database\Capsule;
  3.  
  4. function getToDoID($vars) {
  5. return Capsule::table('tbltodolist')
  6. ->where('status', 'In Progress')
  7. ->where('title', 'Domain Pending Transfer')
  8. ->where('description', 'LIKE', '% ' . $vars['domain'] . '%')
  9. ->get();
  10. }
  11.  
  12. add_hook('DomainTransferCompleted', 1, function($vars) {
  13. $toDoID = getToDoID($vars)
  14. //Loop through the ID's and set them as completed.
  15. foreach ($toDoID as $entry) {
  16. $command = 'UpdateToDoItem';
  17. $postData = array(
  18. 'itemid' => $entry->id,
  19. 'adminid' => '11', //Update this ID to an admin ID
  20. 'status' => 'Completed',
  21. );
  22.  
  23. localAPI($command, $postData);
  24. logActivity('Clean-up To-do List: ID ' . $entry->id . ' has been set as complete as the transfer completed successfully - Domain ID: ' . $vars['domainid'] . ' - Domain: ' . $vars['domain']);
  25. }
  26.  
  27. });
  28.  
  29. add_hook('DomainTransferFailed', 1, function($vars) {
  30. //This hook will update to-do items for ttransfer that fails.
  31. $toDoID = Capsule::table('tbltodolist')
  32. ->where('status', 'In Progress')
  33. ->where('title', 'Domain Pending Transfer')
  34. ->where('description', 'LIKE', '% ' . $vars['domain'] . '%')
  35. ->get();
  36.  
  37. foreach ($toDoID as $entry) {
  38. $description = Capsule::table('tbltodolist')
  39. ->where('id', $entry->id)
  40. ->value('description');
  41.  
  42. $command = 'UpdateToDoItem';
  43. $postData = array(
  44. 'itemid' => $entry->id,
  45. 'adminid' => '11', //Update this ID to an admin ID
  46. 'status' => 'Incomplete',
  47. 'description' => '*FAILED* '.$description,
  48. );
  49. localAPI($command, $postData);
  50. logActivity('Clean-up To-do List: ID ' . $entry->id . ' has been set as incomplete as the transfer has failed - Domain ID: ' . $vars['domainid'] . ' - Domain: ' . $vars['domain']);
  51. }
  52. });
Advertisement
Add Comment
Please, Sign In to add comment