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 $childgroup_id = getIntFromRequest('childgroup_id');
41 if (!forge_check_perm('docman', $group_id, 'read')) {
42 $return_msg= _('Document Manager Access Denied');
43 session_redirect('/docman/?group_id='.$group_id.'&warning_msg='.urlencode($return_msg));
46 // plugin projects_hierarchy
48 $g = group_get_object($childgroup_id);
51 $df = new DocumentFactory($g);
53 exit_error($df->getErrorMessage(), 'docman');
55 $dgf = new DocumentGroupFactory($g);
57 exit_error($dgf->getErrorMessage(), 'docman');
59 $dgh = new DocumentGroupHTML($g);
61 exit_error($dgh->getErrorMessage(), 'docman');
63 $df->setDocGroupID($dirid);
66 * var must be named d_arr & nested_groups
67 * because used by tree.php
69 $d_arr =& $df->getDocuments();
70 $nested_groups = $dgf->getNested();
71 $linkmenu = 'listfile';
73 $nested_docs = array();
77 $ndg = new DocumentGroup($g, $dirid);
78 $DocGroupName = $ndg->getName();
79 $dgpath = $ndg->getPath(true, false);
81 session_redirect('/docman/?group_id='.$group_id.'&error_msg='.urlencode($g->getErrorMessage()));
83 if ($ndg->getState() != 1) {
84 $error_msg = _('Invalid folder');
85 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&error_msg='.urlencode($error_msg));
89 if ($d_arr != NULL ) {
90 if (!$d_arr || count($d_arr) > 0) {
91 // Get the document groups info
92 //put the doc objects into an array keyed off the docgroup
93 foreach ($d_arr as $doc) {
94 $nested_docs[$doc->getDocGroupID()][] = $doc;
101 $d_pending_arr =& $df->getDocuments();
102 $nested_pending_groups =& $dgf->getNested();
104 if ($d_pending_arr != NULL ) {
105 if (!$d_pending_arr || count($d_pending_arr) > 0) {
106 // Get the document groups info
107 //put the doc objects into an array keyed off the docgroup
108 foreach ($d_pending_arr as $doc) {
109 $nested_pending_docs[$doc->getDocGroupID()][] = $doc;
116 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
117 var controllerListFile;
119 jQuery(document).ready(function() {
120 controllerListFile = new DocManListFileController({
121 groupId: <?php echo $group_id ?>,
122 divAddItem: jQuery('#additem'),
123 divEditDirectory: jQuery('#editdocgroup'),
124 buttonAddItem: jQuery('#docman-additem'),
125 buttonEditDirectory: jQuery('#docman-editdirectory'),
126 docManURL: '<?php util_make_uri("docman") ?>',
127 lockIntervalDelay: 60000, //in millisecond and if you change this value, please update the check value 600
128 divLeft: jQuery('#left'),
129 divHandle: jQuery('#handle'),
130 divRight: jQuery('#right'),
137 echo '<div id="left" style="float:left; width:17%; min-width: 50px; overflow: auto;">';
138 include ($gfcommon.'docman/views/tree.php');
140 echo '<div id="handle" style="float:left; height:100px; margin:3px; width:3px; background: #000; cursor:e-resize;"></div>';
141 echo '<div id="right" style="float:left; width: 80%; overflow: auto; max-width: 90%;">';
143 echo '<h4>'._('Path:').' <i>'.$dgpath.'</i></h4>';
144 echo '<h3 class="docman_h3" >'._('Document Folder:').'<i>'.$DocGroupName.'</i> ';
145 if (forge_check_perm('docman', $group_id, 'approve')) {
146 echo '<a href="#" class="tabtitle" id="docman-editdirectory" title="'._('Edit this folder').'" >'. html_image('docman/configure-directory.png',22,22,array('alt'=>'edit')). '</a>';
147 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>';
148 if (!isset($nested_docs[$dirid]) && !isset($nested_groups[$dirid]) && !isset($nested_pending_docs[$dirid])) {
149 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>';
153 if (forge_check_perm('docman', $group_id, 'submit')) {
154 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>';
157 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>';
161 if (forge_check_perm('docman', $group_id, 'approve')) {
162 echo '<div class="docman_div_include" id="editdocgroup" style="display:none;">';
163 echo '<h4 class="docman_h4">'. _('Edit this folder') .'</h4>';
164 include ($gfcommon.'docman/views/editdocgroup.php');
167 if (forge_check_perm('docman', $group_id, 'submit')) {
168 echo '<div class="docman_div_include" id="additem" style="display:none">';
169 echo '<h4 class="docman_h4">'. _('Add a new item') .'</h4>';
170 include ($gfcommon.'docman/views/additem.php');
175 if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
176 $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'));
177 $classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '');
178 if (forge_check_perm('docman', $group_id, 'approve')) {
179 $tabletop[] = _('Actions');
180 $classth[] = 'unsortable';
182 echo '<div class="docmanDiv">';
183 echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
185 foreach ($nested_docs[$dirid] as $d) {
188 if (!$d->getLocked() && !$d->getReserved()) {
189 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'" onchange="controllerListFile.checkgeneral(\'active\')" />';
191 if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
192 echo '<input type="checkbox" name="disabled" disabled="disabled"';
194 echo '<input type="checkbox" value="'.$d->getID().'" class="checkeddocidactive tabtitle-w" title="'._('Select / Deselect this document for massaction').'"" onchange="controllerListFile.checkgeneral(\'active\')" />';
198 switch ($d->getFileType()) {
200 $docurl = $d->getFileName();
204 $docurl = util_make_uri('/docman/view.php/'.$group_id.'/'.$d->getID().'/'.urlencode($d->getFileName()));
207 echo '<td><a href="'.$docurl.'" class="tabtitle-nw" title="'._('View this document').'" >';
208 echo html_image($d->getFileTypeImage(), '22', '22', array('alt'=>$d->getFileType()));;
209 echo '</a></td>'."\n";
211 if (($d->getUpdated() && $time_new > (time() - $d->getUpdated())) || $time_new > (time() - $d->getCreated())) {
212 $html_image_attr = array();
213 $html_image_attr['alt'] = _('new');
214 $html_image_attr['class'] = 'tabtitle-ne';
215 $html_image_attr['title'] = _('Created or updated since less than 7 days');
216 echo html_image('docman/new.png', '14', '14', $html_image_attr);
218 echo ' '.$d->getFileName();
220 echo '<td>'.$d->getName().'</td>';
221 echo '<td>'.$d->getDescription().'</td>';
222 echo '<td>'.make_user_link($d->getCreatorUserName(), $d->getCreatorRealName()).'</td>';
224 if ( $d->getUpdated() ) {
225 echo date(_('Y-m-d H:i'), $d->getUpdated());
227 echo date(_('Y-m-d H:i'), $d->getCreated());
231 if ($d->getReserved()) {
232 $html_image_attr = array();
233 $html_image_attr['alt'] = _('Reserved Document');
234 $html_image_attr['class'] = 'tabtitle';
235 $html_image_attr['title'] = _('Reserved Document');
236 echo html_image('docman/document-reserved.png', '22', '22', $html_image_attr);
238 echo $d->getStateName();
242 switch ($d->getFileType()) {
248 echo human_readable_bytes($d->getFileSize());
254 if (forge_check_perm('docman', $group_id, 'approve')) {
256 /* should we steal the lock on file ? */
257 if ($d->getLocked()) {
258 if ($d->getLockedBy() == $u->getID()) {
260 /* if you change the 60000 value above, please update here too */
261 } elseif ((time() - $d->getLockdate()) > 600) {
265 if (!$d->getLocked() && !$d->getReserved()) {
266 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>';
267 if (session_loggedin()) {
268 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>';
269 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>';
272 if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
273 if (forge_check_perm('docman', $group_id, 'admin')) {
274 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')));
277 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>';
278 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>';
279 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>';
282 if (session_loggedin()) {
283 if ($d->isMonitoredBy($u->getID())) {
285 $titleMonitor = _('Stop monitoring this document');
288 $titleMonitor = _('Start monitoring this document');
290 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>';
296 echo $HTML->listTableBottom();
298 echo '<span class="tabtitle" id="docman-massactionmessage" title="'. _('Actions availables for selected documents, you need to check at least one document to get actions') . '" >';
299 echo _('Mass actions for selected documents:');
301 echo '<span id="massactionactive" style="display: none;" >';
302 if (forge_check_perm('docman', $group_id, 'approve')) {
303 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>';
304 if (session_loggedin()) {
305 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>';
306 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>';
307 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>';
308 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>';
311 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>';
317 echo '<p class="information">'._('No documents.').'</p>';
320 if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
321 include ($gfcommon.'docman/views/pendingfiles.php');
322 include ($gfcommon.'docman/views/editfile.php');
325 echo '<div style="clear: both;" />';