Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / document.send.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,61 ko)

1
<?php
2
/*
3
 * @version $Id: document.send.php 7763 2009-01-06 18:44:50Z moyo $
4
 -------------------------------------------------------------------------
5
 GLPI - Gestionnaire Libre de Parc Informatique
6
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
7

8
 http://indepnet.net/   http://glpi-project.org
9
 -------------------------------------------------------------------------
10

11
 LICENSE
12

13
 This file is part of GLPI.
14

15
 GLPI is free software; you can redistribute it and/or modify
16
 it under the terms of the GNU General Public License as published by
17
 the Free Software Foundation; either version 2 of the License, or
18
 (at your option) any later version.
19

20
 GLPI is distributed in the hope that it will be useful,
21
 but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 GNU General Public License for more details.
24

25
 You should have received a copy of the GNU General Public License
26
 along with GLPI; if not, write to the Free Software
27
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 --------------------------------------------------------------------------
29
 */
30

    
31
// ----------------------------------------------------------------------
32
// Original Author of file: Julien Dombre
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36

    
37
$NEEDED_ITEMS=array("document","tracking");
38

    
39
define('GLPI_ROOT', '..');
40
include (GLPI_ROOT . "/inc/includes.php");
41

    
42
if ($CFG_GLPI["public_faq"] == 0)
43
checkLoginUser();
44

    
45
if (isset($_GET["file"])){
46

    
47
        $splitter=split("/",$_GET["file"]);
48

    
49
        if (count($splitter)==2){
50
                $send=false;
51

    
52
                if ($splitter[0]=="_dumps"&&haveRight("backup","w")) $send=true;
53

    
54
                if (!$send){
55
                        $doc=new Document;
56
                        $founded=$doc->getFromDBbyFilename($_GET["file"]);
57

    
58
                        if ($founded){
59

    
60

    
61
                                if (isset($_SESSION["glpiactiveprofile"]["interface"])&&$_SESSION["glpiactiveprofile"]["interface"]=="central"){
62
                                        // My doc Check and Common doc right access
63
                                        if (haveRight("document","r")
64
                                                        ||$doc->fields["FK_users"]==$_SESSION["glpiID"])
65
                                                $send=true;
66

    
67
                                        // Knowbase Case
68
                                        if (!$send&&haveRight("knowbase","r")){
69
                                                $query = "SELECT * FROM glpi_doc_device WHERE glpi_doc_device.device_type = '".KNOWBASE_TYPE."' AND glpi_doc_device.FK_doc='".$doc->fields["ID"]."'";
70

    
71
                                                $result=$DB->query($query);
72
                                                if ($DB->numrows($result)>0)
73
                                                        $send=true;
74
                                        }
75
                                        if (!$send&&haveRight("faq","r")){
76
                                                $query = "SELECT * FROM glpi_doc_device LEFT JOIN glpi_kbitems ON (glpi_kbitems.ID = glpi_doc_device.Fk_device) WHERE glpi_doc_device.device_type = '".KNOWBASE_TYPE."' AND glpi_doc_device.FK_doc='".$doc->fields["ID"]."' AND glpi_kbitems.faq='1'";
77

    
78
                                                $result=$DB->query($query);
79
                                                if ($DB->numrows($result)>0)
80
                                                        $send=true;
81
                                        }
82

    
83

    
84
                                        // Tracking Case
85
                                        if (!$send&&isset($_GET["tracking"])){
86
                                                $job=new Job;
87
                                                $job->getFromDB($_GET["tracking"]);
88

    
89
                                                if ($job->fields["author"]==$_SESSION["glpiID"]||$job->fields["assign"]==$_SESSION["glpiID"]){
90
                                                        $query = "SELECT * FROM glpi_doc_device WHERE glpi_doc_device.FK_device = '".$_GET["tracking"]."' AND glpi_doc_device.device_type = '".TRACKING_TYPE."' AND FK_doc='".$doc->fields["ID"]."'";
91
                                                        $result=$DB->query($query);
92
                                                        if ($DB->numrows($result)>0)
93
                                                                $send=true;
94
                                                }
95
                                        }
96
                                } else {
97

    
98
                                        // Check if it is my doc
99
                                        if (isset($_SESSION["glpiID"])&&$doc->fields["FK_users"]==$_SESSION["glpiID"]){
100
                                                $send=true;
101
                                        } else {
102
                                                if (haveRight("faq","r")||$CFG_GLPI["public_faq"]){
103
                                                        // Check if it is a FAQ document
104
                                                        $query = "SELECT * FROM glpi_doc_device LEFT JOIN glpi_kbitems ON (glpi_kbitems.ID = glpi_doc_device.Fk_device) WHERE glpi_doc_device.device_type = '".KNOWBASE_TYPE."' AND glpi_doc_device.FK_doc='".$doc->fields["ID"]."' AND glpi_kbitems.faq='1'";
105

    
106
                                                        $result=$DB->query($query);
107
                                                        if ($DB->numrows($result)>0)
108
                                                                $send=true;
109
                                                }
110

    
111
                                                // Tracking Case
112
                                                if (!$send&&isset($_GET["tracking"])){
113
                                                        $job=new Job;
114
                                                        $job->getFromDB($_GET["tracking"]);
115

    
116
                                                        if ($job->fields["author"]==$_SESSION["glpiID"]){
117
                                                                $query = "SELECT * FROM glpi_doc_device WHERE glpi_doc_device.FK_device = '".$_GET["tracking"]."' AND glpi_doc_device.device_type = '".TRACKING_TYPE."' AND FK_doc='".$doc->fields["ID"]."'";
118
                                                                $result=$DB->query($query);
119
                                                                if ($DB->numrows($result)>0)
120
                                                                        $send=true;
121
                                                        }
122
                                                }
123

    
124
                                        }
125
                                }
126
                        } else echo $LANG["document"][43];
127
                }
128

    
129

    
130
                if ($send&&file_exists(GLPI_DOC_DIR."/".$_GET["file"]))
131
                        sendFile(GLPI_DOC_DIR."/".$_GET["file"],$splitter[1]);
132
                else echo $LANG["document"][45];
133
        } else echo $LANG["document"][44];
134
}
135

    
136

    
137

    
138
?>
Redmine Appliance - Powered by TurnKey Linux