3 * FusionForge Documentation Manager
5 * Copyright 2000, Quentin Cregan/Sourceforge
6 * Copyright 2002-2003, Tim Perdue/GForge, LLC
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /* please do not add require here : use www/docman/index.php to add require */
27 /* global variables used */
28 global $g; //group object
29 global $dirid; //id of doc_group
30 global $group_id; // id of group
32 $redirecturl = '/docman/?group_id='.$group_id.'&view=listfile';
33 if (!forge_check_perm('docman', $group_id, 'approve')) {
34 $return_msg = _('Document Manager Action Denied.');
35 session_redirect($redirecturl.'&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
38 // plugin projects-hierarchy handler
39 $childgroup_id = getIntFromRequest('childgroup_id');
41 if (!forge_check_perm('docman', $childgroup_id, 'approve')) {
42 $return_msg = _('Document Manager Action Denied.');
43 session_redirect($redirecturl.'&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
45 $redirecturl .= '&childgroup_id='.$childgroup_id;
46 $g = group_get_object($childgroup_id);
49 /* when moving a document group to trash, it's recursive and it's applied to documents that belong to these document groups */
50 /* Get the document groups info */
51 $df = new DocumentFactory($g);
53 exit_error($df->getErrorMessage(), 'docman');
55 $dgf = new DocumentGroupFactory($g);
57 exit_error($dgf->getErrorMessage(), 'docman');
59 $trashnested_groups =& $dgf->getNested();
61 $df->setDocGroupID($dirid);
62 $d_arr =& $df->getDocuments();
64 $trashnested_docs = array();
65 /* put the doc objects into an array keyed of the docgroup */
66 if (is_array($d_arr)) {
67 foreach ($d_arr as $doc) {
68 $trashnested_docs[$doc->getDocGroupID()][] = $doc;
72 /* set to trash content of this dirid */
73 docman_recursive_stateid($dirid, $trashnested_groups, $trashnested_docs, 2);
75 /* set this dirid to trash */
76 $dg = new DocumentGroup($g, $dirid);
77 $currentParent = $dg->getParentID();
78 if (!$dg->setStateID('2'))
79 session_redirect($redirecturl.'&error_msg='.urlencode($dg->getErrorMessage()));
81 $dm = new DocumentManager($g);
82 if (!$dg->setParentDocGroupId($dm->getTrashID()))
83 session_redirect($redirecturl.'&dirid='.$currentParent.'&error_msg='.urlencode($dg->getErrorMessage()));
85 $return_msg = sprintf(_('Documents folder %s moved to trash successfully.'),$dg->getName());
86 session_redirect($redirecturl.'&dirid='.$currentParent.'&feedback='.urlencode($return_msg));