tbrehm
2005-12-06 2d368b7939d7c567820b262e6a652fe21a0a4512
commit | author | age
b5a2f8 1 <?php
T 2 /*
3 Copyright (c) 2005, 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 require_once('../../lib/config.inc.php');
30 require_once('../../lib/app.inc.php');
31
32 /******************************************
33 * Begin Form configuration
34 ******************************************/
35
36 $list_def_file = "list/dbsync.list.php";
37
38 /******************************************
39 * End Form configuration
40 ******************************************/
41
42 // Checke Berechtigungen für Modul
43 if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) {
44     header("Location: ../index.php");
45     exit;
46 }
47
48 $app->uses('tpl,listform');
49
50 // Listen Definition laden
51 $app->listform->loadListDef($list_def_file);
52
53 if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) {
54     $app->uses('listform_tpl_generator');
55     $app->listform_tpl_generator->buildHTML($app->listform->listDef);
56 }
57
58 $app->tpl->newTemplate("form.tpl.htm");
59 $app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm');
60
61 // SQL für Suche generieren
62 if($app->listform->listDef["name"] != 'no') {
63     if($_SESSION["s"]["user"]["typ"] == "admin") {
64         $sql_where = "";
65     } else {
66         $sql_where = "userid = ".$_SESSION["s"]["user"]["userid"]." and";
67     }
68 }
69
70 $sql_where = $app->listform->getSearchSQL($sql_where);
71 $app->tpl->setVar($app->listform->searchValues);
72
73 // SQL für Paging generieren
74 $limit_sql = $app->listform->getPagingSQL($sql_where);
75 $app->tpl->setVar("paging",$app->listform->pagingHTML);
76
77 // hole alle Datensätze
78 $records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $limit_sql");
79
80 $bgcolor = "#FFFFFF";
81
82 if(is_array($records)) {
83     $idx_key = $app->listform->listDef["table_idx"]; 
84     foreach($records as $rec) {
85     
86         $rec = $app->listform->decode($rec);
87
88         // Farbwechsel
89         $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
90         $rec["bgcolor"] = $bgcolor;
91         
92         // die Variable "id" enthält immer die Index variable
93         $rec["id"] = $rec[$idx_key];
94
95         $records_new[] = $rec;
96     }
97 }
98
99 $app->tpl->setLoop('records',$records_new);
100
101 // Language File setzen
102 $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
103 include($lng_file);
104 $app->tpl->setVar($wb);
105
106 $app->tpl_defaults();
107 $app->tpl->pparse();
108
109
110
111 ?>