-
Notifications
You must be signed in to change notification settings - Fork 3
/
attentively.php
124 lines (109 loc) · 3.61 KB
/
attentively.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
<?php
define('ENV', 1); // Set ENV to 1 for production API (https://api.attentive.ly) or 0 for test API (http://apidev.attentive.ly)
define('EXT_NAME', basename(__DIR__));
require_once 'attentively.civix.php';
/**
* Implements hook_civicrm_config().
*/
function attentively_civicrm_config(&$config) {
_attentively_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_xmlMenu().
*/
function attentively_civicrm_xmlMenu(&$files) {
_attentively_civix_civicrm_xmlMenu($files);
}
/**
* Implements hook_civicrm_install().
*/
function attentively_civicrm_install() {
CRM_Core_Session::singleton()->set('authEnabled', TRUE);
return _attentively_civix_civicrm_install();
}
/**
* Implements hook_civicrm_uninstall().
*/
function attentively_civicrm_uninstall() {
return _attentively_civix_civicrm_uninstall();
}
/**
* Implements hook_civicrm_enable().
*/
function attentively_civicrm_enable() {
$config = CRM_Core_Config::singleton();
CRM_Core_Session::singleton()->set('authEnabled', TRUE);
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $config->extensionsDir . EXT_NAME . '/sql/attentively_enable.sql');
return _attentively_civix_civicrm_enable();
}
/**
* Implements hook_civicrm_disable().
*/
function attentively_civicrm_disable() {
$config = CRM_Core_Config::singleton();
CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $config->extensionsDir . EXT_NAME . '/sql/attentively_disable.sql');
return _attentively_civix_civicrm_disable();
}
/**
* Implements hook_civicrm_upgrade().
*/
function attentively_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _attentively_civix_civicrm_upgrade($op, $queue);
}
/**
* Implements hook_civicrm_managed().
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*/
function attentively_civicrm_managed(&$entities) {
return _attentively_civix_civicrm_managed($entities);
}
/**
* Implements hook_civicrm_tabs().
*/
function attentively_civicrm_tabs(&$tabs, $contactID) {
$url = CRM_Utils_System::url('civicrm/contact/view/scores',
"reset=1&snippet=1&force=1&cid=$contactID");
$count = CRM_Attentively_BAO_Attentively::getCount($contactID);
$tabs[] = array(
'id' => 'socialMedia',
'url' => $url,
'title' => 'Social Media',
'weight' => 85,
'count' => $count,
);
}
/**
* Implements hook_civicrm_queryObjects().
*/
function attentively_civicrm_queryObjects(&$queryObjects, $type) {
if ($type == 'Contact') {
$queryObjects[] = new CRM_Attentively_BAO_Query();
}
}
/**
* Implements hook_civicrm_pageRun().
*/
function attentively_civicrm_pageRun(&$page) {
if (get_class($page) == 'CRM_Admin_Page_Extensions' && CRM_Core_Session::singleton()->get('authEnabled')) {
CRM_Core_Session::singleton()->set('authEnabled', FALSE);
if (CRM_Attentively_BAO_Attentively::checkAttentivelyAuth() == 'none') {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/auth', "reset=1"));
}
}
if (get_class($page) == 'CRM_Admin_Page_OptionValue' && $page->getVar('_gName') == 'attentively_terms') {
CRM_Core_Region::instance('page-body')->add(array(
'template' => 'CRM/Attentively/WatchedTerms.tpl',
));
}
}
/**
* Implements hook_civicrm_buildForm().
*/
function attentively_civicrm_buildForm($formName, &$form) {
if ($formName == 'CRM_Admin_Form_OptionValue' && $form->getVar('_gName') == 'attentively_terms') {
$form->add('text', 'label', ts('Term'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), TRUE);
$form->add('text', 'value', ts('Nickname'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE);
}
}