Skip to content

Commit f88d3fe

Browse files
committed
Fixed several strict errors in listform.inc.php and listform_actions.inc.php
1 parent da5e7a0 commit f88d3fe

File tree

2 files changed

+168
-167
lines changed

2 files changed

+168
-167
lines changed

interface/lib/classes/listform.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function loadListDef($file,$module = '') {
5757

5858
// Fill datasources
5959
foreach($this->listDef["item"] as $key => $field) {
60-
if(is_array($field['datasource'])) {
60+
if(@is_array($field['datasource'])) {
6161
$this->listDef["item"][$key]["value"] = $this->getDatasourceData($field);
6262
}
6363
}
@@ -86,7 +86,7 @@ function getDatasourceData($field) {
8686
$querystring = str_replace("{USERID}",$_SESSION["s"]["user"]["userid"],$querystring);
8787
$querystring = str_replace("{GROUPID}",$_SESSION["s"]["user"]["default_group"],$querystring);
8888
$querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring);
89-
$table_idx = $this->formDef['db_table_idx'];
89+
//$table_idx = $this->formDef['db_table_idx'];
9090
//$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
9191
$app->uses("tform");
9292
$querystring = str_replace("{AUTHSQL}",$app->tform->getAuthSQL('r'),$querystring);
@@ -142,13 +142,13 @@ function getSearchSQL($sql_where = "") {
142142
if(is_array($i['value'])) {
143143
$out = '<option value=""></option>';
144144
foreach($i['value'] as $k => $v) {
145-
$selected = ($k == $_SESSION["search"][$list_name][$search_prefix.$field] && $_SESSION["search"][$list_name][$search_prefix.$field] != '')?' SELECTED':'';
145+
$selected = (isset($_SESSION["search"][$list_name][$search_prefix.$field]) && $k == $_SESSION["search"][$list_name][$search_prefix.$field] && $_SESSION["search"][$list_name][$search_prefix.$field] != '')?' SELECTED':'';
146146
$out .= "<option value='$k'$selected>$v</option>\r\n";
147147
}
148148
}
149149
$this->searchValues[$search_prefix.$field] = $out;
150150
} else {
151-
$this->searchValues[$search_prefix.$field] = $_SESSION["search"][$list_name][$search_prefix.$field];
151+
if(isset($_SESSION["search"][$list_name][$search_prefix.$field])) $this->searchValues[$search_prefix.$field] = $_SESSION["search"][$list_name][$search_prefix.$field];
152152
}
153153
}
154154

@@ -158,7 +158,7 @@ function getSearchSQL($sql_where = "") {
158158
foreach($this->listDef["item"] as $i) {
159159
$field = $i["field"];
160160
//if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and";
161-
if($_SESSION["search"][$list_name][$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_SESSION["search"][$list_name][$search_prefix.$field].$i["suffix"]."' and";
161+
if(isset($_SESSION["search"][$list_name][$search_prefix.$field]) && $_SESSION["search"][$list_name][$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_SESSION["search"][$list_name][$search_prefix.$field].$i["suffix"]."' and";
162162
}
163163

164164
if($sql_where != '') {
@@ -201,7 +201,7 @@ function getPagingSQL($sql_where = "1") {
201201
$vars["pages"] = $pages;
202202
$vars["max_pages"] = $pages + 1;
203203
$vars["records_gesamt"] = $record_count["anzahl"];
204-
$vars["page_params"] = $this->listDef["page_params"];
204+
$vars["page_params"] = (isset($this->listDef["page_params"]))? $this->listDef["page_params"]:'';
205205
//$vars["module"] = $_SESSION["s"]["module"]["name"];
206206

207207

@@ -219,9 +219,9 @@ function getPagingSQL($sql_where = "1") {
219219
function getPagingHTML($vars) {
220220
global $app;
221221
$content = '<a href="'."javascript:loadContent('".$vars["list_file"].'?page=0'.$vars["page_params"]."');".'"><img src="themes/grey/images/btn_left.png" border="0"></a> &nbsp; ';
222-
if($vars["show_page_back"] == 1) $content .= '<a href="'."javascript:loadContent('".$vars["list_file"].'?page='.$vars["last_page"].$vars["page_params"]."');".'"><img src="themes/grey/images/btn_back.png" border="0"></a> ';
222+
if(isset($vars["show_page_back"]) && $vars["show_page_back"] == 1) $content .= '<a href="'."javascript:loadContent('".$vars["list_file"].'?page='.$vars["last_page"].$vars["page_params"]."');".'"><img src="themes/grey/images/btn_back.png" border="0"></a> ';
223223
$content .= ' '.$app->lng('Page').' '.$vars["next_page"].' '.$app->lng('of').' '.$vars["max_pages"].' ';
224-
if($vars["show_page_next"] == 1) $content .= '<a href="'."javascript:loadContent('".$vars["list_file"].'?page='.$vars["next_page"].$vars["page_params"]."');".'"><img src="themes/grey/images/btn_next.png" border="0"></a> &nbsp; ';
224+
if(isset($vars["show_page_next"]) && $vars["show_page_next"] == 1) $content .= '<a href="'."javascript:loadContent('".$vars["list_file"].'?page='.$vars["next_page"].$vars["page_params"]."');".'"><img src="themes/grey/images/btn_next.png" border="0"></a> &nbsp; ';
225225
$content .= '<a href="'."javascript:loadContent('".$vars["list_file"].'?page='.$vars["pages"].$vars["page_params"]."');".'"> <img src="themes/grey/images/btn_right.png" border="0"></a>';
226226

227227
return $content;
Lines changed: 160 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,161 @@
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-
var $SQLOrderBy = '';
45-
46-
function onLoad() {
47-
global $app, $conf, $list_def_file;
48-
49-
if(!is_object($app->tpl)) $app->uses('tpl');
50-
if(!is_object($app->listform)) $app->uses('listform');
51-
if(!is_object($app->tform)) $app->uses('tform');
52-
53-
// Clear session variable that is used when lists are embedded with the listview plugin
54-
$_SESSION["s"]["form"]["return_to"] = '';
55-
56-
// Load list definition
57-
$app->listform->loadListDef($list_def_file);
58-
59-
if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) {
60-
$app->uses('listform_tpl_generator');
61-
$app->listform_tpl_generator->buildHTML($app->listform->listDef);
62-
}
63-
64-
$app->tpl->newTemplate("listpage.tpl.htm");
65-
$app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm');
66-
67-
// Getting Datasets from DB
68-
$records = $app->db->queryAllRecords($this->getQueryString());
69-
70-
71-
$this->DataRowColor = "#FFFFFF";
72-
if(is_array($records)) {
73-
$this->idx_key = $app->listform->listDef["table_idx"];
74-
foreach($records as $rec) {
75-
$records_new[] = $this->prepareDataRow($rec);
76-
}
77-
}
78-
79-
$app->tpl->setLoop('records',$records_new);
80-
81-
$this->onShow();
82-
83-
84-
}
85-
86-
function prepareDataRow($rec) {
87-
global $app;
88-
89-
$rec = $app->listform->decode($rec);
90-
91-
// Alternating datarow colors
92-
$this->DataRowColor = ($this->DataRowColor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
93-
$rec["bgcolor"] = $this->DataRowColor;
94-
95-
// substitute value for select fields
96-
foreach($app->listform->listDef["item"] as $field) {
97-
$key = $field["field"];
98-
if($field['formtype'] == "SELECT") {
99-
$rec[$key] = $field['value'][$rec[$key]];
100-
}
101-
}
102-
103-
// The variable "id" contains always the index variable
104-
$rec["id"] = $rec[$this->idx_key];
105-
106-
return $rec;
107-
}
108-
109-
function getQueryString() {
110-
global $app;
111-
112-
// Generate the search sql
113-
if($app->listform->listDef["auth"] != 'no') {
114-
if($_SESSION["s"]["user"]["typ"] == "admin") {
115-
$sql_where = "";
116-
} else {
117-
$sql_where = $app->tform->getAuthSQL('r')." and";
118-
}
119-
}
120-
121-
if($this->SQLExtWhere != '') {
122-
$sql_where .= " ".$this->SQLExtWhere." and";
123-
}
124-
125-
$sql_where = $app->listform->getSearchSQL($sql_where);
126-
$app->tpl->setVar($app->listform->searchValues);
127-
128-
$order_by_sql = $this->SQLOrderBy;
129-
130-
// Generate SQL for paging
131-
$limit_sql = $app->listform->getPagingSQL($sql_where);
132-
$app->tpl->setVar("paging",$app->listform->pagingHTML);
133-
134-
return "SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $order_by_sql $limit_sql";
135-
136-
}
137-
138-
139-
function onShow() {
140-
global $app;
141-
142-
// Language File setzen
143-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
144-
include($lng_file);
145-
$app->tpl->setVar($wb);
146-
$app->tpl->setVar("form_action",$app->listform->listDef["file"]);
147-
148-
// Parse the templates and send output to the browser
149-
$this->onShowEnd();
150-
}
151-
152-
function onShowEnd() {
153-
global $app;
154-
155-
$app->tpl_defaults();
156-
$app->tpl->pparse();
157-
}
158-
}
159-
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+
var $SQLOrderBy = '';
45+
46+
function onLoad() {
47+
global $app, $conf, $list_def_file;
48+
49+
if(!@is_object($app->tpl)) $app->uses('tpl');
50+
if(!@is_object($app->listform)) $app->uses('listform');
51+
if(!@is_object($app->tform)) $app->uses('tform');
52+
53+
// Clear session variable that is used when lists are embedded with the listview plugin
54+
$_SESSION["s"]["form"]["return_to"] = '';
55+
56+
// Load list definition
57+
$app->listform->loadListDef($list_def_file);
58+
59+
if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) {
60+
$app->uses('listform_tpl_generator');
61+
$app->listform_tpl_generator->buildHTML($app->listform->listDef);
62+
}
63+
64+
$app->tpl->newTemplate("listpage.tpl.htm");
65+
$app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm');
66+
67+
// Getting Datasets from DB
68+
$records = $app->db->queryAllRecords($this->getQueryString());
69+
70+
71+
$this->DataRowColor = "#FFFFFF";
72+
$records_new = '';
73+
if(is_array($records)) {
74+
$this->idx_key = $app->listform->listDef["table_idx"];
75+
foreach($records as $rec) {
76+
$records_new[] = $this->prepareDataRow($rec);
77+
}
78+
}
79+
80+
$app->tpl->setLoop('records',$records_new);
81+
82+
$this->onShow();
83+
84+
85+
}
86+
87+
function prepareDataRow($rec) {
88+
global $app;
89+
90+
$rec = $app->listform->decode($rec);
91+
92+
// Alternating datarow colors
93+
$this->DataRowColor = ($this->DataRowColor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
94+
$rec["bgcolor"] = $this->DataRowColor;
95+
96+
// substitute value for select fields
97+
foreach($app->listform->listDef["item"] as $field) {
98+
$key = $field["field"];
99+
if($field['formtype'] == "SELECT") {
100+
$rec[$key] = $field['value'][$rec[$key]];
101+
}
102+
}
103+
104+
// The variable "id" contains always the index variable
105+
$rec["id"] = $rec[$this->idx_key];
106+
107+
return $rec;
108+
}
109+
110+
function getQueryString() {
111+
global $app;
112+
113+
// Generate the search sql
114+
if($app->listform->listDef["auth"] != 'no') {
115+
if($_SESSION["s"]["user"]["typ"] == "admin") {
116+
$sql_where = "";
117+
} else {
118+
$sql_where = $app->tform->getAuthSQL('r')." and";
119+
}
120+
}
121+
122+
if($this->SQLExtWhere != '') {
123+
$sql_where .= " ".$this->SQLExtWhere." and";
124+
}
125+
126+
$sql_where = $app->listform->getSearchSQL($sql_where);
127+
$app->tpl->setVar($app->listform->searchValues);
128+
129+
$order_by_sql = $this->SQLOrderBy;
130+
131+
// Generate SQL for paging
132+
$limit_sql = $app->listform->getPagingSQL($sql_where);
133+
$app->tpl->setVar("paging",$app->listform->pagingHTML);
134+
135+
return "SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $order_by_sql $limit_sql";
136+
137+
}
138+
139+
140+
function onShow() {
141+
global $app;
142+
143+
// Language File setzen
144+
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
145+
include($lng_file);
146+
$app->tpl->setVar($wb);
147+
$app->tpl->setVar("form_action",$app->listform->listDef["file"]);
148+
149+
// Parse the templates and send output to the browser
150+
$this->onShowEnd();
151+
}
152+
153+
function onShowEnd() {
154+
global $app;
155+
156+
$app->tpl_defaults();
157+
$app->tpl->pparse();
158+
}
159+
}
160+
160161
?>

0 commit comments

Comments
 (0)