Skip to content

Commit 5c12280

Browse files
committed
bug in listform fixed
1 parent 87a4a65 commit 5c12280

File tree

1 file changed

+153
-152
lines changed

1 file changed

+153
-152
lines changed
Lines changed: 153 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,154 @@
1-
<?php
2-
3-
/*
4-
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
5-
All rights reserved.
6-
7-
Redistribution and use in source and binary forms, with or without modification,
8-
are permitted provided that the following conditions are met:
9-
10-
* Redistributions of source code must retain the above copyright notice,
11-
this list of conditions and the following disclaimer.
12-
* Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
* Neither the name of ISPConfig nor the names of its contributors
16-
may be used to endorse or promote products derived from this software without
17-
specific prior written permission.
18-
19-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22-
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24-
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26-
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
*/
30-
31-
/**
32-
* Action framework for the listform library.
33-
*
34-
* @author Till Brehm <t.brehm@scrigo.org>
35-
* @copyright Copyright &copy; 2005, Till Brehm
36-
*/
37-
38-
class listform_actions {
39-
40-
var $id;
41-
var $idx_key;
42-
var $DataRowColor;
43-
var $SQLExtWhere = '';
44-
45-
function onLoad() {
46-
global $app, $conf, $list_def_file;
47-
48-
if(!is_object($app->tpl)) $app->uses('tpl');
49-
if(!is_object($app->listform)) $app->uses('listform');
50-
51-
// Load list definition
52-
$app->listform->loadListDef($list_def_file);
53-
54-
if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) {
55-
$app->uses('listform_tpl_generator');
56-
$app->listform_tpl_generator->buildHTML($app->listform->listDef);
57-
}
58-
59-
$app->tpl->newTemplate("form.tpl.htm");
60-
$app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm');
61-
62-
// Getting Datasets from DB
63-
$records = $app->db->queryAllRecords($this->getQueryString());
64-
65-
66-
$this->DataRowColor = "#FFFFFF";
67-
if(is_array($records)) {
68-
$this->idx_key = $app->listform->listDef["table_idx"];
69-
foreach($records as $rec) {
70-
$records_new[] = $this->prepareDataRow($rec);
71-
}
72-
}
73-
74-
$app->tpl->setLoop('records',$records_new);
75-
76-
$this->onShow();
77-
78-
79-
}
80-
81-
function prepareDataRow($rec) {
82-
global $app;
83-
84-
$rec = $app->listform->decode($rec);
85-
86-
// Alternating datarow colors
87-
$this->DataRowColor = ($this->DataRowColor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
88-
$rec["bgcolor"] = $this->DataRowColor;
89-
90-
// substitute value for select fields
91-
foreach($app->listform->listDef["item"] as $field) {
92-
$key = $field["field"];
93-
if($field['formtype'] == "SELECT") {
94-
$rec[$key] = $field['value'][$rec[$key]];
95-
}
96-
}
97-
98-
// The variable "id" contains always the index variable
99-
$rec["id"] = $rec[$this->idx_key];
100-
101-
return $rec;
102-
}
103-
104-
function getQueryString() {
105-
global $app;
106-
107-
// Generate the search sql
108-
if($app->listform->listDef["auth"] != 'no') {
109-
if($_SESSION["s"]["user"]["typ"] == "admin") {
110-
$sql_where = "";
111-
} else {
112-
$sql_where = $app->tform->getAuthSQL('r')." and";
113-
}
114-
}
115-
116-
if($this->SQLExtWhere != '') {
117-
$sql_where .= " ".$this->SQLExtWhere." and";
118-
}
119-
120-
$sql_where = $app->listform->getSearchSQL($sql_where);
121-
$app->tpl->setVar($app->listform->searchValues);
122-
123-
// Generate SQL for paging
124-
$limit_sql = $app->listform->getPagingSQL($sql_where);
125-
$app->tpl->setVar("paging",$app->listform->pagingHTML);
126-
127-
return "SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql";
128-
129-
}
130-
131-
132-
function onShow() {
133-
global $app;
134-
135-
// Language File setzen
136-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
137-
include($lng_file);
138-
$app->tpl->setVar($wb);
139-
$app->tpl->setVar("form_action",$app->listform->listDef["file"]);
140-
141-
// Parse the templates and send output to the browser
142-
$this->onShowEnd();
143-
}
144-
145-
function onShowEnd() {
146-
global $app;
147-
148-
$app->tpl_defaults();
149-
$app->tpl->pparse();
150-
}
151-
}
152-
1+
<?php
2+
3+
/*
4+
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/**
32+
* Action framework for the listform library.
33+
*
34+
* @author Till Brehm <t.brehm@scrigo.org>
35+
* @copyright Copyright &copy; 2005, Till Brehm
36+
*/
37+
38+
class listform_actions {
39+
40+
var $id;
41+
var $idx_key;
42+
var $DataRowColor;
43+
var $SQLExtWhere = '';
44+
45+
function onLoad() {
46+
global $app, $conf, $list_def_file;
47+
48+
if(!is_object($app->tpl)) $app->uses('tpl');
49+
if(!is_object($app->listform)) $app->uses('listform');
50+
if(!is_object($app->tform)) $app->uses('tform');
51+
52+
// Load list definition
53+
$app->listform->loadListDef($list_def_file);
54+
55+
if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) {
56+
$app->uses('listform_tpl_generator');
57+
$app->listform_tpl_generator->buildHTML($app->listform->listDef);
58+
}
59+
60+
$app->tpl->newTemplate("form.tpl.htm");
61+
$app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm');
62+
63+
// Getting Datasets from DB
64+
$records = $app->db->queryAllRecords($this->getQueryString());
65+
66+
67+
$this->DataRowColor = "#FFFFFF";
68+
if(is_array($records)) {
69+
$this->idx_key = $app->listform->listDef["table_idx"];
70+
foreach($records as $rec) {
71+
$records_new[] = $this->prepareDataRow($rec);
72+
}
73+
}
74+
75+
$app->tpl->setLoop('records',$records_new);
76+
77+
$this->onShow();
78+
79+
80+
}
81+
82+
function prepareDataRow($rec) {
83+
global $app;
84+
85+
$rec = $app->listform->decode($rec);
86+
87+
// Alternating datarow colors
88+
$this->DataRowColor = ($this->DataRowColor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
89+
$rec["bgcolor"] = $this->DataRowColor;
90+
91+
// substitute value for select fields
92+
foreach($app->listform->listDef["item"] as $field) {
93+
$key = $field["field"];
94+
if($field['formtype'] == "SELECT") {
95+
$rec[$key] = $field['value'][$rec[$key]];
96+
}
97+
}
98+
99+
// The variable "id" contains always the index variable
100+
$rec["id"] = $rec[$this->idx_key];
101+
102+
return $rec;
103+
}
104+
105+
function getQueryString() {
106+
global $app;
107+
108+
// Generate the search sql
109+
if($app->listform->listDef["auth"] != 'no') {
110+
if($_SESSION["s"]["user"]["typ"] == "admin") {
111+
$sql_where = "";
112+
} else {
113+
$sql_where = $app->tform->getAuthSQL('r')." and";
114+
}
115+
}
116+
117+
if($this->SQLExtWhere != '') {
118+
$sql_where .= " ".$this->SQLExtWhere." and";
119+
}
120+
121+
$sql_where = $app->listform->getSearchSQL($sql_where);
122+
$app->tpl->setVar($app->listform->searchValues);
123+
124+
// Generate SQL for paging
125+
$limit_sql = $app->listform->getPagingSQL($sql_where);
126+
$app->tpl->setVar("paging",$app->listform->pagingHTML);
127+
128+
return "SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql";
129+
130+
}
131+
132+
133+
function onShow() {
134+
global $app;
135+
136+
// Language File setzen
137+
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
138+
include($lng_file);
139+
$app->tpl->setVar($wb);
140+
$app->tpl->setVar("form_action",$app->listform->listDef["file"]);
141+
142+
// Parse the templates and send output to the browser
143+
$this->onShowEnd();
144+
}
145+
146+
function onShowEnd() {
147+
global $app;
148+
149+
$app->tpl_defaults();
150+
$app->tpl->pparse();
151+
}
152+
}
153+
153154
?>

0 commit comments

Comments
 (0)