Advertisement
leemahoney3

Untitled

Aug 17th, 2022
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. This will work, create a hook file and add the following code.
  2.  
  3. -----------
  4.  
  5. <?php
  6.  
  7. use WHMCS\Database\Capsule;
  8.  
  9.  
  10. function decrypt_ticket_password_custom_fields($vars) {
  11.  
  12. $ticketID = Capsule::table('tbltickets')->where('tid', $_GET['tid'])->first()->id;
  13.  
  14. $script = "<script type='text/javascript'>
  15. $(document).ready(function() {
  16. ";
  17.  
  18. foreach ($vars['customfields'] as $field) {
  19.  
  20. if ($field['type'] !== 'password') {
  21. continue;
  22. }
  23.  
  24. $value = Capsule::table('tblcustomfieldsvalues')->where(['fieldid' => $field['id'], 'relid' => $ticketID])->first();
  25.  
  26. if (count($value)) {
  27. $request = localAPI('DecryptPassword', ['password2' => $value->value]);
  28.  
  29. $password = $request['password'];
  30.  
  31. $script .= "
  32. $('div[menuitemname=\"{$field['name']}\"]').children('div').eq(1).html('{$password}');
  33. ";
  34. } else {
  35. $script .= "
  36. $('div[menuitemname=\"{$field['name']}\"]').children('div').eq(1).html('N/A');
  37. ";
  38. }
  39.  
  40.  
  41.  
  42. }
  43.  
  44. $script .= " });
  45. </script>
  46. ";
  47. $output['customfieldjavascript'] = $script;
  48.  
  49. return $output;
  50.  
  51. }
  52.  
  53. add_hook('ClientAreaPageViewTicket', 1, 'decrypt_ticket_password_custom_fields');
  54.  
  55. ---------------
  56.  
  57. Then open your viewticket.tpl file in whatever theme you use and add the following variable at the bottom:
  58.  
  59. {$customfieldjavascript}
  60.  
  61. This will work for multiple custom fields that are of the type password. Other custom fields will remain untouched.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement