1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * -------------------------------------------------------------------------* |
---|
4 | * This library is free software; you can redistribute it and/or modify it * |
---|
5 | * under the terms of the GNU Lesser General Public License as published by * |
---|
6 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
7 | * or any later version. * |
---|
8 | \**************************************************************************/ |
---|
9 | |
---|
10 | require_once("class.notifications.inc.php"); |
---|
11 | |
---|
12 | class uiconfig |
---|
13 | { |
---|
14 | private $bo; |
---|
15 | private $template; |
---|
16 | |
---|
17 | var $public_functions = array |
---|
18 | ( |
---|
19 | 'createFolder' => True, |
---|
20 | 'folders' => True, |
---|
21 | 'groups_users' => True, |
---|
22 | 'load_quota' => True, |
---|
23 | 'notifyUploads' => True, |
---|
24 | 'renameFolder' => True, |
---|
25 | 'removeFolder' => True, |
---|
26 | 'reconstructFolder' => True, |
---|
27 | 'search_dir' => True, |
---|
28 | 'set_owner' => True, |
---|
29 | 'search_user' => True, |
---|
30 | 'set_permission' => True, |
---|
31 | 'update_quota' => True, |
---|
32 | 'quota' => True |
---|
33 | ); |
---|
34 | |
---|
35 | function uiconfig() |
---|
36 | { |
---|
37 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
38 | $this->template = $GLOBALS['phpgw']->template; |
---|
39 | |
---|
40 | $GLOBALS['phpgw_info']['flags'] = array |
---|
41 | ( |
---|
42 | 'currentapp' => 'filemanager', |
---|
43 | 'noheader' => False, |
---|
44 | 'nonavbar' => False, |
---|
45 | 'nofooter' => False, |
---|
46 | 'noappheader' => False, |
---|
47 | 'enable_browser_class' => True |
---|
48 | ); |
---|
49 | } |
---|
50 | |
---|
51 | function vfs_functions(){} |
---|
52 | |
---|
53 | function folders() |
---|
54 | { |
---|
55 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
56 | |
---|
57 | $this->template->set_file(array('config_list' => 'config_folders.tpl')); |
---|
58 | $this->template->set_block('config_list','body','body'); |
---|
59 | |
---|
60 | $vars = array( |
---|
61 | 'lang_back' => lang('Back'), |
---|
62 | 'lang_directory' => lang('directory'), |
---|
63 | 'lang_search' => lang('search'), |
---|
64 | 'lang_remove' => lang('remove'), |
---|
65 | 'lang_rename' => lang('rename'), |
---|
66 | 'lang_create' => lang('create'), |
---|
67 | 'lang_reconstruct' => lang('reconstruct'), |
---|
68 | 'lang_Folder_ Management' => lang('Folder Management'), |
---|
69 | 'path_filemanager' => $GLOBALS['phpgw_info']['flags']['currentapp'] |
---|
70 | ); |
---|
71 | |
---|
72 | $this->template->set_var($vars); |
---|
73 | $this->template->pparse('out','body'); |
---|
74 | |
---|
75 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
76 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | function groups_users() |
---|
81 | { |
---|
82 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
83 | |
---|
84 | $this->template->set_file(array('config_list' => 'config_owner.tpl')); |
---|
85 | $this->template->set_block('config_list','body','body'); |
---|
86 | |
---|
87 | $vars = array( |
---|
88 | 'lang_Add' => lang('Add'), |
---|
89 | 'lang_back' => lang('Back'), |
---|
90 | 'lang_directory' => lang('directory'), |
---|
91 | 'lang_Delete' => lang('Delete'), |
---|
92 | 'lang_Edit' => lang('Edit'), |
---|
93 | 'lang_Read' => lang('Read'), |
---|
94 | 'lang_private' => lang('private'), |
---|
95 | 'lang_search' => lang('search'), |
---|
96 | 'lang_setowner' => lang('set owner'), |
---|
97 | 'lang_setperm' => lang('set permission'), |
---|
98 | 'lang_Search_Folders' => lang('Search Folders'), |
---|
99 | 'lang_Search_Users' => lang('Search Users'), |
---|
100 | 'lang_users_and_groups' => lang('Users and groups'), |
---|
101 | 'lang_permissions_groups_users' => lang('Permissions of groups and users'), |
---|
102 | 'path_filemanager' => $GLOBALS['phpgw_info']['flags']['currentapp'] |
---|
103 | ); |
---|
104 | |
---|
105 | $this->template->set_var($vars); |
---|
106 | $this->template->pparse('out','body'); |
---|
107 | |
---|
108 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
109 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
110 | } |
---|
111 | |
---|
112 | function createFolder() |
---|
113 | { |
---|
114 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
115 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
116 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
117 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
118 | |
---|
119 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
120 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name'])); |
---|
121 | if (strlen($name) < 2) |
---|
122 | return false; |
---|
123 | $c = CreateObject('phpgwapi.config','filemanager'); |
---|
124 | $c->read_repository(); |
---|
125 | $current_config = $c->config_data; |
---|
126 | |
---|
127 | $this->bo->vfs->override_acl = 1; |
---|
128 | |
---|
129 | if ( $this->bo->vfs->mkdir(array( |
---|
130 | 'string' => $name, |
---|
131 | 'relatives' => array(RELATIVE_NONE) |
---|
132 | )) ) |
---|
133 | if ( $this->bo->vfs->set_quota(array( |
---|
134 | 'string' => $name, |
---|
135 | 'relatives' => array(RELATIVE_NONE), |
---|
136 | 'new_quota' => $current_config['filemanager_quota_size'] |
---|
137 | )) ) |
---|
138 | $return = True; |
---|
139 | |
---|
140 | $this->bo->vfs->override_acl = 0; |
---|
141 | if ($return){ |
---|
142 | echo "Folder created"; |
---|
143 | } |
---|
144 | else |
---|
145 | echo "Error"; |
---|
146 | } |
---|
147 | |
---|
148 | function removeFolder() |
---|
149 | { |
---|
150 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
151 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
152 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
153 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
154 | |
---|
155 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
156 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_POST['dir'])); |
---|
157 | if (strlen($name) < 2) |
---|
158 | return false; |
---|
159 | if ( $this->bo->vfs->delete(array( |
---|
160 | 'string' => $name, |
---|
161 | 'relatives' => array(RELATIVE_NONE) |
---|
162 | )) ) |
---|
163 | { |
---|
164 | /* Clean the log */ |
---|
165 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
166 | if ($GLOBALS['phpgw']->db->Error) |
---|
167 | echo "Erro"; |
---|
168 | else |
---|
169 | { |
---|
170 | $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs_quota WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
171 | if (!$GLOBALS['phpgw']->db->Error) |
---|
172 | echo lang('directory removed sucessfully'); |
---|
173 | else |
---|
174 | echo "Erro"; |
---|
175 | } |
---|
176 | } |
---|
177 | else |
---|
178 | echo lang("No permission to delete the folder %1", $name ); |
---|
179 | |
---|
180 | } |
---|
181 | |
---|
182 | function reconstructFolder() |
---|
183 | { |
---|
184 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
185 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
186 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
187 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
188 | |
---|
189 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
190 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_POST['dir'])); |
---|
191 | if (strlen($name) < 2) |
---|
192 | return false; |
---|
193 | $this->bo->vfs->update_real(array( |
---|
194 | 'string' => $name, |
---|
195 | 'relatives' => array(RELATIVE_NONE) |
---|
196 | ),True); |
---|
197 | $this->bo->vfs->flush_journal(array( |
---|
198 | 'string' => $name, |
---|
199 | 'relatives' => array(RELATIVE_NONE), |
---|
200 | 'deleteall' => True |
---|
201 | )); |
---|
202 | echo lang('Your operation was successfully executed'); |
---|
203 | } |
---|
204 | |
---|
205 | function renameFolder() |
---|
206 | { |
---|
207 | $GLOBALS['phpgw_info']['flags'] = array |
---|
208 | ( |
---|
209 | 'currentapp' => 'filemanager', |
---|
210 | 'noheader' => True, |
---|
211 | 'nonavbar' => True, |
---|
212 | 'nofooter' => True, |
---|
213 | 'noappheader' => True, |
---|
214 | 'enable_browser_class' => True |
---|
215 | ); |
---|
216 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
217 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
218 | $to = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['to'])); |
---|
219 | if (strlen($name) < 2) |
---|
220 | return false; |
---|
221 | if ( $this->bo->vfs->mv(array( |
---|
222 | 'from' => $name, |
---|
223 | 'to' => $to, |
---|
224 | 'relatives' => array(RELATIVE_NONE) |
---|
225 | )) ){ |
---|
226 | $this->bo->vfs->flush_journal(array( |
---|
227 | 'string' => $name, |
---|
228 | 'relatives' => array(RELATIVE_NONE), |
---|
229 | 'deleteall' => True |
---|
230 | )); |
---|
231 | echo lang('Your operation was successfully executed'); |
---|
232 | } |
---|
233 | else |
---|
234 | echo lang('Error'); |
---|
235 | } |
---|
236 | |
---|
237 | function quota() |
---|
238 | { |
---|
239 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
240 | |
---|
241 | $this->template->set_file(array('config_list' => 'config_quota.tpl')); |
---|
242 | $this->template->set_block('config_list','body','body'); |
---|
243 | |
---|
244 | $vars = array( |
---|
245 | 'lang_back' => lang('Back'), |
---|
246 | 'lang_directory' => lang('directory'), |
---|
247 | 'lang_save' =>lang('save'), |
---|
248 | 'lang_search' => lang('search'), |
---|
249 | 'lang_Management_Quota' => lang('Management Quota'), |
---|
250 | 'path_filemanager' => $GLOBALS['phpgw_info']['flags']['currentapp'] |
---|
251 | ); |
---|
252 | |
---|
253 | $this->template->set_var($vars); |
---|
254 | $this->template->pparse('out','body'); |
---|
255 | |
---|
256 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
257 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
258 | } |
---|
259 | |
---|
260 | function notifyUploads() |
---|
261 | { |
---|
262 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Filemanager') ." - " . lang("Email notify uploads"); |
---|
263 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
264 | |
---|
265 | $notify = new notifications(); |
---|
266 | $value_email_to = ""; |
---|
267 | |
---|
268 | if( $_POST['button_add'] || $_GET['editUser'] ) |
---|
269 | { |
---|
270 | if( $_GET['editUser'] ) |
---|
271 | { |
---|
272 | $result = $notify->SearchId($_GET['editUser']); |
---|
273 | $emails_to = explode(",", $result[0]['email_to']); |
---|
274 | |
---|
275 | for( $i = 0 ; $i < count($emails_to); $i++ ) |
---|
276 | { |
---|
277 | $value_email_to .= "<tr>"; |
---|
278 | $value_email_to .= "<td>".$emails_to[$i]."</td>"; |
---|
279 | $value_email_to .= "<td align='center'>"; |
---|
280 | $value_email_to .= "<a href='javascript:void();' onclick='notify.deleteEmail(\"".$emails_to[$i]."\",this);'>Remover</a>"; |
---|
281 | $value_email_to .= "</td>"; |
---|
282 | $value_email_to .= "</tr>"; |
---|
283 | } |
---|
284 | } |
---|
285 | |
---|
286 | $vars = array( |
---|
287 | 'action_url_back' => "./index.php?menuaction=filemanager.uiconfig.notifyUploads", |
---|
288 | 'attr_readonly' => ( $result[0]['email_from'] ) ? 'readonly="readonly"' : "", |
---|
289 | 'lang_Add' => lang("Add"), |
---|
290 | 'lang_Back' => lang("Back"), |
---|
291 | 'lang_Email' => lang("Email"), |
---|
292 | 'lang_Excluir' => lang("Delete"), |
---|
293 | 'lang_legend1' => lang("When the user with the email send a file"), |
---|
294 | 'lang_legend2' => lang("Notify email"), |
---|
295 | 'lang_legend3' => lang("Emails reported"), |
---|
296 | 'lang_from' => lang("From"), |
---|
297 | 'lang_to' => lang("To"), |
---|
298 | 'value_email_from' => ( $result[0]['email_from'] ) ? $result[0]['email_from'] : "", |
---|
299 | 'value_email_to' => $value_email_to |
---|
300 | ); |
---|
301 | |
---|
302 | $handle = "AddEmail"; |
---|
303 | } |
---|
304 | else |
---|
305 | { |
---|
306 | if( trim( $_POST['search_email'] ) != "" ) |
---|
307 | { |
---|
308 | $limit = 10; |
---|
309 | $offset = 1; |
---|
310 | |
---|
311 | if( $_POST['bt_next'] ) |
---|
312 | $offset = $_POST['button_next'] + 1 ; |
---|
313 | |
---|
314 | if( $_POST['bt_previous'] && $_POST['button_next'] > 1) |
---|
315 | { |
---|
316 | $offset = $_POST['button_next'] - 1; |
---|
317 | } |
---|
318 | |
---|
319 | $result = $notify->SearchEmail( $_POST['search_email'], $limit, $offset ); |
---|
320 | |
---|
321 | foreach( $result as $tmp ) |
---|
322 | { |
---|
323 | $value_email_to .= '<tr>'; |
---|
324 | $value_email_to .= '<td align="left" width="40%">'.$tmp['email_from'].'</td>'; |
---|
325 | $value_email_to .= '<td align="left" width="40%">'.str_replace(",", "<br/>", $tmp['email_to']).'</td>'; |
---|
326 | $value_email_to .= '<td align="center" width="10%"><a href="./index.php?menuaction=filemanager.uiconfig.notifyUploads&editUser='.$tmp['filemanager_id'].'">'.lang("Edit").'</a></td>'; |
---|
327 | $value_email_to .= '<td align="center" width="10%"><a href="javascript:void();" onclick="notify.deleteEmailUser(\''.$tmp['filemanager_id'].'\', this);">'.lang("Delete").'</a></td>'; |
---|
328 | $value_email_to .= '</tr>'; |
---|
329 | } |
---|
330 | } |
---|
331 | |
---|
332 | $vars = array( |
---|
333 | 'action_url' => "./index.php?menuaction=filemanager.uiconfig.notifyUploads", |
---|
334 | 'action_url_back' => "./admin", |
---|
335 | 'display_bt_previous' => ( $offset > 1 ) ? "line" : "none", |
---|
336 | 'display_bt_next' => ( count($result) < $limit ) ? "none" : "line", |
---|
337 | 'lang_Add' => lang("Add"), |
---|
338 | 'lang_Back' => lang("Back"), |
---|
339 | 'lang_Delete' => lang("Delete"), |
---|
340 | 'lang_Edit' => lang("Edit"), |
---|
341 | 'lang_From' => lang("From"), |
---|
342 | 'lang_To' => lang("To"), |
---|
343 | 'lang_search' => lang("Search"), |
---|
344 | 'lang_next' => lang("Next"), |
---|
345 | 'lang_previous' => lang("Previous"), |
---|
346 | 'value_search_email' => $_POST['search_email'], |
---|
347 | 'value_email_to' => $value_email_to, |
---|
348 | 'value_next' => $offset, |
---|
349 | 'value_previous' => $limit |
---|
350 | ); |
---|
351 | |
---|
352 | $handle = "index"; |
---|
353 | } |
---|
354 | |
---|
355 | $this->template->set_file(array('config_email' => 'notify_upload.tpl')); |
---|
356 | $this->template->set_block('config_email',$handle); |
---|
357 | $this->template->set_var($vars); |
---|
358 | $this->template->pparse('out',$handle); |
---|
359 | |
---|
360 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
361 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
362 | } |
---|
363 | |
---|
364 | function search_dir() |
---|
365 | { |
---|
366 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
367 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
368 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
369 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
370 | |
---|
371 | $_options = ""; |
---|
372 | $query = ""; |
---|
373 | |
---|
374 | $name = $GLOBALS['phpgw']->db->db_addslashes($_POST['name']); |
---|
375 | |
---|
376 | $query = 'SELECT directory,name from phpgw_vfs WHERE directory = \'/home\' and name like \'%'.$name.'%\' LIMIT 1'; |
---|
377 | |
---|
378 | $GLOBALS['phpgw']->db->query( $query,__LINE__,__FILE__ ); |
---|
379 | |
---|
380 | while ( $GLOBALS['phpgw']->db->next_record() ) |
---|
381 | { |
---|
382 | $val = $GLOBALS['phpgw']->db->row(); |
---|
383 | $_options .= "<option>".$val['directory']."/".$val['name']."</option>"; |
---|
384 | } |
---|
385 | |
---|
386 | echo $_options; |
---|
387 | } |
---|
388 | |
---|
389 | function search_user() |
---|
390 | { |
---|
391 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
392 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
393 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
394 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
395 | |
---|
396 | $_options = ""; |
---|
397 | |
---|
398 | $account_info = $GLOBALS['phpgw']->accounts->get_list('both',0,'','',$_POST['name'],'all'); |
---|
399 | |
---|
400 | foreach($account_info as $val) |
---|
401 | $_options .= "<option value='".$val['account_id']."'>".$val['account_lid']."</option>"; |
---|
402 | |
---|
403 | echo $_options; |
---|
404 | } |
---|
405 | |
---|
406 | function set_permission() |
---|
407 | { |
---|
408 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
409 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
410 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
411 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
412 | |
---|
413 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
414 | $perms = ($_GET['perms'])*1; |
---|
415 | $owner = ($_GET['owner'])*1; |
---|
416 | $dirs=explode('/',$name); |
---|
417 | $GLOBALS['phpgw']->db->query('SELECT owner_id from phpgw_vfs WHERE directory = \'/'.$dirs[1].'\' and name=\''.$dirs[2].'\' LIMIT 1',__LINE__,__FILE__); |
---|
418 | if ($GLOBALS['phpgw']->db->next_record()){ |
---|
419 | $val = $GLOBALS['phpgw']->db->row(); |
---|
420 | $owner_id = $val['owner_id']; |
---|
421 | } |
---|
422 | |
---|
423 | $query = "SELECT count(*) FROM phpgw_acl WHERE acl_appname = 'filemanager' and acl_account = '".$owner_id."' and acl_location='".$owner."'"; |
---|
424 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
425 | $val = $GLOBALS['phpgw']->db->row(); |
---|
426 | else |
---|
427 | { |
---|
428 | echo $GLOBALS['phpgw']->db->error; |
---|
429 | return false; |
---|
430 | } |
---|
431 | if ($val['count'] == '1') |
---|
432 | $GLOBALS['phpgw']->db->query("UPDATE phpgw_acl SET acl_rights = ".$perms." where acl_appname = 'filemanager' and acl_account = '".$owner_id."' AND acl_location = '".$owner."'",__LINE__,__FILE__); |
---|
433 | else |
---|
434 | $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_acl values('filemanager','".$owner."','".$owner_id."',".$perms.")",__LINE__,__FILE__); |
---|
435 | if ($GLOBALS['phpgw']->db->Error) |
---|
436 | echo "Erro"; |
---|
437 | else |
---|
438 | { |
---|
439 | echo lang('entry updated sucessfully'); |
---|
440 | } |
---|
441 | return; |
---|
442 | } |
---|
443 | |
---|
444 | |
---|
445 | function set_owner() |
---|
446 | { |
---|
447 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
448 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
449 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
450 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
451 | |
---|
452 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir'])); |
---|
453 | $owner = ($_GET['owner'])*1; |
---|
454 | |
---|
455 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
456 | if ($GLOBALS['phpgw']->db->Error) |
---|
457 | echo "Erro"; |
---|
458 | else |
---|
459 | { |
---|
460 | $dirs=explode('/',$name); |
---|
461 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \'/'.$dirs[1].'\' and name=\''.$dirs[2].'\'',__LINE__,__FILE__); |
---|
462 | if ($GLOBALS['phpgw']->db->Error) |
---|
463 | echo "Erro"; |
---|
464 | else |
---|
465 | { |
---|
466 | echo lang('entry updated sucessfully'); |
---|
467 | } |
---|
468 | } |
---|
469 | return; |
---|
470 | } |
---|
471 | |
---|
472 | function update_quota() |
---|
473 | { |
---|
474 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
475 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
476 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
477 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
478 | |
---|
479 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_POST['dir'])); |
---|
480 | $size = ($_POST['val']) * 1; |
---|
481 | |
---|
482 | $eAdminDbFunctions = CreateObject('expressoAdmin1_2.db_functions'); |
---|
483 | if($eAdminDbFunctions->use_cota_control()) { |
---|
484 | $eAdminFunctions = CreateObject('expressoAdmin1_2.functions'); |
---|
485 | |
---|
486 | if(!$eAdminFunctions->has_file_disk_quota($name,$size)){ |
---|
487 | echo lang("not enough quota"); |
---|
488 | return; |
---|
489 | } |
---|
490 | |
---|
491 | } |
---|
492 | |
---|
493 | /* See if quota exists or not */ |
---|
494 | $query = "SELECT count(directory) FROM phpgw_vfs_quota WHERE directory = '".$name."' LIMIT 1"; |
---|
495 | if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record()) |
---|
496 | $val = $GLOBALS['phpgw']->db->row(); |
---|
497 | else |
---|
498 | { |
---|
499 | echo $GLOBALS['phpgw']->db->error; |
---|
500 | return false; |
---|
501 | } |
---|
502 | if ($val['count'] == '1') |
---|
503 | { |
---|
504 | $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs_quota SET quota_size = '.$size.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__); |
---|
505 | if ($GLOBALS['phpgw']->db->Error) |
---|
506 | echo "Erro"; |
---|
507 | else |
---|
508 | echo lang('entry updated sucessfully'); |
---|
509 | } |
---|
510 | else |
---|
511 | { |
---|
512 | /*preferences does not exist*/ |
---|
513 | $query = "INSERT INTO phpgw_vfs_quota values ('".$name."',".$size.")"; |
---|
514 | if (!$GLOBALS['phpgw']->db->query($query)) |
---|
515 | echo $GLOBALS['phpgw']->db->error; |
---|
516 | else |
---|
517 | echo lang('entry updated sucessfully'); |
---|
518 | } |
---|
519 | } |
---|
520 | |
---|
521 | function load_quota() |
---|
522 | { |
---|
523 | $GLOBALS['phpgw_info']['flags']['noheader'] = True; |
---|
524 | $GLOBALS['phpgw_info']['flags']['nonavbar'] = True; |
---|
525 | $GLOBALS['phpgw_info']['flags']['nofooter'] = True; |
---|
526 | $GLOBALS['phpgw_info']['flags']['noappheader'] = True; |
---|
527 | |
---|
528 | $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name'])); |
---|
529 | $GLOBALS['phpgw']->db->query('SELECT quota_size FROM phpgw_vfs_quota WHERE directory = \''.$name.'\' LIMIT 1',__LINE__,__FILE__); |
---|
530 | $GLOBALS['phpgw']->db->next_record(); |
---|
531 | $val =$GLOBALS['phpgw']->db->row(); |
---|
532 | echo $val['quota_size']; |
---|
533 | return; |
---|
534 | |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | ?> |
---|