Skip to content
Snippets Groups Projects
Commit 148dab94 authored by Seamus Lee's avatar Seamus Lee
Browse files

Migrate CiviTest Examples for two hooks that still reference them

parent 09496f77
No related branches found
No related tags found
1 merge request!373Migrate CiviTest Examples for two hooks that still reference them
...@@ -25,20 +25,31 @@ used to add content to the dashboard page. ...@@ -25,20 +25,31 @@ used to add content to the dashboard page.
- the HTML to include in the dashboard - the HTML to include in the dashboard
## Example ## Example
```php
function civitest_civicrm_dashboard( $contactID, &$contentPlacement ) { function civitest_civicrm_dashboard($contactID, &$contentPlacement) {
// REPLACE Activity Listing with custom content // REPLACE Activity Listing with custom content
$contentPlacement = 3; $contentPlacement = 3;
return array( 'Custom Content' => "Here is some custom content: $contactID", $content = array(
'Custom Table' => " 'Custom Content' => "Here is some custom content: $contactID",
<table> 'Custom Table' => "
<tr><th>Contact Name</th><th>Date</th></tr> <table>
<tr><td>Foo</td><td>Bar</td></tr> <tr><th>Contact Name</th><th>Date</th></tr>
<tr><td>Goo</td><td>Tar</td></tr> <tr><td>Foo</td><td>Bar</td></tr>
</table> <tr><td>Goo</td><td>Tar</td></tr>
", </table>",
); );
} return $content;
}
Also check [Civitest Sample ```
Module](http://svn.civicrm.org/civicrm/branches/v2.2/drupal/civitest.module.sample) ### CiviTest example
\ No newline at end of file ```php
function civitest_civicrm_dashboard_defaults($availableDashlets, &$defaultDashlets){
$contactID = CRM_Core_Session::singleton()->get('userID');
$defaultDashlets[] = array(
'dashboard_id' => 3,
'is_active' => 1,
'column_no' => 1,
'contact_id' => $contactID,
);
}
```
...@@ -44,4 +44,48 @@ This hook was first available in CiviCRM 4.1.0 ...@@ -44,4 +44,48 @@ This hook was first available in CiviCRM 4.1.0
## Example ## Example
See civitest.module.sample. ```php
\ No newline at end of file function civitest_civicrm_emailProcessorContact( $email, $contactID, &$result ) {
require_once 'CRM/Utils/Mail/Incoming.php';
// first split the email into name and domain
// really simple, definitely wrong implementation
list($mailName, $mailDomain) = CRM_Utils_System::explode('@', $email, 2);
// we are doing all our checks based on mailDomain, so if empty
// return and let EmailProcessor do its own thing
if (empty($mailDomain)) {
return;
}
define('FILE_TO_ORG_ALWAYS_TAG', 'MyTag1');
$orgID = _civitest_find_org_with_tag(FILE_TO_ORG_ALWAYS_TAG, $mailDomain);
if ($orgID) {
$result = array(
'contactID' => $orgID,
'action' => CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE,
);
return;
}
// if we already have a match, we will
// return and let EmailProcessor do its own thing
if ($contactID) {
return;
}
// Orgs with this tag will have same-domain emails filed on them only if it
// passes through the ALWAYS tag check without finding a match, AND it does
// not match an individual.
define('FILE_TO_ORG_INDIVIDUAL_UNMATCHED_TAG', 'MyTag2');
$orgID = _civitest_find_org_with_tag(FILE_TO_ORG_INDIVIDUAL_UNMATCHED_TAG, $mailDomain);
if ($orgID) {
$result = array(
'contactID' => $orgID,
'action' => CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE);
return;
}
$result = array('action' => CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL);
}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment