Compare commits

..

No commits in common. "master" and "3.3" have entirely different histories.
master ... 3.3

7 changed files with 48 additions and 1672 deletions

View File

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

View File

@ -1,28 +0,0 @@
<?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. 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. 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.
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" This extension provides additional mail merge tokens for CiviCRM for use in emails, mass emails, or PDF letters. All the token descriptions start with "Community News & Enagagement".
Main features: Main features:
@ -10,29 +10,6 @@ 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. 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 a token for each active Petition (Petitions are part of CiviCampaign) 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.
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. E) 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.
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

@ -29,7 +29,7 @@ function fancytokens_civicrm_tokens( &$tokens ){
$e_id = $dao->id; $e_id = $dao->id;
$e_title = $dao->title; $e_title = $dao->title;
$e_start_date = $dao->start_date; $e_start_date = $dao->start_date;
$label = 'Registration Page: '.$e_title.' '.$e_start_date.' (id: '.$e_id.') :: Events'; $label = 'Registration Page: '.$e_title.' on '.$e_start_date.' (id: '.$e_id.') :: Events';
$key = 'communitynews.event_registrationpage___'.$e_id ; $key = 'communitynews.event_registrationpage___'.$e_id ;
$tokens['communitynews'][$key] = $label; $tokens['communitynews'][$key] = $label;
@ -58,27 +58,6 @@ function fancytokens_civicrm_tokens( &$tokens ){
} }
} }
// 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;
}
}
// Get all active profiles and create tokens for the ones that can be stand-alone. // Get all active profiles and create tokens for the ones that can be stand-alone.
$params = array( $params = array(
@ -99,9 +78,8 @@ function fancytokens_civicrm_tokens( &$tokens ){
$p_type = ""; $p_type = "";
if( isset( $cur['group_type'])){ if( isset( $cur['group_type'])){
$p_type = $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 $type_array = explode( "," , $p_type); // Contributions Activity
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 ) )) { 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 ) )) {
@ -113,7 +91,6 @@ function fancytokens_civicrm_tokens( &$tokens ){
} }
} }
}
} }
@ -123,75 +100,32 @@ function fancytokens_civicrm_tokens( &$tokens ){
//print "<br><br>"; //print "<br><br>";
//print_r($config); //print_r($config);
if ($config->userSystem->is_drupal){ if ($config->userSystem->is_drupal){
if (function_exists("module_exists") && module_exists("webform_civicrm")) { if( module_exists( "webform_civicrm") && module_exists( "webform_civicrm")){
//$drupal_db = getUserFrameworkDatabaseName(); $drupal_db = getUserFrameworkDatabaseName();
//$sql = "SELECT cforms.nid, node.title FROM $drupal_db.webform_civicrm_forms cforms $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 "; 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 ); // LEFT JOIN url_alias ua ON cforms.nid = substr( ua.source) AND ua.source LIKE 'node/%'
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
foreach ($dq_result as $record) {
$nid = $record->nid;
$title = $record->title;
while($dao->fetch()){
$nid = $dao->nid;
$title = $dao->title;
//$url_alias = $dao->alias;
$key = 'communitynews.dwform___'.$nid ; $key = 'communitynews.dwform___'.$nid ;
$label = "$title (nid: $nid) :: Forms"; $label = "$title (nid: $nid) :: Forms";
$tokens['communitynews'][$key] = $label; $tokens['communitynews'][$key] = $label;
} }
$dao->free();
} }
} }
$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(){ function getUserFrameworkDatabaseName(){
// ['userFrameworkDSN'] => mysql://dev1_username:mypassword@localhost/dev1_main?new_link=true // ['userFrameworkDSN'] => mysql://dev1_username:mypassword@localhost/dev1_main?new_link=true
@ -213,166 +147,14 @@ function fancytokens_civicrm_tokens( &$tokens ){
function fancytokens_civicrm_tokenValues( &$values, &$contactIDs, $job = null, $tokens = array(), $context = null) { 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'])){ 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']; $ssl_in_use = $_SERVER['HTTPS'];
if( strlen($ssl_in_use) > 0){ if( strlen($ssl_in_use) > 0){
$protocol = "https://"; $protocol = "https://";
}else{ }else{
$protocol = "http://"; $protocol = "http://";
} }
}else{
$protocol = "http://";
}
*/
while( $cur_token_raw = current( $tokens['communitynews'] )){ while( $cur_token_raw = current( $tokens['communitynews'] )){
$tmp_key = key($tokens['communitynews']); $tmp_key = key($tokens['communitynews']);
@ -456,36 +238,6 @@ $protocol = $isSecure ? 'https://' : 'http://';
} }
}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'){ }else if( $partial_token == 'upcomingevents'){
@ -499,7 +251,7 @@ $protocol = $isSecure ? 'https://' : 'http://';
if( is_numeric( $date_number) && ( $date_unit == 'day' || $date_unit == 'week' || $date_unit == 'month' )){ if( is_numeric( $date_number) && ( $date_unit == 'day' || $date_unit == 'week' || $date_unit == 'month' )){
// get event data // get event data
$sql = "SELECT e.id , e.summary, e.title, e.registration_link_text, $sql = "SELECT e.id , e.summary, e.title, e.registration_link_text,
e.start_date as start_date , date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date ,
if( e.is_online_registration = 1 AND if( e.is_online_registration = 1 AND
( e.registration_end_date is null || now() <= e.registration_end_date ) 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 ( e.registration_start_date is null || now() >= e.registration_start_date ), '1', '0') as
@ -549,7 +301,7 @@ $protocol = $isSecure ? 'https://' : 'http://';
$summary_html = ""; $summary_html = "";
} }
$tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> ". $tmp_event_html = $tmp_event_html."\n<br><br><a href='".$event_info_link_url.$eid."'>".$e_title."</a> on ".
$e_start_date.$register_html.$summary_html; $e_start_date.$register_html.$summary_html;
} }
$dao->free(); $dao->free();
@ -571,13 +323,13 @@ $protocol = $isSecure ? 'https://' : 'http://';
if( is_numeric( $token_event_id) ){ if( is_numeric( $token_event_id) ){
// get event data // get event data
$sql = "SELECT e.id , e.summary, e.title, e.registration_link_text, $sql = "SELECT e.id , e.summary, e.title, e.registration_link_text,
e.start_date as start_date , date_format( e.start_date, '%W %b %e at %l:%i %p' ) as start_date ,
if( e.is_online_registration = 1 AND if( e.is_online_registration = 1 AND
( e.registration_end_date is null || now() <= e.registration_end_date ) 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 ( e.registration_start_date is null || now() >= e.registration_start_date ), '1', '0') as
show_registration_link show_registration_link
FROM civicrm_event e FROM civicrm_event e
WHERE e.is_active = 1 AND e.is_template <> 1 AND WHERE e.is_active = 1 AND e.is_public = 1 AND e.is_template <> 1 AND
e.start_date >= now() AND e.id = '".$token_event_id."' e.start_date >= now() AND e.id = '".$token_event_id."'
ORDER BY e.start_date"; ORDER BY e.start_date";
@ -621,7 +373,7 @@ $protocol = $isSecure ? 'https://' : 'http://';
$summary_html = ""; $summary_html = "";
} }
$tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." ". $tmp_event_html = $tmp_event_html."\n<br><br>".$e_title." on ".
$e_start_date.$register_html.$summary_html; $e_start_date.$register_html.$summary_html;
} }
$dao->free(); $dao->free();
@ -637,36 +389,10 @@ $protocol = $isSecure ? 'https://' : 'http://';
$token_node_id = $token_as_array[1]; $token_node_id = $token_as_array[1];
// $drupal_db = getUserFrameworkDatabaseName(); $drupal_db = getUserFrameworkDatabaseName();
if( is_numeric( $token_node_id) ){ if( is_numeric( $token_node_id) ){
// get Drupal WebForm data for this 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 $sql = "SELECT cforms.nid, node.title, ua.alias
FROM $drupal_db.webform_civicrm_forms cforms FROM $drupal_db.webform_civicrm_forms cforms
JOIN $drupal_db.node ON cforms.nid = node.nid AND node.status = 1 JOIN $drupal_db.node ON cforms.nid = node.nid AND node.status = 1
@ -687,12 +413,11 @@ $protocol = $isSecure ? 'https://' : 'http://';
} }
$dao->free(); $dao->free();
*/
foreach ( $contactIDs as $cid ) { foreach ( $contactIDs as $cid ) {
$tmp_checksum = CRM_Contact_BAO_Contact_Utils::generateChecksum($cid); $tmp_checksum = CRM_Contact_BAO_Contact_Utils::generateChecksum($cid);
$full_webform_link = $partial_webform_link_url."cs=".$tmp_checksum."&cid=".$cid; $full_webform_link = $partial_webform_link_url."?"."cs=".$tmp_checksum."&cid=".$cid;
$tmp_webform_html = "<a href='".$full_webform_link."'>".$link_label."</a>"; $tmp_webform_html = "<a href='".$full_webform_link."'>".$link_label."</a>";
$values[$cid][$token_to_fill] = $tmp_webform_html; $values[$cid][$token_to_fill] = $tmp_webform_html;

View File

@ -1,24 +1,23 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<extension key="com.pogstone.fancytokens" type="module"> <extension key="com.pogstone.fancytokens" type="module">
<file>fancytokens</file> <file>fancytokens</file>
<name>Save time preparing newsletters: Fancy tokens for upcoming events, petitions, contribution pages, and forms</name> <name>Save time preparing newsletters: Fancy tokens for upcoming events, 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> <description>Additional tokens for contribution pages, upcoming event lists, 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> <urls>
<url desc="Main Extension Page">https://civicrm.org/extensions/fancy-tokens</url> <url>http://pogstone.com</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> </urls>
<license>AGPL-3.0</license> <license>AGPL-3.0</license>
<maintainer> <maintainer>
<author>Sarah Gladstone</author> <author>Sarah Gladstone</author>
<email>info@fountaintribe.com</email> <email>info@pogstone.com</email>
</maintainer> </maintainer>
<releaseDate>2019-05-30</releaseDate> <releaseDate>2015-05-24</releaseDate>
<version>5.1</version> <version>3.3</version>
<develStage>stable</develStage> <develStage>stable</develStage>
<compatibility> <compatibility>
<ver>5.9</ver> <ver>4.4</ver>
<ver>4.5</ver>
<ver>4.6</ver>
</compatibility> </compatibility>
<comments></comments> <comments></comments>
<civix> <civix>

View File

@ -1,148 +0,0 @@
<?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>";
}
}
}

File diff suppressed because it is too large Load Diff