3 * FusionForge Documentation Manager
5 * Copyright 2012, Franck Villaume - TrivialDev
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 /* please do not add require here : use www/docman/index.php to add require */
25 /* global variables used */
26 global $dirid; //id of doc_group
27 global $group_id; // id of group
29 $sysdebug_enable = false;
31 $urlparam = '/docman/?group_id='.$group_id;
32 if (isset($childgroup_id) && $childgroup_id) {
33 $g = group_get_object($childgroup_id);
34 $urlparam .= '&childgroup_id='.$childgroup_id;
37 $doc_group = getIntFromRequest('doc_group');
38 $fromview = getStringFromRequest('fromview');
41 case 'listrashfile': {
42 $urlparam .= '&view='.$fromview;
46 $urlparam .= '&view=listfile&dirid='.$doc_group;
51 if (!forge_check_perm('docman', $group_id, 'approve')) {
52 $return_msg = _('Document Manager Action Denied.');
53 session_redirect($urlparam.'&warning_msg='.urlencode($return_msg));
56 $fileid = getIntFromRequest('fileid');
57 $childgroup_id = getIntFromRequest('childgroup_id');
58 $details = getIntFromRequest('details');
60 $g = group_get_object($childgroup_id);
62 $d = new Document($g, $fileid);
64 session_redirect($urlparam.'&error_msg='.urlencode($d->getErrorMessage()));
68 $filearray["name"] = $d->getFileName();
69 $filearray["type"] = $d->getFileType();
70 $filearray["title"] = $d->getName();
71 $filearray["description"] = $d->getDescription();
72 $filearray["stateid"] = $d->getStateID();
73 $filearray["docgroupid"] = $d->getDocGroupID();
74 $filearray["isurl"] = $d->isURL();
76 $filearray["body"] = $d->getFileData();
77 echo json_encode($filearray);