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 $d_arr_active =& $df->getDocuments();
78 if ($d_arr_active != NULL)
79 $d_arr = $d_arr_active;
82 $d_arr_hidden =& $df->getDocuments();
83 if ($d_arr != NULL && $d_arr_hidden != NULL) {
84 $d_arr = array_merge($d_arr, $d_arr_hidden);
85 } else if ($d_arr_hidden != NULL) {
86 $d_arr = $d_arr_hidden;
90 $d_arr_private =& $df->getDocuments();
91 if ($d_arr != NULL && $d_arr_private != NULL) {
92 $d_arr = array_merge($d_arr, $d_arr_private);
93 } else if ($d_arr_private != NULL) {
94 $d_arr = $d_arr_private;
97 $nested_groups = $dgf->getNested();
99 $nested_docs = array();
103 $ndg = new DocumentGroup($g, $dirid);
104 $DocGroupName = $ndg->getName();
105 $dgpath = $ndg->getPath(true, false);
106 if (!$DocGroupName) {
107 session_redirect($baseredirecturl.'&error_msg='.urlencode($g->getErrorMessage()));
109 if ($ndg->getState() != 1) {
110 $error_msg = _('Invalid folder');
111 session_redirect($baseredirecturl.'&view=listfile&error_msg='.urlencode($error_msg));
115 if ($d_arr != NULL ) {
116 if (!$d_arr || count($d_arr) > 0) {
117 // Get the document groups info
118 //put the doc objects into an array keyed off the docgroup
119 foreach ($d_arr as $doc) {
120 $nested_docs[$doc->getDocGroupID()][] = $doc;
125 $df->setStateID('3');
126 $d_pending_arr =& $df->getDocuments();
127 $nested_pending_groups =& $dgf->getNested();
129 if ($d_pending_arr != NULL ) {
130 if (!$d_pending_arr || count($d_pending_arr) > 0) {
131 // Get the document groups info
132 //put the doc objects into an array keyed off the docgroup
133 foreach ($d_pending_arr as $doc) {
134 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
141 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
142 var controllerListFile;
144 jQuery(document).ready(function() {
145 controllerListFile = new DocManListFileController({
146 groupId: <?php echo $group_id ?>,
147 divAddItem: jQuery('#additem'),
148 divEditDirectory: jQuery('#editdocgroup'),
149 buttonAddItem: jQuery('#docman-additem'),
150 buttonEditDirectory: jQuery('#docman-editdirectory'),
151 docManURL: '<?php util_make_uri("docman") ?>',
152 lockIntervalDelay: 60000, //in millisecond and if you change this value, please update the check value 600
153 divLeft: jQuery('#left'),
154 divHandle: jQuery('#handle'),
155 divRight: jQuery('#right'),
156 childGroupId: <?php echo util_ifsetor($childgroup_id, 0) ?>
163 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
164 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
166 $headerPath = '<h4>';
168 $headerPath .= _('Subproject').' '.':'.' '.util_make_link('/docman/?group_id='.$g->getID(),$g->getPublicName()).' ';
170 $headerPath .= _('Path:').' <i>'.$dgpath.'</i></h4>';
172 echo '<h3 class="docman_h3" >'._('Document Folder:').' <i>'.$DocGroupName.'</i> ';
173 if (forge_check_perm('docman', $group_id, 'approve')) {
174 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
175 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>';
176 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
177 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>';
181 if (forge_check_perm('docman', $group_id, 'submit')) {
182 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>';
185 $numFiles = $ndg->getNumberOfDocuments(1);
186 if (forge_check_perm('docman', $group_id, 'approve'))
187 $numPendingFiles = $ndg->getNumberOfDocuments(3);
188 if ($numFiles || (isset($numPendingFiles) && $numPendingFiles))
189 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>';
193 if (forge_check_perm('docman', $group_id, 'approve')) {
194 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
195 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
196 include ($gfcommon.'docman/views/editdocgroup.php');
199 if (forge_check_perm('docman', $group_id, 'submit')) {
200 echo '<div class="docman_div_include" id="additem" style="display:none">';
201 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
202 include ($gfcommon.'docman/views/additem.php');
207 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
208 $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'));
209 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
210 if (forge_check_perm('docman', $group_id, 'approve')) {
211 $tabletop[] = _('Actions');
212 $classth[] = 'unsortable';
214 echo '<div class="docmanDiv">';
215 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
217 foreach ($nested_docs[$dirid] as $d) {
220 if (!$d->getLocked() && !$d->getReserved()) {
221 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
223 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
224 echo '<input type="checkbox" name="disabled" disabled="disabled"';
226 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
230 switch ($d->getFileType()) {
232 $docurl = $d->getFileName();
236 $docurl = util_make_uri('/docman/view.php/'.$d->Group->getID().'/'.$d->getID().'/'.urlencode($d->getFileName()));
239 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'._('View this document').'" >';
240 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
241 echo '</a></td>'."\n";
243 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
244 $html_image_attr = array();
245 $html_image_attr['alt'] = _('new');
246 $html_image_attr['class'] = 'tabtitle-ne';
247 $html_image_attr['title'] = _('Created or updated since less than 7 days');
248 echo html_image('docman/new.png', '14', '14', $html_image_attr);
250 echo ' '.$d->getFileName();
252 echo '<td>'.$d->getName().'</td>';
253 echo '<td>'.$d->getDescription().'</td>';
254 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
256 if ( $d->getUpdated() ) {
257 echo date(_('Y-m-d H:i'), $d->getUpdated());
259 echo date(_('Y-m-d H:i'), $d->getCreated());
263 if ($d->getReserved()) {
264 $html_image_attr = array();
265 $html_image_attr['alt'] = _('Reserved Document');
266 $html_image_attr['class'] = 'tabtitle';
267 $html_image_attr['title'] = _('Reserved Document');
268 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
270 echo $d->getStateName();
274 switch ($d->getFileType()) {
280 echo human_readable_bytes($d->getFileSize());
286 if (forge_check_perm('docman', $group_id, 'approve')) {
288 /* should we steal the lock on file ? */
289 if ($d->getLocked()) {
290 if ($d->getLockedBy() == $u->getID()) {
292 /* if you change the 60000 value above, please update here too */
293 } elseif ((time() - $d->getLockdate()) > 600) {
297 if (!$d->getLocked() && !$d->getReserved()) {
298 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>';
299 if (session_loggedin()) {
300 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>';
301 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>';
304 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
305 if (forge_check_perm('docman', $group_id, 'admin')) {
306 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')));
309 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>';
310 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>';
311 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>';
314 if (session_loggedin()) {
315 if ($d->isMonitoredBy($u->getID())) {
317 $titleMonitor = _('Stop monitoring this document');
320 $titleMonitor = _('Start monitoring this document');
322 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>';
327 if (forge_check_perm('docman', $d->Group->getID(), 'approve')) {
328 echo '<tr id="docid'.$d->getID().'" class="docman_editfile_nodisplay" ><td colspan="10" >';
333 echo $HTML->listTableBottom();
335 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
336 echo _('Mass actions for selected documents:');
338 echo '<span id="massactionactive" style="display: none;" >';
339 if (forge_check_perm('docman', $group_id, 'approve')) {
340 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>';
341 if (session_loggedin()) {
342 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>';
343 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>';
344 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>';
345 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>';
348 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>';
354 echo '<p class="information">'._('No documents.').'</p>';
357 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
358 include ($gfcommon.'docman/views/pendingfiles.php');
361 echo '<div style="clear: both;" />';