source: trunk/jabberit_messenger/inc/class.ujabber.inc.php @ 417

Revision 417, 1.8 KB checked in by niltonneto, 16 years ago (diff)

Vide changelog do módulo.
http://www.expressolivre.org/dev/wiki/jabberit/changelog
Alterações feitas por Alexandre Correia
email: alexandrecorreia@…

  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  *  Expresso - Expresso Messenger                                            *
4  *     - Alexandre Correia / Rodrigo Souza                                                               *
5  *     - JETI - http://jeti-im.org/                                                                              *
6  * ------------------------------------------------------------------------- *
7  *  This program is free software; you can redistribute it and/or modify it  *
8  *  under the terms of the GNU General Public License as published by the    *
9  *  Free Software Foundation; either version 2 of the License, or (at your   *
10  *  option) any later version.                                               *
11  \***************************************************************************/
12
13require_once "class.jabber.inc.php";
14
15class ujabber
16{
17        private $jabber;
18        private $error;
19
20        function __construct()
21        {
22               
23                $this->jabber = new Jabber();
24                $this->jabber->username  = $_SESSION['phpgw_info']['jabberit_messenger']['user'];
25                $this->jabber->password  = $_SESSION['phpgw_info']['jabberit_messenger']['passwd'];
26                $this->jabber->server    = $_SESSION['phpgw_info']['jabberit_messenger']['name_jabberit'];
27                $this->jabber->resource  = "JABADD";
28        }       
29       
30        function connect()
31        {
32                if(!$this->jabber->Connect())
33                {
34                        $this->error = "No Connect";
35                        return false;   
36                }
37                if(!$this->jabber->SendAuth())
38                {
39                        $this->error = "No Auth";
40                        return false;
41                }
42               
43                return true;
44        }
45       
46        function disconnect()
47        {
48               
49                $this->jabber->Disconnect();
50        }
51       
52        function AddNewContact($pNewUser)
53        {
54                $this->connect();
55                $jid    = $pNewUser['uid']."@". $this->jabber->server;
56                $id             = 'add_user'.time();
57                $name   = $pNewUser['name'];
58                $group  = $pNewUser['group'];
59               
60                if($this->jabber->RosterAddUser($jid,$id,$name,$group))
61                {
62                        if($this->jabber->Subscribe($jid))
63                                return true;
64                }
65                else
66                {
67                        return false;
68                }
69
70                $this->disconnect();
71        }
72}
73?>     
Note: See TracBrowser for help on using the repository browser.