commit | author | age
|
b5a2f8
|
1 |
<?php
|
T |
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 |
|
4991f9
|
19 |
//$app->listform->SQLExtWhere = "type = 'alias'";
|
T |
20 |
|
b5a2f8
|
21 |
$listTpl = new tpl;
|
T |
22 |
$listTpl->newTemplate('templates/'.$app->listform->listDef["name"].'_list.htm');
|
|
23 |
|
|
24 |
// Changing some of the list values to reflect that the list is called within a tform page
|
|
25 |
$app->listform->listDef["file"] = $app->tform->formDef["action"];
|
|
26 |
$app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"];
|
|
27 |
|
|
28 |
|
|
29 |
// Generate the SQL for searching
|
|
30 |
if($app->listform->listDef["auth"] != 'no') {
|
|
31 |
if($_SESSION["s"]["user"]["typ"] == "admin") {
|
|
32 |
$sql_where = "";
|
|
33 |
} else {
|
|
34 |
$sql_where = $app->tform->getAuthSQL('r')." and";
|
|
35 |
}
|
|
36 |
}
|
4991f9
|
37 |
|
T |
38 |
if($this->options["sqlextwhere"] != '') {
|
|
39 |
$sql_where .= " ".$this->options["sqlextwhere"]." and";
|
|
40 |
}
|
b5a2f8
|
41 |
|
T |
42 |
$sql_where = $app->listform->getSearchSQL($sql_where);
|
|
43 |
$listTpl->setVar($app->listform->searchValues);
|
|
44 |
|
|
45 |
// Generate SQL for paging
|
|
46 |
$limit_sql = $app->listform->getPagingSQL($sql_where);
|
|
47 |
$listTpl->setVar("paging",$app->listform->pagingHTML);
|
|
48 |
|
|
49 |
// Get the data
|
|
50 |
$records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql");
|
|
51 |
|
|
52 |
$bgcolor = "#FFFFFF";
|
|
53 |
if(is_array($records)) {
|
|
54 |
$idx_key = $app->listform->listDef["table_idx"];
|
|
55 |
foreach($records as $rec) {
|
|
56 |
|
|
57 |
$rec = $app->listform->decode($rec);
|
|
58 |
|
|
59 |
// Change of color
|
|
60 |
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
|
|
61 |
$rec["bgcolor"] = $bgcolor;
|
|
62 |
|
|
63 |
// The variable "id" contains always the index field
|
|
64 |
$rec["id"] = $rec[$idx_key];
|
|
65 |
|
|
66 |
$records_new[] = $rec;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
$listTpl->setLoop('records',$records_new);
|
|
71 |
|
|
72 |
// Loading language field
|
|
73 |
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
|
|
74 |
include($lng_file);
|
|
75 |
$listTpl->setVar($wb);
|
|
76 |
|
|
77 |
return $listTpl->grab();
|
|
78 |
|
|
79 |
}
|
|
80 |
}
|
|
81 |
|
|
82 |
?> |