Skip to content

Commit ec9634d

Browse files
author
Marius Burkard
committed
- removed master_directive_snippet code that was (in 2016) accidently backported from master but never used
1 parent 3c53b6b commit ec9634d

File tree

11 files changed

+47
-240
lines changed

11 files changed

+47
-240
lines changed

interface/web/admin/directive_snippets_edit.php

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -49,79 +49,32 @@
4949

5050
class page_action extends tform_actions {
5151

52-
function onShow() {
53-
global $app, $conf;
54-
55-
if($this->id > 0){
56-
$record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id);
57-
if($record['master_directive_snippets_id'] > 0){
58-
unset($app->tform->formDef["tabs"]['directive_snippets']['fields']['name'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['type'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['snippet'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['required_php_snippets']);
59-
}
60-
unset($record);
61-
}
62-
63-
parent::onShow();
64-
}
65-
66-
function onShowEnd() {
67-
global $app;
68-
69-
$is_master = false;
70-
if($this->id > 0){
71-
if($this->dataRecord['master_directive_snippets_id'] > 0){
72-
$is_master = true;
73-
$app->tpl->setVar("name", $this->dataRecord['name'], true);
74-
$app->tpl->setVar("type", $this->dataRecord['type'], true);
75-
$app->tpl->setVar("snippet", $this->dataRecord['snippet'], true);
76-
}
77-
}
78-
79-
$app->tpl->setVar("is_master", $is_master);
80-
81-
parent::onShowEnd();
82-
}
8352

8453
public function onAfterUpdate() {
8554
global $app, $conf;
8655

87-
if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y') {
88-
if($this->dataRecord['active'] === 'y' && $this->dataRecord['update_sites'] === 'y') {
89-
if($this->dataRecord['type'] === 'php') {
90-
$rlike = $this->dataRecord['directive_snippets_id'].'|,'.$this->dataRecord['directive_snippets_id'].'|'.$this->dataRecord['directive_snippets_id'].',';
91-
$affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets REGEXP ? AND type = ?', $rlike, 'apache');
92-
if(is_array($affected_snippets) && !empty($affected_snippets)) {
93-
foreach($affected_snippets as $snippet) {
94-
$sql_in[] = $snippet['directive_snippets_id'];
95-
}
96-
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in);
97-
}
98-
} elseif($this->dataRecord['type'] === 'apache') {
99-
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id = ?', $conf['server_id'], $this->dataRecord['directive_snippets_id']);
100-
}
101-
102-
if(is_array($affected_sites) && !empty($affected_sites)) {
103-
foreach($affected_sites as $site) {
104-
$website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']);
105-
$app->db->datalogUpdate('web_domain', $website, 'domain_id', $site['domain_id'], true);
56+
if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y' && $this->dataRecord['active'] === 'y') {
57+
if($this->dataRecord['type'] === 'php') {
58+
$rlike = $this->dataRecord['directive_snippets_id'].'|,'.$this->dataRecord['directive_snippets_id'].'|'.$this->dataRecord['directive_snippets_id'].',';
59+
$affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets REGEXP ? AND type = ?', $rlike, 'apache');
60+
if(is_array($affected_snippets) && !empty($affected_snippets)) {
61+
foreach($affected_snippets as $snippet) {
62+
$sql_in[] = $snippet['directive_snippets_id'];
10663
}
64+
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in);
10765
}
66+
} elseif($this->dataRecord['type'] === 'apache' || $this->dataRecord['type'] === 'nginx') {
67+
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id = ?', $conf['server_id'], $this->dataRecord['directive_snippets_id']);
10868
}
109-
}
110-
}
111-
112-
public function onSubmit() {
113-
global $app;
11469

115-
if($this->id > 0){
116-
$record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id);
117-
if($record['master_directive_snippets_id'] > 0){
118-
unset($app->tform->formDef["tabs"]['directive_snippets']['fields']['name'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['type'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['snippet'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['required_php_snippets']);
70+
if(is_array($affected_sites) && !empty($affected_sites)) {
71+
foreach($affected_sites as $site) {
72+
$website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']);
73+
$app->db->datalogUpdate('web_domain', $website, 'domain_id', $site['domain_id'], true);
74+
}
11975
}
12076
}
121-
122-
parent::onSubmit();
12377
}
124-
12578
}
12679

12780
$page = new page_action;

interface/web/admin/directive_snippets_list.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public function prepareDataRow($rec)
5757
//* Alternating datarow colors
5858
$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
5959
$rec['bgcolor'] = $this->DataRowColor;
60-
61-
$rec['is_master'] = $rec['master_directive_snippets_id'];
6260

6361
//* substitute value for select fields
6462
if(is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) {
@@ -79,15 +77,8 @@ public function prepareDataRow($rec)
7977
$rec['id'] = $rec[$this->idx_key];
8078
return $rec;
8179
}
82-
80+
8381
}
8482
$list = new list_action;
8583
$list->SQLOrderBy = 'ORDER BY directive_snippets.name';
8684
$list->onLoad();
87-
88-
//$app->listform_actions->SQLExtWhere = 'master_directive_snippets_id = 0';
89-
/*
90-
$app->listform_actions->SQLOrderBy = 'ORDER BY directive_snippets.name';
91-
$app->listform_actions->onLoad();
92-
*/
93-
?>

interface/web/admin/form/directive_snippets.tform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
'name' => array (
6767
'datatype' => 'VARCHAR',
6868
'formtype' => 'TEXT',
69-
'validators' => array (
69+
'validators' => array (
7070
0 => array ( 'type' => 'NOTEMPTY', 'errmsg'=> 'directive_snippets_name_empty'),
7171
1 => array ( 'type' => 'CUSTOM', 'class' => 'validate_server_directive_snippets', 'function' => 'validate_snippet'),
7272
),
@@ -121,7 +121,7 @@
121121
'formtype' => 'CHECKBOXARRAY',
122122
'default' => '',
123123
'datasource' => array ( 'type' => 'SQL',
124-
'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name",
124+
'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y' ORDER BY name",
125125
'keyfield' => 'directive_snippets_id',
126126
'valuefield' => 'name'
127127
),

interface/web/admin/list/directive_snippets.list.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
'suffix' => "",
7575
'width' => "",
7676
'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy'));
77-
77+
7878
$liste["item"][] = array( 'field' => "customer_viewable",
7979
'datatype' => "VARCHAR",
8080
'formtype' => "SELECT",
@@ -83,14 +83,3 @@
8383
'suffix' => "",
8484
'width' => "",
8585
'value' => array('y' => $app->lng('yes_txt'), 'n' => $app->lng('no_txt')));
86-
87-
$liste["item"][] = array( 'field' => "master_directive_snippets_id",
88-
'datatype' => "BOOLEAN",
89-
'formtype' => "SELECT",
90-
'op' => "IS",
91-
'prefix' => "",
92-
'suffix' => "",
93-
'width' => "",
94-
'value' => array(0 => $app->lng('select_directive_snippet_txt'), 1 => $app->lng('select_master_directive_snippet_txt')));
95-
96-
?>

interface/web/admin/templates/directive_snippets_edit.htm

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
<div class="form-group">
22
<label for="name" class="col-sm-3 control-label">{tmpl_var name='name_txt'}</label>
3-
<tmpl_if name='is_master'><div class="col-sm-9 col-text">{tmpl_var name='name'}</div></tmpl_else><div class="col-sm-9"><input type="text" name="name" id="name" value="{tmpl_var name='name'}" class="form-control" /></div></tmpl_if>
3+
<div class="col-sm-9"><input type="text" name="name" id="name" value="{tmpl_var name='name'}" class="form-control" /></div>
44
</div>
55
<div class="form-group">
66
<label for="type" class="col-sm-3 control-label">{tmpl_var name='type_txt'}</label>
7-
<tmpl_if name='is_master'><div class="col-sm-9 col-text">{tmpl_var name='type'}</div></tmpl_else><div class="col-sm-9"><select name="type" id="type" class="form-control">
7+
<div class="col-sm-9"><select name="type" id="type" class="form-control">
88
{tmpl_var name='type'}
9-
</select></div></tmpl_if>
9+
</select></div>
1010
</div>
1111
<div class="form-group">
1212
<label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
13-
<tmpl_if name='is_master'><div class="col-sm-9 col-text"><pre>{tmpl_var name='snippet'}</pre></div></tmpl_else><div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea>
13+
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea>
1414
&nbsp; Nginx {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOMAIN}</a>, <a href="javascript:void(0);" class="addPlaceholder">{FASTCGIPASS}</a>, <a href="javascript:void(0);" class="addPlaceholder">{PHPFALLBACKFASTCGIPASS}</a><br />
1515
&nbsp; Apache {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOMAIN}</a> <br />
1616
&nbsp; PHP {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{WEBROOT}</a>
17-
</div></tmpl_if>
17+
</div>
1818
</div>
19-
<tmpl_if name='is_master'></tmpl_else>
20-
<tmpl_if name='required_php_snippets'>
21-
<div class="form-group php">
19+
<div class="form-group php">
2220
<label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>
2321
<div class="col-sm-9">
2422
{tmpl_var name='required_php_snippets'}
2523
</div>
2624
</div>
27-
</tmpl_if>
28-
</tmpl_if>
29-
<div class="form-group">
25+
<div class="form-group">
3026
<label class="col-sm-3 control-label">{tmpl_var name='customer_viewable_txt'}</label>
3127
<div class="col-sm-9">
3228
{tmpl_var name='customer_viewable'}

interface/web/admin/templates/directive_snippets_list.htm

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ <h1><tmpl_var name="list_head_txt"></h1>
1717
<th data-column="name"><tmpl_var name="name_txt"></th>
1818
<th data-column="type"><tmpl_var name="type_txt"></th>
1919
<th data-column="customer_viewable"><tmpl_var name="customer_viewable_txt"></th>
20-
<th data-column="master_directive_snippets_id"><tmpl_var name="master_directive_snippets_id_txt"></th>
2120
<th class="small-col text-right">{tmpl_var name='search_limit'}</th>
2221
</tr>
2322
<tr>
2423
<td><select class="form-control" name="search_active">{tmpl_var name='search_active'}</select></td>
2524
<td><input class="form-control" type="text" name="search_name" value="{tmpl_var name='search_name'}" /></td>
2625
<td><select class="form-control" name="search_type">{tmpl_var name='search_type'}</select></td>
2726
<td><select class="form-control" name="search_customer_viewable">{tmpl_var name='search_customer_viewable'}</select></td>
28-
<td><select class="form-control" name="search_master_directive_snippets_id">{tmpl_var name='search_master_directive_snippets_id'}</select></td>
2927
<td class="text-right">
3028
<button type="button" class="btn btn-default formbutton-default formbutton-narrow" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" data-submit-form="pageForm" data-form-action="admin/directive_snippets_list.php"><span class="icon icon-filter"></span></button>
3129
</td>
@@ -38,22 +36,21 @@ <h1><tmpl_var name="list_head_txt"></h1>
3836
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="name"}</a></td>
3937
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="type"}</a></td>
4038
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="customer_viewable"}</a></td>
41-
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="master_directive_snippets_id"}</a></td>
4239
<td class="text-right">
43-
<tmpl_if name='is_master'></tmpl_else><a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('admin/directive_snippets_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a></tmpl_if>
40+
<a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('admin/directive_snippets_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a>
4441
</td>
4542
</tr>
4643
</tmpl_loop>
4744
<tmpl_unless name="records">
4845
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
49-
<td colspan="6">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
46+
<td colspan="5">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
5047
</tr>
5148
</tmpl_unless>
5249
</tbody>
5350

5451
<tfoot>
5552
<tr>
56-
<td colspan="6"><tmpl_var name="paging"></td>
53+
<td colspan="5"><tmpl_var name="paging"></td>
5754
</tr>
5855
</tfoot>
5956
</table>

interface/web/sites/ajax_get_json.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@
203203
$web_config = $app->getconf->get_server_config($server_id, 'web');
204204
if (!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
205205

206-
$m_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id > 0 AND type = ? ORDER BY name ASC", $server_type);
207-
208-
$snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type);
206+
$snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND type = ? ORDER BY name ASC", $server_type);
209207

210-
$json = json_encode(array('m_snippets' => $m_snippets, 'snippets' => $snippets));
208+
$json = json_encode(array('snippets' => $snippets));
211209
}
212210

213211
if($type == 'getclientssldata'){
@@ -216,7 +214,7 @@
216214
$client = $app->db->queryOneRecord("SELECT company_name,contact_firstname, contact_name, street, zip, city, telephone, mobile,fax, country, state, email FROM client WHERE client_id = ?",$sys_group['client_id']);
217215
if(is_array($client) && !empty($client)){
218216
if($client['telephone'] == '' && $client['mobile'] != '') $client['telephone'] = $client['mobile'];
219-
217+
220218
$fname = '';
221219
$lname = '';
222220
$parts = preg_split("/\s+/", $client['contact_name']);

interface/web/sites/templates/web_vhost_domain_edit.htm

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,18 +420,6 @@
420420
function reloadDirectiveSnippets() {
421421
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getdirectivesnippet"}, function(data) {
422422
var options = '<option value="0">-</option>';
423-
options += "<optgroup label=\"{tmpl_var name='select_master_directive_snippet_txt'}\">";
424-
for (var i = 0, len = data['m_snippets'].length; i < len; i++) {
425-
var isSelected = '';
426-
427-
if ($('#directive_snippets_id').val() == i + 1) {
428-
isSelected = 'selected="selected"';
429-
}
430-
431-
options += '<option ' + isSelected + ' value="' + data['m_snippets'][i]['directive_snippets_id'] + '">' + data['m_snippets'][i]['name'] + '</option>';
432-
}
433-
options += '</optgroup>';
434-
435423
options += "<optgroup label=\"{tmpl_var name='select_directive_snippet_txt'}\">";
436424
for (var i = 0, len = data['snippets'].length; i < len; i++) {
437425
var isSelected = '';

0 commit comments

Comments
 (0)