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-2013, 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.
33 function doc_get_state_box($checkedval = 'xzxz', $removedval = '') {
34 if (!empty($removedval)) {
35 $res_states = db_query_params('select * from doc_states where stateid not in ($1)', array($removedval));
37 $res_states = db_query_params('select * from doc_states', array());
39 echo html_build_select_box($res_states, 'stateid', $checkedval, false);
43 * docman_fill_zip - Recursive function to add docgroup and documents inside zip for backup
46 * @param $array nested groups
47 * @param $object documentfactory
48 * @param $int documentgroup id : default value = 0
49 * @param $string documentgroup parent name : default value = empty
50 * @return boolean success or not
53 function docman_fill_zip($zip, $nested_groups, $document_factory, $docgroup = 0, $parent_docname = '') {
54 if (is_array(@$nested_groups[$docgroup])) {
55 foreach ($nested_groups[$docgroup] as $dg) {
56 if (!$zip->addEmptyDir(iconv("UTF-8", "ASCII//TRANSLIT", $parent_docname).'/'.iconv("UTF-8", "ASCII//TRANSLIT", $dg->getName())))
59 $document_factory->setDocGroupID($dg->getID());
60 $docs = $document_factory->getDocuments(1); // no caching
61 if (is_array($docs) && count($docs) > 0) { // this group has documents
62 foreach ($docs as $doc) {
63 if (!$zip->addFromString(iconv("UTF-8", "ASCII//TRANSLIT", $parent_docname).'/'.iconv("UTF-8", "ASCII//TRANSLIT", $dg->getName()).'/'.iconv("UTF-8", "ASCII//TRANSLIT", $doc->getFileName()), $doc->getFileData()))
67 if (!docman_fill_zip($zip, $nested_groups, $document_factory, $dg->getID(), iconv("UTF-8", "ASCII//TRANSLIT", $parent_docname).'/'.iconv("UTF-8", "ASCII//TRANSLIT", $dg->getName()))) {
75 function docman_recursive_stateid($docgroup, $nested_groups, $nested_docs, $stateid = 2) {
76 $localdocgroup_arr = array();
77 $localdocgroup_arr[] = $docgroup;
78 if (is_array(@$nested_groups[$docgroup])) {
79 foreach ($nested_groups[$docgroup] as $dg) {
80 $dg->setStateID($stateid);
81 $localdocgroup_arr[] = $dg->getID();
84 foreach ($localdocgroup_arr as $docgroup_id) {
85 if (isset($nested_docs[$docgroup_id]) && is_array($nested_docs[$docgroup_id])) {
86 foreach ($nested_docs[$docgroup_id] as $d) {
87 $d->setState($stateid);