Skip to content

Commit 7629493

Browse files
authored
Issue #33: Get rid of obsolete code related to the php module (#35)
1 parent b05fc79 commit 7629493

File tree

2 files changed

+25
-47
lines changed

2 files changed

+25
-47
lines changed

matomo.admin.inc

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -90,52 +90,36 @@ function matomo_admin_settings_form($form_state) {
9090
);
9191

9292
// Page specific visibility configurations.
93-
$php_access = user_access('use php for matomo tracking visibility');
94-
$visibility = $config->get('visibility_pages');
95-
$pages = $config->get('pages');
96-
9793
$form['tracking']['page_vis_settings'] = array(
9894
'#type' => 'fieldset',
9995
'#title' => t('Pages'),
10096
'#collapsible' => TRUE,
10197
'#collapsed' => TRUE,
10298
);
99+
$options = array(
100+
t('Every page except the listed pages'),
101+
t('The listed pages only')
102+
);
103+
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
104+
'%blog' => 'blog',
105+
'%blog-wildcard' => 'blog/*',
106+
'%front' => '<front>',
107+
));
103108

104-
if ($visibility == 2 && !$php_access) {
105-
$form['tracking']['page_vis_settings'] = array();
106-
$form['tracking']['page_vis_settings']['visibility_pages'] = array('#type' => 'value', '#value' => 2);
107-
$form['tracking']['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $pages);
108-
}
109-
else {
110-
$options = array(
111-
t('Every page except the listed pages'),
112-
t('The listed pages only')
113-
);
114-
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
115-
116-
if (module_exists('php') && $php_access) {
117-
$options[] = t('Pages on which this PHP code returns <code>TRUE</code> (experts only)');
118-
$title = t('Pages or PHP code');
119-
$description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Backdrop site.', array('%php' => '<?php ?>'));
120-
}
121-
else {
122-
$title = t('Pages');
123-
}
124-
$form['tracking']['page_vis_settings']['visibility_pages'] = array(
125-
'#type' => 'radios',
126-
'#title' => t('Add tracking to specific pages'),
127-
'#options' => $options,
128-
'#default_value' => $visibility,
129-
);
130-
$form['tracking']['page_vis_settings']['pages'] = array(
131-
'#type' => 'textarea',
132-
'#title' => $title,
133-
'#title_display' => 'invisible',
134-
'#default_value' => $pages,
135-
'#description' => $description,
136-
'#rows' => 10,
137-
);
138-
}
109+
$form['tracking']['page_vis_settings']['visibility_pages'] = array(
110+
'#type' => 'radios',
111+
'#title' => t('Add tracking to specific pages'),
112+
'#options' => $options,
113+
'#default_value' => $config->get('visibility_pages'),
114+
);
115+
$form['tracking']['page_vis_settings']['pages'] = array(
116+
'#type' => 'textarea',
117+
'#title' => t('Pages'),
118+
'#title_display' => 'invisible',
119+
'#default_value' => $config->get('pages'),
120+
'#description' => $description,
121+
'#rows' => 10,
122+
);
139123

140124
// Render the role overview.
141125
$form['tracking']['role_vis_settings'] = array(
@@ -338,9 +322,8 @@ function matomo_admin_settings_form($form_state) {
338322
'#element_validate' => array('token_element_validate'),
339323
'#token_types' => array('node'),
340324
);
341-
if (module_exists('token')) {
342-
$form['custom_var']['slots'][$i]['value']['#element_validate'][] = 'token_element_validate';
343-
}
325+
$form['custom_var']['slots'][$i]['value']['#element_validate'][] = 'token_element_validate';
326+
344327
$form['custom_var']['slots'][$i]['scope'] = array(
345328
'#default_value' => !empty($matomo_custom_vars['slots'][$i]['scope']) ? $matomo_custom_vars['slots'][$i]['scope'] : 'visit',
346329
'#description' => t('The scope for the custom variable.'),

matomo.module

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ function matomo_permission() {
4545
'title' => t('Opt-in or out of tracking'),
4646
'description' => t('Allow users to decide if tracking code will be added to pages or not.'),
4747
),
48-
'use php for matomo tracking visibility' => array(
49-
'title' => t('Use PHP for tracking visibility'),
50-
'description' => t('Enter PHP code in the field for tracking visibility settings.'),
51-
'restrict access' => TRUE,
52-
),
5348
'add js snippets for matomo' => array(
5449
'title' => t('Add JavaScript snippets'),
5550
'description' => 'Enter JavaScript code snippets for advanced Matomo functionality.',

0 commit comments

Comments
 (0)