3 * FusionForge Documentation Manager
5 * Copyright 1999-2001, VA Linux Systems
6 * Copyright 2000, Quentin Cregan/SourceForge
7 * Copyright 2002-2004, GForge Team
8 * Copyright 2010-2011, Franck Villaume - Capgemini
9 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
10 * Copyright 2012-2014,2016 Franck Villaume - TrivialDev
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.
36 * @param string $checkedval
37 * @param array $removedval
41 function doc_get_state_box($checkedval = 'xzxz', $removedval = array()) {
42 if (count($removedval)) {
43 //TODO: find an easier way to get != ANY($1)
44 $res_states = db_query_params('select * from doc_states where stateid NOT IN (select stateid from doc_states where stateid = ANY($1))', array(db_int_array_to_any_clause($removedval)));
46 $res_states = db_query_params('select * from doc_states', array());
48 return html_build_select_box($res_states, 'stateid', $checkedval, false);
52 * docman_fill_zip - Recursive function to add docgroup and documents inside zip for backup
55 * @param array $nested_groups
56 * @param object $document_factory
57 * @param int $docgroup id : default value = 0
58 * @param string $parent_docname parent name : default value = empty
59 * @return boolean success or not
62 function docman_fill_zip($zip, $nested_groups, $document_factory, $docgroup = 0, $parent_docname = '') {
63 if (is_array(@$nested_groups[$docgroup])) {
64 foreach ($nested_groups[$docgroup] as $dg) {
65 if ($parent_docname != '') {
66 $path = iconv('UTF-8', 'ASCII//TRANSLIT', $parent_docname).'/'.iconv('UTF-8', 'ASCII//TRANSLIT', $dg->getName());
68 $path = iconv('UTF-8', 'ASCII//TRANSLIT', $dg->getName());
71 if (!$zip->addEmptyDir($path)) {
75 $stateidArr = array(1);
77 if (forge_check_perm('docman', $document_factory->Group->getID(), 'approve')) {
78 $stateidArr = array(1, 4, 5);
81 $document_factory->setDocGroupID($dg->getID());
82 $document_factory->setStateID($stateidArr);
83 $document_factory->setDocGroupState($stateIdDg);
84 $docs = $document_factory->getDocuments(1); // no caching
85 if (is_array($docs) && count($docs)) {
86 foreach ($docs as $doc) {
88 if (!$zip->addFromString($path.'/'.iconv('UTF-8', 'ASCII//TRANSLIT', $doc->getFileName()), $doc->getFileData())) {
94 if (!docman_fill_zip($zip, $nested_groups, $document_factory, $dg->getID(), $path)) {