source: contrib/Dms/inc/class.uifolder.inc.php @ 3526

Revision 3526, 7.4 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado modulos Timesheet e DMS para a comunidade.

  • Property svn:executable set to *
Line 
1<?php
2        /***************************************************************************\
3        * eGroupWare - mydms                                                        *
4        * http://www.linux-at-work.de                                               *
5        * http://www.phpgw.de                                                       *
6        * http://www.egroupware.org                                                 *
7        * Written by : Lars Kneschke [lkneschke@linux-at-work.de]                   *
8        * -------------------------------------------------                         *
9        * This program is free software; you can redistribute it and/or modify it   *
10        * under the terms of the GNU General Public License as published by the     *
11        * Free Software Foundation; version 2 of the License.                       *
12        \***************************************************************************/
13       
14        /* $Id: class.uifolder.inc.php 22760 2006-10-28 07:37:32Z lkneschke $ */
15
16        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.Settings.php');
17        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.DBAccess.php');
18        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.AccessUtils.php');
19        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassAccess.php');
20        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassUser.php');
21        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassGroup.php');
22        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassFolder.php');
23        require_once(PHPGW_SERVER_ROOT.'/mydms/inc/inc.ClassDocument.php');
24
25        class uifolder
26        {
27                var $public_functions = array
28                (
29                        'copyFolder'            => 'true',
30                        'getInitialFolderView'  => 'true',
31                        'getSubFolder'          => 'true',
32                );
33               
34                function uifolder() {
35                        $this->charset  = $GLOBALS['phpgw']->translation->charset();
36                }
37               
38                function copyFolder()
39                {
40                        if(isset($_GET['folderid']) && isset($_POST['targetid']) && isset($_POST['copy']))
41                        {
42                                $bo     =& CreateObject('mydms.bofolder');
43                               
44                                $folderID = (int)$_GET['folderid'];
45                                $targetID = (int)$_POST['targetid'];
46                                $newFolderName = $_POST['newfoldername'];
47                               
48                                //var_export($_POST);
49                                //options
50                                $copySubFolder = ($_POST['copy_subfolder'] == 'on' ? true : false);
51                                $copyDocuments = ($_POST['copy_documents'] == 'on' ? true : false);
52                               
53                                if($newFolder = $bo->copyFolder($folderID, $targetID, $newFolderName, $copySubFolder, $copyDocuments))
54                                {
55                                        $newFolderID = $newFolder->getID();
56                                }
57                                else
58                                {
59                                        $newFolderID = 1;
60                                }
61                                $GLOBALS['phpgw']->redirect_link('/mydms/out/out.ViewFolder.php','folderid=' . $newFolderID);
62                        }
63                        elseif(isset($_GET['folderid']) && isset($_POST['cancel']))
64                        {
65                                $folderID = ((int)$_GET['folderid'] > 0 ? (int)$_GET['folderid'] : 1);
66                                // redirect
67                                $GLOBALS['phpgw']->redirect_link('/mydms/out/out.ViewFolder.php','folderid=' . $folderID);
68                        }
69
70                        $t      =& CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
71
72                        $folderID = (int)$_GET['folderid'];
73                        $formName = $_GET['form'];
74                       
75                        $folder = getFolder($folderID);
76                        $parent = $folder->getParent();
77
78                        $this->display_app_header();
79                        $this->translate($t);
80               
81                        $t->set_file(array("copyFolder" => "copyFolder.tpl"));
82                        $t->set_block('copyFolder', 'main', 'main');
83
84                        $t->set_var('current_folder_id',$folderID);
85                        $t->set_var('newfoldername',$folder->getName());
86
87                        $t->set_var('foldername',$parent->getName());
88                        $t->set_var('folderid',$parent->getID());
89                       
90                        $linkData = array
91                        (
92                                'menuaction'    => 'mydms.uimydms.folderChooser',
93                        );
94                        $t->set_var('folderChooserURL', $GLOBALS['phpgw']->link('/index.php',$linkData));
95
96                        $linkData = array
97                        (
98                                'menuaction'    => 'mydms.uimydms.folderChooser',
99                        );
100                        $t->set_var('folderChooserURL', $GLOBALS['phpgw']->link('/index.php',$linkData));
101
102                        $linkData = array
103                        (
104                                'menuaction'    => 'mydms.uifolder.copyFolder',
105                                'folderid'      => $folderID,
106                        );
107                        $t->set_var('form_action', $GLOBALS['phpgw']->link('/index.php',$linkData));
108
109                        $t->parse("out","main");
110                       
111                        print $t->get('out','main');
112                }
113               
114                function display_app_header()
115                {
116                        if(!@is_object($GLOBALS['phpgw']->js))
117                        {
118                                $GLOBALS['phpgw']->js =& CreateObject('phpgwapi.javascript');
119                        }
120                        if (!is_object($GLOBALS['phpgw']->jscalendar))
121                        {
122                                $GLOBALS['phpgw']->jscalendar = CreateObject('phpgwapi.jscalendar');
123                        }
124                        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
125                        $GLOBALS['phpgw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
126                        $GLOBALS['phpgw']->js->validate_file('jscode','mydms','mydms');
127
128                        $GLOBALS['phpgw_info']['flags']['include_xajax'] = True;
129
130                        $GLOBALS['phpgw']->common->phpgw_header();
131                       
132                        echo parse_navbar();
133                }
134
135                function generateXML($_folder, $_childID, $_targetID, $_childContent) {
136                       
137                        $subFolders = $_folder->getSubFolders();
138                       
139                        foreach((array)$subFolders as $subFolderObject) {
140                                $subFolderID    = $subFolderObject->getID();
141                                $subFolderName  = htmlspecialchars($subFolderObject->getName(), ENT_QUOTES, $this->charset);
142                                $hasSubfolder   = ($subFolderObject->getSubFolders() ? 1 : 0);
143                                $childContent   = ($subFolderID == $_childID ? $_childContent : '');
144                                $selectedNode   = ($subFolderID == $_targetID ? " select='1'" : '');
145                                $openNode       = ($subFolderID == $_childID ? " open='1'" : '');
146                                $retValue .="<item child='$hasSubfolder' id='$subFolderID' text='$subFolderName' im0='folderClosed.gif'$selectedNode$openNode>$childContent</item>";
147                        }
148
149                        return $retValue;
150                }
151               
152                function getInitialFolderView()
153                {
154                        header("Content-type:text/xml");
155                        print("<?xml version=\"1.0\" encoding=\"$this->charset\"?>");
156                       
157                        if (isset($_GET["id"]))
158                                $folderID=$_GET["id"];
159                        else
160                                $folderID=1;
161
162                        if($folderObject = getFolder($folderID)) {
163                       
164                                $path = $folderObject->getPathNew();
165                       
166                                $xmlContent     = '';
167                                $clientID       = $folderID;
168                       
169                                // skip the last path part
170                                array_pop($path);
171
172                                while($subFolder = array_pop($path)) {
173                                        $xmlContent     = $this->generateXML($subFolder, $clientID, $folderID, $xmlContent);
174                                        $clientID       = $subFolder->getID();
175                                }
176
177                        }
178                        print "<tree id='$clientID'>$xmlContent</tree>";
179                       
180                        $GLOBALS['phpgw']->common->phpgw_exit();
181                }
182                       
183                function getSubFolder()
184                {
185                        header("Content-type:text/xml");
186                        print("<?xml version=\"1.0\" encoding=\"$this->charset\"?>");
187                        if (isset($_GET["id"]))
188                                $folderID=$_GET["id"];
189                        else
190                                $folderID=1;
191
192                        print("<tree id='".$folderID."'>");
193
194                        if($folderObject = getFolder($folderID)) {
195                       
196                                $subFolders = $folderObject->getSubFolders();
197                       
198
199                                foreach((array)$subFolders as $subFolderObject) {
200                                        $subFolderID    = $subFolderObject->getID();
201                                        $subFolderName  = lang(htmlspecialchars($subFolderObject->getName(), ENT_QUOTES, $this->charset));
202                                        $hasSubfolder   = ($subFolderObject->getSubFolders() ? 1 : 0);
203                                        print("<item child='$hasSubfolder' id='$subFolderID' text='$subFolderName' im0='folderClosed.gif'></item>");
204                                }
205
206                        }
207
208                        print("</tree>");
209
210                        $GLOBALS['phpgw']->common->phpgw_exit();
211                }
212
213                function translate(&$template)
214                {
215                        $template->set_var('lang_cancel',lang('cancel'));
216                        $template->set_var('lang_copy',lang('copy'));
217                        $template->set_var('lang_copy_documents',lang('copy documents'));
218                        $template->set_var('lang_copy_options',lang('copy options'));
219                        $template->set_var('lang_copy_subfolders',lang('copy subfolders'));
220                        $template->set_var('lang_folder',lang('folder'));
221                        $template->set_var('lang_name',lang('name'));
222                        $template->set_var('lang_select_folder',lang('select folder'));
223                        $template->set_var('lang_select_target_folder',lang('Select target folder'));
224                        $template->set_var('lang_target_folder',lang('target folder'));
225                }
226        }
227?>
Note: See TracBrowser for help on using the repository browser.