[317] | 1 | countFiles = 1; |
---|
| 2 | |
---|
| 3 | function create_institutional_accounts() |
---|
| 4 | { |
---|
| 5 | select_owners = Element('ea_select_owners'); |
---|
| 6 | for(var i = 0;i < select_owners.options.length; i++) |
---|
| 7 | select_owners.options[i].selected = true; |
---|
| 8 | cExecuteForm ("$this.ldap_functions.create_institutional_accounts", document.forms['institutional_accounts_form'], handler_create_institutional_accounts); |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | function handler_create_institutional_accounts(data_return) |
---|
| 12 | { |
---|
| 13 | handler_create_institutional_accounts2(data_return); |
---|
| 14 | return; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function handler_create_institutional_accounts2(data_return) |
---|
| 18 | { |
---|
| 19 | if (!data_return.status) |
---|
| 20 | { |
---|
| 21 | write_msg(data_return.msg, 'error'); |
---|
| 22 | } |
---|
| 23 | else |
---|
| 24 | { |
---|
| 25 | close_lightbox(); |
---|
[2712] | 26 | write_msg( ExpressoLivre.translate( 'Institutional account successful created' ) + '.', 'normal'); |
---|
[317] | 27 | } |
---|
| 28 | return; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | function set_onload() |
---|
| 32 | { |
---|
| 33 | sinc_combos_org(Element('ea_combo_org').value); |
---|
| 34 | get_available_users(Element('ea_combo_org').value); |
---|
[2350] | 35 | get_associated_domain(Element('ea_combo_org').value); |
---|
[317] | 36 | } |
---|
| 37 | |
---|
| 38 | function get_available_users(context) |
---|
| 39 | { |
---|
| 40 | var handler_get_users = function(data) |
---|
| 41 | { |
---|
| 42 | select_available_users = Element('ea_select_available_users'); |
---|
| 43 | |
---|
| 44 | //Clean select |
---|
| 45 | for(var i=0; i<select_available_users.options.length; i++) |
---|
| 46 | { |
---|
| 47 | select_available_users.options[i] = null; |
---|
| 48 | i--; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | if ((data) && (data.length > 0)) |
---|
| 52 | { |
---|
| 53 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 54 | select_available_users.innerHTML = ' ' + data; |
---|
| 55 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 56 | |
---|
| 57 | select_available_users.disabled = false; |
---|
| 58 | select_available_users_clone = Element('ea_select_available_users').cloneNode(true); |
---|
| 59 | //document.getElementById('ea_input_searchUser').value = ''; |
---|
| 60 | } |
---|
| 61 | } |
---|
[2707] | 62 | ExpressoLivre.go( { |
---|
| 63 | "access" : 'expressoAdmin1_2.ldap_functions.get_available_users&context=' + escape(context), |
---|
| 64 | "handler" : handler_get_users |
---|
| 65 | } ); |
---|
[317] | 66 | } |
---|
| 67 | |
---|
| 68 | function search_organization(key, element) |
---|
| 69 | { |
---|
| 70 | var organizations = Element(element); |
---|
| 71 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 72 | |
---|
| 73 | for(i = 0; i < organizations.length; i++) |
---|
| 74 | { |
---|
| 75 | if (RegExp_org.test(organizations[i].text)) |
---|
| 76 | { |
---|
| 77 | organizations[i].selected = true; |
---|
| 78 | return; |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | function sinc_combos_org(context) |
---|
| 84 | { |
---|
| 85 | combo_org_available_users = Element('ea_combo_org_available_users'); |
---|
| 86 | |
---|
| 87 | for (i=0; i<combo_org_available_users.length; i++) |
---|
| 88 | { |
---|
| 89 | if (combo_org_available_users.options[i].value == context) |
---|
| 90 | { |
---|
| 91 | combo_org_available_users.options[i].selected = true; |
---|
| 92 | get_available_users(context); |
---|
| 93 | break; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | var finderTimeout = ''; |
---|
| 99 | function optionFinderTimeout(obj) |
---|
| 100 | { |
---|
| 101 | clearTimeout(finderTimeout); |
---|
| 102 | var oWait = Element("ea_span_searching"); |
---|
[2712] | 103 | oWait.innerHTML = ExpressoLivre.translate( 'searching' ) + '...'; |
---|
[317] | 104 | finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500); |
---|
| 105 | } |
---|
| 106 | function optionFinder(id) { |
---|
| 107 | var oWait = Element("ea_span_searching"); |
---|
| 108 | var oText = Element(id); |
---|
| 109 | |
---|
| 110 | //Limpa todo o select |
---|
| 111 | var select_available_users_tmp = Element('ea_select_available_users') |
---|
| 112 | |
---|
| 113 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 114 | select_available_users_tmp.options[i--] = null; |
---|
| 115 | |
---|
| 116 | var RegExp_name = new RegExp("\\b"+oText.value, "i"); |
---|
| 117 | |
---|
[2352] | 118 | //Inclui usuario comecando com a pesquisa |
---|
[2707] | 119 | //for(i = 0; i < select_available_users_clone.length; i++){ |
---|
| 120 | // if ( RegExp_name.test(select_available_users_clone[i].text) || (select_available_users_clone[i].value == -1) ) |
---|
| 121 | // { |
---|
| 122 | // sel = select_available_users_tmp.options; |
---|
| 123 | // option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value); |
---|
| 124 | // |
---|
| 125 | // if (select_available_users_clone[i].value == -1) |
---|
| 126 | // option.disabled = true; |
---|
| 127 | // |
---|
| 128 | // sel[sel.length] = option; |
---|
| 129 | // } |
---|
| 130 | // } |
---|
[317] | 131 | oWait.innerHTML = ' '; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | function add_user() |
---|
| 135 | { |
---|
| 136 | select_available_users = Element('ea_select_available_users'); |
---|
| 137 | select_owners = Element('ea_select_owners'); |
---|
| 138 | |
---|
| 139 | var count_available_users = select_available_users.length; |
---|
| 140 | // var count_owners = select_owners.options.length; |
---|
| 141 | var new_options = ''; |
---|
| 142 | |
---|
| 143 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 144 | { |
---|
| 145 | if (select_available_users.options[i].selected) |
---|
| 146 | { |
---|
| 147 | if(document.all) |
---|
| 148 | { |
---|
| 149 | if ( (select_owners.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 150 | { |
---|
| 151 | new_options += "<option value=" |
---|
| 152 | + select_available_users.options[i].value |
---|
| 153 | + ">" |
---|
| 154 | + select_available_users.options[i].text |
---|
| 155 | + "</options>"; |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | else |
---|
| 159 | { |
---|
| 160 | if ( (select_owners.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 161 | { |
---|
| 162 | new_options += "<option value=" |
---|
| 163 | + select_available_users.options[i].value |
---|
| 164 | + ">" |
---|
| 165 | + select_available_users.options[i].text |
---|
| 166 | + "</options>"; |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | if (new_options != '') |
---|
| 173 | { |
---|
| 174 | select_owners.innerHTML = ' ' + new_options + select_owners.innerHTML; |
---|
| 175 | select_owners.outerHTML = select_owners.outerHTML; |
---|
| 176 | document.getElementById('ea_input_searchUser').value = ""; |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | function remove_user() |
---|
| 181 | { |
---|
| 182 | select_owners = Element('ea_select_owners'); |
---|
| 183 | for(var i = 0;i < select_owners.options.length; i++) |
---|
| 184 | if(select_owners.options[i].selected) |
---|
| 185 | select_owners.options[i--] = null; |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | function get_institutional_accounts_timeOut(input) |
---|
| 189 | { |
---|
[2712] | 190 | var head_table = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+ ExpressoLivre.translate( "full name" )+'</td><td width="30%">'+ ExpressoLivre.translate( "mail" )+'</td><td width="5%" align="center">'+ ExpressoLivre.translate( "remove" )+'</td></tr></table>'; |
---|
[317] | 191 | |
---|
| 192 | if (input.length > 4) |
---|
| 193 | { |
---|
| 194 | clearTimeout(finderTimeout); |
---|
| 195 | finderTimeout = setTimeout("get_institutional_accounts('"+input+"')",500); |
---|
| 196 | } |
---|
| 197 | else |
---|
| 198 | { |
---|
| 199 | Element('institutional_accounts_content').innerHTML = head_table; |
---|
| 200 | } |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | function get_institutional_accounts(input) |
---|
| 204 | { |
---|
| 205 | var handler_get_institutional_accounts = function(data) |
---|
| 206 | { |
---|
[2707] | 207 | data = data.JSON( ); |
---|
[317] | 208 | if (data.status == 'true') |
---|
| 209 | { |
---|
[2712] | 210 | var table = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+ ExpressoLivre.translate( "full name" )+'</td><td width="30%">'+ ExpressoLivre.translate( "mail" )+'</td><td width="5%" align="center">'+ ExpressoLivre.translate( "remove" )+'</td></tr>'+data.trs+'</table>'; |
---|
[317] | 211 | Element('institutional_accounts_content').innerHTML = table; |
---|
| 212 | } |
---|
| 213 | else |
---|
| 214 | write_msg(data.msg, 'error'); |
---|
| 215 | } |
---|
[2707] | 216 | ExpressoLivre.go( { |
---|
| 217 | "access" : 'expressoAdmin1_2.ldap_functions.get_institutional_accounts&input='+input, |
---|
| 218 | "handler" : handler_get_institutional_accounts |
---|
| 219 | } ); |
---|
[317] | 220 | } |
---|
| 221 | |
---|
| 222 | function edit_institutional_account(uid) |
---|
| 223 | { |
---|
| 224 | var handle_edit_institutional_account = function(data) |
---|
| 225 | { |
---|
| 226 | if (data.status == 'true') |
---|
| 227 | { |
---|
| 228 | modal('institutional_accounts_modal','save'); |
---|
| 229 | |
---|
| 230 | var combo_org = Element('ea_combo_org'); |
---|
| 231 | for (i=0; i<combo_org.length; i++) |
---|
| 232 | { |
---|
| 233 | if (combo_org.options[i].value == data.user_context) |
---|
| 234 | { |
---|
| 235 | combo_org.options[i].selected = true; |
---|
| 236 | break; |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | // anchor |
---|
| 241 | Element('anchor').value = "uid=" + uid + ',' + data.user_context; |
---|
| 242 | |
---|
| 243 | if (data.accountStatus != 'active') |
---|
| 244 | Element('accountStatus').checked = false; |
---|
| 245 | |
---|
| 246 | if (data.phpgwAccountVisible == '-1') |
---|
| 247 | Element('phpgwAccountVisible').checked = true; |
---|
| 248 | |
---|
| 249 | Element('cn').value = data.cn; |
---|
| 250 | Element('mail').value = data.mail; |
---|
[1975] | 251 | Element('desc').value = data.description; |
---|
[2352] | 252 | //Necessario, pois o IE6 tem um bug que nao exibe as novas opcoes se o innerHTML estava vazio |
---|
[1975] | 253 | Element('ea_select_owners').innerHTML = ' ' + data.owners; |
---|
| 254 | Element('ea_select_owners').outerHTML = Element('ea_select_owners').outerHTML; |
---|
[317] | 255 | |
---|
| 256 | sinc_combos_org(data.user_context); |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | write_msg(data.msg, 'error'); |
---|
| 260 | } |
---|
| 261 | cExecute ('$this.ldap_functions.get_institutional_account_data&uid='+uid, handle_edit_institutional_account); |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | function save_institutional_accounts() |
---|
| 265 | { |
---|
| 266 | if (is_ie){ |
---|
| 267 | var i = 0; |
---|
| 268 | while (document.forms(i).name != "institutional_accounts_form"){i++} |
---|
| 269 | form = document.forms(i); |
---|
| 270 | } |
---|
| 271 | else |
---|
| 272 | form = document.forms["institutional_accounts_form"]; |
---|
| 273 | |
---|
| 274 | select_owners = Element('ea_select_owners'); |
---|
| 275 | for(var i = 0;i < select_owners.options.length; i++) |
---|
| 276 | select_owners.options[i].selected = true; |
---|
| 277 | cExecuteForm ("$this.ldap_functions.save_institutional_accounts", form, handler_save_institutional_accounts); |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | function handler_save_institutional_accounts(data_return) |
---|
| 281 | { |
---|
| 282 | handler_save_institutional_accounts2(data_return); |
---|
| 283 | return; |
---|
| 284 | } |
---|
| 285 | function handler_save_institutional_accounts2(data_return) |
---|
| 286 | { |
---|
| 287 | if (!data_return.status) |
---|
| 288 | { |
---|
| 289 | write_msg(data_return.msg, 'error'); |
---|
| 290 | } |
---|
| 291 | else |
---|
| 292 | { |
---|
| 293 | get_institutional_accounts(Element('ea_institutional_account_search').value); |
---|
| 294 | close_lightbox(); |
---|
[2712] | 295 | write_msg( ExpressoLivre.translate( 'Institutional account successful saved' ) + '.', 'normal'); |
---|
[317] | 296 | } |
---|
| 297 | return; |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | function delete_institutional_accounts(uid) |
---|
| 301 | { |
---|
[2712] | 302 | if (!confirm( ExpressoLivre.translate( 'Are you sure that you want to delete this institutional account' ) + "?")) |
---|
[317] | 303 | return; |
---|
| 304 | |
---|
| 305 | var handle_delete_institutional_account = function(data_return) |
---|
| 306 | { |
---|
| 307 | if (!data_return.status) |
---|
| 308 | { |
---|
| 309 | write_msg(data_return.msg, 'error'); |
---|
| 310 | } |
---|
| 311 | else |
---|
| 312 | { |
---|
[2712] | 313 | write_msg( ExpressoLivre.translate( 'Institutional account successful deleted' ) + '.', 'normal'); |
---|
[317] | 314 | get_institutional_accounts(Element('ea_institutional_account_search').value); |
---|
| 315 | } |
---|
| 316 | return; |
---|
| 317 | } |
---|
| 318 | cExecute ('$this.ldap_functions.delete_institutional_account_data&uid='+uid, handle_delete_institutional_account); |
---|
[2352] | 319 | } |
---|