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