3 * FusionForge Documentation Manager
5 * Copyright 2000, Quentin Cregan/Sourceforge
6 * Copyright 2002-2003, Tim Perdue/GForge, LLC
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2011-2014, Franck Villaume - TrivialDev
9 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
10 * http://fusionforge.org
12 * This file is part of FusionForge. FusionForge is free software;
13 * you can redistribute it and/or modify it under the terms of the
14 * GNU General Public License as published by the Free Software
15 * Foundation; either version 2 of the Licence, or (at your option)
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 /* please do not add require here : use www/docman/index.php to add require */
29 /* global variables used */
30 global $group_id; // id of the group
31 global $dirid; // id of doc_group
32 global $g; // the Group object
34 $linkmenu = 'listtrashfile';
35 $childgroup_id = getIntFromRequest('childgroup_id');
36 $baseredirecturl = '/docman/?group_id='.$group_id;
37 $redirecturl = $baseredirecturl.'&view='.$linkmenu.'&dirid='.$dirid;
38 if (!forge_check_perm('docman', $group_id, 'approve')) {
39 $warning_msg = _('Document Manager Access Denied');
40 session_redirect($baseredirecturl);
43 echo html_ao('div', array('id' => 'leftdiv'));
44 include ($gfcommon.'docman/views/tree.php');
45 echo html_ac(html_ap() - 1);
47 // plugin projects-hierarchy
48 $childgroup_id = getIntFromRequest('childgroup_id');
50 if (!forge_check_perm('docman', $childgroup_id, 'read')) {
51 $warning_msg = _('Document Manager Access Denied');
52 session_redirect($baseredirecturl);
54 $redirecturl .= '&childgroup_id='.$childgroup_id;
55 $g = group_get_object($childgroup_id);
58 $df = new DocumentFactory($g);
60 exit_error($df->getErrorMessage(), 'docman');
62 $dgf = new DocumentGroupFactory($g);
64 exit_error($dgf->getErrorMessage(), 'docman');
68 $d_arr =& $df->getDocuments();
70 $nested_docs = array();
74 $ndg = new DocumentGroup($g, $dirid);
75 $DocGroupName = $ndg->getName();
77 $error_msg = $g->getErrorMessage();
78 session_redirect($baseredirecturl);
80 if ($ndg->getState() != 2) {
81 $error_msg = _('Invalid folder');
82 session_redirect($baseredirecturl.'&view='.$linkmenu);
86 if ($d_arr != NULL ) {
87 if (!$d_arr || count($d_arr) > 0) {
88 // Get the document groups info
89 //put the doc objects into an array keyed off the docgroup
90 foreach ($d_arr as $doc) {
91 $nested_docs[$doc->getDocGroupID()][] = $doc;
96 echo html_ao('div', array('id' => 'rightdiv'));
97 echo html_ao('div', array('style' => 'padding:5px'));
98 echo $HTML->openForm(array('id' => 'emptytrash', 'name' => 'emptytrash', 'method' => 'post', 'action' => util_make_uri('/docman/?group_id='.$group_id.'&action=emptytrash')));
99 echo html_e('input', array('id' => 'submitemptytrash', 'type' => 'submit', 'value' => _('Delete permanently all documents and folders with deleted status.')));
100 echo $HTML->closeForm();
101 echo html_ac(html_ap() - 1);
103 <script type="text/javascript">//<![CDATA[
104 var controllerListTrash;
106 jQuery(document).ready(function() {
107 controllerListTrash = new DocManListFileController({
108 groupId: <?php echo $group_id ?>,
109 divEditDirectory: jQuery('#editdocgroup'),
110 buttonEditDirectory: jQuery('#docman-editdirectory'),
111 docManURL: '<?php util_make_uri('/docman') ?>',
112 lockIntervalDelay: 60000, //in microsecond and if you change this value, please update the check value 600
113 divLeft: jQuery('#leftdiv'),
114 divRight: jQuery('#rightdiv'),
115 divEditFile: jQuery('#editFile'),
116 divEditTitle: '<?php echo _("Edit document dialog box") ?>',
124 $content = _('Document Folder')._(': ').html_e('i', array(), $DocGroupName, false).' ';
125 if ($DocGroupName != '.trash') {
126 $content .= util_make_link('#', html_image('docman/configure-directory.png', 22, 22, array('alt' => _('Edit'))), array('id' => 'docman-editdirectory', 'title' => _('Edit this folder'), 'onclick' => 'javascript:controllerListTrash.toggleEditDirectoryView({lockIntervalDelay: 60000, doc_group:'.$ndg->getID().', groupId:'.$ndg->Group->getID().', docManURL:\''.util_make_uri('/docman').'\'})' ), true);
127 $content .= util_make_link($redirecturl.'&action=deldir', html_image('docman/delete-directory.png', 22, 22, array('alt' => _('Delete folder'))), array('id' => 'docman-deletedirectory', 'title' => _('Delete permanently this folder and his content.')));
129 echo html_e('h3', array('class' => 'docman_h3'), $content, false);
130 echo html_ao('div', array('class' => 'docman_div_include hide', 'id' => 'editdocgroup'));
131 echo html_e('h4', array('class' => 'docman_h4'), _('Edit this folder'), false);
132 include ($gfcommon.'docman/views/editdocgroup.php');
133 echo html_ac(html_ap() - 1);
136 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
137 $tabletop = array(html_e('input', array('id' => 'checkallactive', 'title' => _('Select / Deselect all documents for massaction'), 'type' => 'checkbox', 'onClick' => 'controllerListTrash.checkAll("checkeddocidactive", "active")')), '', _('File Name'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'), _('Actions'));
138 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '', 'unsortable');
139 echo html_ao('div', array('class' => 'docmanDiv'));
140 echo $HTML->listTableTop($tabletop, array(), 'sortable_docman_listfile', 'sortable', $classth);
142 foreach ($nested_docs[$dirid] as $d) {
144 $cells[][] = html_e('input', array('type' => 'checkbox', 'class' => 'checkeddocidactive', 'value' => $d->getID(), 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListTrash.checkgeneral("active")'));
145 switch ($d->getFileType()) {
147 $cells[][] = util_make_link($d->getFileName(), html_image($d->getFileTypeImage(), '22', '22', array('alt' => $d->getFileType())), array('title' => _('Visit this link')));
151 $cells[][] = util_make_link('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()), html_image($d->getFileTypeImage(), '22', '22', array('alt' => $d->getFileType())), array('title' => _('View this document')));
155 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
156 $nextcell = html_image('docman/new.png', '14', '14', array('alt' => _('new'), 'class' => 'docman-newdocument', 'title' => _('Updated since less than 7 days'))).' ';
158 $cells[] = array($nextcell.$d->getFileName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
159 $cells[] = array($d->getName(), 'style' => 'word-wrap: break-word; max-width: 250px;');
160 $cells[] = array($d->getDescription(), 'style' => 'word-wrap: break-word; max-width: 250px;');
161 $cells[][] = make_user_link($d->getCreatorUserName(), $d->getCreatorRealName());
162 if ($d->getUpdated()) {
163 $cells[] = array(date(_('Y-m-d H:i'), $d->getUpdated()), 'sorttable_customkey' => $d->getUpdated());
165 $cells[] = array(date(_('Y-m-d H:i'), $d->getCreated()), 'sorttable_customkey' => $d->getCreated());
167 $cells[][] = $d->getStateName();
168 switch ($d->getFileType()) {
174 $cells[][] = human_readable_bytes($d->getFileSize());
178 $newdgf = new DocumentGroupFactory($d->Group);
179 $editfileaction = '/docman/?action=editfile&fromview=listfile&dirid='.$d->getDocGroupID();
180 if (isset($GLOBALS['childgroup_id']) && $GLOBALS['childgroup_id']) {
181 $editfileaction .= '&childgroup_id='.$GLOBALS['childgroup_id'];
183 $editfileaction .= '&group_id='.$GLOBALS['group_id'];
185 $nextcell .= util_make_link($redirecturl.'&action=delfile&fileid='.$d->getID(), html_image('docman/delete-directory.png', 22, 22, array('alt' => _('Delete permanently this document.'))), array('title' => _('Delete permanently this document.')));
186 $nextcell .= util_make_link('#', html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))), array('onclick' => 'javascript:controllerListTrash.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json','2').', docgroupDict:'.$dm->getDocGroupList($newdgf->getNested(), 'json').', title:\''.$d->getName().'\', filename:\''.$d->getFilename().'\', description:\''.$d->getDescription().'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri("docman").'\'})', 'title' => _('Edit this document')), true);
187 $cells[][] = $nextcell;
188 echo $HTML->multiTableRow(array(), $cells);
190 echo $HTML->listTableBottom();
192 echo html_ao('span', array('id' => 'massactionactive', 'class' => 'hide'));
193 echo html_e('span', array('id' => 'docman-massactionmessage', 'title' => _('Actions availables for selected documents, you need to check at least one document to get actions')), _('Mass actions for selected documents:'), false);
194 echo util_make_link('#', html_image('docman/delete-directory.png', 22, 22, array('alt' => _('Permanently Delete'))), array('onclick' => 'window.location.href=\''.util_make_uri($redirecturl.'&action=delfile&fileid=\'+controllerListTrash.buildUrlByCheckbox("active")'), 'title' => _('Permanently Delete')), true);
195 echo util_make_link('#', html_image('docman/download-directory-zip.png', 22, 22, array('alt' => _('Download as a ZIP'))), array('onclick' => 'window.location.href=\''.util_make_uri('/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListTrash.buildUrlByCheckbox("active")'), 'title' => _('Download as a ZIP')), true);
196 echo html_ac(html_ap() - 3);
199 echo $HTML->information(_('No documents.'));
203 echo html_ac(html_ap() -1);
205 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
206 $foundFiles = count($nested_docs[$dirid]);
208 if (forge_check_perm('docman', $g->getID(), 'approve') && $foundFiles) {
209 include ($gfcommon.'docman/views/editfile.php');