source: sandbox/filemanager/inc/class.uiconfig.inc.php @ 1905

Revision 1905, 12.3 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Melhoria do FM. melhorias na interface, Compartilhamento de grupos

  • Property svn:executable set to *
Line 
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        class uiconfig
11        {
12                var $public_functions = array(
13                        'search_dir' => True,
14                        'search_user' => True,
15                        'update_quota' => True,
16                        'load_quota' => True,
17                        'quota' => True,
18                        'removeFolder' => True,
19                        'reconstructFolder' => True,
20                        'set_owner' => True,
21                        'renameFolder' => True,
22                        'createFolder' => True,
23                        'groups_users' => True,
24                        'folders' => True
25                 );
26
27                function vfs_functions(){
28                }
29                 function folders(){
30                         $GLOBALS['phpgw_info']['flags'] = array
31                                 (
32                                         'currentapp'    => 'filemanager',
33                                         'noheader'      => False,
34                                         'nonavbar' => False,
35                                         'nofooter'      => False,
36                                         'noappheader'   => False,
37                                         'enable_browser_class'  => True
38                                 );
39
40                         $GLOBALS['phpgw']->common->phpgw_header();
41                        include('load_lang.php');
42                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>";
43                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>";
44                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>";
45                        $t = $GLOBALS['phpgw']->template;
46                        $t->set_file(array('config_list' => 'config_folders.tpl'));
47                        $t->set_block('config_list','body','body');
48                        $vars[lang_directory]=lang('directory');
49                        $vars[lang_search]=lang('search');
50                        $vars[lang_remove]=lang('remove');
51                        $vars[lang_rename]=lang('rename');
52                        $vars[lang_create]=lang('create');
53                        $vars[lang_reconstruct]=lang('reconstruct');
54
55                        $t->set_var($vars);
56                        $t->pparse('out','body');
57                        $GLOBALS['phpgw']->common->phpgw_footer();
58                        $GLOBALS['phpgw']->common->phpgw_exit();
59
60                 }
61                 function groups_users(){
62                         $GLOBALS['phpgw_info']['flags'] = array
63                                 (
64                                         'currentapp'    => 'filemanager',
65                                         'noheader'      => False,
66                                         'nonavbar' => False,
67                                         'nofooter'      => False,
68                                         'noappheader'   => False,
69                                         'enable_browser_class'  => True
70                                 );
71
72                         $GLOBALS['phpgw']->common->phpgw_header();
73                        include('load_lang.php');
74                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>";
75                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>";
76                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>";
77                        $t = $GLOBALS['phpgw']->template;
78                        $t->set_file(array('config_list' => 'config_owner.tpl'));
79                        $t->set_block('config_list','body','body');
80                        $vars[lang_users_and_groups]=lang('Users and groups');
81                        $vars[lang_search]=lang('search');
82                        $vars[lang_directory]=lang('directory');
83                        $vars[lang_config]=lang('config');
84
85                        $t->set_var($vars);
86                        $t->pparse('out','body');
87                        $GLOBALS['phpgw']->common->phpgw_footer();
88                        $GLOBALS['phpgw']->common->phpgw_exit();
89
90                 }
91
92                function createFolder(){
93                         $GLOBALS['phpgw_info']['flags'] = array
94                                 (
95                                         'currentapp'    => 'filemanager',
96                                         'noheader'      => True,
97                                         'nonavbar' => True,
98                                         'nofooter'      => True,
99                                         'noappheader'   => True,
100                                         'enable_browser_class'  => True
101                                 );
102                         $bo = CreateObject('filemanager.bofilemanager');
103                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name']));
104                         if (strlen($name) < 2)
105                                 return false;
106                         $c = CreateObject('phpgwapi.config','filemanager');
107                         $c->read_repository();
108                         $current_config = $c->config_data;
109
110                         $bo->vfs->override_acl = 1;
111
112                         if ( $bo->vfs->mkdir(array(
113                                 'string' => $name,
114                                 'relatives' => array(RELATIVE_NONE)
115                         )) )
116                         if ( $bo->vfs->set_quota(array(
117                                 'string' => $name,
118                                 'relatives' => array(RELATIVE_NONE),
119                                 'new_quota' => $current_config['filemanager_quota_size']
120                         )) )
121                         $return = True;
122
123                         $bo->vfs->override_acl = 0;
124                         if ($return){
125                                 echo "Folder created";
126                         }
127                         else
128                                 echo "Error";
129                 }
130
131                 function removeFolder(){
132                         $GLOBALS['phpgw_info']['flags'] = array
133                                 (
134                                         'currentapp'    => 'filemanager',
135                                         'noheader'      => True,
136                                         'nonavbar' => True,
137                                         'nofooter'      => True,
138                                         'noappheader'   => True,
139                                         'enable_browser_class'  => True
140                                 );
141                         $bo = CreateObject('filemanager.bofilemanager');
142                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir']));
143                         if (strlen($name) < 2)
144                                 return false;
145                         $bo->vfs->delete(array(
146                                 'string' => $name,
147                                 'relatives' => array(RELATIVE_NONE)
148                         ));
149
150                         /* Clean the log */
151                         $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs WHERE directory = \''.$name.'\'',__LINE__,__FILE__);
152                         if ($GLOBALS['phpgw']->db->Error)
153                                 echo "Erro";
154                         else
155                         {               
156                                 $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_vfs_quota WHERE directory = \''.$name.'\'',__LINE__,__FILE__);
157                                 if (!$GLOBALS['phpgw']->db->Error)
158                                         echo lang('directory removed sucessfully');
159                                 else
160                                         echo "Erro";
161                         }
162                         return;
163
164                 }
165                 function reconstructFolder(){
166                         $GLOBALS['phpgw_info']['flags'] = array
167                                 (
168                                         'currentapp'    => 'filemanager',
169                                         'noheader'      => True,
170                                         'nonavbar' => True,
171                                         'nofooter'      => True,
172                                         'noappheader'   => True,
173                                         'enable_browser_class'  => True
174                                 );
175                         $bo = CreateObject('filemanager.bofilemanager');
176                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir']));
177                         if (strlen($name) < 2)
178                                 return false;
179                         $bo->vfs->update_real(array(
180                                 'string'        => $name,
181                                 'relatives'     => array(RELATIVE_NONE)
182                         ));
183                         $bo->vfs->flush_journal(array(
184                                 'string' => $name,
185                                 'relatives' => array(RELATIVE_NONE),
186                                 'deleteall' => True
187                         ));
188                         echo lang('Your operation was successfully executed');
189                 }
190
191                 function renameFolder(){
192                         $GLOBALS['phpgw_info']['flags'] = array
193                                 (
194                                         'currentapp'    => 'filemanager',
195                                         'noheader'      => True,
196                                         'nonavbar' => True,
197                                         'nofooter'      => True,
198                                         'noappheader'   => True,
199                                         'enable_browser_class'  => True
200                                 );
201                         $bo = CreateObject('filemanager.bofilemanager');
202                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir']));
203                         $to = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['to']));
204                         if (strlen($name) < 2)
205                                 return false;
206                        if ( $bo->vfs->mv(array(
207                                 'from'        => $name,
208                                 'to'   => $to,
209                                 'relatives'     => array(RELATIVE_NONE)
210                         )) ){
211                                 $bo->vfs->flush_journal(array(
212                                         'string' => $name,
213                                         'relatives' => array(RELATIVE_NONE),
214                                         'deleteall' => True
215                                 ));
216                                 echo lang('Your operation was successfully executed');
217                         }
218                        else
219                                echo lang('Error');
220                 }
221
222                 function quota(){
223                         $GLOBALS['phpgw_info']['flags'] = array
224                                 (
225                                         'currentapp'    => 'filemanager',
226                                         'noheader'      => False,
227                                         'nonavbar' => False,
228                                         'nofooter'      => False,
229                                         'noappheader'   => False,
230                                         'enable_browser_class'  => True
231                                 );
232
233                        $GLOBALS['phpgw']->common->phpgw_header();
234                        include('load_lang.php');
235                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>";
236                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>";
237                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/config.js'></script>";
238                        $t = $GLOBALS['phpgw']->template;
239                        $t->set_file(array('config_list' => 'config_quota.tpl'));
240                        $t->set_block('config_list','body','body');
241                        $vars[lang_directory]=lang('directory');
242                        $vars[lang_search]=lang('search');
243                        $vars[lang_save]=lang('save');
244
245                        $t->set_var($vars);
246                        $t->pparse('out','body');
247                        $GLOBALS['phpgw']->common->phpgw_footer();
248                        $GLOBALS['phpgw']->common->phpgw_exit();
249
250                 }
251                 function search_dir(){
252                         $GLOBALS['phpgw_info']['flags'] = array
253                                 (
254                                         'currentapp'    => 'filemanager',
255                                         'noheader'      => True,
256                                         'nonavbar' => True,
257                                         'nofooter'      => True,
258                                         'noappheader'   => True,
259                                         'enable_browser_class'  => True
260                                 );
261                         $name = $GLOBALS['phpgw']->db->db_addslashes($_GET['name']);
262                         $GLOBALS['phpgw']->db->query('SELECT DISTINCT directory FROM phpgw_vfs WHERE (directory like \'%'.$name.'%\') LIMIT 20',__LINE__,__FILE__);
263                         while ($GLOBALS['phpgw']->db->next_record()){
264                                 $val = $GLOBALS['phpgw']->db->row();
265                                 echo "<option>".$val['directory']."</option>";
266                         }
267                         $GLOBALS['phpgw']->db->query('SELECT directory,name from phpgw_vfs WHERE directory = \'/home\' and name like \'%'.$name.'%\' LIMIT 1',__LINE__,__FILE__);
268                         if ($GLOBALS['phpgw']->db->next_record()){
269                                 $val = $GLOBALS['phpgw']->db->row();
270                                 echo "<option>".$val['directory']."/".$val['name']."</option>";
271                         }
272                       
273
274                 }
275                 function search_user(){
276                         $GLOBALS['phpgw_info']['flags'] = array
277                                 (
278                                         'currentapp'    => 'filemanager',
279                                         'noheader'      => True,
280                                         'nonavbar' => True,
281                                         'nofooter'      => True,
282                                         'noappheader'   => True,
283                                         'enable_browser_class'  => True
284                                 );
285                         $account_info = $GLOBALS['phpgw']->accounts->get_list('both',0,'','',$_GET['name'],'all');
286
287                         foreach($account_info as $val)
288                                 echo "<option value='".$val['account_id']."'>".$val['account_lid']."</option>";
289                 }
290                 function set_owner(){
291                         $GLOBALS['phpgw_info']['flags'] = array
292                                 (
293                                         'currentapp'    => 'filemanager',
294                                         'noheader'      => True,
295                                         'nonavbar' => True,
296                                         'nofooter'      => True,
297                                         'noappheader'   => True,
298                                         'enable_browser_class'  => True
299                                 );
300                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir']));
301                         $owner = ($_GET['owner'])*1;
302
303                         $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__);
304                         if ($GLOBALS['phpgw']->db->Error)
305                                 echo "Erro";
306                         else
307                         {
308                                 $dirs=explode('/',$name);
309                                 $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs SET owner_id = '.$owner.' WHERE directory = \'/'.$dirs[1].'\' and name=\''.$dirs[2].'\'',__LINE__,__FILE__);
310                                 if ($GLOBALS['phpgw']->db->Error)
311                                         echo "Erro";
312                                 else
313                                 {
314                                         echo lang('entry updated sucessfully');
315                                 }
316                         }
317                         return;
318                 }
319       
320                 function update_quota(){
321                         $GLOBALS['phpgw_info']['flags'] = array
322                                 (
323                                         'currentapp'    => 'filemanager',
324                                         'noheader'      => True,
325                                         'nonavbar' => True,
326                                         'nofooter'      => True,
327                                         'noappheader'   => True,
328                                         'enable_browser_class'  => True
329                                 );
330                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['dir']));
331                         $size = ($_GET['val'])*1;
332
333                         /* See if quota exists or not */
334                         $query = "SELECT count(directory) FROM phpgw_vfs_quota WHERE directory = '".$name."' LIMIT 1";
335                         if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record())
336                                 $val = $GLOBALS['phpgw']->db->row();
337                         else
338                         {
339                                 echo $GLOBALS['phpgw']->db->error;
340                                 return false;
341                         }
342                         if ($val['count'] == '1')
343                         {
344                                 $GLOBALS['phpgw']->db->query('UPDATE phpgw_vfs_quota SET quota_size = '.$size.' WHERE directory = \''.$name.'\'',__LINE__,__FILE__);
345                                 if ($GLOBALS['phpgw']->db->Error)
346                                         echo "Erro";
347                                 else
348                                         echo lang('entry updated sucessfully');
349                         }
350                         else
351                         {
352                                 /*preferences does not exist*/
353                                 $query = "INSERT INTO phpgw_vfs_quota values ('".$name."',".$size.")";
354                                 if (!$GLOBALS['phpgw']->db->query($query))
355                                         echo $GLOBALS['phpgw']->db->error;
356                                 else
357                                         echo lang('entry updated sucessfully');
358                         }
359                         return;
360                 }
361                 function load_quota(){
362                         $GLOBALS['phpgw_info']['flags'] = array
363                                 (
364                                         'currentapp'    => 'filemanager',
365                                         'noheader'      => True,
366                                         'nonavbar' => True,
367                                         'nofooter'      => True,
368                                         'noappheader'   => True,
369                                         'enable_browser_class'  => True
370                                 );
371                         $name = $GLOBALS['phpgw']->db->db_addslashes(base64_decode($_GET['name']));
372                         $GLOBALS['phpgw']->db->query('SELECT quota_size FROM phpgw_vfs_quota WHERE directory = \''.$name.'\' LIMIT 1',__LINE__,__FILE__);
373                         $GLOBALS['phpgw']->db->next_record();
374                         $val =$GLOBALS['phpgw']->db->row();
375                         echo $val['quota_size'];
376                         return;
377
378                 }
379
380
381        }
382?>
Note: See TracBrowser for help on using the repository browser.