source: companies/serpro/admin/inc/class.soapplications.inc.php @ 903

Revision 903, 3.4 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - administration                                              *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12
13        class soapplications
14        {
15                var $db;
16
17                function soapplications()
18                {
19                        $this->db = $GLOBALS['phpgw']->db;
20                }
21
22                function read($app_name)
23                {
24                        $sql = "SELECT * FROM phpgw_applications WHERE app_name='$app_name'";
25
26                        $this->db->query($sql,__LINE__,__FILE__);
27                        $this->db->next_record();
28                        $app_info = array(
29                                $this->db->f('app_name'),
30                                $GLOBALS['phpgw_info']['apps'][$this->db->f('app_name')]['title'],
31                                $this->db->f('app_enabled'),
32                                $this->db->f('app_name'),
33                                $this->db->f('app_order')
34                        );
35                        return $app_info;
36                }
37
38                function get_list()
39                {
40                        $this->db->query('SELECT * FROM phpgw_applications WHERE app_enabled!=3',__LINE__,__FILE__);
41                        if($this->db->num_rows())
42                        {
43                                while ($this->db->next_record())
44                                {
45                                        $app = $this->db->f('app_name');
46                                        $title = @$GLOBALS['phpgw_info']['apps'][$app]['title'];
47                                        if (empty($title))
48                                        {
49                                                $title = lang($app) == $app.'*' ? $app : lang($app);
50                                        }
51                                        $apps[$app] = array(
52                                                'title'  => $title,
53                                                'name'   => $app,
54                                                'status' => $this->db->f('app_enabled')
55                                        );
56                                }
57                        }
58                        return $apps;
59                }
60
61                function add($data)
62                {
63                        /* Yes, the sequence should work, but after a mass import in setup (new install)
64                          it does not work on pg
65                        */
66                        $sql = 'SELECT MAX(app_id) from phpgw_applications';
67                        $this->db->query($sql,__LINE__,__FILE__);
68                        $this->db->next_record();
69                        $app_id = $this->db->f(0) + 1;
70                        $sql = 'INSERT INTO phpgw_applications (app_id,app_name,app_enabled,app_order) VALUES('
71                                . $app_id . ",'" . addslashes($data['n_app_name']) . "','"
72                                . $data['n_app_status'] . "','" . $data['app_order'] . "')";
73
74                        $this->db->query($sql,__LINE__,__FILE__);
75                        return True;
76                }
77
78                function save($data)
79                {
80                        $sql = "UPDATE phpgw_applications SET "
81                                . "app_enabled='" . $data['n_app_status'] . "',app_order='" . $data['app_order']
82                                . "' WHERE app_name='" . $data['app_name'] . "'";
83
84                        $this->db->query($sql,__LINE__,__FILE__);
85                        return True;
86                }
87
88                function exists($app_name)
89                {
90                        $this->db->query("SELECT COUNT(app_name) FROM phpgw_applications WHERE app_name='" . addslashes($app_name) . "'",__LINE__,__FILE__);
91                        $this->db->next_record();
92
93                        if ($this->db->f(0) != 0)
94                        {
95                                return True;
96                        }
97                        return False;
98                }
99
100                function app_order()
101                {
102                        $this->db->query('SELECT (MAX(app_order)+1) FROM phpgw_applications',__LINE__,__FILE__);
103                        $this->db->next_record();
104                        return $this->db->f(0);
105                }
106
107                function delete($app_name)
108                {
109                        $this->db->query("DELETE FROM phpgw_applications WHERE app_name='$app_name'",__LINE__,__FILE__);
110                }
111
112                function register_hook($app)
113                {
114                        $this->db->query("INSERT INTO phpgw_hooks(hook_appname,hook_location,hook_filename) "
115                                . "VALUES ('".$app['app_name']."','".$app['hook']."','hook_".$app['hook'].".inc.php')",__LINE__,__FILE__
116                        );
117                }
118        }
Note: See TracBrowser for help on using the repository browser.