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

Revision 24, 2.3 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

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