-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontenttokens.php
621 lines (555 loc) · 25.2 KB
/
contenttokens.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<?php
require_once 'contenttokens.civix.php';
function contenttokens_civicrm_tokens( &$tokens ){
$tokens['content'] = array();
$types_in_use = contenttokens_getContentTypesInUse();
foreach( $types_in_use as $cur_type){
/*
$tokens['content'] = array(
'content.type___story___day_7' => 'Content: Stories created in the last 7 days',
'content.type___story___day_14' => 'Content: Stories created in the last 14 days',
'content.type___story___day_30' => 'Content: Stories created in the last 30 days',
'content.type___story___week_3' => 'Content: Stories created in the last 3 weeks',
'content.type___story___month_3' => 'Content: Stories created in the last 3 months',
);
*/
// by day
$key = "content.type___".$cur_type."___day_7";
$label = "Content of type '$cur_type' created in the last 7 days";
$tokens['content'][$key] = $label;
// by week
$key = "content.type___".$cur_type."___week_4";
$label = "Content of type '$cur_type' created in the last 4 weeks";
$tokens['content'][$key] = $label;
// by month
$key = "content.type___".$cur_type."___month_3";
$label = "Content of type '$cur_type' created in the last 3 months";
$tokens['content'][$key] = $label;
}
$categories_in_use = contenttokens_getCategoriesInUse();
foreach( $categories_in_use as $cid => $cur_category) {
$cur_category_clean = contenttoken_clean_string_for_token( $cur_category);
// by day
$key = "content.category___".$cid."___".$cur_category_clean."___day_7";
$label = "Content with category '$cur_category' created in the last 7 days";
$tokens['content'][$key] = $label;
// by week
$key = "content.category___".$cid."___".$cur_category_clean."___week_4";
$label = "Content with category '$cur_category' created in the last 4 weeks";
$tokens['content'][$key] = $label;
// by month
$key = "content.category___".$cid."___".$cur_category_clean."___month_3";
$label = "Content with category '$cur_category' created in the last 3 months";
$tokens['content'][$key] = $label;
}
$feeds_in_use = contenttokens_getFeedsInUse();
foreach( $feeds_in_use as $fid => $cur_feed){
$cur_feed_clean = contenttoken_clean_string_for_token( $cur_feed);
$key = "content.feed___".$fid."___".$cur_feed_clean."___month_3";
$label = "Content from feed '$cur_feed' created in the last 3 months";
$tokens['content'][$key] = $label;
}
}
function contenttoken_clean_string_for_token( $param){
$tmp_clean = str_replace( " ", "_", $param) ;
$tmp_clean = str_replace( "'", "_", $tmp_clean) ;
$tmp_clean = str_replace( ",", "_", $tmp_clean) ;
$tmp_clean = str_replace( "-", "_", $tmp_clean) ;
$tmp_clean = str_replace( "/", "_", $tmp_clean) ;
$tmp_clean = str_replace( "\\", "_", $tmp_clean) ;
return $tmp_clean;
}
function contenttokens_civicrm_tokenValues( &$values, &$contactIDs, $job = null, $tokens = array(), $context = null) {
$tmp_content_tokens = isset($tokens['content']) ? $tokens['content'] : null;
if( is_null( $tmp_content_tokens) ){
return;
}
while( $cur_token_raw = current( $tokens['content'] )){
$config = CRM_Core_Config::singleton();
$drupal_version = contenttokens_getDrupalVersion();
$civi_url = CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE);
$website_host_name = parse_url( $civi_url, PHP_URL_HOST );
$ssl_in_use = isset($_SERVER['HTTPS'] ) ? $_SERVER['HTTPS'] : '';
if( strlen($ssl_in_use) > 0){
$protocol = "https://";
}else{
$protocol = "http://";
}
$url_beginning = $protocol.$website_host_name."/";
$cck_types_in_use = contenttokens_getContentTypesInUse();
$categories_in_use = contenttokens_getCategoriesInUse() ;
$tmp_key = key($tokens['content']);
$font_size = "10px";
// CiviCRM is buggy here, if token is being used in CiviMail, we need to use the key
// as the token. Otherwise ( PDF Letter, one-off email, etc) we
// need to use the value.
$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 = 'content.'.$cur_token;
//print "<br><br>Token to fill: ".$token_to_fill."<br>";
$token_as_array = explode("___", $cur_token );
$partial_token = $token_as_array[0];
if( $partial_token == 'type' || $partial_token == 'category' || $partial_token == 'feed'){
if( $partial_token == 'type' && in_array( $token_as_array[1], $cck_types_in_use) ){
$cck_type = $token_as_array[1];
$token_date = $token_as_array[2];
}else if( $partial_token == 'category' && array_key_exists($token_as_array[1], $categories_in_use) ){
$category_id = $token_as_array[1];
$token_date = $token_as_array[3];
}else if( $partial_token == 'feed'){
$feed_id = $token_as_array[1];
$token_date = $token_as_array[3];
}else{
// SHould skip this
}
$date_array = explode("_", $token_date);
$date_unit = $date_array[0];
$date_number = $date_array[1];
$tmp_content_html = "";
if( is_numeric( $date_number) && ( $date_unit == 'day' || $date_unit == 'week' || $date_unit == 'month' )){
// get content data
$cms_db = contenttokens_getUserFrameworkDatabaseName();
if( $config->userFramework=="Drupal" || $config->userFramework=="Drupal6" ){
if( $drupal_version == "6"){
$revision_tb = "$cms_db.node_revisions";
$source = "src";
$alias = "dst";
if ($partial_token == 'type'){
$sql = "SELECT t1.nid as nid, t1.url_alias, rv.title as title, rv.teaser ,
t1.created, DATE( FROM_UNIXTIME(t1.created )) as formatted_create_date
FROM
(SELECT max(nr.vid) as vid, nr.nid, n.created, ifnull(alias.dst, concat( 'node/' , n.nid) ) as url_alias
FROM $revision_tb nr join $cms_db.node n ON n.nid = nr.nid
LEFT JOIN $cms_db.url_alias alias ON CONCAT('node/' , n.nid ) = alias.src
WHERE n.status = 1 AND n.type = '$cck_type'
AND DATE( FROM_UNIXTIME(n.created )) > date_sub( now() , INTERVAL $date_number $date_unit)
GROUP BY nr.nid )
as t1
LEFT JOIN $revision_tb rv ON t1.vid = rv.vid
ORDER BY t1.created DESC";
}else if($partial_token == 'category' ){
$sql = "SELECT t1.nid as nid, t1.url_alias, rv.title as title, rv.teaser ,
t1.created, DATE( FROM_UNIXTIME(t1.created )) as formatted_create_date
FROM
(SELECT max(nr.vid) as vid, tn.nid, n.created, ifnull(alias.dst, concat( 'node/' , n.nid) ) as url_alias
FROM $cms_db.term_node tn
JOIN $cms_db.node n ON tn.nid = n.nid
JOIN $revision_tb nr ON n.nid = nr.nid
LEFT JOIN $cms_db.url_alias alias ON CONCAT('node/' , n.nid ) = alias.src
where n.status = 1 AND tn.tid = $category_id
AND DATE( FROM_UNIXTIME(n.created )) > date_sub( now() , INTERVAL $date_number $date_unit)
group by n.nid) as t1
LEFT JOIN $revision_tb rv ON t1.vid = rv.vid
ORDER BY t1.created DESC ";
}else if( $partial_token == 'feed'){
if(function_exists('module_exists') && module_exists( "aggregator")){
$sql = "SELECT title as title, link as full_url, DATE( FROM_UNIXTIME( timestamp )) as formatted_create_date
FROM $cms_db.aggregator_item where fid = $feed_id
AND DATE( FROM_UNIXTIME( timestamp )) > date_sub( now() , INTERVAL $date_number $date_unit)
ORDER BY timestamp DESC ";
}
}
} else {
// Drupal7 +
$revision_tb = "$cms_db.node_revision";
$source = "source";
$alias = "alias";
if ($partial_token == 'type'){
$sql = "SELECT t1.nid as nid, t1.url_alias, rv.title as title , t1.created, DATE( FROM_UNIXTIME(t1.created )) as formatted_create_date
FROM
(SELECT max(nr.vid) as vid, nr.nid, n.created, ifnull(alias.alias, concat( 'node/' , n.nid) ) as url_alias
FROM $revision_tb nr join $cms_db.node n ON n.nid = nr.nid
LEFT JOIN $cms_db.url_alias alias ON CONCAT('node/' , n.nid ) = alias.source
WHERE n.status = 1 AND n.type = '$cck_type'
AND DATE( FROM_UNIXTIME(n.created )) > date_sub( now() , INTERVAL $date_number $date_unit)
GROUP BY nr.nid )
as t1
LEFT JOIN $revision_tb rv ON t1.vid = rv.vid
ORDER BY t1.created DESC";
}else if($partial_token == 'category'){
$sql_getvocab = "SELECT vocab.machine_name FROM $cms_db.taxonomy_term_data t
JOIN $cms_db.taxonomy_vocabulary vocab ON t.vid = vocab.vid
WHERE t.tid = $category_id ";
$dao_vocab =& CRM_Core_DAO::executeQuery( $sql_getvocab, CRM_Core_DAO::$_nullArray ) ;
if( $dao_vocab->fetch()){
$vocab_table_name = "field_data_field_".$dao_vocab->machine_name;
$vocab_field_name = "field_".$dao_vocab->machine_name."_tid";
}
$dao_vocab->free();
$sql = "SELECT t1.nid as nid, t1.url_alias, rv.title as title ,
t1.created , DATE( FROM_UNIXTIME(t1.created )) as formatted_create_date
FROM
(SELECT tn.revision_id as vid, tn.entity_id as nid, n.created, ifnull(alias.alias, concat( 'node/' , n.nid) ) as url_alias
FROM $cms_db.$vocab_table_name tn
JOIN $cms_db.node n ON tn.entity_id = n.nid AND tn.entity_type = 'node'
JOIN $revision_tb nr ON n.nid = nr.nid
LEFT JOIN $cms_db.url_alias alias ON CONCAT('node/' , n.nid ) = alias.source
where n.status = 1 AND tn.$vocab_field_name = $category_id
AND tn.entity_type = 'node'
AND tn.deleted <> 1
AND DATE( FROM_UNIXTIME(n.created )) > date_sub( now() , INTERVAL $date_number $date_unit)
group by n.nid) as t1
LEFT JOIN $revision_tb rv ON t1.vid = rv.vid
ORDER BY t1.created DESC ";
}else if($partial_token == 'feed' ){
if(function_exists('module_exists') && module_exists( "aggregator")){
// substring( description, 1, 250) as teasertest
$sql = "SELECT title as title, link as full_url , DATE( FROM_UNIXTIME( timestamp )) as formatted_create_date
FROM $cms_db.aggregator_item where fid = $feed_id
AND DATE( FROM_UNIXTIME( timestamp )) > date_sub( now() , INTERVAL $date_number $date_unit)
ORDER BY timestamp DESC ";
}
}
}
}else if($config->userFramework=="WordPress" ){
if ($partial_token == 'type'){
$sql = "SELECT p.ID as nid, p.guid as url_alias, p.post_title as title ,p.post_content as teaser, p.post_date as formatted_create_date
FROM $cms_db.wp_posts p
where p.post_type = '$cck_type'
AND p.post_date > date_sub( now() , INTERVAL $date_number $date_unit)
AND p.post_status = 'publish'
ORDER BY p.post_date DESC";
}else if($partial_token == 'category'){
$sql = "SELECT p.ID as nid, p.guid as url_alias, p.post_title as title ,p.post_content as teaser, p.post_date as formatted_create_date,
t.term_name from
$cms_db.wp_posts p join $cms_db.wp_term_relationships tr on p.id = tr.object_id
join $cms_db.wp_terms t ON t.term_id = tr.term_taxonomy_id
WHERE t.term_id = $category_id
AND p.post_date > date_sub( now() , INTERVAL $date_number $date_unit)
AND p.post_status = 'publish'
ORDER BY p.post_date DESC";
}
}else if($config->userFramework=="Joomla"){
// state values
// 0 = unpublished
// 1 = published
// -1 = archived
// -2 = marked for deletion
$cms_tbl_prefix = contenttokens_getJoomlaTablePrefix();
if ($partial_token == 'type'){
$sql="SELECT c.ID as nid, c.alias as url_alias, c.title as title ,c.introtext as teaser,
c.publish_up as formatted_create_date, ca.alias as term_name FROM
{$cms_db}.{$cms_tbl_prefix}_content c inner join
{$cms_db}.{$cms_tbl_prefix}_categories ca on c.catid=ca.id where
ca.extension= '$cck_type' AND c.publish_up > date_sub( now() , INTERVAL
$date_number $date_unit) AND c.state=1 ORDER BY c.publish_up DESC";
}else if($partial_token == 'category'){
$sql="SELECT c.ID as nid, c.alias as url_alias, c.title as title ,c.introtext as teaser, c.publish_up as formatted_create_date, ca.alias as term_name
FROM {$cms_db}.{$cms_tbl_prefix}_content c inner join {$cms_db}.{$cms_tbl_prefix}_categories ca on c.catid=ca.id
where
ca.id= $category_id
AND c.publish_up > date_sub( now() , INTERVAL $date_number $date_unit)
AND c.state=1
ORDER BY c.publish_up DESC";
}
}
$tmp_content_html = "";
if( strlen( $sql) > 0 ){
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
$read_more_label = ts('Read More');
while($dao->fetch()){
$nid = $dao->nid;
$content_title = $dao->title;
$url_alias = $dao->url_alias;
$formatted_create_date = $dao->formatted_create_date;
if ($config->userFramework=="Drupal" || $config->userFramework=="Drupal6"){
if( $drupal_version == "7" && $partial_token <> 'feed' ){
// $content_teaser = render(node_view(node_load($nid), 'teaser'));
$node = node_view(node_load($nid),'teaser');
$content_teaser = $node['body'][0]['#markup'];
}else if( $drupal_version == "6"){
$content_teaser = $dao->teaser;
}
}else if($config->userFramework=="WordPress" ){
$content_teaser = $dao->teaser;
}else if($config->userFramework=="Joomla" ){
$content_teaser = $dao->teaser;
}
if( $partial_token == 'feed'){
$full_url = $dao->full_url;
}else{
$full_url = $url_beginning.$url_alias;
}
// Convert any relative paths to absolute paths.
$content_ready_to_use = str_ireplace( "src='/" , "src='".$url_beginning , $content_teaser );
$content_ready_to_use = str_ireplace( 'src="/' , 'src="'.$url_beginning , $content_ready_to_use );
$content_ready_to_use = str_ireplace( "href='/", "href='".$url_beginning , $content_ready_to_use);
$content_ready_to_use = str_ireplace( 'href="/', 'href="'.$url_beginning , $content_ready_to_use);
// need to deal with anchor-type urls, such as <a href="#sectionb">
$content_ready_to_use = str_ireplace( "href='#", "href='".$full_url."#" , $content_ready_to_use);
$content_ready_to_use = str_ireplace( 'href="#', 'href="'.$full_url."#" , $content_ready_to_use);
$tmp_content_html = $tmp_content_html."<br><div><b><a href='$full_url'>$content_title</a></b><br>".$content_ready_to_use.
"<br><a href='$full_url'>".$read_more_label."</a></div>";
}
$dao->free();
}
foreach ( $contactIDs as $cid ) {
// Populate the token value for this contact.
$values[$cid][$token_to_fill] = $tmp_content_html;
}
}
}
next($tokens['content']);
}
}
function contenttokens_getFeedsInUse(){
$feeds_in_use = array();
$cms_db = contenttokens_getUserFrameworkDatabaseName();
$config = CRM_Core_Config::singleton();
// print "<br><br>";
// print_r( $config) ;
if ($config->userFramework=="Drupal" || $config->userFramework=="Drupal6"){
if(function_exists('module_exists') && module_exists( "aggregator")){
// get all aggregator feeds that are used
$sql = "SELECT fid as feed_id, title as feed_title FROM $cms_db.aggregator_feed";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$feeds_in_use[$dao->feed_id] = $dao->feed_title;
}
$dao->free();
// print "<br>$sql";
}
}else if( $config->userFramework=="WordPress"){
// TODO: Figure out how to get this info from WordPress
}else if( $config->userFramework=="Joomla" ){
// TODO: Figure out how to get this info from Joomla.
}
return $feeds_in_use;
}
function contenttokens_getContentTypesInUse(){
$types = [];
$config = CRM_Core_Config::singleton();
$cms_db = contenttokens_getUserFrameworkDatabaseName();
// print "<br><br>";
// print_r( $config) ;
if ($config->userFramework=="Drupal" || $config->userFramework=="Drupal6"){
// get all CCK content types that are used by published content
$sql = "SELECT type FROM $cms_db.node n where status = 1 GROUP BY type";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$types[] = $dao->type;
}
$dao->free();
// print "<br>$sql";
}else if( $config->userFramework=="WordPress"){
try {
$sql = "SELECT p.post_type as type FROM $cms_db.wp_posts p WHERE p.post_status = 'publish' group by post_type";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$types[] = $dao->type;
}
$dao->free();
} catch (Exception $e) {
Civi::log()->warning('Error retrieving WordPress post types '.$e->warning());
}
}else if( $config->userFramework=="Joomla" ){
$cms_tbl_prefix = contenttokens_getJoomlaTablePrefix();
$sql = "SELECT ca.extension as type
FROM {$cms_db}.{$cms_tbl_prefix}_content c
inner join {$cms_db}.{$cms_tbl_prefix}_categories ca on c.catid=ca.id
WHERE c.state = 1
group by ca.extension";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$types[] = $dao->type;
}
}
return $types;
}
function contenttokens_getDrupalVersion(){
$drupal_version_tmp = "";
// userFramework
$config = CRM_Core_Config::singleton();
$cms_str = $config->userFramework;
if ( $cms_str == "Drupal6" ){
$drupal_version_tmp = "6";
} else if( $cms_str == "Drupal" ){
$drupal_version_tmp = "7";
}
return $drupal_version_tmp;
}
function contenttokens_getCategoriesInUse(){
$terms = [];
$cms_db = contenttokens_getUserFrameworkDatabaseName();
$config = CRM_Core_Config::singleton();
$drupal_version = contenttokens_getDrupalVersion();
if ($config->userFramework=="Drupal" || $config->userFramework=="Drupal6"){
if($drupal_version == "6"){
$sql = "SELECT t.tid as category_id, concat( v.name , '-', t.name) as category_term_name
FROM $cms_db.term_node tn
JOIN $cms_db.term_data t ON tn.tid = t.tid
JOIN $cms_db.vocabulary v ON v.vid = t.vid
GROUP BY t.tid" ;
// print "<br><br>$sql";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$cid = $dao->category_id;
$terms[$cid] = $dao->category_term_name;
}
$dao->free();
} else if( $drupal_version == "7"){
$sql = "SELECT t.tid as category_id, concat( v.name , '-', t.name) as category_term_name
FROM $cms_db.taxonomy_term_data t
JOIN $cms_db.taxonomy_vocabulary v ON t.vid = v.vid
GROUP BY t.tid" ;
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$cid = $dao->category_id;
$terms[$cid] = $dao->category_term_name;
}
$dao->free();
}
}else if( $config->userFramework=="WordPress"){
try {
$sql = "SELECT t.term_id as category_id , t.name as category_term_name from
$cms_db.wp_posts p join $cms_db.wp_term_relationships tr on p.id = tr.object_id
join $cms_db.wp_terms t ON t.term_id = tr.term_taxonomy_id AND
p.post_status = 'publish'
GROUP BY t.term_id";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$cid = $dao->category_id;
$terms[$cid] = $dao->category_term_name;
}
$dao->free();
} catch (Exception $e) {
Civi::log()->warning('Error retrieving WordPress terms '.$e->warning());
}
}else if( $config->userFramework=="Joomla" ){
$cms_tbl_prefix = contenttokens_getJoomlaTablePrefix();
$sql = "SELECT ca.id as category_id, ca.alias as category_term_name
FROM {$cms_db}.{$cms_tbl_prefix}_content c
inner join {$cms_db}.{$cms_tbl_prefix}_categories ca on c.catid=ca.id
WHERE c.state = 1
group by ca.alias";
$dao =& CRM_Core_DAO::executeQuery( $sql, CRM_Core_DAO::$_nullArray ) ;
while($dao->fetch()){
$cid = $dao->category_id;
$terms[$cid] = $dao->category_term_name;
}
$dao->free();
}
return $terms;
}
function contenttokens_getJoomlaTablePrefix(){
$config = CRM_Core_Config::singleton();
$cms_usr_str = $config->userFrameworkUsersTableName ;
$cms_tmp = explode( '_', $cms_usr_str) ;
if( strlen($cms_tmp[0]) > 0){
$cms_prefix = $cms_tmp[0];
}
return $cms_prefix;
}
function contenttokens_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]);
if( strlen($cms_tmp3[0]) > 0){
$cms_db_name = $cms_tmp3[0];
}
return $cms_tmp3[0];
}
/**
* Implementation of hook_civicrm_config
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
*/
function contenttokens_civicrm_config(&$config) {
_contenttokens_civix_civicrm_config($config);
}
/**
* Implementation of hook_civicrm_xmlMenu
*
* @param $files array(string)
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
*/
function contenttokens_civicrm_xmlMenu(&$files) {
_contenttokens_civix_civicrm_xmlMenu($files);
}
/**
* Implementation of hook_civicrm_install
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function contenttokens_civicrm_install() {
return _contenttokens_civix_civicrm_install();
}
/**
* Implementation of hook_civicrm_uninstall
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function contenttokens_civicrm_uninstall() {
return _contenttokens_civix_civicrm_uninstall();
}
/**
* Implementation of hook_civicrm_enable
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
*/
function contenttokens_civicrm_enable() {
return _contenttokens_civix_civicrm_enable();
}
/**
* Implementation of hook_civicrm_disable
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
*/
function contenttokens_civicrm_disable() {
return _contenttokens_civix_civicrm_disable();
}
/**
* Implementation of hook_civicrm_upgrade
*
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
*/
function contenttokens_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _contenttokens_civix_civicrm_upgrade($op, $queue);
}
/**
* Implementation of hook_civicrm_managed
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
*/
function contenttokens_civicrm_managed(&$entities) {
return _contenttokens_civix_civicrm_managed($entities);
}
/**
* Implementation of hook_civicrm_caseTypes
*
* Generate a list of case-types
*
* Note: This hook only runs in CiviCRM 4.4+.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
*/
function contenttokens_civicrm_caseTypes(&$caseTypes) {
_contenttokens_civix_civicrm_caseTypes($caseTypes);
}
/**
* Implementation of hook_civicrm_alterSettingsFolders
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
*/
function contenttokens_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
_contenttokens_civix_civicrm_alterSettingsFolders($metaDataFolders);
}