This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhidedisableditems.php
82 lines (76 loc) · 2.55 KB
/
hidedisableditems.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
<?php
require_once 'hidedisableditems.civix.php';
/**
* Implementation of hook_civicrm_config
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
*/
function hidedisableditems_civicrm_config(&$config) {
_hidedisableditems_civix_civicrm_config($config);
}
/**
* Implementation of hook_civicrm_install
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function hidedisableditems_civicrm_install() {
_hidedisableditems_civix_civicrm_install();
}
/**
* Implementation of hook_civicrm_enable
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
*/
function hidedisableditems_civicrm_enable() {
_hidedisableditems_civix_civicrm_enable();
}
/**
* Implementation of hook_civicrm_navigationMenu
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
*/
function hidedisableditems_civicrm_navigationMenu(&$menu) {
_hidedisableditems_civix_insert_navigation_menu($menu, 'Administer/Customize Data and Screens', [
'label' => ts('Hide Disabled Items Settings', ['domain' => 'biz.jmaconsulting.hidedisableditems']),
'name' => 'Hide Disabled Items Settings',
'url' => CRM_Utils_System::url('civicrm/hidedisabled/settings', 'reset=1&action=browse', TRUE),
'active' => 1,
'has_separator' => 1,
'permission_operator' => 'AND',
'permission' => 'administer CiviCRM',
]);
_hidedisableditems_civix_navigationMenu($menu);
}
/**
* Implementation of hook_civicrm_pageRun
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pageRun
*/
function hidedisableditems_civicrm_pageRun(&$page) {
if ($page->getVar('_name') == "CRM_Admin_Page_ScheduleReminders") {
$items = Civi::settings()->get('hide_disabled_items');
if (!empty($items['reminders'])) {
$reminders = CRM_Core_Smarty::singleton()->get_template_vars('rows');
foreach ($reminders as $key => $reminder) {
if (!$reminder['is_active']) {
unset($reminders[$key]);
}
}
$page->assign('rows', $reminders);
}
}
if ($page->getVar('_name') == "CRM_Admin_Page_MessageTemplates") {
$items = Civi::settings()->get('hide_disabled_items');
if (!empty($items['templates'])) {
$templates = CRM_Core_Smarty::singleton()->get_template_vars('rows');
foreach ($templates as $key => &$section) {
foreach ($section as $index => $template) {
if (!$template['is_active']) {
unset($section[$index]);
}
}
}
$page->assign('rows', $templates);
}
}
}