Skip to content

Commit f141883

Browse files
committed
Fixes in the listview plugin_listviewfirst version of the dns module.
1 parent 18dc997 commit f141883

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3529
-121
lines changed
Lines changed: 104 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,105 @@
1-
<?php
2-
3-
class plugin_listview extends plugin_base {
4-
5-
var $module;
6-
var $form;
7-
var $tab;
8-
var $record_id;
9-
var $formdef;
10-
var $options;
11-
12-
function onShow() {
13-
14-
global $app;
15-
16-
$app->uses('listform');
17-
$app->listform->loadListDef($this->options["listdef"]);
18-
19-
//$app->listform->SQLExtWhere = "type = 'alias'";
20-
21-
$listTpl = new tpl;
22-
$listTpl->newTemplate('templates/'.$app->listform->listDef["name"].'_list.htm');
23-
24-
//die(print_r($app->tform_actions));
25-
26-
// Changing some of the list values to reflect that the list is called within a tform page
27-
$app->listform->listDef["file"] = $app->tform->formDef["action"];
28-
// $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
29-
$app->listform->listDef["page_params"] = "&id=".$_REQUEST["id"]."&next_tab=".$_SESSION["s"]["form"]["tab"];
30-
31-
32-
// Generate the SQL for searching
33-
if($app->listform->listDef["auth"] != 'no') {
34-
if($_SESSION["s"]["user"]["typ"] == "admin") {
35-
$sql_where = "";
36-
} else {
37-
$sql_where = $app->tform->getAuthSQL('r')." and";
38-
}
39-
}
40-
41-
if($this->options["sqlextwhere"] != '') {
42-
$sql_where .= " ".$this->options["sqlextwhere"]." and";
43-
}
44-
45-
$sql_where = $app->listform->getSearchSQL($sql_where);
46-
$listTpl->setVar($app->listform->searchValues);
47-
48-
// Generate SQL for paging
49-
$limit_sql = $app->listform->getPagingSQL($sql_where);
50-
$listTpl->setVar("paging",$app->listform->pagingHTML);
51-
52-
53-
54-
// Get the data
55-
$records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql");
56-
57-
$bgcolor = "#FFFFFF";
58-
if(is_array($records)) {
59-
$idx_key = $app->listform->listDef["table_idx"];
60-
foreach($records as $rec) {
61-
62-
$rec = $app->listform->decode($rec);
63-
64-
// Change of color
65-
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
66-
$rec["bgcolor"] = $bgcolor;
67-
68-
// substitute value for select fields
69-
foreach($app->listform->listDef["item"] as $field) {
70-
$key = $field["field"];
71-
if($field['formtype'] == "SELECT") {
72-
$rec[$key] = $field['value'][$rec[$key]];
73-
}
74-
}
75-
76-
// The variable "id" contains always the index field
77-
$rec["id"] = $rec[$idx_key];
78-
79-
$records_new[] = $rec;
80-
}
81-
}
82-
83-
$listTpl->setLoop('records',$records_new);
84-
85-
// Loading language field
86-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
87-
include($lng_file);
88-
$listTpl->setVar($wb);
89-
90-
// Setting Returnto information in the session
91-
$list_name = $app->listform->listDef["name"];
92-
$_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id;
93-
$_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
94-
$_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
95-
$_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
96-
$_SESSION["s"]["form"]["return_to"] = $list_name;
97-
98-
return $listTpl->grab();
99-
100-
}
101-
}
102-
1+
<?php
2+
3+
class plugin_listview extends plugin_base {
4+
5+
var $module;
6+
var $form;
7+
var $tab;
8+
var $record_id;
9+
var $formdef;
10+
var $options;
11+
12+
function onShow() {
13+
14+
global $app;
15+
16+
$app->uses('listform');
17+
$app->listform->loadListDef($this->options["listdef"]);
18+
19+
//$app->listform->SQLExtWhere = "type = 'alias'";
20+
21+
$listTpl = new tpl;
22+
$listTpl->newTemplate('templates/'.$app->listform->listDef["name"].'_list.htm');
23+
24+
//die(print_r($app->tform_actions));
25+
26+
// Changing some of the list values to reflect that the list is called within a tform page
27+
$app->listform->listDef["file"] = $app->tform->formDef["action"];
28+
// $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
29+
$app->listform->listDef["page_params"] = "&id=".$this->form->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
30+
$listTpl->setVar('parent_id',$this->form->id);
31+
32+
// Generate the SQL for searching
33+
if($app->listform->listDef["auth"] != 'no') {
34+
if($_SESSION["s"]["user"]["typ"] == "admin") {
35+
$sql_where = "";
36+
} else {
37+
$sql_where = $app->tform->getAuthSQL('r')." and";
38+
}
39+
}
40+
41+
if($this->options["sqlextwhere"] != '') {
42+
$sql_where .= " ".$this->options["sqlextwhere"]." and";
43+
}
44+
45+
$sql_where = $app->listform->getSearchSQL($sql_where);
46+
$listTpl->setVar($app->listform->searchValues);
47+
48+
// Generate SQL for paging
49+
$limit_sql = $app->listform->getPagingSQL($sql_where);
50+
$listTpl->setVar("paging",$app->listform->pagingHTML);
51+
52+
53+
54+
// Get the data
55+
$records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql");
56+
57+
$bgcolor = "#FFFFFF";
58+
if(is_array($records)) {
59+
$idx_key = $app->listform->listDef["table_idx"];
60+
foreach($records as $rec) {
61+
62+
$rec = $app->listform->decode($rec);
63+
64+
// Change of color
65+
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
66+
$rec["bgcolor"] = $bgcolor;
67+
68+
// substitute value for select fields
69+
foreach($app->listform->listDef["item"] as $field) {
70+
$key = $field["field"];
71+
if($field['formtype'] == "SELECT") {
72+
$rec[$key] = $field['value'][$rec[$key]];
73+
}
74+
}
75+
76+
// The variable "id" contains always the index field
77+
$rec["id"] = $rec[$idx_key];
78+
79+
$records_new[] = $rec;
80+
}
81+
}
82+
83+
$listTpl->setLoop('records',$records_new);
84+
85+
// Loading language field
86+
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
87+
include($lng_file);
88+
$listTpl->setVar($wb);
89+
90+
// Setting Returnto information in the session
91+
$list_name = $app->listform->listDef["name"];
92+
// $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id;
93+
$_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
94+
$_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
95+
$_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
96+
$_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
97+
$_SESSION["s"]["form"]["return_to"] = $list_name;
98+
//die(print_r($_SESSION["s"]["list"][$list_name]));
99+
100+
return $listTpl->grab();
101+
102+
}
103+
}
104+
103105
?>

interface/lib/classes/tform_actions.inc.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ function onUpdate() {
141141
$_SESSION["s"]["form"]["return_to"] = '';
142142
session_write_close();
143143
header($redirect);
144-
// When a returnto variable is set
145-
} elseif ($_SESSION["s"]["form"]["return_to_url"] != '') {
146-
$redirect = $_SESSION["s"]["form"]["return_to_url"];
147-
$_SESSION["s"]["form"]["return_to_url"] = '';
148-
session_write_close();
149-
header("Location: ".$redirect);
150-
exit;
151-
// Use the default list of the form
152-
} else {
153-
header("Location: ".$app->tform->formDef['list_default']);
154-
}
155-
exit;
156-
} else {
144+
// When a returnto variable is set
145+
} elseif ($_SESSION["s"]["form"]["return_to_url"] != '') {
146+
$redirect = $_SESSION["s"]["form"]["return_to_url"];
147+
$_SESSION["s"]["form"]["return_to_url"] = '';
148+
session_write_close();
149+
header("Location: ".$redirect);
150+
exit;
151+
// Use the default list of the form
152+
} else {
153+
header("Location: ".$app->tform->formDef['list_default']);
154+
}
155+
exit;
156+
} else {
157157
$this->onShow();
158158
}
159159
} else {

interface/web/dns/dns_a_edit.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/*
3+
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
31+
/******************************************
32+
* Begin Form configuration
33+
******************************************/
34+
35+
$tform_def_file = "form/dns_a.tform.php";
36+
37+
/******************************************
38+
* End Form configuration
39+
******************************************/
40+
41+
require_once('../../lib/config.inc.php');
42+
require_once('../../lib/app.inc.php');
43+
44+
// Checking module permissions
45+
if(!stristr($_SESSION["s"]["user"]["modules"],'dns')) {
46+
header("Location: ../index.php");
47+
exit;
48+
}
49+
50+
// Loading classes
51+
$app->uses('tpl,tform,tform_actions');
52+
$app->load('tform_actions');
53+
54+
class page_action extends tform_actions {
55+
56+
function onSubmit() {
57+
global $app, $conf;
58+
59+
// Get the parent soa record of the domain
60+
$soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
61+
62+
// Set the server ID of the rr record to the same server ID as the parent record.
63+
$this->dataRecord["server_id"] = $soa["server_id"];
64+
65+
parent::onSubmit();
66+
}
67+
}
68+
69+
$page = new page_action;
70+
$page->onLoad();
71+
72+
?>

interface/web/dns/dns_a_list.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
require_once('../../lib/config.inc.php');
3+
require_once('../../lib/app.inc.php');
4+
5+
/******************************************
6+
* Begin Form configuration
7+
******************************************/
8+
9+
$list_def_file = "list/dns_a.list.php";
10+
11+
/******************************************
12+
* End Form configuration
13+
******************************************/
14+
15+
// Checking module permissions
16+
if(!stristr($_SESSION["s"]["user"]["modules"],'dns')) {
17+
header("Location: ../index.php");
18+
exit;
19+
}
20+
21+
$app->uses('listform_actions');
22+
$app->listform_actions->SQLExtWhere = "type = 'A'";
23+
24+
$app->listform_actions->onLoad();
25+
26+
27+
?>

0 commit comments

Comments
 (0)