3 * FusionForge Documentation Manager
5 * Copyright 2000, Quentin Cregan/Sourceforge
6 * Copyright 2002-2003, Tim Perdue/GForge, LLC
7 * Copyright (C) 2010 Alcatel-Lucent
8 * Copyright 2010-2011, Franck Villaume - Capgemini
9 * Copyright 2012, Franck Villaume - TrivialDev
11 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
12 * http://fusionforge.org
14 * This file is part of FusionForge. FusionForge is free software;
15 * you can redistribute it and/or modify it under the terms of the
16 * GNU General Public License as published by the Free Software
17 * Foundation; either version 2 of the Licence, or (at your option)
20 * FusionForge is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License along
26 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 /* please do not add require here : use www/docman/index.php to add require */
31 /* global variables used */
32 global $group_id; // id of the group
33 global $dirid; // id of doc_group
34 global $HTML; // Layout object
35 global $u; // User object
36 global $g; // the Group object
37 global $dm; // the docman manager
39 $linkmenu = 'listfile';
40 $baseredirecturl = '/docman/?group_id='.$group_id;
41 $redirecturl = $baseredirecturl.'&view=listfile&dirid='.$dirid;
42 $actionlistfileurl = '?group_id='.$group_id.'&view=listfile&dirid='.$dirid;
43 if (!forge_check_perm('docman', $group_id, 'read')) {
44 $return_msg= _('Document Manager Access Denied');
45 session_redirect($baseredirecturl.'&warning_msg='.urlencode($return_msg));
48 echo '<div id="left" style="float:left; width:17%; min-width: 50px; overflow: auto;">';
49 include ($gfcommon.'docman/views/tree.php');
52 // plugin projects-hierarchy
53 $childgroup_id = getIntFromRequest('childgroup_id');
55 if (!forge_check_perm('docman', $childgroup_id, 'read')) {
56 $return_msg= _('Document Manager Access Denied');
57 session_redirect($baseredirecturl.'&warning_msg='.urlencode($return_msg));
59 $redirecturl .= '&childgroup_id='.$childgroup_id;
60 $actionlistfileurl .= '&childgroup_id='.$childgroup_id;
61 $g = group_get_object($childgroup_id);
64 $df = new DocumentFactory($g);
66 exit_error($df->getErrorMessage(), 'docman');
68 $dgf = new DocumentGroupFactory($g);
70 exit_error($dgf->getErrorMessage(), 'docman');
72 $dgh = new DocumentGroupHTML($g);
74 exit_error($dgh->getErrorMessage(), 'docman');
76 $df->setDocGroupID($dirid);
79 $d_arr_active =& $df->getDocuments();
80 if ($d_arr_active != NULL)
81 $d_arr = $d_arr_active;
84 $d_arr_hidden =& $df->getDocuments();
85 if ($d_arr != NULL && $d_arr_hidden != NULL) {
86 $d_arr = array_merge($d_arr, $d_arr_hidden);
87 } elseif ($d_arr_hidden != NULL) {
88 $d_arr = $d_arr_hidden;
92 $d_arr_private =& $df->getDocuments();
93 if ($d_arr != NULL && $d_arr_private != NULL) {
94 $d_arr = array_merge($d_arr, $d_arr_private);
95 } elseif ($d_arr_private != NULL) {
96 $d_arr = $d_arr_private;
99 $nested_groups = $dgf->getNested();
101 $nested_docs = array();
105 $ndg = new DocumentGroup($g, $dirid);
106 $DocGroupName = $ndg->getName();
107 $dgpath = $ndg->getPath(true, false);
108 if (!$DocGroupName) {
109 session_redirect($baseredirecturl.'&error_msg='.urlencode($g->getErrorMessage()));
111 if ($ndg->getState() != 1) {
112 $error_msg = _('Invalid folder');
113 session_redirect($baseredirecturl.'&view=listfile&error_msg='.urlencode($error_msg));
117 if ($d_arr != NULL ) {
118 if (!$d_arr || count($d_arr) > 0) {
119 // Get the document groups info
120 //put the doc objects into an array keyed off the docgroup
121 foreach ($d_arr as $doc) {
122 $nested_docs[$doc->getDocGroupID()][] = $doc;
127 $df->setStateID('3');
128 $d_pending_arr =& $df->getDocuments();
130 if ($d_pending_arr != NULL ) {
131 if (!$d_pending_arr || count($d_pending_arr) > 0) {
132 // Get the document groups info
133 //put the doc objects into an array keyed off the docgroup
134 foreach ($d_pending_arr as $doc) {
135 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
142 <script language="JavaScript" type="text/javascript">//<![CDATA[
143 var controllerListFile;
145 jQuery(document).ready(function() {
146 controllerListFile = new DocManListFileController({
147 groupId: <?php echo $group_id ?>,
148 divAddItem: jQuery('#additem'),
149 divEditDirectory: jQuery('#editdocgroup'),
150 buttonAddItem: jQuery('#docman-additem'),
151 buttonEditDirectory: jQuery('#docman-editdirectory'),
152 docManURL: '<?php util_make_uri("docman") ?>',
153 divLeft: jQuery('#left'),
154 divHandle: jQuery('#handle'),
155 divRight: jQuery('#right'),
156 childGroupId: <?php echo util_ifsetor($childgroup_id, 0) ?>,
157 divEditFile: jQuery('#editFile'),
158 divEditTitle: '<?php echo _("Edit document dialog box") ?>',
165 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
166 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
168 $headerPath = '<h4>';
170 $headerPath .= _('Subproject').' '.':'.' '.util_make_link('/docman/?group_id='.$g->getID(),$g->getPublicName()).' ';
172 $headerPath .= _('Path:').' <i>'.$dgpath.'</i></h4>';
174 echo '<h3 class="docman_h3" >'._('Document Folder:').' <i>'.$DocGroupName.'</i> ';
175 if (forge_check_perm('docman', $ndg->Group->getID(), 'approve')) {
176 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
177 echo '<a href="'.$actionlistfileurl.'&action=trashdir" class="tabtitle" id="docman-trashdirectory" title="'._('Move this folder and his content to trash').'" >'. html_image('docman/trash-empty.png',22,22,array('alt'=>'trashdir')). '</a>';
178 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
179 echo '<a href="'.$actionlistfileurl.'&action=deldir" class="tabtitle" id="docman-deletedirectory" title="'._('Permanently delete this folder').'" >'. html_image('docman/delete-directory.png',22,22,array('alt'=>'deldir')). '</a>';
183 if (forge_check_perm('docman', $group_id, 'submit')) {
184 echo '<a href="#" class="tabtitle" id="docman-additem" title="'. _('Add a new item in this folder') . '" >'. html_image('docman/insert-directory.png',22,22,array('alt'=>'additem')). '</a>';
187 $numFiles = $ndg->getNumberOfDocuments(1);
188 if (forge_check_perm('docman', $group_id, 'approve'))
189 $numPendingFiles = $ndg->getNumberOfDocuments(3);
190 if ($numFiles || (isset($numPendingFiles) && $numPendingFiles))
191 echo '<a href="/docman/view.php/'.$ndg->Group->getID().'/zip/full/'.$dirid.'" class="tabtitle" title="'. _('Download this folder as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
193 if (session_loggedin()) {
194 if ($ndg->isMonitoredBy($u->getID())) {
196 $titleMonitor = _('Stop monitoring this directory');
199 $titleMonitor = _('Start monitoring this directory');
201 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=monitordirectory&option='.$option.'&directoryid='.$ndg->getID().'" title="'.$titleMonitor.'" >'.html_image('docman/monitor-'.$option.'document.png',22,22,array('alt'=>$titleMonitor)). '</a>';
205 if (forge_check_perm('docman', $ndg->Group->getID(), 'approve')) {
206 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
207 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
208 include ($gfcommon.'docman/views/editdocgroup.php');
211 if (forge_check_perm('docman', $ndg->Group->getID(), 'submit')) {
212 echo '<div class="docman_div_include" id="additem" style="display:none">';
213 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
214 include ($gfcommon.'docman/views/additem.php');
219 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
220 $tabletop = array('<input id="checkallactive" type="checkbox" title="'._('Select / Deselect all documents for massaction').'" class="tabtitle-w" onchange="controllerListFile.checkAll(\'checkeddocidactive\', \'active\')" />', '', _('Filename'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'), _('View'));
221 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '', '');
222 if (forge_check_perm('docman', $ndg->Group->getID(), 'approve')) {
223 $tabletop[] = _('Actions');
224 $classth[] = 'unsortable';
226 echo '<div class="docmanDiv">';
227 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
229 foreach ($nested_docs[$dirid] as $d) {
232 if (!$d->getLocked() && !$d->getReserved()) {
233 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
235 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
236 echo '<input type="checkbox" name="disabled" disabled="disabled"';
238 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
242 switch ($d->getFileType()) {
244 $docurl = $d->getFileName();
245 $docurltitle = _('Visit this link');
249 $docurl = util_make_uri('/docman/view.php/'.$d->Group->getID().'/'.$d->getID().'/'.urlencode($d->getFileName()));
250 $docurltitle = _('View this document');
253 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'.$docurltitle.'" >';
254 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));
255 echo '</a></td>'."\n";
257 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
258 $html_image_attr = array();
259 $html_image_attr['alt'] = _('new');
260 $html_image_attr['class'] = 'tabtitle-ne';
261 $html_image_attr['title'] = _('Created or updated since less than 7 days');
262 echo html_image('docman/new.png', '14', '14', $html_image_attr);
264 echo ' '.$d->getFileName();
266 echo '<td>'.$d->getName().'</td>';
267 echo '<td>'.$d->getDescription().'</td>';
268 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
270 if ( $d->getUpdated() ) {
271 echo date(_('Y-m-d H:i'), $d->getUpdated());
273 echo date(_('Y-m-d H:i'), $d->getCreated());
277 if ($d->getReserved()) {
278 $html_image_attr = array();
279 $html_image_attr['alt'] = _('Reserved Document');
280 $html_image_attr['class'] = 'tabtitle';
281 $html_image_attr['title'] = _('Reserved Document');
282 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
284 echo $d->getStateName();
288 switch ($d->getFileType()) {
294 echo human_readable_bytes($d->getFileSize());
300 echo $d->getDownload();
303 if (forge_check_perm('docman', $group_id, 'approve')) {
305 /* should we steal the lock on file ? */
306 if ($d->getLocked()) {
307 if ($d->getLockedBy() == $u->getID()) {
309 /* if you change the 60000 value below, please update here too */
310 } elseif ((time() - $d->getLockdate()) > 600) {
314 $editfileaction = '?action=editfile&fromview=listfile&dirid='.$d->getDocGroupID();
315 if (isset($GLOBALS['childgroup_id']) && $GLOBALS['childgroup_id']) {
316 $editfileaction .= '&childgroup_id='.$GLOBALS['childgroup_id'];
318 $editfileaction .= '&group_id='.$GLOBALS['group_id'];
319 if (!$d->getLocked() && !$d->getReserved()) {
320 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=trashfile&fileid='.$d->getID().'" title="'. _('Move this document to trash') .'" >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
321 echo '<a class="tabtitle-ne" href="#" onclick="javascript:controllerListFile.toggleEditFileView({action:\''.$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').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', title:\''.addslashes($d->getName()).'\', filename:\''.$d->getFilename().'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri("docman").'\'})" title="'. _('Edit this document') .'" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
322 if (session_loggedin()) {
323 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=reservefile&fileid='.$d->getID().'" title="'. _('Reserve this document for later edition') .'" >'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve this document'))). '</a>';
326 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
327 if (forge_check_perm('docman', $ndg->Group->getID(), 'admin')) {
328 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=enforcereserve&fileid='.$d->getID().'" title="'. _('Enforce reservation') .'" >'.html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation')));
331 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=trashfile&fileid='.$d->getID().'" title="'. _('Move this document to trash') .'" >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash this document'))). '</a>';
332 echo '<a class="tabtitle-ne" href="#" onclick="javascript:controllerListFile.toggleEditFileView({action:\''.$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').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', title:\''.addslashes($d->getName()).'\', filename:\''.$d->getFilename().'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri("docman").'\'})" title="'. _('Edit this document') .'" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
333 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=releasefile&fileid='.$d->getID().'" title="'. _('Release reservation') .'" >'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
336 if (session_loggedin()) {
337 if ($d->isMonitoredBy($u->getID())) {
339 $titleMonitor = _('Stop monitoring this document');
342 $titleMonitor = _('Start monitoring this document');
344 echo '<a class="tabtitle-ne" href="'.$actionlistfileurl.'&action=monitorfile&option='.$option.'&fileid='.$d->getID().'" title="'.$titleMonitor.'" >'.html_image('docman/monitor-'.$option.'document.png',22,22,array('alt'=>$titleMonitor)). '</a>';
350 echo $HTML->listTableBottom();
352 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
353 echo _('Mass actions for selected documents:');
355 echo '<span id="massactionactive" style="display: none;" >';
356 if (forge_check_perm('docman', $ndg->Group->getID(), 'approve')) {
357 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\'?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Move to trash') .'" >'.html_image('docman/trash-empty.png',22,22,array('alt'=>_('Move to trash'))). '</a>';
358 if (session_loggedin()) {
359 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\''.$actionlistfileurl.'&action=reservefile&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Reserve for later edition') .'" >'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve'))). '</a>';
360 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\''.$actionlistfileurl.'&action=releasefile&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Release reservation') .'">'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
361 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\''.$actionlistfileurl.'&action=monitorfile&option=add&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Start monitoring') .'" >'.html_image('docman/monitor-adddocument.png',22,22,array('alt'=>_('Start monitoring'))). '</a>';
362 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\''.$actionlistfileurl.'&action=monitorfile&option=remove&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Stop monitoring') .'" >'.html_image('docman/monitor-removedocument.png',22,22,array('alt'=>_('Stop monitoring'))). '</a>';
365 echo '<a class="tabtitle" href="#" onclick="window.location.href=\'/docman/view.php/'.$group_id.'/zip/selected/'.$dirid.'/\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Download as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'Download as Zip')). '</a>';
371 echo '<p class="information">'._('No documents.').'</p>';
374 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
375 include ($gfcommon.'docman/views/pendingfiles.php');
378 echo '<div style="clear: both;" />';
379 if (forge_check_perm('docman', $g->getID(), 'approve')) {
380 include ($gfcommon.'docman/views/editfile.php');