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

Revision 20, 2.4 KB checked in by niltonneto, 17 years ago (diff)

Inclusão do módulo Mensageiro Instantâneo no CVS.

  • 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 $teste;
17       
18        function db_im(){
19                $this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
20                $this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
21                $this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
22                $this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
23                $this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
24                $this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
25               
26                $this->db = new db();           
27                $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
28        }
29
30        function get_contacts_im($pFrom = false, $pTo)
31        {               
32                $result = array();
33                $from = explode("/",$pFrom);
34                $to = explode("/",$pTo);
35                if($pFrom)
36                        $query = "select im_from, im_to from phpgw_im_auth_user where im_from = '".$from[0]."' and im_to = '".$to[0]."'";
37                else
38                        $query = "select im_from, im_to from phpgw_im_auth_user where im_to = '".$to[0]."' order by im_from";                   
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 insert_contacts($pFrom, $pTo)
50        {
51                $from = explode("/",$pFrom);
52                $to = explode("/",$pTo);
53                $query = "insert into phpgw_im_auth_user values('".$from[0]."','".$to[0]."')";
54                return $this->query_db($query);         
55        }
56       
57        function delete_contacts($pFrom, $pTo)
58        {
59                $from = explode("/",$pFrom);
60                $to = explode("/",$pTo);
61                $query = "delete from phpgw_im_auth_user where im_from = '".$from[0]."' and im_to = '".$to[0]."'";
62                return $this->query_db($query);
63        }
64       
65        function get_accounts_acl()
66        {
67                $result = array();
68                $query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";
69               
70                if (!$this->db->query($query))
71                return null;
72               
73                while($this->db->next_record())
74                        $result[] = $this->db->row();
75
76                return $result;
77        }
78       
79        function query_db($pQuery)
80        {
81                if (!$this->db->query($pQuery))
82                return false;
83                else
84                        return true;
85        }
86}
87?>
Note: See TracBrowser for help on using the repository browser.