/**
* Cache for the current domain object.
+ * @var object
*/
- static $_domain = NULL;
+ public static $_domain = NULL;
/**
* Cache for a domain's location array
+ * @var array
*/
private $_location = NULL;
public function &getLocationValues() {
if ($this->_location == NULL) {
$domain = self::getDomain(NULL);
- $params = array(
+ $params = [
'contact_id' => $domain->contact_id,
- );
+ ];
$this->_location = CRM_Core_BAO_Location::getValues($params, TRUE);
if (empty($this->_location)) {
* domain
*/
public static function edit(&$params, &$id) {
+ CRM_Utils_Hook::pre('edit', 'Domain', CRM_Utils_Array::value('id', $params), $params);
$domain = new CRM_Core_DAO_Domain();
$domain->id = $id;
$domain->copyValues($params);
$domain->save();
+ CRM_Utils_Hook::post('edit', 'Domain', $domain->id, $domain);
return $domain;
}
* domain
*/
public static function create($params) {
+ $hook = empty($params['id']) ? 'create' : 'edit';
+ CRM_Utils_Hook::pre($hook, 'Domain', CRM_Utils_Array::value('id', $params), $params);
$domain = new CRM_Core_DAO_Domain();
$domain->copyValues($params, TRUE);
$domain->save();
+ CRM_Utils_Hook::post($hook, 'Domain', $domain->id, $domain);
return $domain;
}
/**
* @param bool $skipFatal
- *
+ * @param bool $returnString
* @return array
* name & email for domain
* @throws Exception
$fromName = CRM_Utils_Array::value(1, $fromArray);
break;
}
- return array($fromName, $email);
+ return [$fromName, $email];
}
if ($skipFatal) {
- return array(NULL, NULL);
+ return [NULL, NULL];
}
$url = CRM_Utils_System::url('civicrm/admin/options/from_email_address',
'reset=1'
);
- $status = ts("There is no valid default from email address configured for the domain. You can configure here <a href='%1'>Configure From Email Address.</a>", array(1 => $url));
+ $status = ts("There is no valid default from email address configured for the domain. You can configure here <a href='%1'>Configure From Email Address.</a>", [1 => $url]);
CRM_Core_Error::fatal($status);
}
$groupID = self::getGroupId();
if ($groupID) {
- $contactIDs = array($contactID);
+ $contactIDs = [$contactID];
CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIDs, $groupID);
return $groupID;
*/
public static function getChildGroupIds() {
$domainGroupID = self::getGroupId();
- $childGrps = array();
+ $childGrps = [];
if ($domainGroupID) {
$childGrps = CRM_Contact_BAO_GroupNesting::getChildGroupIds($domainGroupID);
*/
public static function getContactList() {
$siteGroups = CRM_Core_BAO_Domain::getChildGroupIds();
- $siteContacts = array();
+ $siteContacts = [];
if (!empty($siteGroups)) {
$query = "
* Try default from address then fall back to using logged in user details
*/
public static function getDefaultReceiptFrom() {
- $domain = civicrm_api3('domain', 'getsingle', array('id' => CRM_Core_Config::domainID()));
+ $domain = civicrm_api3('domain', 'getsingle', ['id' => CRM_Core_Config::domainID()]);
if (!empty($domain['from_email'])) {
- return array($domain['from_name'], $domain['from_email']);
+ return [$domain['from_name'], $domain['from_email']];
}
if (!empty($domain['domain_email'])) {
- return array($domain['name'], $domain['domain_email']);
+ return [$domain['name'], $domain['domain_email']];
}
$userName = '';
$userEmail = '';
if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
- return array($userName, $userEmail);
+ return [$userName, $userEmail];
}
$userID = CRM_Core_Session::singleton()->getLoggedInContactID();
}
// If still empty fall back to the logged in user details.
// return empty values no matter what.
- return array($userName, $userEmail);
+ return [$userName, $userEmail];
}
/**