-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from JohnFF/maintenance/eileen_updates
Maintenance/eileen updates Massive refresh by Eileen. Contains a minor interface bug fix. Most work is around regenerating values, removing some boilerplate, standards compliance.
- Loading branch information
Showing
24 changed files
with
944 additions
and
499 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Email-Amender | ||
A CiviCRM extension that automatically corrects email addresses as they're added. Includes a handy interface to add new correction settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* EmailAmender.BatchUpdate API specification | ||
* This is used for documentation and validation. | ||
* | ||
* @param array $spec description of fields supported by this API call | ||
* | ||
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | ||
*/ | ||
function _civicrm_api3_email_amender_batch_update_spec(&$spec) { | ||
} | ||
|
||
/** | ||
* EmailAmender.BatchUpdate API specification | ||
* | ||
* @param array $params | ||
* | ||
* @return array API result descriptor | ||
* * @see civicrm_api3_create_success | ||
* | ||
* @throws API_Exception | ||
*@throws \CiviCRM_API3_Exception | ||
* | ||
*/ | ||
function civicrm_api3_email_amender_batch_update($params) { | ||
$candidates = civicrm_api3('EmailAmender', 'find_candidates', $params)['values']; | ||
$result = []; | ||
foreach ($candidates as $candidate) { | ||
$result += civicrm_api3('EmailAmender', 'fix_email', $candidate)['values']; | ||
} | ||
return civicrm_api3_create_success($result, $params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* EmailAmender.find_candidatesAPI specification | ||
* This is used for documentation and validation. | ||
* | ||
* @param array $spec description of fields supported by this API call | ||
* | ||
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | ||
*/ | ||
function _civicrm_api3_email_amender_find_candidates_spec(&$spec) { | ||
|
||
} | ||
|
||
/** | ||
* EmailAmender.find_candidatesAPI specification | ||
* | ||
* @param array $params | ||
* | ||
* @return array API result descriptor | ||
* | ||
* @throws \CiviCRM_API3_Exception | ||
* @throws \API_Exception | ||
* | ||
* @see civicrm_api3_create_success | ||
*/ | ||
function civicrm_api3_email_amender_find_candidates($params) { | ||
$topLevel = Civi::settings()->get('emailamender.top_level_domain_corrections'); | ||
$secondLevel = Civi::settings()->get('emailamender.second_level_domain_corrections'); | ||
|
||
$options = _civicrm_api3_get_options_from_params($params); | ||
$topLevelDomainList = CRM_Utils_Type::escape(implode('|', array_filter(array_keys($topLevel))), 'String'); | ||
$secondLevelDomainList = CRM_Utils_Type::escape(implode('|', array_filter(array_keys($secondLevel))), 'String'); | ||
// Can't use api due to lack of regex support. | ||
// Also - I'm not hunting out subdomains at this stage - it's great that John handled | ||
// edge cases like [email protected] but it feels like it can stay out of scope of this | ||
// api at this stage. | ||
$values = CRM_Core_DAO::executeQuery(" | ||
SELECT id, contact_id, email FROM civicrm_email | ||
WHERE email REGEXP '\.({$topLevelDomainList})$' | ||
OR email REGEXP '@({$secondLevelDomainList})\\\.' | ||
LIMIT " . $options['limit'] | ||
); | ||
$return = []; | ||
while ($values->fetch()) { | ||
$return[$values->id] = ['email' => $values->email, 'id' => $values->id, 'contact_id' => $values->contact_id]; | ||
} | ||
|
||
return civicrm_api3_create_success($return); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* EmailAmender.fix_emailAPI specification | ||
* This is used for documentation and validation. | ||
* | ||
* @param array $spec description of fields supported by this API call | ||
* | ||
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | ||
*/ | ||
function _civicrm_api3_email_amender_fix_email_spec(&$spec) { | ||
|
||
} | ||
|
||
/** | ||
* EmailAmender.fix_emailAPI specification | ||
* | ||
* @param array $params | ||
* | ||
* @return array API result descriptor | ||
* | ||
* @throws \CiviCRM_API3_Exception | ||
* | ||
* @see civicrm_api3_create_success | ||
*/ | ||
function civicrm_api3_email_amender_fix_email($params) { | ||
$emailAmender = CRM_Emailamender::singleton(); | ||
$return = []; | ||
if ($emailAmender->fixEmailAddress($params['id'], $params['contact_id'], $params['email'])) { | ||
$return[$params['id']] = ['id' => $params['id'], 'contact_id' => $params['contact_id']]; | ||
} | ||
|
||
return civicrm_api3_create_success($return); | ||
} |
Oops, something went wrong.