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
10 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
11 * http://fusionforge.org
13 * This file is part of FusionForge. FusionForge is free software;
14 * you can redistribute it and/or modify it under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation; either version 2 of the Licence, or (at your option)
19 * FusionForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 /* please do not add require here : use www/docman/index.php to add require */
30 /* global variables used */
31 global $group_id; // id of the group
32 global $dirid; // id of doc_group
33 global $HTML; // Layout object
34 global $u; // User object
35 global $g; // the Group object
37 $linkmenu = 'listfile';
38 $baseredirecturl = '/docman/?group_id='.$group_id;
39 $redirecturl = $baseredirecturl.'&view=listfile&dirid='.$dirid;
40 $actionlistfileurl = '?group_id='.$group_id.'&view=listfile&dirid='.$dirid;
41 if (!forge_check_perm('docman', $group_id, 'read')) {
42 $return_msg= _('Document Manager Access Denied');
43 session_redirect($baseredirecturl.'&warning_msg='.urlencode($return_msg));
46 echo '<div id="left" style="float:left; width:17%; min-width: 50px; overflow: auto;">';
47 include ($gfcommon.'docman/views/tree.php');
50 // plugin projects_hierarchy
51 $childgroup_id = getIntFromRequest('childgroup_id');
53 if (!forge_check_perm('docman', $childgroup_id, 'read')) {
54 $return_msg= _('Document Manager Access Denied');
55 session_redirect($baseredirecturl.'&warning_msg='.urlencode($return_msg));
57 $redirecturl .= '&childgroup_id='.$childgroup_id;
58 $actionlistfileurl .= '&childgroup_id='.$childgroup_id;
59 $g = group_get_object($childgroup_id);
62 $df = new DocumentFactory($g);
64 exit_error($df->getErrorMessage(), 'docman');
66 $dgf = new DocumentGroupFactory($g);
68 exit_error($dgf->getErrorMessage(), 'docman');
70 $dgh = new DocumentGroupHTML($g);
72 exit_error($dgh->getErrorMessage(), 'docman');
74 $df->setDocGroupID($dirid);
77 * var must be named d_arr & nested_groups
78 * because used by tree.php
80 $d_arr =& $df->getDocuments();
81 $nested_groups = $dgf->getNested();
83 $nested_docs = array();
87 $ndg = new DocumentGroup($g, $dirid);
88 $DocGroupName = $ndg->getName();
89 $dgpath = $ndg->getPath(true, false);
91 session_redirect($baseredirecturl.'&error_msg='.urlencode($g->getErrorMessage()));
93 if ($ndg->getState() != 1) {
94 $error_msg = _('Invalid folder');
95 session_redirect($baseredirecturl.'&view=listfile&error_msg='.urlencode($error_msg));
99 if ($d_arr != NULL ) {
100 if (!$d_arr || count($d_arr) > 0) {
101 // Get the document groups info
102 //put the doc objects into an array keyed off the docgroup
103 foreach ($d_arr as $doc) {
104 $nested_docs[$doc->getDocGroupID()][] = $doc;
109 $df->setStateID('3');
111 $d_pending_arr =& $df->getDocuments();
112 $nested_pending_groups =& $dgf->getNested();
114 if ($d_pending_arr != NULL ) {
115 if (!$d_pending_arr || count($d_pending_arr) > 0) {
116 // Get the document groups info
117 //put the doc objects into an array keyed off the docgroup
118 foreach ($d_pending_arr as $doc) {
119 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
126 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
127 var controllerListFile;
129 jQuery(document).ready(function() {
130 controllerListFile = new DocManListFileController({
131 groupId: <?php echo $group_id ?>,
132 divAddItem: jQuery('#additem'),
133 divEditDirectory: jQuery('#editdocgroup'),
134 buttonAddItem: jQuery('#docman-additem'),
135 buttonEditDirectory: jQuery('#docman-editdirectory'),
136 docManURL: '<?php util_make_uri("docman") ?>',
137 lockIntervalDelay: 60000, //in millisecond and if you change this value, please update the check value 600
138 divLeft: jQuery('#left'),
139 divHandle: jQuery('#handle'),
140 divRight: jQuery('#right'),
147 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
148 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
150 echo '<h4>'._('Path:').' <i>'.$dgpath.'</i></h4>';
151 echo '<h3 class="docman_h3" >'._('Document Folder:').' <i>'.$DocGroupName.'</i> ';
152 if (forge_check_perm('docman', $group_id, 'approve')) {
153 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
154 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>';
155 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
156 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>';
160 if (forge_check_perm('docman', $group_id, 'submit')) {
161 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>';
164 $numFiles = $ndg->getNumberOfDocuments(1);
165 if (forge_check_perm('docman', $group_id, 'approve'))
166 $numPendingFiles = $ndg->getNumberOfDocuments(3);
167 if ($numFiles || (isset($numPendingFiles) && $numPendingFiles))
168 echo '<a href="/docman/view.php/'.$group_id.'/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>';
172 if (forge_check_perm('docman', $group_id, 'approve')) {
173 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
174 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
175 include ($gfcommon.'docman/views/editdocgroup.php');
178 if (forge_check_perm('docman', $group_id, 'submit')) {
179 echo '<div class="docman_div_include" id="additem" style="display:none">';
180 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
181 include ($gfcommon.'docman/views/additem.php');
186 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
187 $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'));
188 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
189 if (forge_check_perm('docman', $group_id, 'approve')) {
190 $tabletop[] = _('Actions');
191 $classth[] = 'unsortable';
193 echo '<div class="docmanDiv">';
194 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
196 foreach ($nested_docs[$dirid] as $d) {
199 if (!$d->getLocked() && !$d->getReserved()) {
200 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
202 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
203 echo '<input type="checkbox" name="disabled" disabled="disabled"';
205 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
209 switch ($d->getFileType()) {
211 $docurl = $d->getFileName();
215 $docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
218 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'._('View this document').'" >';
219 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
220 echo '</a></td>'."\n";
222 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
223 $html_image_attr = array();
224 $html_image_attr['alt'] = _('new');
225 $html_image_attr['class'] = 'tabtitle-ne';
226 $html_image_attr['title'] = _('Created or updated since less than 7 days');
227 echo html_image('docman/new.png', '14', '14', $html_image_attr);
229 echo ' '.$d->getFileName();
231 echo '<td>'.$d->getName().'</td>';
232 echo '<td>'.$d->getDescription().'</td>';
233 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
235 if ( $d->getUpdated() ) {
236 echo date(_('Y-m-d H:i'), $d->getUpdated());
238 echo date(_('Y-m-d H:i'), $d->getCreated());
242 if ($d->getReserved()) {
243 $html_image_attr = array();
244 $html_image_attr['alt'] = _('Reserved Document');
245 $html_image_attr['class'] = 'tabtitle';
246 $html_image_attr['title'] = _('Reserved Document');
247 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
249 echo $d->getStateName();
253 switch ($d->getFileType()) {
259 echo human_readable_bytes($d->getFileSize());
265 if (forge_check_perm('docman', $group_id, 'approve')) {
267 /* should we steal the lock on file ? */
268 if ($d->getLocked()) {
269 if ($d->getLockedBy() == $u->getID()) {
271 /* if you change the 60000 value above, please update here too */
272 } elseif ((time() - $d->getLockdate()) > 600) {
276 if (!$d->getLocked() && !$d->getReserved()) {
277 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>';
278 if (session_loggedin()) {
279 echo '<a class="tabtitle-ne" href="#" onclick="javascript:controllerListFile.toggleEditFileView(\''.$d->getID().'\')" title="'. _('Edit this document') .'" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
280 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>';
283 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
284 if (forge_check_perm('docman', $group_id, 'admin')) {
285 echo '<a class="docman-enforcereservation" href="'.$actionlistfileurl.'&action=enforcereserve&fileid='.$d->getID().'" title="'. _('Enforce reservation') .'" >'.html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation')));
288 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>';
289 echo '<a class="tabtitle-ne" href="#" onclick="javascript:controllerListFile.toggleEditFileView(\''.$d->getID().'\')" title="'. _('Edit this document') .'" >'.html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))). '</a>';
290 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>';
293 if (session_loggedin()) {
294 if ($d->isMonitoredBy($u->getID())) {
296 $titleMonitor = _('Stop monitoring this document');
299 $titleMonitor = _('Start monitoring this document');
301 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>';
307 echo $HTML->listTableBottom();
309 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
310 echo _('Mass actions for selected documents:');
312 echo '<span id="massactionactive" style="display: none;" >';
313 if (forge_check_perm('docman', $group_id, 'approve')) {
314 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>';
315 if (session_loggedin()) {
316 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>';
317 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>';
318 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>';
319 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>';
322 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>';
328 echo '<p class="information">'._('No documents.').'</p>';
331 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
332 include ($gfcommon.'docman/views/pendingfiles.php');
333 include ($gfcommon.'docman/views/editfile.php');
336 echo '<div style="clear: both;" />';