29
22
protected $connection;
32
* If this contact exists
39
25
* The ID of the contact this object represents
43
29
protected $contact_id;
46
* The name of the contact
32
* The first_name of the contact
36
protected $first_name;
39
* The first_name of the contact
53
46
* The primary email address of this contact.
60
* The primary phone number of thie contact.
53
* The primary phone number of this contact.
60
* If the contact is active. Inactive contacts should not be able to login
67
67
* Contracts associated with this contact
71
protected $associated_contract_ids = array();
71
protected $associated_contracts = array();
74
74
* Constructs the object representing this contact and loads contact data.
77
* @param integer $contact_id
77
* @param string $contact_id
78
* @throws ContactNotFoundException
79
80
function __construct(CRM &$crm, $contact_id)
91
* Convenience method for setting all contact data at once. This probably is only used by batch
92
* scripts setting up customers.
94
* @param string $customer_id
96
* @param string $email
97
* @param string $phone
99
public function setData($customer_id, $name, $email, $phone)
101
$this->customer = &$this->crm->getCustomer($customer_id);
103
$this->email = $email;
104
$this->phone = $phone;
109
92
* Returns an array of contracts the specified contact can access
111
94
* @param array|boolean $options An array of options that determine which contracts should be returned. For Legacy purposes, if this
112
95
* is boolean then it will be used to indicate if only active contracts should be returned.
113
* @return array An array of support contracts this contact is allowed to access
96
* @return Contract[] An array of support contracts this contact is allowed to access
115
98
abstract public function getContracts($options = false);
102
* Returns an array of contracts ids the contact can access
104
* @param array|boolean $options An array of options that determine which contracts should be returned. For Legacy purposes, if this
105
* is boolean then it will be used to indicate if only active contracts should be returned.
106
* @return integer[] An array of support contract ids this contact is allowed to access
108
abstract public function getContractIDs($options = false);
112
* Returns the customer ids that this contact can access
116
abstract public function getCustomerIDs();
120
* Returns the customer that this contact can access
124
abstract public function getCustomers();
119
128
* Returns true if associated with any active contracts, false otherwise. Optionally
120
129
* takes a support level type. If the type is passed, true will only be a returned
121
130
* if an active contract of the specified type exists.
139
148
* associated with him was just marked as closed.
141
150
* @param integer $issue_id The issue ID
151
* @param string $reason
144
abstract public function notifyIssueClosed($issue_id);
154
abstract public function notifyIssueClosed($issue_id, $reason);
147
* Stores the object in the database. Returns true on success, PEAR_error otherwise.
157
* Loads contact info into the object
149
* @return mixed True on success, PEAR_error otherwise.
160
* @throws ContactNotFoundException
151
abstract public function save();
154
// this method must set the $exists variable
155
162
abstract protected function load();
166
* Returns true if the contact can access the specified contract, false otherwise
168
* @param Contract $contract
171
abstract public function canAccessContract($contract);
158
174
public function getContactID()
160
176
return $this->contact_id;
163
179
public function getName()
181
return $this->first_name . " " . $this->last_name;
184
public function getFirstName()
186
return $this->first_name;
189
public function getLastName()
191
return $this->last_name;
168
194
public function getEmail()
175
201
return $this->phone;
178
public function getCustomerID()
180
return $this->customer->getCustomerID();
184
* Returns a customer object
188
public function &getCustomer()
190
return $this->customer;
193
public function exists()
195
return $this->exists;
199
204
public function __toString()
201
206
return "Contact\nID: " . $this->contact_id . "\n" .
202
"Name: " . $this->name . "\n";
207
"Name: " . $this->getName() . "\n";
213
public function getActive()
215
return $this->active;
220
* Method used to notify the customer contact that a new issue was just
221
* created and associated with his Eventum user.
223
* @param integer $issue_id The issue ID
226
abstract public function notifyNewIssue($issue_id);
230
class ContactNotFoundException extends CRMException
232
public function __construct($contact_id, $message = null, Exception $previous=null) {
233
if ($message !== null) {
234
$message = "Contact '" . $contact_id. "' not found";
236
parent::__construct($message, 0, $previous);
b'\\ No newline at end of file'