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 $childgroup_id = getIntFromRequest('childgroup_id');
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 // plugin projects_hierarchy
46 $g = group_get_object($childgroup_id);
49 $df = new DocumentFactory($g);
51 exit_error($df->getErrorMessage(), 'docman');
53 $dgf = new DocumentGroupFactory($g);
55 exit_error($dgf->getErrorMessage(), 'docman');
57 $dgh = new DocumentGroupHTML($g);
59 exit_error($dgh->getErrorMessage(), 'docman');
61 $df->setDocGroupID($dirid);
64 * var must be named d_arr & nested_groups
65 * because used by tree.php
67 $d_arr =& $df->getDocuments();
68 $nested_groups = $dgf->getNested();
69 $linkmenu = 'listfile';
71 $nested_docs = array();
75 $ndg = new DocumentGroup($g, $dirid);
76 $DocGroupName = $ndg->getName();
77 $dgpath = $ndg->getPath(true, false);
79 session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($g->getErrorMessage()));
81 if ($ndg->getState() != 1) {
82 $error_msg = _('Invalid folder');
83 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&error_msg='.urlencode($error_msg));
87 if ($d_arr != NULL ) {
88 if (!$d_arr || count($d_arr) > 0) {
89 // Get the document groups info
90 //put the doc objects into an array keyed off the docgroup
91 foreach ($d_arr as $doc) {
92 $nested_docs[$doc->getDocGroupID()][] = $doc;
99 $d_pending_arr =& $df->getDocuments();
100 $nested_pending_groups =& $dgf->getNested();
102 if ($d_pending_arr != NULL ) {
103 if (!$d_pending_arr || count($d_pending_arr) > 0) {
104 // Get the document groups info
105 //put the doc objects into an array keyed off the docgroup
106 foreach ($d_pending_arr as $doc) {
107 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
114 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
115 var controllerListFile;
117 jQuery(document).ready(function() {
118 controllerListFile = new DocManListFileController({
119 groupId: <?php echo $group_id ?>,
120 divAddItem: jQuery('#additem'),
121 divEditDirectory: jQuery('#editdocgroup'),
122 buttonAddItem: jQuery('#docman-additem'),
123 buttonEditDirectory: jQuery('#docman-editdirectory'),
124 docManURL: '<?php util_make_uri("docman") ?>',
125 lockIntervalDelay: 60000, //in millisecond and if you change this value, please update the check value 600
126 divLeft: jQuery('#left'),
127 divHandle: jQuery('#handle'),
128 divRight: jQuery('#right'),
135 echo '<div id="left" style="float:left; width:17%; min-width: 50px; overflow: auto;">';
136 include ($gfcommon.'docman/views/tree.php');
138 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
139 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
141 echo '<h4>'._('Path:').' <i>'.$dgpath.'</i></h4>';
142 echo '<h3 class="docman_h3" >'._('Document Folder:').' <i>'.$DocGroupName.'</i> ';
143 if (forge_check_perm('docman', $group_id, 'approve')) {
144 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
145 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>';
146 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
147 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>';
151 if (forge_check_perm('docman', $group_id, 'submit')) {
152 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>';
155 $numFiles = $ndg->getNumberOfDocuments();
156 if (forge_check_perm('docman', $group_id, 'approve'))
157 $numPendingFiles = $ndg->getNumberOfDocuments(3);
158 if ($numFiles || (isset($numPendingFiles) && $numPendingFiles))
159 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>';
163 if (forge_check_perm('docman', $group_id, 'approve')) {
164 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
165 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
166 include ($gfcommon.'docman/views/editdocgroup.php');
169 if (forge_check_perm('docman', $group_id, 'submit')) {
170 echo '<div class="docman_div_include" id="additem" style="display:none">';
171 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
172 include ($gfcommon.'docman/views/additem.php');
177 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
178 $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'));
179 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
180 if (forge_check_perm('docman', $group_id, 'approve')) {
181 $tabletop[] = _('Actions');
182 $classth[] = 'unsortable';
184 echo '<div class="docmanDiv">';
185 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
187 foreach ($nested_docs[$dirid] as $d) {
190 if (!$d->getLocked() && !$d->getReserved()) {
191 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
193 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
194 echo '<input type="checkbox" name="disabled" disabled="disabled"';
196 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
200 switch ($d->getFileType()) {
202 $docurl = $d->getFileName();
206 $docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
209 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'._('View this document').'" >';
210 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
211 echo '</a></td>'."\n";
213 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
214 $html_image_attr = array();
215 $html_image_attr['alt'] = _('new');
216 $html_image_attr['class'] = 'tabtitle-ne';
217 $html_image_attr['title'] = _('Created or updated since less than 7 days');
218 echo html_image('docman/new.png', '14', '14', $html_image_attr);
220 echo ' '.$d->getFileName();
222 echo '<td>'.$d->getName().'</td>';
223 echo '<td>'.$d->getDescription().'</td>';
224 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
226 if ( $d->getUpdated() ) {
227 echo date(_('Y-m-d H:i'), $d->getUpdated());
229 echo date(_('Y-m-d H:i'), $d->getCreated());
233 if ($d->getReserved()) {
234 $html_image_attr = array();
235 $html_image_attr['alt'] = _('Reserved Document');
236 $html_image_attr['class'] = 'tabtitle';
237 $html_image_attr['title'] = _('Reserved Document');
238 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
240 echo $d->getStateName();
244 switch ($d->getFileType()) {
250 echo human_readable_bytes($d->getFileSize());
256 if (forge_check_perm('docman', $group_id, 'approve')) {
258 /* should we steal the lock on file ? */
259 if ($d->getLocked()) {
260 if ($d->getLockedBy() == $u->getID()) {
262 /* if you change the 60000 value above, please update here too */
263 } elseif ((time() - $d->getLockdate()) > 600) {
267 if (!$d->getLocked() && !$d->getReserved()) {
268 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>';
269 if (session_loggedin()) {
270 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>';
271 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>';
274 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
275 if (forge_check_perm('docman', $group_id, 'admin')) {
276 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')));
279 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>';
280 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>';
281 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>';
284 if (session_loggedin()) {
285 if ($d->isMonitoredBy($u->getID())) {
287 $titleMonitor = _('Stop monitoring this document');
290 $titleMonitor = _('Start monitoring this document');
292 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>';
298 echo $HTML->listTableBottom();
300 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
301 echo _('Mass actions for selected documents:');
303 echo '<span id="massactionactive" style="display: none;" >';
304 if (forge_check_perm('docman', $group_id, 'approve')) {
305 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>';
306 if (session_loggedin()) {
307 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>';
308 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>';
309 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>';
310 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>';
313 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>';
319 echo '<p class="information">'._('No documents.').'</p>';
322 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
323 include ($gfcommon.'docman/views/pendingfiles.php');
324 include ($gfcommon.'docman/views/editfile.php');
327 echo '<div style="clear: both;" />';