Skip to content

Commit 6b15d5f

Browse files
author
Marius Burkard
committed
- added {DOCROOT_CLIENT} to directive placeholders (non-symlink docroot)
- made placeholders visible for apache, too - added event raise at formdef loading (on_before_formdef and on_after_formdef) - added possibility to put plugin files into module/lib/plugin.d/ directory
1 parent d240f6d commit 6b15d5f

File tree

6 files changed

+52
-27
lines changed

6 files changed

+52
-27
lines changed

interface/lib/classes/plugin.inc.php

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,50 @@ private function loadPluginCache() {
4343

4444

4545
if(isset($_SESSION['s']['plugin_cache'])) unset($_SESSION['s']['plugin_cache']);
46-
47-
$plugins_dir = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
46+
47+
$plugin_dirs = array();
48+
$plugin_dirs[] = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV;
49+
50+
if(is_dir(ISPC_WEB_PATH)) {
51+
if($dh = opendir(ISPC_WEB_PATH)) {
52+
while(($file = readdir($dh)) !== false) {
53+
if($file !== '.' && $file !== '..' && is_dir($file) && is_dir(ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d')) $plugin_dirs[] = ISPC_WEB_PATH . '/' . $file . '/lib/plugin.d';
54+
}
55+
closedir($dh);
56+
}
57+
}
58+
4859
$_SESSION['s']['plugin_cache'] = array();
4960
$tmp_plugins = array();
50-
51-
if (is_dir($plugins_dir)) {
52-
if ($dh = opendir($plugins_dir)) {
53-
//** Go trough all files in the plugin dir
54-
while (($file = readdir($dh)) !== false) {
55-
if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') {
56-
$plugin_name = substr($file, 0, -8);
57-
$tmp_plugins[$plugin_name] = $file;
61+
62+
for($d = 0; $d < count($plugin_dirs); $d++) {
63+
$plugins_dir = $plugin_dirs[$d];
64+
if (is_dir($plugins_dir)) {
65+
if ($dh = opendir($plugins_dir)) {
66+
//** Go trough all files in the plugin dir
67+
while (($file = readdir($dh)) !== false) {
68+
if($file !== '.' && $file !== '..' && substr($file, -8, 8) == '.inc.php') {
69+
$plugin_name = substr($file, 0, -8);
70+
$tmp_plugins[$plugin_name] = $file;
71+
}
5872
}
59-
}
60-
//** sort the plugins by name
61-
ksort($tmp_plugins);
62-
63-
//** load the plugins
64-
foreach($tmp_plugins as $plugin_name => $file) {
65-
include_once $plugins_dir.$file;
66-
if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
67-
$app->loaded_plugins[$plugin_name] = new $plugin_name;
68-
$app->loaded_plugins[$plugin_name]->onLoad();
73+
closedir($dh);
74+
//** sort the plugins by name
75+
ksort($tmp_plugins);
76+
77+
//** load the plugins
78+
foreach($tmp_plugins as $plugin_name => $file) {
79+
include_once $plugins_dir.$file;
80+
if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG);
81+
$app->loaded_plugins[$plugin_name] = new $plugin_name;
82+
$app->loaded_plugins[$plugin_name]->onLoad();
83+
}
84+
} else {
85+
$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
6986
}
7087
} else {
71-
$app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR);
88+
$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
7289
}
73-
} else {
74-
$app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR);
7590
}
7691

7792
}

interface/lib/classes/tform_actions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ function loadPlugins($next_tab) {
594594
$app->load($plugin_class);
595595
$this->plugins[$plugin_name] = new $plugin_class;
596596
$this->plugins[$plugin_name]->setOptions($plugin_name, $plugin_settings['options']);
597-
// Make the data of the form easily accessible for the plugib
597+
// Make the data of the form easily accessible for the plugin
598598
$this->plugins[$plugin_name]->form = $this;
599599
$this->plugins[$plugin_name]->onLoad();
600600
}

interface/lib/classes/tform_base.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ function loadTableDef($file) {
126126
function loadFormDef($file, $module = '') {
127127
global $app, $conf;
128128

129+
$app->plugin->raiseEvent('on_before_formdef', $module);
129130
include $file;
130131
$this->formDef = $form;
131132

@@ -150,6 +151,8 @@ function loadFormDef($file, $module = '') {
150151
$wb = $app->functions->array_merge($wb_global, $wb);
151152
}
152153
if(isset($wb_global)) unset($wb_global);
154+
155+
$app->plugin->raiseEvent('on_after_formdef', $module);
153156

154157
$this->wordbook = $wb;
155158

interface/web/admin/templates/directive_snippets_edit.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1><tmpl_var name="list_head_txt"></h1>
1616
</div>
1717
<div class="form-group">
1818
<label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
19-
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
19+
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
2020
</div>
2121
<div class="form-group php">
2222
<label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,10 @@ function update($event_name, $data) {
10911091
// Make sure we only have Unix linebreaks
10921092
$vhost_data['apache_directives'] = str_replace("\r\n", "\n", $vhost_data['apache_directives']);
10931093
$vhost_data['apache_directives'] = str_replace("\r", "\n", $vhost_data['apache_directives']);
1094-
$trans = array('{DOCROOT}' => $vhost_data['web_document_root_www']);
1094+
$trans = array(
1095+
'{DOCROOT}' => $vhost_data['web_document_root_www'],
1096+
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root']
1097+
);
10951098
$vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans);
10961099

10971100
// Check if a SSL cert exists

server/plugins-available/nginx_plugin.inc.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,11 @@ function update($event_name, $data) {
11331133
$nginx_directives = str_replace("\r", "\n", $nginx_directives);
11341134
$nginx_directive_lines = explode("\n", $nginx_directives);
11351135
if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){
1136-
$trans = array('{DOCROOT}' => $vhost_data['web_document_root_www'], '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';');
1136+
$trans = array(
1137+
'{DOCROOT}' => $vhost_data['web_document_root_www'],
1138+
'{DOCROOT_CLIENT}' => $vhost_data['web_document_root'],
1139+
'{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';'
1140+
);
11371141
foreach($nginx_directive_lines as $nginx_directive_line){
11381142
$final_nginx_directives[] = array('nginx_directive' => strtr($nginx_directive_line, $trans));
11391143
}

0 commit comments

Comments
 (0)