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
31 global $childgroup_id; // plugin projects hierarchy handler
33 $urlredirect = '/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid;
35 // plugin projects-hierarchy handler
37 $g = group_get_object($childgroup_id);
38 $urlredirect = '/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&childgroup_id='.$childgroup_id;
41 if (!forge_check_perm('docman', $g->getID(), 'approve')) {
42 $return_msg = _('Document Manager Action Denied.');
43 session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($return_msg));
46 $groupname = getStringFromRequest('groupname');
47 $parent_dirid = getIntFromRequest('parent_dirid');
48 $dg = new DocumentGroup($g, $dirid);
50 session_redirect($urlredirect.'&error_msg='.urlencode($dg->getErrorMessage()));
52 if (!$dg->update($groupname, $parent_dirid))
53 session_redirect($urlredirect.'&error_msg='.urlencode($dg->getErrorMessage()));
55 if ($dg->getState() == 2) {
57 * we need to update stateid for the content
58 * Get the document groups info
60 $df = new DocumentFactory($g);
62 exit_error($df->getErrorMessage(), 'docman');
64 $dgf = new DocumentGroupFactory($g);
66 exit_error($dgf->getErrorMessage(), 'docman');
68 $trashnested_groups =& $dgf->getNested();
70 $df->setDocGroupID($dirid);
71 $d_arr =& $df->getDocuments();
73 $trashnested_docs = array();
74 /* put the doc objects into an array keyed of the docgroup */
75 if (is_array($d_arr)) {
76 foreach ($d_arr as $doc) {
77 $trashnested_docs[$doc->getDocGroupID()][] = $doc;
80 docman_recursive_stateid($dirid, $trashnested_groups, $trashnested_docs, 1);
83 if (!$dg->setStateID('1'))
84 session_redirect($urlredirect.'&error_msg='.urlencode($dg->getErrorMessage()));
86 $return_msg = sprintf(_('Documents folder %s updated successfully'), $dg->getName());
88 $return_msg .= ' '.sprintf(_('on project %s'), $g->getPublicName());
90 session_redirect($urlredirect.'&feedback='.urlencode($return_msg));