Skip to content
Snippets Groups Projects
Commit f67c169a authored by Sean Madsen's avatar Sean Madsen Committed by GitHub
Browse files

Merge pull request #373 from seamuslee001/civitest_sample_examples

Migrate CiviTest Examples for two hooks that still reference them
parents 09496f77 148dab94
No related branches found
No related tags found
No related merge requests found
......@@ -25,20 +25,31 @@ used to add content to the dashboard page.
- the HTML to include in the dashboard
## Example
function civitest_civicrm_dashboard( $contactID, &$contentPlacement ) {
// REPLACE Activity Listing with custom content
$contentPlacement = 3;
return array( 'Custom Content' => "Here is some custom content: $contactID",
'Custom Table' => "
<table>
<tr><th>Contact Name</th><th>Date</th></tr>
<tr><td>Foo</td><td>Bar</td></tr>
<tr><td>Goo</td><td>Tar</td></tr>
</table>
",
);
}
Also check [Civitest Sample
Module](http://svn.civicrm.org/civicrm/branches/v2.2/drupal/civitest.module.sample)
\ No newline at end of file
```php
function civitest_civicrm_dashboard($contactID, &$contentPlacement) {
// REPLACE Activity Listing with custom content
$contentPlacement = 3;
$content = array(
'Custom Content' => "Here is some custom content: $contactID",
'Custom Table' => "
<table>
<tr><th>Contact Name</th><th>Date</th></tr>
<tr><td>Foo</td><td>Bar</td></tr>
<tr><td>Goo</td><td>Tar</td></tr>
</table>",
);
return $content;
}
```
### CiviTest example
```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
## Example
See civitest.module.sample.
\ No newline at end of file
```php
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