Compare commits

..

64 Commits
2.0 ... master

Author SHA1 Message Date
rt
03a799a290 Update 'fancytokens.php'
502: 	            $sql = "SELECT e.id , e.summary,  e.title, e.registration_link_text, 
503: +	             e.start_date as start_date  ,
505: 	             if( e.is_online_registration = 1 AND

576: 	            $sql = "SELECT e.id , e.summary,  e.title, e.registration_link_text, 
e.start_date as start_date  ,
2019-10-30 08:41:13 +00:00
rt
adc61f2d58 Update 'fancytokens.php'
Changed format of date and texts
Résumé des changements
31:   		$e_start_date = $dao->start_date;
32: -  		$label = 'Registration Page: '.$e_title.' on '.$e_start_date.' (id: '.$e_id.')  :: Events'; 
33: +  		$label = 'Registration Page: '.$e_title.' '.$e_start_date.' (id: '.$e_id.')  :: Events'; 
34:   		$key = 'communitynews.event_registrationpage___'.$e_id ;

502: 	            $sql = "SELECT e.id , e.summary,  e.title, e.registration_link_text, 
503: -	             date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date  ,
504: +	             date_format( e.start_date, '%d/%m/%Y à %Hh%i' ) as start_date  ,
505: 	             if( e.is_online_registration = 1 AND

553:   		     	} 
554: -  		     	$tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> on ".
555: +  		     	$tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> ".
556:   		     		$e_start_date.$register_html.$summary_html;

576: 	            $sql = "SELECT e.id , e.summary,  e.title, e.registration_link_text, 
577: -	             date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date  ,
578: +	             date_format( e.start_date, '%d/%m/%Y à %Hh%i' ) as start_date  ,
579: 	             if( e.is_online_registration = 1 AND

627:   		     	} 
628: -  		     	$tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." on ".
629: +  		     	$tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." ".
630:   		     		$e_start_date.$register_html.$summary_html;
2019-10-30 08:33:15 +00:00
Sarah Poger Gladstone
2bbbf9aa43
Update info.xml 2019-05-30 00:30:02 -04:00
Sarah Poger Gladstone
98a9042f94
Update README.md 2019-05-30 00:28:33 -04:00
Sarah Poger Gladstone
2cf7197082
Update fancytokens.php 2019-05-30 00:25:18 -04:00
Sarah Poger Gladstone
6166e0b41e
Update fancytokens.php 2019-05-29 23:54:25 -04:00
Sarah Poger Gladstone
03c517e3aa
Update fancytokens.php 2019-05-29 23:39:59 -04:00
Sarah Poger Gladstone
0ad2f42fa2
updated version info 2019-05-28 06:41:58 -04:00
Sarah Poger Gladstone
7cb8bff32c
fixed SSL checks 2019-05-28 06:37:55 -04:00
Sarah Poger Gladstone
3422d6b46c
fixed gender labels 2019-05-28 06:06:22 -04:00
Sarah Poger Gladstone
b64cef5627
added petition logic 2019-05-28 06:00:29 -04:00
Sarah Poger Gladstone
e1d93ac1cf
fixed typo 2019-05-28 04:51:10 -04:00
Sarah Poger Gladstone
13f10399e9
api call for checksum expiration 2019-05-28 04:39:35 -04:00
Sarah Poger Gladstone
3802edc486
added logic for checksum expiration date token 2019-05-28 04:36:29 -04:00
Sarah Poger Gladstone
4c192235e7
fixed typo 2019-05-27 16:28:48 -04:00
Sarah Poger Gladstone
de6827f80b
fixed missing semicolon 2019-05-27 16:27:41 -04:00
Sarah Poger Gladstone
776f666d94
updated version info 2019-05-27 16:14:53 -04:00
Sarah Poger Gladstone
35485af11d
updated prefix behavior, handling of private events 2019-05-27 09:38:50 -04:00
Sarah Poger Gladstone
e72264f058
updated behavior for prefixes related to gender
When the gender is not 'Male' or 'Female' for a contact without a prefix, no assumptions are made. If the greeting token that needs "Mr. " or "Dr." or "Ms." is used in this case, the unknown prefix will be "UNKNOWN PREFIX"
2019-05-27 09:37:25 -04:00
Sarah Poger Gladstone
ec1e8314c7
Allow tokens of type event_registrationpage to work for private events 2019-05-27 09:22:10 -04:00
sgladstone
4333b6ca8e added communication tokens (ie all emails, all phone numbers) 2016-09-05 15:08:57 -04:00
Sarah Gladstone
32bfadcb66 updated date 2016-08-26 15:42:28 -04:00
Sarah Gladstone
1d79d93af5 updated urls 2016-08-26 15:41:58 -04:00
Sarah Gladstone
797a94eccb updated code 2016-08-26 15:40:17 -04:00
Sarah Gladstone
39d7d3ff75 updated code 2016-08-26 13:22:36 -04:00
Sarah Gladstone
59a2ab2bf5 updated version 2016-08-26 10:28:48 -04:00
Sarah Gladstone
9488f1a0b3 fixed warnings 2016-08-26 10:27:05 -04:00
Sarah Gladstone
99838677b7 fixed typo 2016-08-26 09:57:11 -04:00
Sarah Gladstone
27702f4d80 updated code 2016-08-26 09:49:51 -04:00
Sarah Gladstone
f07759184e added description of tokens 2016-08-26 09:47:57 -04:00
Sarah Gladstone
d60bdb098b added tokens for "greetings" for couples, housholds, and single people. 2016-08-26 09:29:35 -04:00
sgladstone
b17dd2d8b4 Updated version info for CiviCRM 4.7.x 2016-07-24 18:23:10 -04:00
Sarah Poger Gladstone
2d003153df Update .project 2016-07-24 18:18:52 -04:00
Sarah Poger Gladstone
f2247b7c29 fixed extra text 2016-07-24 17:48:47 -04:00
Sarah Poger Gladstone
bcbadc64fe Create .buildpath 2016-07-24 17:36:09 -04:00
Sarah Poger Gladstone
8b88267991 Create .project 2016-07-24 17:35:26 -04:00
Sarah Poger Gladstone
ce057368e2 updated version information 2016-05-20 09:51:56 -04:00
Sarah Poger Gladstone
b9cca6e139 Merge pull request #12 from PalanteJon/fix-array-ptypes
Fix in_array and explode warnings
2016-05-20 09:49:35 -04:00
Jon goldberg
f123890b01 Fix in_array and explode warnings 2016-05-20 00:10:22 -04:00
Sarah Poger Gladstone
7103382fec Update fancytokens.php 2016-04-02 13:15:00 -04:00
Sarah Poger Gladstone
5845e4d512 Update info.xml 2015-12-06 06:04:47 -05:00
Sarah Poger Gladstone
59b353ed8c Merge pull request #9 from colemanw/patch-1
Prevent possible fatal error
2015-12-04 20:56:54 -05:00
colemanw
fcf17df571 Prevent possible fatal error 2015-11-21 15:06:00 -05:00
Sarah Poger Gladstone
25ac625ebc Update README.md 2015-11-21 14:25:34 -05:00
Sarah Poger Gladstone
4bd5c885f6 Update info.xml 2015-11-21 14:21:47 -05:00
Sarah Poger Gladstone
bce5c1e0fe Query Drupal tables using Drupal API
Use Drupal API for querying Drupal tables, this way if drupal table prefixes are used Drupal handles this automatically.
2015-11-21 14:20:29 -05:00
Sarah Poger Gladstone
8130a3f6a1 cleaned up description 2015-05-28 10:50:32 -04:00
Sarah Poger Gladstone
623e267af9 update versions 2015-05-28 10:34:30 -04:00
Sarah Poger Gladstone
a478746281 update name 2015-05-28 10:33:51 -04:00
Sarah Poger Gladstone
aebddc6e04 improve name 2015-05-28 10:16:26 -04:00
Sarah Poger Gladstone
2d6e77a250 updated list of versions 2015-05-26 09:25:53 -04:00
Sarah Gladstone
c6d741dbcd Merge pull request #4 from rajeshrhino/master
Generate URL using CRM_Utils_System::url function to cater for all CMS
2015-02-10 05:25:59 -05:00
Rajesh Sundararajan
6bec40cfe0 Disabled organisation type in profile for fancy tokens 2015-02-06 16:27:55 +00:00
Rajesh Sundararajan
c6ac04af50 Generate URL using CRM_Utils_System::url function to cater for all CMS 2015-01-26 16:09:51 +00:00
Sarah Gladstone
fac36ad426 Update for version 4.5 2014-11-12 00:36:30 -05:00
Sarah Gladstone
e12474306c Update for version 4.5 2014-11-12 00:35:39 -05:00
Sarah Gladstone
858cfea106 Rename InsertTokens.tpl to InsertTokensBAK.tpl 2014-11-12 00:34:34 -05:00
Sarah Gladstone
44b9324946 Update info.xml 2014-09-11 21:00:01 -04:00
Sarah Gladstone
35bb10341e Update README.md 2014-09-11 09:26:31 -04:00
Sarah Gladstone
54207cfc55 Update README.md 2014-09-03 19:00:01 -04:00
Sarah Gladstone
e5cc09ce0c Update README.md 2014-09-03 18:59:36 -04:00
Sarah Gladstone
1b0cc8eac9 Update README.md 2014-09-03 18:57:38 -04:00
Sarah Gladstone
85448ba7ef Update fancytokens.php 2014-09-03 18:53:46 -04:00
Sarah Gladstone
9da5cf26fa Update info.xml 2014-09-03 18:51:38 -04:00
8 changed files with 1761 additions and 48 deletions

5
.buildpath Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

28
.project Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Fancy Tokens</name>
<comment>This file and the .buildpath file make Eclipse happy</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View File

@ -1,6 +1,6 @@
Install this extension as you would any other CiviCRM extension.
Install this extension as you would any other CiviCRM extension. If you are using Drupal Webforms and your Drupal tables are in a different database than your CiviCRM tables then you will need to verify that the CiviCRM database user has permission to query tables in the Drupal database.
Additional mail merge tokens for CiviCRM for use in emails, mass emails, or PDF letters. All the token descriptions start with "Community News & Enagagement".
This extension provides additional mail merge tokens for CiviCRM for use in emails, mass emails, or PDF letters. All the tokens are under one of the following token categories: "Events", "Contribution Pages", "Forms" or "Greetings"
Main features:
@ -10,4 +10,29 @@ Main features:
C) There is a token for each of the next X event registration pages ( i.e. future events that also have online registration enabled). The token includes the event ID which can be manually changed to any valid event ID. The hyperlink will include the checksum for the recipient.
D) There is one token for each active profile that does not use any fields that would prevent it from being used as a stand-alone profile form. For example, it does not create tokens for profiles that use participant or contribution fields. This token will produce a hyperlink that includes the checksum for the recipient. The clickable text will be the title of the profile.
D) There is a token for each active Petition (Petitions are part of CiviCampaign) The hyperlink will include the checksum for the recipient.
E) There is one token for each active profile that does not use any fields that would prevent it from being used as a stand-alone profile form. For example, it does not create tokens for profiles that use participant or contribution fields. This token will produce a hyperlink that includes the checksum for the recipient. The clickable text will be the title of the profile.
F) If this extension is running under Drupal and the CiviCRM-WebForm integration module is installed, then one token will be created for each published WebForm. (This logic checks if Drupal is in use before attempting to call any Drupal APIs. So this extension is safe to use with WordPress, Joomla and Stand-Alone. (Note: The only version of Drupal this has been tested with is Drupal7.)
G) There are a set of tokens under the category "Greetings" that provide convenient tokens for addressing married couples, households, and also single people. For example, Sometimes you want to use the nickname if not empty, otherwise fallback to their first name. (The greetings for couples currently only work for the English language)
Greeting tokens:
'greetings.joint_casual' - 'Casual: Mike and Judy Kline (Uses nickname if available) '
'greetings.solo_casual' - 'Casual: Mike Kline (Uses nickname if available, does not show spouse) '
'greetings.joint_casual_firstname_lastname' - 'Casual first name and last name: Michael and Judith Kline'
'greetings.joint_casual_nickname_only' - 'Casual nickname only: Mike and Judy (Uses nickname if available)'
'greetings.solo_casual_nickname_only' - 'Casual nickname only: Mike(Uses nickname if available, does not show spouse)'
'greetings.joint_casual_firstname_only' - 'Casual first name only: Michael and Judith'
'greetings.joint_formal' - 'Formal: Mr. and Mrs. Kline'
'greetings.joint_formal_firstname' - 'Formal with first name: Mr. and Mrs. Michael Kline'
If any of these greeting tokens are used for an organization, then the display name is used.

View File

@ -5,11 +5,11 @@ require_once 'fancytokens.civix.php';
function fancytokens_civicrm_tokens( &$tokens ){
$tokens['communitynews'] = array(
'communitynews.upcomingevents___day_7' => 'Community News & Engagement: Events in the next 7 days',
'communitynews.upcomingevents___day_14' => 'Community News & Engagement: Events in the next 14 days',
'communitynews.upcomingevents___day_30' => 'Community News & Engagement: Events in the next 30 days',
'communitynews.upcomingevents___week_3' => 'Community News & Engagement: Events in the next 3 weeks',
'communitynews.upcomingevents___month_3' => 'Community News & Engagement: Events in the next 3 months',
'communitynews.upcomingevents___day_7' => 'Events in the next 7 days :: Events',
'communitynews.upcomingevents___day_14' => 'Events in the next 14 days :: Events',
'communitynews.upcomingevents___day_30' => 'Events in the next 30 days :: Events',
'communitynews.upcomingevents___week_3' => 'Events in the next 3 weeks :: Events',
'communitynews.upcomingevents___month_3' => 'Events in the next 3 months :: Events',
);
@ -29,7 +29,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
$e_id = $dao->id;
$e_title = $dao->title;
$e_start_date = $dao->start_date;
$label = 'Community News & Engagement: Event Registration Page: '.$e_title.' on '.$e_start_date.' (id: '.$e_id.')';
$label = 'Registration Page: '.$e_title.' '.$e_start_date.' (id: '.$e_id.') :: Events';
$key = 'communitynews.event_registrationpage___'.$e_id ;
$tokens['communitynews'][$key] = $label;
@ -52,7 +52,28 @@ function fancytokens_civicrm_tokens( &$tokens ){
foreach($contrib_pages as $cur){
$key = 'communitynews.contributionpage___'.$cur['id'] ;
$label = 'Community News & Engagement: Contribution Page: '.$cur['title'].' (id: '.$cur['id'].')';
$label = $cur['title'].' (id: '.$cur['id'].') :: Contribution Pages';
$tokens['communitynews'][$key] = $label;
}
}
// Create tokens for all active Petitions ( part of CiviCampaign)
$params = array(
'sequential' => 1,
'is_active' => 1,
'activity_type_id.name' => 'Petition',
);
$result = civicrm_api3('Survey', 'get', $params);
if( $result['is_error'] <> 0 ){
print "<br><br>Error calling get API for Survey-Petition";
print_r($result);
}else{
$petitions = $result['values'] ;
foreach($petitions as $cur){
$key = 'communitynews.signpetition___'.$cur['id'] ;
$label = $cur['title'].' (id: '.$cur['id'].') :: Petitions';
$tokens['communitynews'][$key] = $label;
}
@ -78,38 +99,280 @@ function fancytokens_civicrm_tokens( &$tokens ){
$p_type = "";
if( isset( $cur['group_type'])){
$p_type = $cur['group_type'];
// Some group_types are arrays, if the profile is used on an event form
$p_type = is_array($p_type) ? $p_type[0] : $p_type;
}
$type_array = explode( "," , $p_type); // Contributions Activity
if ( false == ( in_array("Participant", $type_array ) || in_array("Organization", $type_array ) || in_array("Membership", $type_array ) || in_array("Household", $type_array ) || in_array("Contributions", $type_array ) || in_array("Activity", $type_array ) )) {
if ( false == ( in_array("Participant", $type_array ) || in_array("Membership", $type_array ) || in_array("Household", $type_array ) || in_array("Contributions", $type_array ) || in_array("Activity", $type_array ) )) {
$key = 'communitynews.standaloneprofile___'.$cur['id'] ;
$label = 'Community News & Engagement: Standalone Profile Form: '.$cur['title'].' (id: '.$cur['id'].')';
$label = $cur['title'].' (id: '.$cur['id'].') :: Forms';
$tokens['communitynews'][$key] = $label;
}
}
}
}
// Check if this is Drupal, and if so check if the 'WebForm CiviCRM' module is installed.
// Then generate tokens for each published Drupal WebForm that uses CiviCRM integration.
$config = CRM_Core_Config::singleton();
//print "<br><br>";
//print_r($config);
if ($config->userSystem->is_drupal){
if (function_exists("module_exists") && module_exists("webform_civicrm")) {
//$drupal_db = getUserFrameworkDatabaseName();
//$sql = "SELECT cforms.nid, node.title FROM $drupal_db.webform_civicrm_forms cforms
// JOIN $drupal_db.node ON cforms.nid = node.nid AND node.status = 1 ";
$dsql = "SELECT cforms.nid, node.title FROM {webform_civicrm_forms} cforms
JOIN {node} node ON cforms.nid = node.nid AND node.status = 1 ";
$dq_result = db_query( $dsql );
foreach ($dq_result as $record) {
$nid = $record->nid;
$title = $record->title;
$key = 'communitynews.dwform___'.$nid ;
$label = "$title (nid: $nid) :: Forms";
$tokens['communitynews'][$key] = $label;
}
}
}
$tok_category_label = " :: Greetings";
$tokens['greetings'] = array(
'greetings.joint_casual' => 'Casual: Mike and Judy Kline (Uses nickname if available) '.$tok_category_label,
'greetings.solo_casual' => 'Casual: Mike Kline (Uses nickname if available, does not show spouse) '.$tok_category_label,
'greetings.joint_casual_firstname_lastname' => 'Casual first name and last name: Michael and Judith Kline'.$tok_category_label,
'greetings.joint_casual_nickname_only' => 'Casual nickname only: Mike and Judy (Uses nickname if available)'.$tok_category_label,
'greetings.solo_casual_nickname_only' => 'Casual nickname only: Mike(Uses nickname if available, does not show spouse)'.$tok_category_label,
'greetings.joint_casual_firstname_only' => 'Casual first name only: Michael and Judith'.$tok_category_label,
'greetings.joint_formal' => 'Formal: Mr. and Mrs. Kline'.$tok_category_label,
'greetings.joint_formal_firstname' => 'Formal with first name: Mr. and Mrs. Michael Kline'.$tok_category_label,
);
$tok_category_label = " :: Dates";
$tokens['dates'] = array(
'dates.today' => 'Today (m/d/yyyy)'.$tok_category_label,
'dates.today___j_F_yyyy' => 'Today (d monthname yyyy)'.$tok_category_label,
'dates.today___F_j_yyyy' => 'Today (monthname d, yyyy)'.$tok_category_label,
'dates.birth_date___F_j' => 'Birth Date (monthname d)'.$tok_category_label,
'dates.checksum_expiration' => 'Checksum Expiration Date '.$tok_category_label,
);
$tok_category_label = " :: Communication";
$tokens['communication'] = array(
'communication.phone_all' => 'All Phone Numbers'.$tok_category_label,
'communication.email_all' => 'All Email Addresses'.$tok_category_label,
);
}
function getUserFrameworkDatabaseName(){
// ['userFrameworkDSN'] => mysql://dev1_username:mypassword@localhost/dev1_main?new_link=true
$cms_db_name = "";
$config = CRM_Core_Config::singleton();
$cms_dsn_str = $config->userFrameworkDSN ;
$cms_tmp1 = explode( '@', $cms_dsn_str) ;
$cms_tmp2 = explode( '/', $cms_tmp1[1]);
$cms_tmp3 = explode( '?', $cms_tmp2[1]);
//print "<br><br>".$cms_tmp2[1];
if( strlen($cms_tmp3[0]) > 0){
$cms_db_name = $cms_tmp3[0];
}
return $cms_tmp3[0];
}
function fancytokens_civicrm_tokenValues( &$values, &$contactIDs, $job = null, $tokens = array(), $context = null) {
if(!empty($tokens['dates'])){
// deal with tokens for 'today', birth_date', and similar.
$today = date_create();
$checksum_expire_result = civicrm_api3('Setting', 'get', [ 'sequential' => 1, 'return' => ["checksum_timeout"], ]);
$checksum_expire_date_tmp = "" ;
if ($checksum_expire_result['is_error'] == 0 && $checksum_expire_result['count'] == 1){
$tmp_checksum_int = $checksum_expire_result['values'][0]['checksum_timeout'];
$interval_str = $tmp_checksum_int." days" ;
$exp_date = date_create();
date_add($exp_date, date_interval_create_from_date_string($interval_str));
$checksum_expire_date_tmp = date_format($exp_date, 'F j');
}else{
# print_r( $checksum_expire_result );
}
foreach ( $contactIDs as $cid ) {
$values[$cid]['dates.today'] = date("n/j/Y");
$values[$cid]['dates.today___j_F_yyyy'] = date("j F Y");
$values[$cid]['dates.today___F_j_yyyy'] = date("F j, Y");
$values[$cid]['dates.checksum_expiration'] = $checksum_expire_date_tmp ;
}
$birthday_token = 'dates.birth_date___F_j' ;
while( $cur_token_raw = current( $tokens['dates'] )){
$tmp_key = key($tokens['dates']);
$cur_token = '';
if( is_numeric( $tmp_key)){
$cur_token = $cur_token_raw;
}else{
// Its being used by CiviMail.
$cur_token = $tmp_key;
}
$token_to_fill = 'dates.'.$cur_token;
if($token_to_fill == $birthday_token ){
$sql_cids = implode( ",", $contactIDs);
if( strlen( $sql_cids) > 0 ){
$sql = "select c.id as contact_id, date_format( c.birth_date, '%M %e') as birth_date
FROM civicrm_contact c
WHERE c.id IN ( ".$sql_cids." )
ORDER BY c.id" ;
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$cid = $dao->contact_id ;
$birth_date_formatted = $dao->birth_date;
$values[$cid][$birthday_token] = $birth_date_formatted ;
}
$dao->free();
}
}
next($tokens['dates']);
}
}
if(!empty($tokens['communication'] )){
$phone_token = 'communication.phone_all' ;
$email_token = 'communication.email_all' ;
require_once( 'utils/CommunicationTokenHelper.php');
$commUtils = new CommunicationTokenHelper();
$commUtils->getTableOfPhones($contactIDs, $values, $phone_token );
$commUtils->getTableOfEmails($contactIDs, $values, $email_token );
}
if (!empty($tokens['greetings'])) {
$greetings_token_names = array(
'greetings.joint_casual' => 'greetings.joint_casual',
'greetings.joint_casual_firstname_lastname' => 'greetings.joint_casual_firstname_lastname',
'greetings.joint_casual_nickname_only' => 'greetings.joint_casual_nickname_only',
'greetings.joint_casual_firstname_only' => 'greetings.joint_casual_firstname_only',
'greetings.solo_casual' => 'greetings.solo_casual',
'greetings.solo_casual_nickname_only' => 'greetings.solo_casual_nickname_only',
'greetings.joint_formal' => 'greetings.joint_formal',
'greetings.joint_formal_firstname' => 'greetings.joint_formal_firstname',
);
if ( is_array( $contactIDs ) ) {
require_once ('utils/GreetingHelper.php');
$tmpGreetingHelper = new GreetingHelper();
$prefixes = $tmpGreetingHelper->get_all_prefixes();
$suffixes = $tmpGreetingHelper->get_all_suffixes();
$tmp_contactIds = $contactIDs ;
// process all spouses using 'Spouse of' relationships.
$household_id = '';
$tmpGreetingHelper->process_spouses( $suffixes, $prefixes, $values, $contactIDs , $greetings_token_names, $household_id );
$tmpGreetingHelper->process_households( $suffixes, $prefixes, $values, $contactIDs , $greetings_token_names);
// process people not in households and without spouses.
$tmpGreetingHelper->process_singles( $suffixes, $prefixes, $values, $greetings_token_names);
// process organizations
$tmpGreetingHelper->process_organizations( $suffixes, $prefixes, $values, $greetings_token_names);
// Deal with 'solo' type greetings, no need to worry about relationships.
$tmpGreetingHelper->process_solo_greetings( $suffixes, $prefixes, $values, $contactIDs , $greetings_token_names);
// if any token is empty, use display_name of contact.
// $tmpGreetingHelper->avoid_empty_tokens( $values, $contactIDs , $greetings_token_names);
}
}
if(!empty($tokens['communitynews'])){
$website_host_name = $_SERVER['SERVER_NAME'];
/*
$civi_url = CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE);
$website_host_name = parse_url( $civi_url, PHP_URL_HOST );
$isSecure = false;
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$isSecure = true;
}elseif ( ( !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') ||
(!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower( $_SERVER['HTTP_X_FORWARDED_SSL']) == 'on') ) {
$isSecure = true;
}
$protocol = $isSecure ? 'https://' : 'http://';
*/
/*
if ( array_key_exists( 'HTTPS', $_SERVER )){
$ssl_in_use = $_SERVER['HTTPS'];
if( strlen($ssl_in_use) > 0){
$protocol = "https://";
}else{
$protocol = "http://";
}
}else{
$protocol = "http://";
}
*/
while( $cur_token_raw = current( $tokens['communitynews'] )){
$tmp_key = key($tokens['communitynews']);
@ -137,7 +400,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
if($partial_token == 'standaloneprofile'){
$profile_id = $token_as_array[1];
$partial_profile_link_url = $protocol.$website_host_name."/civicrm/profile/edit?reset=1&gid=";
$partial_profile_link_url = CRM_Utils_System::url('civicrm/profile/edit', 'reset=1&gid=', TRUE, NULL, TRUE, TRUE);
if( is_numeric( $profile_id )){
@ -166,7 +429,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
}else if( $partial_token == 'contributionpage' ){
$contrib_page_id = $token_as_array[1];
$partial_contrib_page_link_url = $protocol.$website_host_name."/civicrm/contribute/transact?reset=1&id=";
$partial_contrib_page_link_url = CRM_Utils_System::url('civicrm/contribute/transact', 'reset=1&id=', TRUE, NULL, TRUE, TRUE);
if( is_numeric( $contrib_page_id )){
@ -193,6 +456,36 @@ function fancytokens_civicrm_tokens( &$tokens ){
}
}else if( $partial_token == 'signpetition'){
# https://something.org/civicrm/petition/sign?reset=1&sid=IDNUMBER&{contact.checksum}&cid={contact.contact_id}
$petition_id = $token_as_array[1];
$partial_petition_link_url = CRM_Utils_System::url('civicrm/petition/sign', 'reset=1&sid=', TRUE, NULL, TRUE, TRUE);
if( is_numeric( $petition_id )){
$params = array(
'version' => 3,
'sequential' => 1,
'id' => $petition_id,
);
$result = civicrm_api('Survey', 'getsingle', $params);
$link_label = $result['title'];
foreach ( $contactIDs as $cid ) {
$tmp_checksum = CRM_Contact_BAO_Contact_Utils::generateChecksum($cid);
$full_petition_link = $partial_petition_link_url.$petition_id."&cs=".$tmp_checksum."&cid=".$cid;
$tmp_petition_html = "<a href='".$full_petition_link."'>".$link_label."</a>";
$values[$cid][$token_to_fill] = $tmp_petition_html;
}
}
}else if( $partial_token == 'upcomingevents'){
@ -206,7 +499,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
if( is_numeric( $date_number) && ( $date_unit == 'day' || $date_unit == 'week' || $date_unit == 'month' )){
// get event data
$sql = "SELECT e.id , e.summary, e.title, e.registration_link_text,
date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date ,
e.start_date as start_date ,
if( e.is_online_registration = 1 AND
( e.registration_end_date is null || now() <= e.registration_end_date ) AND
( e.registration_start_date is null || now() >= e.registration_start_date ), '1', '0') as
@ -218,8 +511,8 @@ function fancytokens_civicrm_tokens( &$tokens ){
// print "<br>SQL: ".$sql;
$event_info_link_url = $protocol.$website_host_name."/civicrm/event/info?reset=1&id=";
$event_register_link_url = $protocol.$website_host_name."/civicrm/event/register?reset=1&id=";
$event_info_link_url = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=', TRUE, NULL, TRUE, TRUE);
$event_register_link_url = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=', TRUE, NULL, TRUE, TRUE);
// print "<br>contacts: ";
@ -256,7 +549,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
$summary_html = "";
}
$tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> on ".
$tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> ".
$e_start_date.$register_html.$summary_html;
}
$dao->free();
@ -278,20 +571,20 @@ function fancytokens_civicrm_tokens( &$tokens ){
if( is_numeric( $token_event_id) ){
// get event data
$sql = "SELECT e.id , e.summary, e.title, e.registration_link_text,
date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date ,
e.start_date as start_date ,
if( e.is_online_registration = 1 AND
( e.registration_end_date is null || now() <= e.registration_end_date ) AND
( e.registration_start_date is null || now() >= e.registration_start_date ), '1', '0') as
show_registration_link
FROM civicrm_event e
WHERE e.is_active = 1 AND e.is_public = 1 AND e.is_template <> 1 AND
WHERE e.is_active = 1 AND e.is_template <> 1 AND
e.start_date >= now() AND e.id = '".$token_event_id."'
ORDER BY e.start_date";
// print "<br>SQL: ".$sql;
// $event_info_link_url = $protocol.$website_host_name."/civicrm/event/info?reset=1&id=";
$event_register_link_url = $protocol.$website_host_name."/civicrm/event/register?reset=1&id=";
$event_register_link_url = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=', TRUE, NULL, TRUE, TRUE);
// print "<br>contacts: ";
@ -328,7 +621,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
$summary_html = "";
}
$tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." on ".
$tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." ".
$e_start_date.$register_html.$summary_html;
}
$dao->free();
@ -340,6 +633,74 @@ function fancytokens_civicrm_tokens( &$tokens ){
}
}else if( $partial_token == 'dwform' ){
$token_node_id = $token_as_array[1];
// $drupal_db = getUserFrameworkDatabaseName();
if( is_numeric( $token_node_id) ){
// get Drupal WebForm data for this node id.
$dsql = "SELECT cforms.nid, node.title, ua.alias
FROM {webform_civicrm_forms} cforms
JOIN {node} node ON cforms.nid = node.nid AND node.status = 1
LEFT JOIN {url_alias} ua ON cforms.nid = SUBSTRING( ua.source, 6 )
AND ua.source LIKE 'node/%'
WHERE node.nid = $token_node_id";
$dq_result = db_query( $dsql );
foreach ($dq_result as $record) {
$tmp_title = $record->title;
$tmp_alias = $record->alias;
$tmp_nid = $record->nid;
if( strlen( $tmp_alias) > 0){
//$partial_webform_link_url = $protocol.$website_host_name."/".$tmp_alias;
$partial_webform_link_url = CRM_Utils_System::url($tmp_alias, "", TRUE, NULL, TRUE, TRUE);
}else{
//$partial_webform_link_url = $protocol.$website_host_name."/node/".$tmp_nid;
$partial_webform_link_url = CRM_Utils_System::url("/node/".$tmp_nid , "", TRUE, NULL, TRUE, TRUE);
}
$link_label = $tmp_title;
}
/*
$sql = "SELECT cforms.nid, node.title, ua.alias
FROM $drupal_db.webform_civicrm_forms cforms
JOIN $drupal_db.node ON cforms.nid = node.nid AND node.status = 1
LEFT JOIN $drupal_db.url_alias ua ON cforms.nid = SUBSTRING( ua.source, 6 )
AND ua.source LIKE 'node/%'
WHERE node.nid = $token_node_id";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$tmp_title = $dao->title;
$tmp_alias = $dao->alias;
$tmp_nid = $dao->nid;
if( strlen( $tmp_alias) > 0){
$partial_webform_link_url = $protocol.$website_host_name."/".$tmp_alias;
}else{
$partial_webform_link_url = $protocol.$website_host_name."/node/".$tmp_nid;
}
$link_label = $tmp_title;
}
$dao->free();
*/
foreach ( $contactIDs as $cid ) {
$tmp_checksum = CRM_Contact_BAO_Contact_Utils::generateChecksum($cid);
$full_webform_link = $partial_webform_link_url."cs=".$tmp_checksum."&cid=".$cid;
$tmp_webform_html = "<a href='".$full_webform_link."'>".$link_label."</a>";
$values[$cid][$token_to_fill] = $tmp_webform_html;
}
}
}
next($tokens['communitynews']);
}

View File

@ -1,22 +1,24 @@
<?xml version="1.0"?>
<extension key="com.pogstone.fancytokens" type="module">
<file>fancytokens</file>
<name>Fancy Tokens</name>
<description>Community News and Engagement tokens, such as for contribution pages, upcoming event lists, individual event registration pages, and stand-alone CiviCRM profiles. All hyperlinks include the recipient checksum as appropriate. </description>
<name>Save time preparing newsletters: Fancy tokens for upcoming events, petitions, contribution pages, and forms</name>
<description>Additional tokens for contribution pages, upcoming event lists, petitions, individual event registration pages, and stand-alone CiviCRM profiles. If Drupal WebForm is in use, then any webforms that use CiviCRM integration will also be available as a token. All hyperlinks include the recipient checksum as appropriate. To see the additional tokens, start composing an email and click 'insert tokens'.</description>
<urls>
<url>http://pogstone.com</url>
<url desc="Main Extension Page">https://civicrm.org/extensions/fancy-tokens</url>
<url desc="Documentation">https://civicrm.org/extensions/fancy-tokens</url>
<url desc="Support">https://github.com/sgladstone/com.pogstone.fancytokens/issues</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<license>AGPL-3.0</license>
<maintainer>
<author>Sarah Gladstone at Pogstone Inc.</author>
<email>info@pogstone.com</email>
<author>Sarah Gladstone</author>
<email>info@fountaintribe.com</email>
</maintainer>
<releaseDate>2014-09-01</releaseDate>
<version>2.0</version>
<releaseDate>2019-05-30</releaseDate>
<version>5.1</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.3</ver>
<ver>4.4</ver>
<ver>5.9</ver>
</compatibility>
<comments></comments>
<civix>

View File

@ -0,0 +1,148 @@
<?php
class CommunicationTokenHelper{
function getTableOfPhones(&$contactIDs, &$values, &$token_needed ){
require_once('utils/CustomSearchTools.php');
$tmp = new CustomSearchTools();
$sql_cids = $tmp->convertArrayToSqlString($contactIDs);
$sql = "select ph.contact_id, ph.phone , ph.is_primary,
lt.display_name as location_type_label,
ov.label as phone_type_label
FROM civicrm_phone ph
LEFT JOIN civicrm_location_type lt ON ph.location_type_id = lt.id ,
civicrm_option_value ov ,
civicrm_option_group og
WHERE ph.contact_id IN ( ".$sql_cids." )
AND ph.phone_type_id = ov.value
AND ov.option_group_id = og.id AND og.name = 'phone_type'
ORDER BY ph.contact_id" ;
// print "\n\n<br><br>sql: ".$sql;
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
$first = true;
$prev_cid = "";
while($dao->fetch()){
//print "\n\n<br>Inside while loop";
$cid = $dao->contact_id ;
$phone = $dao->phone;
$is_primary = $dao->is_primary;
$location_type_label = $dao->location_type_label;
$phone_type_label = $dao->phone_type_label;
if(strcmp( $is_primary, '1') == 0 ){
$is_primary_formatted = 'Yes';
}else{
$is_primary_formatted = 'No';
}
if( strcmp($cid, $prev_cid ) <> 0 ){
// First phone for this contact
$values[$cid][$token_needed] = "<table border=0 width='100%'><tr><th align=left>Number</th>
<th align=left>Is Primary?</th><th align=left>Location</th><Th align=left>Phone Type</th></tr>";
// wrap up token for prev. cid
if( strcmp( $prev_cid, "") <> 0){
$values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."</table>";
}
}
// add the data for this child to this parent's token
$values[$cid][$token_needed] = $values[$cid][$token_needed]."<tr><td>$phone</td>".
"<td>$is_primary_formatted</td><td>$location_type_label</td><td>$phone_type_label</td></tr>";
$prev_cid = $cid;
}
$dao->free();
if( strcmp( $prev_cid, "") <> 0){
$values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."</table>";
}
}
function getTableOfEmails(&$contactIDs, &$values, &$token_needed){
require_once('utils/CustomSearchTools.php');
$tmp = new CustomSearchTools();
$sql_cids = $tmp->convertArrayToSqlString($contactIDs);
$sql = "select em.contact_id, em.email , em.is_primary,
lt.display_name as location_type_label
FROM civicrm_email em
LEFT JOIN civicrm_location_type lt ON em.location_type_id = lt.id
WHERE em.contact_id IN ( ".$sql_cids." )
ORDER BY em.contact_id" ;
// print "\n\n<br><br>sql: ".$sql;
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
$first = true;
$prev_cid = "";
while($dao->fetch()){
//print "\n\n<br>Inside while loop";
$cid = $dao->contact_id ;
$email = $dao->email;
$is_primary = $dao->is_primary;
$location_type_label = $dao->location_type_label;
if(strcmp( $is_primary, '1') == 0 ){
$is_primary_formatted = 'Yes';
}else{
$is_primary_formatted = 'No';
}
if( strcmp($cid, $prev_cid ) <> 0 ){
// First phone for this contact
$values[$cid][$token_needed] = "<table border=0 width='100%'><tr><th align=left>Email</th>
<th align=left>Is Primary?</th><th align=left>Location</th></tr>";
// wrap up token for prev. cid
if( strcmp( $prev_cid, "") <> 0){
$values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."</table>";
}
}
// add the data for this child to this parent's token
$values[$cid][$token_needed] = $values[$cid][$token_needed]."<tr><td>$email</td>".
"<td>$is_primary_formatted</td><td>$location_type_label</td></tr>";
$prev_cid = $cid;
}
$dao->free();
if( strcmp( $prev_cid, "") <> 0){
$values[$prev_cid][$token_needed] = $values[$prev_cid][$token_needed]."</table>";
}
}
}

1144
utils/GreetingHelper.php Normal file

File diff suppressed because it is too large Load Diff