2 * Copyright (C) 2015 Dany De Bontridder <dany@alchimerys.be>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * contains the javascript for the administration page
23 * Display the forbidden folders if the request comes from a form
24 * with an input text (id:database_filter_input) then this text is
26 * @param {type} p_user : the user id
29function folder_display(p_user)
32 * If form exist and there is something
36 if ($('database_filter_input')) {
37 p_filter = $('database_filter_input').value;
40 * Ajax request to display the folder
42 new Ajax.Request('ajax_misc.php', {
44 parameters: {"p_user": p_user, "op": "folder_display", "p_filter": p_filter, 'gDossier': 0},
45 onSuccess: function (p_xml) {
46 // table id = database_list
49 if (!$('folder_list_div')) {
50 folder = create_div({'id': 'folder_list_div', 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:100px'});
53 folder = $('folder_list_div');
55 var answer = p_xml.responseXML;
56 var a = answer.getElementsByTagName('status');
57 var html = answer.getElementsByTagName('content');
59 var rec = req.responseText;
60 alert_box('erreur :' + rec);
63 var content = getNodeText(html[0]);
65 folder.innerHTML = unescape_xml(content);
66 folder.innerHTML.evalScripts();
69 $('database_filter_input').focus();
74 * Remove the grant for an user to the given database id
75 * @param {integer} p_user use_id id of the user
76 * @param {integer} p_dossier id of the database
79function folder_remove(p_user,p_dossier )
81 smoke.confirm (content[50] ,
85 new Ajax.Request('ajax_misc.php', {
87 parameters: {"p_user": p_user, 'p_dossier': p_dossier, "op": "folder_remove", 'gDossier': 0},
88 onSuccess: function (p_xml) {
89 // table id = database_list
90 new Effect.Opacity('row'+p_dossier, { from: 1.0, to: 0.0, duration: 0.2 });
102 * Grant the access to a folder for a given user and add a row in the table
103 * (id : database_list)
104 * @param {integer} p_user use_id id of the user
105 * @param {integer} p_dossier id of the database
106 * @returns {undefined}
108function folder_add(p_user, p_dossier)
111 new Ajax.Request('ajax_misc.php', {
113 parameters: {"p_user": p_user, 'p_dossier': p_dossier, "op": "folder_add", 'gDossier': 0},
114 onSuccess: function (p_xml) {
115 // table id = database_list
116 // Analyze XML answer
117 var answer = p_xml.responseXML;
118 var a = answer.getElementsByTagName('status');
119 var html = answer.getElementsByTagName('content');
121 var rec = req.responseText;
122 alert_box('FOLDERADD-'+content[48] + rec);
125 var content = getNodeText(html[0]);
126 var nb = $('database_list').rows.length + 1;
127 var row = new Element('tr', {'id': 'row' + p_dossier});
129 row.addClassName('even');
131 row.addClassName('odd');
133 row.innerHTML = unescape_xml(content);
134 $('database_list').appendChild(row);
135 $('row_db_'+p_dossier).hide();
136 remove_waiting_box();
141function display_admin_answer(p_dossier,p_action)
144 new Ajax.Request ("ajax_misc.php",{
146 parameters:{"p_dossier":p_dossier,"op":p_action,'gDossier':0},
147 onSuccess : function (p_xml) {
149 var div_display="folder_admin_div";
150 var answer = p_xml.responseXML;
151 var a = answer.getElementsByTagName('status');
152 var html = answer.getElementsByTagName('content');
154 var rec = req.responseText;
155 alert_box('erreur :' + rec);
160 if (!$(div_display)) {
161 folder = create_div({'id': div_display, 'cssclass': "inner_box", style: 'width:90%;right:5%;top:100px'});
164 folder=$(div_display);
166 var content = getNodeText(html[0]);
167 folder.innerHTML=unescape_xml(content);
169 $(div_display).setStyle({top:pos+'px'});
172 remove_waiting_box();
174 alert_box(e.message);
179function folder_drop(p_dossier)
181 display_admin_answer(p_dossier,'folder_drop');
184function folder_modify(p_dossier)
186 display_admin_answer(p_dossier,'folder_modify');
188function modele_modify(p_dossier)
190 display_admin_answer(p_dossier,'modele_modify');
192function modele_drop(p_dossier)
194 display_admin_answer(p_dossier,'modele_drop');