root/trunk/includes/pages/admin/admin_nodes.php @ 1

Revision 1, 3.1 kB (checked in by Winner, 5 years ago)

Initial import

Line 
1<?php
2/*
3 * WiND - Wireless Nodes Database
4 *
5 * Copyright (C) 2005 Nikolaos Nikalexis <winner@cube.gr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 dated June, 1991.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21
22class admin_nodes {
23
24        var $tpl;
25       
26        function admin_nodes() {
27               
28        }
29       
30        function form_search_nodes() {
31                global $db;
32                $form_search_nodes = new form(array('FORM_NAME' => 'form_search_nodes'));
33                $form_search_nodes->db_data('nodes.id, nodes.name, areas.id, regions.id');
34                $form_search_nodes->db_data_enum('areas.id', $db->get("id AS value, name AS output", "areas"));
35                $form_search_nodes->db_data_enum('regions.id', $db->get("id AS value, name AS output", "regions"));
36                $form_search_nodes->db_data_search();
37                return $form_search_nodes;
38        }
39
40        function table_nodes() {
41                global $construct, $db, $main;
42                $form_search_nodes = $this->form_search_nodes();
43                $where = $form_search_nodes->db_data_where(array("nodes__name" => "starts_with"));
44                $table_nodes = new table(array('FORM_NAME' => 'table_nodes', 'TABLE_NAME' => 'table_nodes'));
45                $table_nodes->db_data(
46                        'nodes.id, nodes.name AS nodes__name, areas.name AS areas__name',
47                        'nodes, areas, regions',
48                        'nodes.area_id = areas.id AND areas.region_id = regions.id'.($where!=''?' AND ('.$where.')':""));
49                $table_nodes->db_data_search($form_search_nodes);
50                for($i=1;$i<count($table_nodes->data);$i++) {
51                        if (isset($table_nodes->data[$i])) {
52                                $table_nodes->data[$i]['nodes__name'] .= " (#".$table_nodes->data[$i]['id'].")";
53                                $table_nodes->info['EDIT'][$i] = makelink(array("page" => "mynodes", "node" => $table_nodes->data[$i]['id']));
54                        }
55                }
56                $table_nodes->info['EDIT_COLUMN'] = 'nodes__name';
57                $table_nodes->db_data_multichoice('node', 'id');
58                $table_nodes->info['MULTICHOICE_LABEL'] = 'delete';
59                $table_nodes->db_data_remove('id');
60                return $table_nodes;
61        }
62       
63        function output() {
64                if ($_SERVER['REQUEST_METHOD'] == 'POST' && method_exists($this, 'output_onpost_'.$_POST['form_name'])) return call_user_func(array($this, 'output_onpost_'.$_POST['form_name']));
65                global $construct;
66                $this->tpl['form_search_nodes'] = $construct->form($this->form_search_nodes(), __FILE__);
67                $this->tpl['table_nodes'] = $construct->table($this->table_nodes(), __FILE__);
68                return template($this->tpl, __FILE__);
69        }
70
71        function output_onpost_table_nodes() {
72                global $db, $main;
73                $ret = TRUE;
74                foreach( (array) $_POST['id'] as $key => $value) {
75                        $ret = $ret && $db->del("nodes", "id = '".$value."'");
76                }
77                if ($ret) {
78                        $main->message->set_fromlang('info', 'delete_success', makelink("",TRUE));
79                } else {
80                        $main->message->set_fromlang('error', 'generic');               
81                }
82        }
83
84}
85
86?>
Note: See TracBrowser for help on using the browser.