Documentation is available at event.php
- <?php
- /**
- * Classes helpdeskEvent, helpdeskTicket, helpdeskFollowup
- * @package helpdesk
- * Copyright OSI 2005. All rights reserved.
- * It is expected that version 1.0 will be GPLed, but this interim work
- * is kept closed until 1.0 is ready.
- */
- // echo "<p>Start of " . __FILE__ . "</p>" ;
- $_event_saved_er = error_reporting(E_ALL || E_STRICT) ;
- /**
- * Import time-related code
- */
- require_once("misc.php") ;
- require_once("timeinfo.php") ;
- /**
- * import HD core
- */
- require_once("core.php");
- /**
- * Support contract
- * @package helpdesk
- */
- abstract class helpdeskEvent extends helpdeskObject
- {
- public $nid ; ///< link to drupal node object
- /**
- * Generates the code for hook_form when node is a Helpdesk Contract
- * @return string
- */
- function form ()
- {
- // Now we define the form elements specific to our node type.
- $ret = t ("<p>Defining new %nodename</p>\n", array ('%nodename' => helpdesk_node_name ($node))) ;
- // This would allow format selection, but events are plain text, so we use 1 = filtered html
- // $ret .= filter_form ('format', $node->format);
- $node->format = 1 ; // Filtered HTML
- /**
- * TimeID information for new event
- */
- $ret .= helpdeskTimeInfo::form (
- t ('Date and time problem was notified'),
- t('The start time defines the start of any contractual answering answer time guarantee. '
- . 'It is automatically inserted at the time the issue is created and the '
- . 'ticket is issued.'),
- format_date(time(), 'small', NULL,NULL), TRUE, FALSE,
- format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
- format_date(time(), 'small', NULL,NULL), FALSE, FALSE,
- '', helpdesk_access (HELPDESKHOOKACCESSUPDATE,HELPDESKNODETICKET), TRUE
- ) ;
- /**
- * Contents for new event
- */
- $ret .= form_textarea (
- t ('Describe the issue you\'re having as thouroughly as possible, including the version numbers of any piece of software'
- . ' and the serial number of any product affected by the issue. More precision yields shorter response times.'),
- 'body', isset ($node->body) ? $node->body : '', 60, 20) ;
- return $ret ;
- }
- /**
- * Generates a human-readable ticket number based on the nid of the
- * ticket itself, or the ticket to which a followup is bound
- * @return string the readable ticket number
- */
- abstract function getTicket () ;
- /**
- /**
- * @return string HTML
- *
- * @return unknown
- */
- function view()
- {
- return "helpdeskEvent/view(nid = $this->nid)" ;
- }
- function init($node, $fromDB)
- {
- $this->nid = $node->nid ;
- return get_class($this) . "/view(nid = $this->nid" ;
- }
- /**
- * class constructor
- */
- function __construct()
- {
- $this->nid = 0 ;
- }
- }
- /**
- * @package helpdesk
- */
- class helpdeskTicket extends helpdeskEvent
- {
- public $timeid ;
- public $contractnid ;
- public $txnid ;
- public $tidseverity ;
- public $tidstatus ;
- public $tempcontact ;
- public $attachment ;
- public $uidtech ;
- public $techname;
- /**
- * @return string the readable ticket number
- */
- function getTicket ()
- {
- $prefix = variable_get(HELPDESKVARTICKETPREFIX, '') ;
- $offset = variable_get(HELPDESKVARTICKETOFFSET , 0) ;
- if (!isset($this->nid))
- return '' ;
- else
- return sprintf ("%s%u", $prefix, $offset + $this->nid) ;
- }
- function init($node, $fromDB)
- {
- if (HELPDESKDEBUGALLFUNCTIONS == TRUE)
- { echo "<pre>HD TICKET/init (" . (isset($node->nid) ? $node->nid : 'new node') . ", fromDB = " . ($fromDB ? 'True' : 'False') . ")</pre>\r\n" ; }
- $ret = parent::init($node, $fromDB);
- if ($fromDB)
- {
- // As we are querying for a Ticket, parent and root will be equal to self: we don't need to query for them
- $q = '
- SELECT
- hde.timeid, hde.contractnid, hde.txnid,
- hde.tidseverity, hde.tidstatus,
- hde.tempcontact, hde.attachment,
- hdt.stime, hdt.atime, hdt.mtime, hdt.etime,
- hde.uidtech, u.name techname
- FROM {hd_event} hde
- LEFT JOIN {hd_timeinfo} hdt on hde.timeid = hdt.timeid
- LEFT JOIN {users} u on hde.uidtech = u.uid
- WHERE
- hde.nid = %d
- ' ;
- $req = db_query ($q, $node->nid);
- $ar = db_fetch_array($req) ; // Should give exactly one row of result, zero if ticket does not exist yet
- foreach ($ar as $key => $value)
- {
- $this->$key = $value ;
- }
- echo "<pre>New ticket object: " . print_r ($this, True) . "</pre>\r\n";
- }
- else
- echo "<p>Ticket not from DB</p>" ;
- }
- /**
- * @return string HTML
- *
- */
- function view()
- {
- $headers = array(
- t('Parameter'),
- t('Value')
- );
- $cnode = node_load(array('nid' => $this->contractnid));
- // Must still add display for timeid, txnid, tempcontact, attachment
- $rows = array
- ( // Row with attributes on the row and some of its cells.
- array
- (
- t('Current ticket status'),
- array ('data' => taxonomy_get_term ($this->tidstatus)->name, 'style' => 'text-align: center')
- ),
- array
- (
- t('Current ticket severity'),
- array ('data' => taxonomy_get_term ($this->tidseverity)->name, 'style' => 'text-align: center')
- ),
- array
- (
- t('Helpdesk Tech in charge'),
- array ('data' => isset ($this->techname) ? l($this->techname, "user/$this->uidtech") : t('None assigned yet'), 'style' => 'text-align: center'),
- ),
- array
- (
- t('Contract being charged'),
- array ('data' => l($cnode->title, "node/$this->contractnid"), 'style' => 'text-align: center'),
- )
- );
- $output = theme_table($headers, $rows);
- return $output;
- }
- }
- /**
- * @package helpdesk
- */
- class helpdeskFollowup extends helpdeskTicket
- {
- }
- error_reporting($_event_saved_er) ;
- unset($_event_saved_er) ;
- // echo "<p>End of " . __FILE__ . "</p>" ;
- ?>
Documentation generated on Tue, 01 Nov 2005 23:15:00 +0100 by phpDocumentor 1.3.0RC3