[382] | 1 | (function() |
---|
| 2 | { |
---|
| 3 | var _conn; |
---|
| 4 | var _xtools; |
---|
| 5 | var _window; |
---|
[792] | 6 | var _myWindow; |
---|
[815] | 7 | var _is_ie; |
---|
[382] | 8 | |
---|
| 9 | function _add_user() |
---|
| 10 | { |
---|
[792] | 11 | if( arguments.length > 0 ) |
---|
| 12 | { |
---|
| 13 | _myWindow = arguments[0]; |
---|
| 14 | } |
---|
| 15 | |
---|
[382] | 16 | var _win_add = _window.load('add_user_im'); |
---|
| 17 | _win_add.title('.:: Adicionar Novos Contatos ::.'); |
---|
| 18 | _win_add.size(440); |
---|
| 19 | _win_add.position(200,80); |
---|
| 20 | _win_add.wc.style.padding = "3px"; |
---|
| 21 | |
---|
| 22 | var _params = { |
---|
[946] | 23 | 'lang1':jabberitGetLang('Name of Contacts'), |
---|
| 24 | 'lang2':jabberitGetLang('Search'), |
---|
| 25 | 'lang3':jabberitGetLang('member of organization'), |
---|
| 26 | 'lang4':jabberitGetLang('nickname'), |
---|
| 27 | 'lang5':jabberitGetLang('group'), |
---|
| 28 | 'lang6':jabberitGetLang('add'), |
---|
| 29 | 'lang7':jabberitGetLang('close'), |
---|
| 30 | 'lang8':jabberitGetLang('Others Expressos') |
---|
| 31 | }; |
---|
[382] | 32 | |
---|
| 33 | _win_add.bz.style.display = "none"; |
---|
| 34 | _win_add.bx.style.display = "none"; |
---|
| 35 | |
---|
[519] | 36 | _win_add.content( _xtools.parse(_xtools.xml('adduser'), 'add_user.xsl', _params)); |
---|
[382] | 37 | |
---|
[519] | 38 | _config( _win_add.wc.childNodes[2].childNodes[0], |
---|
[382] | 39 | 'onclick', |
---|
| 40 | function() |
---|
| 41 | { |
---|
| 42 | var _name = document.getElementById('im_name'); |
---|
| 43 | var _group = document.getElementById('im_group'); |
---|
[914] | 44 | var jidUser = document.getElementById('im_jidUser').value; |
---|
[382] | 45 | var _jid = document.getElementById('im_jid').value; |
---|
| 46 | var _status = document.getElementById('im_status_add'); |
---|
| 47 | |
---|
| 48 | _status.innerHTML = ''; |
---|
| 49 | _name.previousSibling.style.color = "#000"; |
---|
| 50 | |
---|
[792] | 51 | if ( _jid ) |
---|
[382] | 52 | { |
---|
| 53 | _name.value = _name.value.replace(/^( )*|( )*$/g, ''); |
---|
| 54 | _group.value = _group.value.replace(/^( )*|( )*$/g, ''); |
---|
| 55 | |
---|
| 56 | if ( !(_name.value) || !(_group.value) ) |
---|
| 57 | { |
---|
| 58 | if ( !(_name.value) ) |
---|
[946] | 59 | alert( jabberitGetLang('ATTENTION') + "!!\n" + jabberitGetLang("Enter a NAME") + "."); |
---|
[382] | 60 | |
---|
| 61 | if ( !(_group.value) ) |
---|
[946] | 62 | alert( jabberitGetLang('ATTENTION') + "!!\n" + jabberitGetLang("Enter a GROUP") + "."); |
---|
[382] | 63 | } |
---|
| 64 | else |
---|
| 65 | { |
---|
| 66 | var _uid; |
---|
[697] | 67 | |
---|
[382] | 68 | if ( (_uid = document.getElementById('im_uid')) ) |
---|
| 69 | _uid = _uid.value; |
---|
| 70 | else |
---|
| 71 | _uid = _jid.substr(0, (_jid.indexOf('@') - 1)); |
---|
| 72 | |
---|
[697] | 73 | _conn.go('$this.contacts_im.verifyAddNewContact', |
---|
| 74 | function(data) |
---|
| 75 | { |
---|
| 76 | data = eval(data); |
---|
[946] | 77 | |
---|
[697] | 78 | if( !data ) |
---|
| 79 | { |
---|
| 80 | alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + |
---|
| 81 | jabberitGetLang("This user is part of a small group!") + |
---|
| 82 | "\n" + jabberitGetLang("Contact was not added!")); |
---|
| 83 | _name.value = ''; |
---|
| 84 | _group.value = ''; |
---|
| 85 | } |
---|
| 86 | else |
---|
| 87 | { |
---|
[792] | 88 | var result; |
---|
[697] | 89 | _name.parentNode.style.display = 'none'; |
---|
| 90 | _name.parentNode.nextSibling.style.display = 'none'; |
---|
[946] | 91 | _status.innerHTML = '<br/>' + jabberitGetLang('Add contact wait') + '....<br/>'; |
---|
[697] | 92 | |
---|
[914] | 93 | try |
---|
| 94 | { |
---|
| 95 | if( elementIframe = document.getElementById('iframe_applet_jabberit') ) |
---|
| 96 | { |
---|
| 97 | if( !_is_ie ) |
---|
| 98 | result = elementIframe.contentDocument.applets[0].addContact( jidUser, _name.value, _group.value ); |
---|
| 99 | else |
---|
| 100 | result = elementIframe.contentWindow.document.applets[0].addContact( jidUser, _name.value, _group.value ); |
---|
| 101 | } |
---|
| 102 | else // If Pop-Up |
---|
| 103 | { |
---|
| 104 | result = _myWindow.document.applets[0].addContact( jidUser, _name.value, _group.value ); |
---|
| 105 | } |
---|
| 106 | _status.innerHTML = '<br/>' + jabberitGetLang('Add contact!') + '<br/>'; |
---|
[792] | 107 | } |
---|
[914] | 108 | catch(e) |
---|
[792] | 109 | { |
---|
[914] | 110 | _status.innerHTML = '<br/>' + jabberitGetLang('The module is not loaded') + '! ' + |
---|
| 111 | jabberitGetLang('Contact was not added!') + '<br/>'; |
---|
[792] | 112 | } |
---|
[946] | 113 | |
---|
[792] | 114 | setTimeout('cleanStatusAddContactIM();',2500); |
---|
[697] | 115 | _name.value = ''; |
---|
| 116 | _group.value = ''; |
---|
| 117 | } |
---|
| 118 | }, "uid="+_uid); |
---|
[382] | 119 | } |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | ); |
---|
| 123 | |
---|
| 124 | _config(_win_add.wc.childNodes[2].childNodes[1], |
---|
| 125 | 'onclick', |
---|
| 126 | function() |
---|
| 127 | { |
---|
| 128 | _win_add.button(_win_add.bc); |
---|
| 129 | } |
---|
| 130 | ); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | function _config(pObj, pEvent, pHandler) |
---|
| 134 | { |
---|
| 135 | if ( typeof pObj == 'object' ) |
---|
| 136 | { |
---|
| 137 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
| 138 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 139 | |
---|
| 140 | if ( pObj.addEventListener ) |
---|
| 141 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 142 | else if ( pObj.attachEvent ) |
---|
| 143 | pObj.attachEvent('on' + pEvent, pHandler); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | function _highlight(e) |
---|
| 148 | { |
---|
| 149 | var el = ( e.target ) ? e.target : e.srcElement; |
---|
| 150 | var color = "#fff"; |
---|
| 151 | if ( e.type.indexOf('mouseover') != -1 ) |
---|
| 152 | color = "#dedede"; |
---|
| 153 | el.style.backgroundColor = color; |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | function _search() |
---|
| 157 | { |
---|
[946] | 158 | var _loading = document.getElementById('__span_load_im'); |
---|
| 159 | var _target = document.getElementById('im_ldap_user'); |
---|
[914] | 160 | |
---|
[946] | 161 | _loading.style.display = "block"; |
---|
| 162 | |
---|
| 163 | _conn.go('$this.contacts_im.list_contacts', |
---|
| 164 | function( data ) |
---|
| 165 | { |
---|
| 166 | if( data ) |
---|
| 167 | { |
---|
| 168 | var _params = { |
---|
| 169 | 'many_results' : jabberitGetLang('More than 50 results. Please, try to refine your search.'), |
---|
| 170 | 'empty' : jabberitGetLang('None result was found.') |
---|
| 171 | }; |
---|
| 172 | |
---|
| 173 | _target.innerHTML = _xtools.parse( data, 'list_ldap_contacts.xsl', _params); |
---|
| 174 | |
---|
| 175 | // Add Contact |
---|
| 176 | function _show(m) |
---|
| 177 | { |
---|
| 178 | m = ( m.target ) ? m.target : m.srcElement; |
---|
| 179 | |
---|
| 180 | if ( m.getAttribute('value')) |
---|
| 181 | { |
---|
| 182 | var jidUser = m.getAttribute('jid'); |
---|
| 183 | m = m.getAttribute('value'); |
---|
| 184 | } |
---|
| 185 | else |
---|
| 186 | { |
---|
| 187 | var jidUser = m.parentNode.getAttribute('jid'); |
---|
| 188 | m = m.parentNode.getAttribute('value'); |
---|
| 189 | } |
---|
[382] | 190 | |
---|
[946] | 191 | if ( !m ) |
---|
| 192 | return false; |
---|
| 193 | |
---|
| 194 | document.getElementById('__span_load_im_group').style.display = 'block'; |
---|
| 195 | document.getElementById('im_jidUser').value = jidUser; |
---|
| 196 | document.getElementById('im_jid').value = m.substr(0, m.indexOf(';')); |
---|
| 197 | document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1)); |
---|
[551] | 198 | |
---|
[946] | 199 | |
---|
| 200 | var _name = document.getElementById('im_name'); |
---|
| 201 | var groups = ""; |
---|
| 202 | var data; |
---|
| 203 | |
---|
| 204 | var first_name = document.getElementById(m).innerHTML; |
---|
| 205 | first_name = first_name.substr(0, first_name.indexOf(' ')); |
---|
| 206 | |
---|
| 207 | _name.value = first_name; |
---|
| 208 | _name.previousSibling.style.color = "#000"; |
---|
| 209 | _name.parentNode.style.display = 'block'; |
---|
| 210 | _name.parentNode.nextSibling.style.display = 'block'; |
---|
| 211 | _name.parentNode.nextSibling.nextSibling.innerHTML = ''; |
---|
| 212 | |
---|
| 213 | try |
---|
| 214 | { |
---|
| 215 | // If Layer; |
---|
| 216 | if( elementIframe = document.getElementById('iframe_applet_jabberit') ) |
---|
| 217 | { |
---|
| 218 | if( !_is_ie ) |
---|
| 219 | groups = elementIframe.contentDocument.applets[0].getGroupsToExpresso(); |
---|
| 220 | else |
---|
| 221 | groups = elementIframe.contentWindow.document.applets[0].getGroupsToExpresso(); |
---|
| 222 | } |
---|
| 223 | else // If Pop-Up |
---|
| 224 | { |
---|
| 225 | groups = _myWindow.document.applets[0].getGroupsToExpresso(); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | if( typeof(groups) == 'object') |
---|
| 229 | { |
---|
| 230 | data = groups + ";"; |
---|
| 231 | data = data.substring(0,(data.length-2)); |
---|
| 232 | } |
---|
| 233 | else |
---|
| 234 | data = groups.substring(0,(groups.length-1)); |
---|
| 235 | |
---|
| 236 | if( data ) |
---|
| 237 | { |
---|
| 238 | document.getElementById('im_group').setAttribute('selectBoxOptions', data); |
---|
| 239 | |
---|
| 240 | if( document.getElementById('selectBox0') == null ) |
---|
| 241 | editS.create(document.getElementById('im_group')); |
---|
| 242 | } |
---|
[551] | 243 | |
---|
[946] | 244 | document.getElementById('__span_load_im_group').style.display = 'none'; |
---|
| 245 | document.getElementById('im_group').value = ''; |
---|
| 246 | document.getElementById('im_group').focus(); |
---|
| 247 | } |
---|
| 248 | catch(e) |
---|
| 249 | { |
---|
| 250 | alert("*********** " + jabberitGetLang("Attention") + "!! ***********\n" + |
---|
| 251 | jabberitGetLang("The module is not loaded") + "!\n" ); |
---|
[914] | 252 | |
---|
[946] | 253 | document.getElementById('__span_load_im_group').style.display = 'none'; |
---|
| 254 | } |
---|
| 255 | } |
---|
[914] | 256 | } |
---|
| 257 | |
---|
[946] | 258 | var _member = _target.firstChild; |
---|
| 259 | |
---|
| 260 | while ( _member ) |
---|
[914] | 261 | { |
---|
[946] | 262 | if( _member.getAttribute('photo') === '1' ) |
---|
| 263 | { |
---|
| 264 | var jid = _member.getAttribute('jid'); |
---|
| 265 | var ou = _member.getAttribute('ou'); |
---|
| 266 | |
---|
| 267 | var _img_path = path_jabberit + 'inc/webservice.php?' + Date.parse( new Date ); |
---|
| 268 | _img_path += '&phpPhoto=' + jid + '&phpOu=' + ou; |
---|
| 269 | |
---|
| 270 | _member.style.backgroundImage = 'url(' + _img_path + ')'; |
---|
| 271 | } |
---|
| 272 | _config(_member, 'onclick', _show); |
---|
[914] | 273 | |
---|
[946] | 274 | _member = _member.nextSibling; |
---|
[914] | 275 | } |
---|
| 276 | |
---|
[946] | 277 | _loading.style.display = "none"; |
---|
| 278 | }, |
---|
| 279 | 'name='+ arguments[0] |
---|
| 280 | ); |
---|
[382] | 281 | } |
---|
| 282 | |
---|
| 283 | function LDAP() |
---|
| 284 | { |
---|
[792] | 285 | _conn = arguments[0]; |
---|
| 286 | _xtools = arguments[1]; |
---|
| 287 | _window = arguments[2]; |
---|
[815] | 288 | _is_ie = arguments[3]; |
---|
[382] | 289 | } |
---|
| 290 | |
---|
| 291 | LDAP.prototype.search = _search; |
---|
| 292 | LDAP.prototype.add = _add_user; |
---|
| 293 | window.JITLdap = LDAP; |
---|
| 294 | } |
---|
| 295 | )(); |
---|
[459] | 296 | |
---|
| 297 | function cleanStatusAddContactIM() |
---|
| 298 | { |
---|
| 299 | document.getElementById('im_status_add').innerHTML = ''; |
---|
| 300 | } |
---|