2
/* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */
3
// +----------------------------------------------------------------------+
4
// | Eventum - Issue Tracking System |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 2003 - 2008 MySQL AB |
7
// | Copyright (c) 2008 - 2010 Sun Microsystem Inc. |
8
// | Copyright (c) 2011 - 2013 Eventum Team. |
10
// | This program is free software; you can redistribute it and/or modify |
11
// | it under the terms of the GNU General Public License as published by |
12
// | the Free Software Foundation; either version 2 of the License, or |
13
// | (at your option) any later version. |
15
// | This program is distributed in the hope that it will be useful, |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
// | GNU General Public License for more details. |
20
// | You should have received a copy of the GNU General Public License |
21
// | along with this program; if not, write to: |
23
// | Free Software Foundation, Inc. |
24
// | 59 Temple Place - Suite 330 |
25
// | Boston, MA 02111-1307, USA. |
26
// +----------------------------------------------------------------------+
27
// | Authors: Bryan Alsdorf <bryan@mysql.com> |
28
// +----------------------------------------------------------------------+
32
* Abstract class that all customer backends should extend. This is so any new
33
* customer methods added in future releases won't break existing backends.
35
* @author Bryan Alsdorf <bryan@mysql.com>
37
class Abstract_Customer_Backend
41
* Return what business hours a customer falls into. Mainly used for international
45
* @param integer $customer_id The customer ID
46
* @return string The business hours
48
function getBusinessHours($customer_id)
54
* Returns a message to be displayed to a customer on the top of the issue creation page.
56
* @param array $customer_id Customer ID.
58
function getNewIssueMessage($customer_id)
64
* Checks whether the given customer has a support contract that
65
* enforces limits for the minimum first response time or not.
68
* @param integer $customer_id The customer ID
69
* @param integer $contract_id The contract ID
72
function hasMinimumResponseTime($customer_id, $contract_id = false)
78
* Returns the minimum first response time in seconds for the
79
* support level associated with the given customer.
82
* @param integer $customer_id The customer ID
83
* @param integer $contract_id The contract ID
84
* @return integer The minimum first response time
86
function getMinimumResponseTime($customer_id, $contract_id = false)
92
* Returns the maximum first response time associated with the
93
* support contract of the given customer.
96
* @param integer $customer_id The customer ID
97
* @param integer $contract_id The contract ID
98
* @return integer The maximum first response time, in seconds
100
function getMaximumFirstResponseTime($customer_id, $contract_id = false)
106
* Returns an array of incident types
108
* @return array An array of incident types.
110
function getIncidentTypes()
117
* Returns true if the backend uses support levels, false otherwise
120
* @return boolean True if the project uses support levels.
122
function usesSupportLevels()
129
* Connect to the customer database
139
* Returns the contract status associated with the given customer ID.
140
* Possible return values are 'active', 'in_grace_period' and 'expired'.
143
* @param integer $customer_id The customer ID
144
* @param integer $contract_id The contract ID
145
* @return string The contract status
147
function getContractStatus($customer_id, $contract_id = false)
153
* Retrieves the customer titles associated with the given list of issues.
156
* @param array $result The list of issues
157
* @see Search::getListing()
159
function getCustomerTitlesByIssues(&$result)
165
* Method used to get the details of the given customer.
168
* @param integer $customer_id The customer ID
169
* @return array The customer details
171
function getDetails($customer_id)
177
* Returns true if this issue has been counted a valid incident
179
* @see /docs/Customer_API.html
181
* @param integer $issue_id The ID of the issue
182
* @return boolean True if this is a redeemed incident.
184
function isRedeemedIncident($issue_id)
190
* Marks an issue as a redeemed incident.
192
* @see /docs/Customer_API.html
194
* @param integer $issue_id The ID of the issue
196
function flagIncident($issue_id)
202
* Marks an issue as not a redeemed incident.
204
* @see /docs/Customer_API.html
206
* @param integer $issue_id The ID of the issue
208
function unflagIncident($issue_id)
214
* Checks whether the active per-incident contract associated with the given
215
* customer ID has any incidents available to be redeemed.
218
* @param integer $customer_id The customer ID
221
function hasIncidentsLeft($customer_id)
227
* Checks whether the active contract associated with the given customer ID
228
* is a per-incident contract or not.
231
* @param integer $customer_id The customer ID
234
public function hasPerIncidentContract($customer_id)
241
* Returns the total number of allowed incidents for the given support
245
* @param integer $prj_id The project ID
246
* @param integer $support_no The support contract ID
247
* @return integer The total number of incidents
249
function getTotalIncidents($support_no)
255
* Returns the number of incidents remaining for the given support
259
* @param integer $support_no The support contract ID
260
* @return integer The number of incidents remaining.
262
function getIncidentsRemaining($support_no)
268
* Method used to send a notice that the per-incident limit being reached.
271
* @param integer $contact_id The customer contact ID
272
* @param integer $customer_id The customer ID
273
* @param boolean $new_issue If the customer just tried to create a new issue.
276
function sendIncidentLimitNotice($contact_id, $customer_id, $new_issue = false)
282
* Returns a list of customers (companies) in the customer database.
285
* @return array An associated array of customers.
287
function getAssocList()
293
* Method used to get the customer names for the given customer id.
296
* @param integer $customer_id The customer ID
297
* @return string The customer name
299
function getTitle($customer_id)
305
* Method used to get an associative array of the customer names
306
* for the given list of customer ids.
309
* @param array $customer_ids The list of customers
310
* @return array The associative array of customer id => customer name
312
function getTitles($prj_id, $customer_ids)
318
* Method used to get the list of email addresses associated with the
319
* contacts of a given customer.
322
* @param integer $customer_id The customer ID
323
* @return array The list of email addresses
325
function getContactEmailAssocList($customer_id)
331
* Method used to get the customer and customer contact IDs associated
332
* with a given list of email addresses.
335
* @param array $emails The list of email addresses
336
* @return array The customer and customer contact ID
338
function getCustomerIDByEmails($emails)
344
* Method used to get the overall statistics of issues in the system for a
348
* @param integer $customer_id The customer ID
349
* @return array The customer related issue statistics
351
function getOverallStats($customer_id)
357
* Method used to build the overall customer profile from the information
358
* stored in the customer database.
361
* @param integer $usr_id The Eventum user ID
362
* @return array The customer profile information
364
function getProfile($usr_id)
370
* Method used to get the contract details for a given customer contact.
373
* @param integer $contact_id The customer contact ID
374
* @return array The customer contract details
376
function getContractDetails($contact_id, $restrict_expiration = TRUE)
382
* Method used to get the details associated with a customer contact.
385
* @param integer $contact_id The customer contact ID
386
* @return array The contact details
388
function getContactDetails($contact_id)
394
* Returns the list of customer IDs that are associated with the given
395
* email value (wildcards welcome).
398
* @param string $email The email value
399
* @return array The list of customer IDs
401
function getCustomerIDsLikeEmail($email)
407
* Method used to notify the customer contact that an existing issue
408
* associated with him was just marked as closed.
411
* @param integer $issue_id The issue ID
412
* @param integer $contact_id The customer contact ID
415
function notifyIssueClosed($issue_id, $contact_id)
421
* Performs a customer lookup and returns the matches, if
425
* @param string $field The field that we are trying to search against
426
* @param string $value The value that we are searching for
427
* @param array $options An array of options for search
428
* @return array The list of customers
430
function lookup($field, $value, $options)
436
* Method used to notify the customer contact that a new issue was just
437
* created and associated with his Eventum user.
440
* @param integer $issue_id The issue ID
441
* @param integer $contact_id The customer contact ID
444
function notifyCustomerIssue($issue_id, $contact_id)
450
* Method used to get the list of available support levels.
453
* @return array The list of available support levels
455
function getSupportLevelAssocList()
461
* Returns the support level of the current support contract for a given
465
* @param integer $customer_id The customer ID
466
* @param integer $contract_id The contract ID
467
* @return string The support contract level
469
function getSupportLevelID($customer_id, $contract_id = false)
475
* Returns the list of customer IDs for a given support contract level.
478
* @param integer $support_level_id The support level ID
479
* @param mixed $support_options An integer or array of integers indicating various options to get customers with.
480
* @return array The list of customer IDs
482
function getListBySupportLevel($support_level_id, $support_options = false)
488
* Returns an array of support levels grouped together.
491
* @return array an array of support levels.
493
function getGroupedSupportLevels()
499
* Method used to send an expiration notice.
502
* @param integer $contact_id The customer contact ID
503
* @param boolean $is_expired Whether this customer is expired or not
506
function sendExpirationNotice($contact_id, $is_expired = FALSE)
512
* Checks whether the given technical contact ID is allowed in the current
513
* support contract or not.
516
* @param integer $customer_contact_id The customer technical contact ID
519
function isAllowedSupportContact($customer_contact_id)
525
* Method used to get the associated customer and customer contact from
526
* a given set of support emails. This is especially useful to automatically
527
* associate an issue to the appropriate customer contact that sent a
531
* @param array $sup_ids The list of support email IDs
532
* @return array The customer and customer contact ID
534
function getCustomerInfoFromEmails($sup_ids)
540
* Method used to send an email notification to the sender of a
541
* set of email messages that were manually converted into an
545
* @param integer $issue_id The issue ID
546
* @param array $sup_ids The email IDs
547
* @param integer $customer_id The customer ID
548
* @return array The list of recipient emails
550
function notifyEmailConvertedIntoIssue($issue_id, $sup_ids, $customer_id = FALSE)
556
* Method used to send an email notification to the sender of an
557
* email message that was automatically converted into an issue.
560
* @param integer $issue_id The issue ID
561
* @param string $sender The sender of the email message (and the recipient of this notification)
562
* @param string $date The arrival date of the email message
563
* @param string $subject The subject line of the email message
566
function notifyAutoCreatedIssue($issue_id, $sender, $date, $subject)
572
* Method used to get the customer login grace period (number of days).
575
* @return integer The customer login grace period
577
function getExpirationOffset()
583
* Method used to get the details of the given customer contact.
586
* @param integer $contact_id The customer contact ID
587
* @return array The customer details
589
function getContactLoginDetails($contact_id)
595
* Returns the end date of the current support contract for a given
599
* @param integer $customer_id The customer ID
600
* @param integer $contract_id The contract ID
601
* @return string The support contract end date
603
function getContractEndDate($customer_id, $contract_id = false)
609
* Returns the name and email of the sales account manager of the given customer ID.
612
* @param integer $customer_id The customer ID
613
* @return array An array containing the name and email of the sales account manager
615
function getSalesAccountManager($customer_id)
621
* Returns the start date of the current support contract for a given
625
* @param integer $customer_id The customer ID
626
* @param integer $contract_id The contract ID
627
* @return string The support contract start date
629
function getContractStartDate($customer_id, $contract_id = false)
634
function getSupportLevelsByIssues(&$result)