/[drupal]/contributions/modules/helpdesk/customer.php
ViewVC logotype

Contents of /contributions/modules/helpdesk/customer.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jan 17 19:55:10 2006 UTC (3 years, 10 months ago) by fgm
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-4-6
File MIME type: text/x-php
First version under CVS control: not yet a working version: only performs a minimal subset of the functionality designed for the module.
1 <?php
2 /**
3 * Class helpdeskUser, helpdeskCustomer
4 * @package helpdesk
5 * Copyright OSI 2005. Licensed under GPL version 2.
6 * $Id$
7 */
8
9 $_customer_saved_er = error_reporting(E_ALL || E_STRICT) ;
10
11 /**
12 * import ancillary functions
13 */
14 require_once("misc.php") ;
15
16 /**
17 * Helpdesk user implementation
18 * @package helpdesk
19 */
20 class helpdeskUser
21 {
22 public $uid ; // Link to core user object
23 public $uidCustomer ; // Link to helpdeskCustomer managing the user
24 public $customerName;
25
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 /**
62 * Helpdesk customer implementation
63 * @package helpdesk
64 */
65 class helpdeskCustomer extends helpdeskUser
66 {
67
68 /**
69 * @return array
70 * @desc Returns the nids of all contracts attached to the customer
71 */
72 function nidContracts ()
73 {
74 $ret = helpdeskContract::getContractsByUid($this->uid) ;
75 return $ret ;
76 }
77
78 /**
79 * gets the list of users bound to a customer account
80 * @return array uid/name pairs
81 */
82 function uidUsers ()
83 {
84 $q = '
85 SELECT
86 u.uid, u.name
87 FROM
88 {hd_user} hdu
89 LEFT JOIN {users} u ON hdu.uid = u.uid
90 WHERE
91 hdu.uidcustomer = %d
92 ORDER BY
93 2, 1
94 ';
95 $res = db_query($q, $this->uid);
96 while ($o = db_fetch_object($res))
97 {
98 // Assigning directly in the while() instruction would add one loop pass with a null value
99 $ret[] = $o;
100 }
101 return $ret ;
102 }
103 }
104
105 error_reporting($_customer_saved_er) ;
106 unset($_customer_saved_er) ;
107 ?>

  ViewVC Help
Powered by ViewVC 1.1.2