Source for file customer.php

Documentation is available at customer.php

  1. <?php
  2. /**
  3. * Class helpdeskUser, helpdeskCustomer
  4. * @package helpdesk
  5. * Copyright OSI 2005. All rights reserved.
  6. * It is expected that version 1.0 will be GPLed, but this interim work
  7. * is kept closed until 1.0 is ready.
  8. */
  9.  
  10. $_customer_saved_er = error_reporting(E_ALL || E_STRICT) ;
  11.  
  12. /**
  13. * import ancillary functions
  14. */
  15. require_once("misc.php") ;
  16.  
  17. /**
  18. * Helpdesk user implementation
  19. * @package helpdesk
  20. */
  21. class helpdeskUser
  22. {
  23. public $uid ; // Link to core user object
  24. public $uidCustomer ; // Link to helpdeskCustomer managing the user
  25. public $customerName;
  26. /**
  27. * initialize properties from uid for existing HD user
  28. * @param int $uid
  29. * @return void
  30. */
  31. function init($uid)
  32. {
  33. if (($this->uid == $uid) && (isset($this->uidCustomer)))
  34. {
  35. // No need to reload
  36. return ;
  37. }
  38. $this->uid = $uid ;
  39.  
  40. $q = '
  41. SELECT
  42. u.uid, u.name
  43. FROM
  44. {hd_user} hdu
  45. LEFT JOIN {users} u ON hdu.uidcustomer = u.uid
  46. WHERE
  47. hdu.uid = %d
  48. ' ;
  49. $res = db_query($q, $uid);
  50. $o = db_fetch_object($res);
  51. if (is_object($o) && isset($o->uid))
  52. {
  53. $this->uidCustomer = $o->uid;
  54. $this->customerName = $o->name;
  55. }
  56. unset($o);
  57. unset($res);
  58. }
  59. }
  60. /**
  61. * Helpdesk customer implementation
  62. * @package helpdesk
  63. */
  64. class helpdeskCustomer extends helpdeskUser
  65. {
  66. /**
  67. * @return array
  68. * @desc Returns the nids of all contracts attached to the customer
  69. */
  70. function nidContracts ()
  71. {
  72. $ret = helpdeskContract::getContractsByUid($this->uid) ;
  73. return $ret ;
  74. }
  75. /**
  76. * gets the list of users bound to a customer account
  77. * @return array uid/name pairs
  78. */
  79. function uidUsers ()
  80. {
  81. $q = '
  82. SELECT
  83. u.uid, u.name
  84. FROM
  85. {hd_user} hdu
  86. LEFT JOIN {users} u ON hdu.uid = u.uid
  87. WHERE
  88. hdu.uidcustomer = %d
  89. ORDER BY
  90. 2, 1
  91. ';
  92. $res = db_query($q, $this->uid);
  93. while ($o = db_fetch_object($res))
  94. {
  95. // Assigning directly in the while() instruction would add one loop pass with a null value
  96. $ret[] = $o;
  97. }
  98. return $ret ;
  99. }
  100. }
  101.  
  102. error_reporting($_customer_saved_er) ;
  103. unset($_customer_saved_er) ;
  104. ?>

Documentation generated on Tue, 01 Nov 2005 23:14:59 +0100 by phpDocumentor 1.3.0RC3