Changeset 2421 for sandbox/jabberit_messenger
- Timestamp:
- 04/05/10 17:48:29 (14 years ago)
- Location:
- sandbox/jabberit_messenger/trophy_expresso
- Files:
-
- 5 added
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/jabberit_messenger/trophy_expresso/inc/class.ContactsIm.inc.php
r2411 r2421 40 40 { 41 41 42 // TESTE REMOVER43 $param['name'] = "alexandre*correia";44 45 42 $order = array(); 46 43 $ou_User = substr($this->ou_User, (strpos($this->ou_User,"=")+1)); … … 54 51 // Hosts Jabber 55 52 $hostsJabber = unserialize($_SESSION['phpgw_info']['jabberit_messenger']['map_org_realm_jabberit']); 56 53 57 54 if( is_array($users) ) 58 55 { … … 107 104 $uidType = "uid"; 108 105 $serversLdap = unserialize(trim($_SESSION['phpgw_info']['jabberit_messenger']['groups_search'])); 109 106 110 107 if( $serversLdap ) 111 108 { -
sandbox/jabberit_messenger/trophy_expresso/inc/class.LdapIM.inc.php
r2411 r2421 49 49 $this->attribute = trim($attributeTypeName); 50 50 } 51 else 52 $this->attribute = "uid"; 51 53 } 52 54 -
sandbox/jabberit_messenger/trophy_expresso/inc/webservice.php
r2411 r2421 3 3 * Expresso - Expresso Messenger * 4 4 * - Alexandre Correia / Rodrigo Souza * 5 * - JETI - http://jeti-im.org/ *6 5 * ------------------------------------------------------------------------- * 7 6 * This program is free software; you can redistribute it and/or modify it * … … 13 12 class webService 14 13 { 15 private $attribute;16 private $conn;17 private $contextLdap;18 private $userLDAP;19 private $jabberName = null;20 private $passwd;21 private $photo_user = array();22 private $refer;23 private $serverLdap;24 private $fileLdapInternal = false;25 private $fileLdapExternal = false;26 private $version3;27 28 function __construct()29 {30 if ( file_exists('confLDAPInternal.php') )31 {32 require_once('confLDAPInternal.php');33 $handle = unserialize(base64_decode($LDAP_INTERNAL));34 35 $this->jabberName = $handle['jabberName'];36 $this->serverLdap = $handle['serverLdap'];37 $this->contextLdap = $handle['contextLdap'];38 $this->userLDAP = $handle['user'];39 $this->passwd = $handle['password'];40 41 $this->refer = true;42 $this->version3 = true;43 44 $this->fileLdapInternal = true;45 }46 47 $this->attribute = "uid";48 49 if ( file_exists('attributeLdap.php') )50 {51 require_once('attributeLdap.php');52 $this->attribute = trim($attributeTypeName);53 }54 }55 56 private final function ldapConnect()57 {58 if(!function_exists('ldap_connect'))59 return False;60 61 if(!$this->conn = ldap_connect($this->serverLdap))62 return False;63 64 if( $this->version3 )65 if( !ldap_set_option($this->conn,LDAP_OPT_PROTOCOL_VERSION,3) )66 $this->version3 = false;67 68 ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->refer);69 70 // Bind as Admin71 if( $this->userLDAP && $this->passwd && !ldap_bind($this->conn, $this->userLDAP . "," . $this->contextLdap, $this->passwd) )72 return False;73 74 // Bind as Anonymous75 if( !$this->userLDAP && !$this->passwd && !@ldap_bind($this->conn) )76 return False;77 }78 79 private final function ldapConnectExternal($pHostJabber)80 {81 if( file_exists('confLDAPExternal.php'))82 {83 require_once('confLDAPExternal.php');84 $handle = unserialize(base64_decode($LDAP_EXTERNAL));85 86 foreach($handle as $itens)87 {88 if(trim($pHostJabber) == $itens['jabberName'])89 {90 $this->jabberName = $itens['jabberName'];91 $this->serverLdap = $itens['serverLdap'];92 $this->contextLdap = $itens['contextLdap'];93 $this->userLDAP = $itens['user'];94 $this->passwd = $itens['password'];95 96 $this->fileLdapExternal = true;97 }98 }99 100 $this->refer = true;101 $this->version3 = true;102 103 $this->ldapConnect();104 }105 }106 107 public final function CallVoipConnect($pVoipFrom, $pVoipTo)108 {109 $this->ldapConnect();110 111 if( $this->conn )112 {113 $filter = "(|(&(phpgwaccounttype=u)(uid=".$pVoipFrom."))(&(phpgwaccounttype=u)(uid=".$pVoipTo.")))";114 $justthese = array("telephoneNumber", "uid");115 $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);116 $entry = ldap_get_entries($this->conn,$search);117 118 $fromNumber = $entry[0]['telephonenumber'][0];119 $toNumber = $entry[1]['telephonenumber'][0];120 121 if ( trim($entry[0]['uid'][0]) !== trim($pVoipFrom) )122 {123 $fromNumber = $entry[1]['telephonenumber'][0];124 $toNumber = $entry[0]['telephonenumber'][0];125 }126 }127 128 if( $fromNumber && $toNumber )129 {130 $voipServer = "www.pabx.celepar.parana";131 $voipUrl = "/telefoniaip/servicos/voip.php";132 $voipPort = "80";133 134 if( !$voipServer || !$voipUrl || !$voipPort )135 return false;136 137 $url = "http://".$voipServer.":".$voipPort.$voipUrl."?magic=1333&acao=liga&ramal=".$fromNumber."&numero=".$toNumber;138 $sMethod = 'GET ';139 $crlf = "\r\n";140 $sRequest = " HTTP/1.1" . $crlf;141 $sRequest .= "Host: localhost" . $crlf;142 $sRequest .= "Accept: */* " . $crlf;143 $sRequest .= "Connection: Close" . $crlf . $crlf;144 $sRequest = $sMethod . $url . $sRequest;145 $sockHttp = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);146 147 if ( !$sockHttp )148 return false;149 150 $resSocketConnect = socket_connect($sockHttp, $voipServer, $voipPort);151 152 if ( !$resSocketConnect )153 return false;154 155 $resSocketWrite = socket_write($sockHttp, $sRequest, strlen($sRequest));156 157 if ( !$resSocketWrite )158 return false;159 160 $sResponse = '';161 162 while ($sRead = socket_read($sockHttp, 512))163 {164 $sResponse .= $sRead;165 }166 167 socket_close($sockHttp);168 169 $pos = strpos($sResponse, $crlf . $crlf);170 171 return substr($sResponse, $pos + 2 * strlen($crlf));172 }173 174 return "ERRO";175 }176 177 178 public final function getNameOrganization($pJid, $pCharset)179 {180 $uid = substr($pJid, 0, strpos($pJid,"@"));181 $return = utf8_encode("Nome : Não Identificado ;Organização : Não Identificado");182 183 if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 )))184 {185 $this->ldapConnect();186 187 if( $this->fileLdapInternal )188 {189 if( $this->conn )190 {191 $filter = "(&(phpgwaccounttype=u)(".$this->attribute."=".$uid.")(!(phpgwaccountvisible=-1)))";192 $justthese = array($this->attribute,"cn","dn");193 $search = ldap_search( $this->conn, $this->contextLdap, $filter,$justthese);194 $get_entries = ldap_get_entries( $this->conn, $search);195 196 if( $get_entries['count'] > 0 )197 {198 $cn = $get_entries[0]['cn'][0];199 $ou = explode("dc=", $get_entries[0]['dn']);200 $ou = explode("ou=",$ou[0]);201 $ou = array_pop($ou);202 $dn = strtoupper(substr($ou,0,strlen($ou)-1));203 $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn);204 }205 }206 }207 }208 else209 {210 $this->ldapConnectExternal(substr($pJid, strpos($pJid, "@") + 1 ));211 212 if( $this->fileLdapExternal )213 {214 if( $this->conn )215 {216 $filter = "(&(phpgwaccounttype=u)(".$this->attribute."=".$uid.")(!(phpgwaccountvisible=-1)))";217 $justthese = array($this->attribute,"cn","dn");218 $search = ldap_search( $this->conn, $this->contextLdap, $filter, $justthese);219 $get_entries = ldap_get_entries( $this->conn, $search);220 221 if( $get_entries['count'] > 0 )222 {223 $cn = $get_entries[0]['cn'][0];224 $ou = explode("dc=", $get_entries[0]['dn']);225 $ou = explode("ou=",$ou[0]);226 $ou = array_pop($ou);227 $dn = strtoupper(substr($ou,0,strlen($ou)-1));228 $return = utf8_encode("Nome : " . $cn . ";Organização : " . $dn);229 }230 }231 }232 }233 234 if( $pCharset === "1" || $pCharset === 1 )235 return $return;236 else237 return mb_convert_encoding($return, "ISO-8859-1", "UTF-8");238 239 }240 241 public final function getPhotoLdap( $pJid , $pLdapInternal )242 {243 $uid = substr($pJid, 0, strpos($pJid, "@"));244 245 if( $pLdapInternal )246 {247 if( !$this->fileLdapInternal )248 return false;249 250 if( $this->jabberName == (substr($pJid, strpos($pJid, "@") + 1 )))251 {252 253 $this->ldapConnect();254 255 if( $this->conn )256 {257 $filter = "(&(phpgwaccounttype=u)(".$this->attribute."=".$uid.")(!(phpgwaccountvisible=-1)))";258 $justthese = array($this->attribute,"jpegPhoto");259 $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);260 $get_entries = ldap_get_entries($this->conn,$search);261 262 if( $get_entries['count'] > 0 )263 {264 $first_entry = ldap_first_entry( $this->conn, $search );265 $photo = @ldap_get_values_len($this->conn, $first_entry, 'jpegphoto');266 267 if ( $photo )268 return $photo[0];269 270 return false;271 }272 }273 }274 }275 else276 {277 if( !$this->fileLdapExternal )278 return false;279 280 $jabberName = substr($pJid, strpos($pJid, "@") + 1 );281 282 if( strpos($jabberName, "/") )283 $jabberName = substr($jabberName, 0, strpos($jabberName, "/"));284 285 $this->ldapConnectExternal($jabberName);286 287 if( $this->conn )288 {289 $filter = "(&(phpgwaccounttype=u)(".$this->attribute."=".$uid.")(!(phpgwaccountvisible=-1)))";290 $justthese = array($this->attribute,"jpegPhoto");291 $search = ldap_search($this->conn,$this->contextLdap,$filter,$justthese);292 $get_entries = ldap_get_entries($this->conn,$search);293 294 if( $get_entries['count'] > 0 )295 {296 $first_entry = ldap_first_entry( $this->conn, $search );297 $photo = @ldap_get_values_len($this->conn, $first_entry, 'jpegphoto');298 299 if ( $photo )300 return $photo[0];301 302 return false;303 }304 }305 }306 307 return false;308 }309 310 14 public final function getPhotoSession($pUid, $pOu) 311 15 { … … 336 40 } 337 41 338 // Applet - utilizando o serviço Voip;339 if(trim($_REQUEST['javaVoipFrom']) != "" && trim($_REQUEST['javaVoipTo']) != "" )340 {341 $obj = new webService();342 $voipFrom = $_REQUEST['javaVoipFrom'];343 $voipTo = $_REQUEST['javaVoipTo'];344 printf("%s",$obj->CallVoipConnect($voipFrom, $voipTo));345 }346 347 // Applet - fotos pelo applet;348 if(trim($_REQUEST['javaPhoto']) != "" )349 {350 $obj = new webService();351 $jid = $_REQUEST['javaPhoto'];352 $jid = ( strpos($jid, "/") !== false ) ? substr($jid, 0, strpos($jid, "/")) : $jid;353 354 $photo = $obj->getPhotoLdap( $jid, true );355 $photoWidth = 70;356 $photoHeight = 90;357 $newImage = imagecreatetruecolor($photoWidth,$photoHeight);358 359 if( $photo )360 {361 $photo = imagecreatefromstring($photo);362 imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));363 }364 else365 {366 $photo = $obj->getPhotoLdap($jid, false);367 if( $photo )368 {369 $photo = imagecreatefromstring($photo);370 imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));371 }372 else373 {374 $photo = @imagecreatefrompng("../templates/default/images/photo.png");375 imagecopyresized($newImage,$photo,0,0,0,0,$photoWidth,$photoHeight,imagesx($photo),imagesy($photo));376 }377 }378 379 ob_start();380 imagepng($newImage);381 $imagePhoto = ob_get_contents();382 imagedestroy($newImage);383 ob_end_clean();384 printf("%s",base64_encode($imagePhoto));385 }386 387 // Applet - jid;388 if(trim($_REQUEST['jid']) != "")389 {390 391 $jid = trim($_REQUEST['jid']);392 $charset = trim($_REQUEST['charset']);393 $obj = new webService();394 395 printf("%s",$obj->getNameOrganization($jid, $charset));396 }397 398 42 // Php - fotos pelo php; 399 43 if(trim($_REQUEST['phpPhoto']) != "") 400 44 { 401 $obj 402 $ou 403 $jid 45 $obj = new webservice(); 46 $ou = $_REQUEST['phpOu']; 47 $jid = $_REQUEST['phpPhoto']; 404 48 405 49 $obj->getPhotoSession($jid, $ou); -
sandbox/jabberit_messenger/trophy_expresso/js/AddUser.js
r2411 r2421 6 6 function addContacts() 7 7 { 8 if( arguments.length > 0 ) 9 { 10 var jidFrom = loadIM.getUserCurrent().jid; 11 var jidTo = arguments[0]; 12 var name = arguments[1]; 13 var group = arguments[2]; 8 var jidFrom = loadIM.getUserCurrent().jid; 9 var jidTo = document.getElementById('user_jid_jabberIM').value; 10 var name = document.getElementById('user_name_jabberIM').value; 11 var group = document.getElementById('user_group_jabberIM').value; 14 12 15 TrophyIM.addContacts( jidFrom, jidTo, name, group ); 16 } 13 alert( jidFrom + "\n" + jidTo + "\n" + name + "\n" + group ); 14 15 //TrophyIM.addContacts( jidFrom, jidTo, name, group ); 16 17 17 } 18 18 … … 24 24 25 25 _span.style.display = "block"; 26 27 if( _input.value.substring((_input.value.length-1),_input.value.length) === "*" ) 28 _input.value = _input.value.substring(0, ( _input.value.length - 1 )); 29 30 if( _input.value.substring(0 ,1) === "*" ) 31 _input.value = _input.value.substring( 1, _input.value.length ); 26 32 27 33 conn.go('p.cc.getListContacts', … … 37 43 _div.innerHTML = Xtools.parse( data, 'listLdapContacts.xsl', _paramsVar ); 38 44 39 var _ member = _div.firstChild;45 var _newUser = _div.firstChild; 40 46 41 while ( _ member )47 while ( _newUser ) 42 48 { 43 if( _ member.getAttribute('photo') === '1' )49 if( _newUser.getAttribute('photo') === '1' ) 44 50 { 45 var jid = _ member.getAttribute('jid');46 var ou = _ member.getAttribute('ou');51 var jid = _newUser.getAttribute('jid'); 52 var ou = _newUser.getAttribute('ou'); 47 53 48 54 var _img_path = path_jabberit + 'inc/webservice.php?' + Date.parse( new Date ); 49 55 _img_path += '&phpPhoto=' + jid + '&phpOu=' + ou; 50 56 51 _ member.style.backgroundImage = 'url(' + _img_path + ')';57 _newUser.style.backgroundImage = 'url(' + _img_path + ')'; 52 58 } 53 59 54 //_config(_member, 'onclick', _show);60 loadIM.configEvents(_newUser, 'onclick', showContact); 55 61 56 _ member = _member.nextSibling;62 _newUser = _newUser.nextSibling; 57 63 } 58 64 … … 61 67 _span.style.display = "none"; 62 68 63 }); 69 },'name=' + _input.value ); 70 } 71 72 function showContact(Element) 73 { 74 var element = ( Element.target ) ? Element.target : Element.srcElement; 75 var infoUser = null; 76 77 if( element.getAttribute('value') ) 78 { 79 var infoUser = 80 { 81 'email' : element.getAttribute('value').substring( 0, element.getAttribute('value').indexOf(';')), 82 'jid' : element.getAttribute('jid'), 83 'lang_group' : "Grupo", 84 'lang_name_contact' : "Contato", 85 'group' : element.getAttribute('ou'), 86 'name' : element.getAttribute('name').substring( 0, element.getAttribute('name').indexOf(' ')), 87 'uid' : element.getAttribute('value').substring( element.getAttribute('value').indexOf(';') + 1 ) 88 }; 89 } 90 else if( element.parentNode.getAttribute('value') ) 91 { 92 var infoUser = 93 { 94 'email' : element.parentNode.getAttribute('value').substring( 0, element.parentNode.getAttribute('value').indexOf(';')), 95 'jid' : element.parentNode.getAttribute('jid'), 96 'lang_group' : "Grupo", 97 'lang_name_contact' : "Contato", 98 'group' : element.parentNode.getAttribute('ou'), 99 'name' : element.parentNode.getAttribute('name').substring( 0, element.parentNode.getAttribute('name').indexOf(' ')), 100 'uid' : element.parentNode.getAttribute('value').substring( element.parentNode.getAttribute('value').indexOf(';') + 1) 101 }; 102 } 103 104 var winAddUser = 105 { 106 id_window : "add_user_info", 107 width : 355, 108 height : 190, 109 top : 85, 110 left : 220, 111 draggable : true, 112 visible : "display", 113 resizable : true, 114 zindex : loadIM.getZIndex(), 115 title : 'Expresso Messenger - Add Contact', 116 closeAction : "remove", 117 content : Xtools.parse( Xtools.xml('adduser'), 'addUser.xsl', infoUser ) 118 }; 119 120 _winBuild( winAddUser ); 121 122 123 var _pButtons = 124 { 125 'lang1' : 'Adicionar', 126 'lang2' : 'Fechar', 127 'onclickClose' : '_winBuild("' + winAddUser.id_window + '","remove");', 128 'onclickSubmit' : 'loadIM.addContacts(this);' 129 }; 130 131 document.getElementById('buttons_adduser').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 64 132 } 65 133 -
sandbox/jabberit_messenger/trophy_expresso/js/loadIM.js
r2411 r2421 44 44 function addContacts() 45 45 { 46 addUser.show(); 46 if( arguments.length > 0 ) 47 addUser.add(); 48 else 49 addUser.show(); 47 50 } 48 51 … … 374 377 function searchUser() 375 378 { 376 addUser.search(); 379 var _input = document.getElementById('search_user_jabber'); 380 381 if( _input.value.length >= 3 ) 382 addUser.search(); 383 else 384 alert('Your search argument must be longer than 3 characters.'); 377 385 } 378 386 … … 450 458 path_jabberit + 'js/trophyim.js', 451 459 path_jabberit + 'js/AddUser.js', 452 path_jabberit + 'templates/default/css/trophyim.css', 460 path_jabberit + 'templates/default/css/button.css', 461 path_jabberit + 'templates/default/css/common.css', 453 462 path_jabberit + 'templates/default/css/' + theme_jabberit 454 463 ]; -
sandbox/jabberit_messenger/trophy_expresso/xsl/addUser.xsl
r2411 r2421 8 8 <xsl:param name="lang_result" /> 9 9 <xsl:param name="path" /> 10 <xsl:param name="group" /> 11 <xsl:param name="jid" /> 12 <xsl:param name="name" /> 10 13 11 14 <xsl:template match="userinfo"> … … 19 22 </div> 20 23 21 <div style="margin:7px 0px 5px 5px;">22 <span style="width:auto; text-decoration:underline;"><xsl:value-of select="$lang_result"/> .: </span>24 <div class="add_organization_members" style="margin:7px 0px 5px 5px;"> 25 <span style="width:auto;"><xsl:value-of select="$lang_result"/> .: </span> 23 26 <br style="clear:both"/> 24 27 <div id="list_users_ldap_im"></div> … … 30 33 <xsl:value-of select="$lang_load" /> ... 31 34 </span> 32 <input id="im_jidUser" type="hidden" /> 33 <input id="im_jid" type="hidden" /> 34 <input id="im_uid" type="hidden" /> 35 35 36 36 </xsl:template> 37 37 38 38 <xsl:template match="adduser"> 39 39 40 40 <div class="add_member_info"> 41 <span><xsl:value-of select="$lang4"/> : </span> 42 <input id="im_name" type="text" size="39" maxlength="50" onclick="this.select();"/> 43 <br/><br style="line-height:4px"/> 44 <span><xsl:value-of select="$lang5"/> : </span> 45 <input id="im_group" type="text" size="40" maxlength="50" selectboxoptions="" onclick="this.select();"/> 41 <form> 42 <span> <xsl:value-of select="$lang_name_contact"/> : </span> 43 <input id="user_name_jabberIM" type="text" size="39" maxlength="50" value="{$name}" onclick="this.select();" /> 44 <br/><br/> 45 <span><xsl:value-of select="$lang_group"/> : </span> 46 <input id="user_group_jabberIM" type="text" size="39" maxlength="50" value="{$group}" onclick="this.select();" /> 47 <input id="user_jid_jabberIM" type="hidden" value="{$jid}" /> 48 </form> 46 49 </div> 47 50 48 51 <div id="buttons_adduser" style="padding-top:30px; padding-bottom: 30px; margin-left: 83px;"/> 49 52 50 53 </xsl:template> 51 54 -
sandbox/jabberit_messenger/trophy_expresso/xsl/listLdapContacts.xsl
r2411 r2421 24 24 <xsl:for-each select="data"> 25 25 <xsl:sort select="cn"/> 26 <span value="{mail};{uid}" jid="{jid}" ou="{ou}" photo="{photo}">26 <span value="{mail};{uid}" jid="{jid}" name="{cn}" ou="{ou}" photo="{photo}"> 27 27 <span id="{mail};{uid}" style="display:none;"><xsl:value-of select="cn" /></span> 28 28 <b><xsl:value-of select="name(..)"/></b>
Note: See TracChangeset
for help on using the changeset viewer.