Source for file event.php

Documentation is available at event.php

  1. <?php
  2. /**
  3. * Classes helpdeskEvent, helpdeskTicket, helpdeskFollowup
  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. // echo "<p>Start of " . __FILE__ . "</p>" ;
  11.  
  12. $_event_saved_er = error_reporting(E_ALL || E_STRICT) ;
  13.  
  14. /**
  15. * Import time-related code
  16. */
  17. require_once("misc.php") ;
  18. require_once("timeinfo.php") ;
  19.  
  20. /**
  21. * import HD core
  22. */
  23. require_once("core.php");
  24.  
  25. /**
  26. * Support contract
  27. * @package helpdesk
  28. */
  29. abstract class helpdeskEvent extends helpdeskObject
  30. {
  31. public $nid ; ///< link to drupal node object
  32. /**
  33. * Generates the code for hook_form when node is a Helpdesk Contract
  34. * @return string
  35. */
  36. function form ()
  37. {
  38. // Now we define the form elements specific to our node type.
  39. $ret = t ("<p>Defining new %nodename</p>\n", array ('%nodename' => helpdesk_node_name ($node))) ;
  40. // This would allow format selection, but events are plain text, so we use 1 = filtered html
  41. // $ret .= filter_form ('format', $node->format);
  42. $node->format = 1 ; // Filtered HTML
  43. /**
  44. * TimeID information for new event
  45. */
  46. $ret .= helpdeskTimeInfo::form (
  47. t ('Date and time problem was notified'),
  48. t('The start time defines the start of any contractual answering answer time guarantee. '
  49. . 'It is automatically inserted at the time the issue is created and the '
  50. . 'ticket is issued.'),
  51. format_date(time(), 'small', NULL,NULL), TRUE, FALSE,
  52. format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
  53. format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
  54. '', helpdesk_access (HELPDESKHOOKACCESSUPDATE,HELPDESKNODETICKET), TRUE
  55. ) ;
  56.  
  57. /**
  58. * Contents for new event
  59. */
  60. $ret .= form_textarea (
  61. t ('Describe the issue you\'re having as thouroughly as possible, including the version numbers of any piece of software'
  62. . ' and the serial number of any product affected by the issue. More precision yields shorter response times.'),
  63. 'body', isset ($node->body) ? $node->body : '', 60, 20) ;
  64. return $ret ;
  65. }
  66. /**
  67. * Generates a human-readable ticket number based on the nid of the
  68. * ticket itself, or the ticket to which a followup is bound
  69. * @return string the readable ticket number
  70. */
  71. abstract function getTicket () ;
  72. /**
  73. /**
  74. * @return string HTML
  75. *
  76. * @return unknown
  77. */
  78. function view()
  79. {
  80. return "helpdeskEvent/view(nid = $this->nid)" ;
  81. }
  82. function init($node, $fromDB)
  83. {
  84. $this->nid = $node->nid ;
  85. return get_class($this) . "/view(nid = $this->nid" ;
  86. }
  87.  
  88. /**
  89. * class constructor
  90. */
  91. function __construct()
  92. {
  93. $this->nid = 0 ;
  94. }
  95. }
  96.  
  97. /**
  98. * @package helpdesk
  99. */
  100. class helpdeskTicket extends helpdeskEvent
  101. {
  102. public $timeid ;
  103. public $contractnid ;
  104. public $txnid ;
  105. public $tidseverity ;
  106. public $tidstatus ;
  107. public $tempcontact ;
  108. public $attachment ;
  109. public $uidtech ;
  110. public $techname;
  111. /**
  112. * @return string the readable ticket number
  113. */
  114. function getTicket ()
  115. {
  116. $prefix = variable_get(HELPDESKVARTICKETPREFIX, '') ;
  117. $offset = variable_get(HELPDESKVARTICKETOFFSET , 0) ;
  118. if (!isset($this->nid))
  119. return '' ;
  120. else
  121. return sprintf ("%s%u", $prefix, $offset + $this->nid) ;
  122. }
  123.  
  124. function init($node, $fromDB)
  125. {
  126. if (HELPDESKDEBUGALLFUNCTIONS == TRUE)
  127. { echo "<pre>HD TICKET/init (" . (isset($node->nid) ? $node->nid : 'new node') . ", fromDB = " . ($fromDB ? 'True' : 'False') . ")</pre>\r\n" ; }
  128. $ret = parent::init($node, $fromDB);
  129. if ($fromDB)
  130. {
  131. // As we are querying for a Ticket, parent and root will be equal to self: we don't need to query for them
  132. $q = '
  133. SELECT
  134. hde.timeid, hde.contractnid, hde.txnid,
  135. hde.tidseverity, hde.tidstatus,
  136. hde.tempcontact, hde.attachment,
  137. hdt.stime, hdt.atime, hdt.mtime, hdt.etime,
  138. hde.uidtech, u.name techname
  139. FROM {hd_event} hde
  140. LEFT JOIN {hd_timeinfo} hdt on hde.timeid = hdt.timeid
  141. LEFT JOIN {users} u on hde.uidtech = u.uid
  142. WHERE
  143. hde.nid = %d
  144. ' ;
  145. $req = db_query ($q, $node->nid);
  146. $ar = db_fetch_array($req) ; // Should give exactly one row of result, zero if ticket does not exist yet
  147. foreach ($ar as $key => $value)
  148. {
  149. $this->$key = $value ;
  150. }
  151. echo "<pre>New ticket object: " . print_r ($this, True) . "</pre>\r\n";
  152. }
  153. else
  154. echo "<p>Ticket not from DB</p>" ;
  155. }
  156. /**
  157. * @return string HTML
  158. *
  159. */
  160. function view()
  161. {
  162. $headers = array(
  163. t('Parameter'),
  164. t('Value')
  165. );
  166.  
  167. $cnode = node_load(array('nid' => $this->contractnid));
  168. // Must still add display for timeid, txnid, tempcontact, attachment
  169. $rows = array
  170. ( // Row with attributes on the row and some of its cells.
  171. array
  172. (
  173. t('Current ticket status'),
  174. array ('data' => taxonomy_get_term ($this->tidstatus)->name, 'style' => 'text-align: center')
  175. ),
  176. array
  177. (
  178. t('Current ticket severity'),
  179. array ('data' => taxonomy_get_term ($this->tidseverity)->name, 'style' => 'text-align: center')
  180. ),
  181. array
  182. (
  183. t('Helpdesk Tech in charge'),
  184. array ('data' => isset ($this->techname) ? l($this->techname, "user/$this->uidtech") : t('None assigned yet'), 'style' => 'text-align: center'),
  185. ),
  186. array
  187. (
  188. t('Contract being charged'),
  189. array ('data' => l($cnode->title, "node/$this->contractnid"), 'style' => 'text-align: center'),
  190. )
  191. );
  192. $output = theme_table($headers, $rows);
  193. return $output;
  194. }
  195. }
  196. /**
  197. * @package helpdesk
  198. */
  199. class helpdeskFollowup extends helpdeskTicket
  200. {
  201. }
  202. error_reporting($_event_saved_er) ;
  203. unset($_event_saved_er) ;
  204. // echo "<p>End of " . __FILE__ . "</p>" ;
  205. ?>

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