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 $dgf; // document group factory
34 global $HTML; // Layout object
35 global $u; // User object
36 global $g; // the Group object
39 if (!forge_check_perm('docman', $group_id, 'read')) {
40 $return_msg= _('Document Manager Access Denied');
41 session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
44 $df->setDocGroupID($dirid);
47 * var must be named d_arr & nested_groups
48 * because used by tree.php
50 $d_arr =& $df->getDocuments();
51 $nested_groups = $dgf->getNested();
52 $linkmenu = 'listfile';
54 $nested_docs = array();
58 $ndg = new DocumentGroup($g,$dirid);
59 $DocGroupName = $ndg->getName();
61 session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($g->getErrorMessage()));
63 if ($ndg->getState() != 1) {
64 $error_msg = _('Invalid folder');
65 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&error_msg='.urlencode($error_msg));
69 if ($d_arr != NULL ) {
70 if (!$d_arr || count($d_arr) > 0) {
71 // Get the document groups info
72 //put the doc objects into an array keyed off the docgroup
73 foreach ($d_arr as $doc) {
74 $nested_docs[$doc->getDocGroupID()][] = $doc;
81 $d_pending_arr =& $df->getDocuments();
82 $nested_pending_groups =& $dgf->getNested();
84 if ($d_pending_arr != NULL ) {
85 if (!$d_pending_arr || count($d_pending_arr) > 0) {
86 // Get the document groups info
87 //put the doc objects into an array keyed off the docgroup
88 foreach ($d_pending_arr as $doc) {
89 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
96 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
97 var controllerListFile;
99 jQuery(document).ready(function() {
100 controllerListFile = new DocManListFileController({
101 groupId: <?php echo $group_id ?>,
102 divAddItem: jQuery('#additem'),
103 divEditDirectory: jQuery('#editdocgroup'),
104 buttonAddItem: jQuery('#docman-additem'),
105 buttonEditDirectory: jQuery('#docman-editdirectory'),
106 docManURL: '<?php util_make_uri("docman") ?>',
107 lockIntervalDelay: 60000, //in microsecond and if you change this value, please update the check value 600
108 divLeft: jQuery('#left'),
109 divHandle: jQuery('#handle'),
110 divRight: jQuery('#right'),
117 echo '<div id="left" style="float:left; width:17%; min-width: 50px;">';
118 include ($gfcommon.'docman/views/tree.php');
120 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
121 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
123 echo '<h3 class="docman_h3" >'._('Document Folder:').' <i>'.$DocGroupName.'</i> ';
124 if (forge_check_perm('docman', $group_id, 'approve')) {
125 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
126 echo '<a href="?group_id='.$group_id.'&action=trashdir&dirid='.$dirid.'" 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>';
127 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
128 echo '<a href="?group_id='.$group_id.'&action=deldir&dirid='.$dirid.'" class="tabtitle" id="docman-deletedirectory" title="'._('Permanently delete this folder').'" >'. html_image('docman/delete-directory.png',22,22,array('alt'=>'deldir')). '</a>';
132 if (forge_check_perm('docman', $group_id, 'submit')) {
133 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>';
136 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>';
140 if (forge_check_perm('docman', $group_id, 'approve')) {
141 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
142 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
143 include ($gfcommon.'docman/views/editdocgroup.php');
146 if (forge_check_perm('docman', $group_id, 'submit')) {
147 echo '<div class="docman_div_include" id="additem" style="display:none">';
148 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
149 include ($gfcommon.'docman/views/additem.php');
154 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
155 $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'));
156 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
157 if (forge_check_perm('docman', $group_id, 'approve')) {
158 $tabletop[] = _('Actions');
159 $classth[] = 'unsortable';
161 echo '<div class="docmanDiv">';
162 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
164 foreach ($nested_docs[$dirid] as $d) {
167 if (!$d->getLocked() && !$d->getReserved()) {
168 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
170 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
171 echo '<input type="checkbox" name="disabled" disabled="disabled"';
173 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
177 switch ($d->getFileType()) {
179 $docurl = $d->getFileName();
183 $docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
186 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'._('View this document').'" >';
187 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
188 echo '</a></td>'."\n";
190 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
191 $html_image_attr = array();
192 $html_image_attr['alt'] = _('new');
193 $html_image_attr['class'] = 'tabtitle-ne';
194 $html_image_attr['title'] = _('Created or updated since less than 7 days');
195 echo html_image('docman/new.png', '14', '14', $html_image_attr);
197 echo ' '.$d->getFileName();
199 echo '<td>'.$d->getName().'</td>';
200 echo '<td>'.$d->getDescription().'</td>';
201 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
203 if ( $d->getUpdated() ) {
204 echo date(_('Y-m-d H:i'), $d->getUpdated());
206 echo date(_('Y-m-d H:i'), $d->getCreated());
210 if ($d->getReserved()) {
211 $html_image_attr = array();
212 $html_image_attr['alt'] = _('Reserved Document');
213 $html_image_attr['class'] = 'tabtitle';
214 $html_image_attr['title'] = _('Reserved Document');
215 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
217 echo $d->getStateName();
221 switch ($d->getFileType()) {
227 echo human_readable_bytes($d->getFileSize());
233 if (forge_check_perm('docman', $group_id, 'approve')) {
235 /* should we steal the lock on file ? */
236 if ($d->getLocked()) {
237 if ($d->getLockedBy() == $u->getID()) {
239 /* if you change the 60000 value above, please update here too */
240 } elseif ((time() - $d->getLockdate()) > 600) {
244 if (!$d->getLocked() && !$d->getReserved()) {
245 echo '<a class="tabtitle-ne" href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&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>';
246 if (session_loggedin()) {
247 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>';
248 echo '<a class="tabtitle-ne" href="?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" title="'. _('Reserve this document for later edition') .'" >'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve this document'))). '</a>';
251 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
252 if (forge_check_perm('docman', $group_id, 'admin')) {
253 echo '<a class="docman-enforcereservation" href="?group_id='.$group_id.'&action=enforcereserve&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" title="'. _('Enforce reservation') .'" >'.html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation')));
256 echo '<a class="tabtitle-ne" href="?group_id='.$group_id.'&action=trashfile&view=listfile&dirid='.$dirid.'&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>';
257 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>';
258 echo '<a class="tabtitle-ne" href="?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" title="'. _('Release reservation') .'" >'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
261 if (session_loggedin()) {
262 if ($d->isMonitoredBy($u->getID())) {
264 $titleMonitor = _('Stop monitoring this document');
267 $titleMonitor = _('Start monitoring this document');
269 echo '<a class="tabtitle-ne" href="?group_id='.$group_id.'&action=monitorfile&option='.$option.'&view=listfile&dirid='.$dirid.'&fileid='.$d->getID().'" title="'.$titleMonitor.'" >'.html_image('docman/monitor-'.$option.'document.png',22,22,array('alt'=>$titleMonitor)). '</a>';
275 echo $HTML->listTableBottom();
277 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
278 echo _('Mass actions for selected documents:');
280 echo '<span id="massactionactive" style="display: none;" >';
281 if (forge_check_perm('docman', $group_id, 'approve')) {
282 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>';
283 if (session_loggedin()) {
284 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\'?group_id='.$group_id.'&action=reservefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Reserve for later edition') .'" >'.html_image('docman/reserve-document.png',22,22,array('alt'=>_('Reserve'))). '</a>';
285 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\'?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Release reservation') .'">'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
286 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=add&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Start monitoring') .'" >'.html_image('docman/monitor-adddocument.png',22,22,array('alt'=>_('Start monitoring'))). '</a>';
287 echo '<a class="tabtitle-ne" href="#" onclick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox(\'active\')" title="'. _('Stop monitoring') .'" >'.html_image('docman/monitor-removedocument.png',22,22,array('alt'=>_('Stop monitoring'))). '</a>';
290 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>';
296 echo '<p class="information">'._('No documents.').'</p>';
299 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
300 include ($gfcommon.'docman/views/pendingfiles.php');
301 include ($gfcommon.'docman/views/editfile.php');
304 echo '<div style="clear: both;" />';