source: trunk/instant_messenger/inc/class.db_im.inc.php @ 151

Revision 151, 2.6 KB checked in by niltonneto, 16 years ago (diff)

Commit da nova versão do módulo, usando agente em C.
Vide Página do módulo do Trac:
http://www.expressolivre.org/dev/wiki/messenger

A versão anterior encontra-se na subpasta bkp (32/64).

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2define('PHPGW_INCLUDE_ROOT','../');     
3define('PHPGW_API_INC','../phpgwapi/inc');
4require_once(PHPGW_API_INC.'/class.db.inc.php');
5       
6class db_im
7{       
8       
9        var $db;
10        var $db_name;
11        var $db_host;
12        var $db_port;
13        var $db_user;
14        var $db_pass;
15        var $db_type;
16        var $user_id;
17        var $teste;
18       
19        function db_im()
20        {
21                session_start();               
22                $this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
23                $this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
24                $this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
25                $this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
26                $this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
27                $this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
28                $this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
29               
30                $this->db = new db();
31                $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
32                session_write_close();         
33        }
34
35        function get_accounts_acl()
36        {
37                $result = array();
38                $query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";
39               
40                if (!$this->db->query($query))
41                return null;
42               
43                while($this->db->next_record())
44                        $result[] = $this->db->row();
45
46                return $result;
47        }
48       
49        function query_db($pQuery)
50        {
51                if (!$this->db->query($pQuery))
52                return false;
53                else
54                        return true;
55        }
56       
57        function set_preferences($param)
58        {
59                $preferences = $param['preferences'];
60                $user_id  = $this->user_id;
61                $app_name = $this->name_app();
62               
63                $query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
64               
65                if($this->query_db($query))
66                {
67                        return "true";
68                }
69                else
70                {
71                        $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
72                        if($this->query_db($query))
73                                return "true";
74                        else
75                                return "false";                 
76                }               
77        }
78       
79        function get_preferences()
80        {
81                $result = array();
82                $user_id  = $this->user_id;
83                $app_name = $this->name_app();
84               
85                $query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
86               
87                if (!$this->db->query($query))
88                return NULL;
89               
90                while($this->db->next_record())
91                        $result[] = $this->db->row();
92
93                if(count($result) > 0)
94                        return unserialize($result[0]['preference_value']);
95                else
96                        return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false";
97        }               
98       
99        function name_app()
100        {
101                return "instant_messenger";
102        }
103}
104?>
Note: See TracBrowser for help on using the repository browser.