stringcriteria.class.php
1 |
<?php
|
---|---|
2 |
/*
|
3 |
----------------------------------------------------------------------
|
4 |
GLPI - Gestionnaire Libre de Parc Informatique
|
5 |
Copyright (C) 2003-2008 by the INDEPNET Development Team.
|
6 |
|
7 |
http://indepnet.net/ http://glpi-project.org/
|
8 |
----------------------------------------------------------------------
|
9 |
|
10 |
LICENSE
|
11 |
|
12 |
This file is part of GLPI.
|
13 |
|
14 |
GLPI is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License as published by
|
16 |
the Free Software Foundation; either version 2 of the License, or
|
17 |
(at your option) any later version.
|
18 |
|
19 |
GLPI 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.
|
23 |
|
24 |
You should have received a copy of the GNU General Public License
|
25 |
along with GLPI; if not, write to the Free Software
|
26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
27 |
------------------------------------------------------------------------
|
28 |
*/
|
29 |
|
30 |
// ----------------------------------------------------------------------
|
31 |
// Original Author of file:
|
32 |
// Purpose of file:
|
33 |
// ----------------------------------------------------------------------
|
34 |
|
35 |
class StringCriteria extends PluginReportsAutoCriteria |
36 |
{ |
37 |
function __construct($report, $name, $label = '') |
38 |
{ |
39 |
parent :: __construct($report, $name); |
40 |
$this->addCriteriaLabel($name, $label); |
41 |
} |
42 |
|
43 |
/**
|
44 |
* Set default criteria value to '' and entity restriction to current entity only
|
45 |
*/
|
46 |
public function setDefaultValues() |
47 |
{ |
48 |
$this->addParameter($this->getName(), ''); |
49 |
$this->setEntityRestriction($_SESSION["glpiactive_entity"]); |
50 |
$this->setDisplayComments();
|
51 |
} |
52 |
|
53 |
/**
|
54 |
* Display criteria in the criteria's selection form
|
55 |
*/
|
56 |
public function displayCriteria() |
57 |
{ |
58 |
global $LANG; |
59 |
|
60 |
$this->getReport()->startColumn();
|
61 |
echo $this->getCriteriaLabel(); |
62 |
$this->getReport()->endColumn();
|
63 |
|
64 |
$this->getReport()->startColumn();
|
65 |
$this->displayStringCriteria();
|
66 |
$this->getReport()->endColumn();
|
67 |
} |
68 |
|
69 |
/**
|
70 |
* Show dropdown comments (enable by defaults)
|
71 |
*/
|
72 |
public function setDisplayComments() |
73 |
{ |
74 |
$this->displayComments = true; |
75 |
} |
76 |
|
77 |
/**
|
78 |
* Hide dropdown comments
|
79 |
*/
|
80 |
public function setNoDisplayComments() |
81 |
{ |
82 |
$this->displayComments = false; |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Get display comments status
|
87 |
*/
|
88 |
public function getDisplayComments() |
89 |
{ |
90 |
return $this->displayComments; |
91 |
} |
92 |
|
93 |
/**
|
94 |
* Change entity restriction
|
95 |
* Values are :
|
96 |
* REPORTS_NO_ENTITY_RESTRICTION : no entity restriction (everything is displayed)
|
97 |
* REPORTS_CURRENT_ENTITY : only values from the current entity
|
98 |
* REPORTS_SUB_ENTITIES : values from the current entity + sub-entities
|
99 |
*/
|
100 |
public function setEntityRestriction($restriction) |
101 |
{ |
102 |
global $CFG_GLPI; |
103 |
switch ($restriction) { |
104 |
case REPORTS_NO_ENTITY_RESTRICTION : |
105 |
$this->entity_restrict = -1; |
106 |
break;
|
107 |
case REPORTS_CURRENT_ENTITY : |
108 |
$this->entity_restrict = $_SESSION["glpiactive_entity"]; |
109 |
break;
|
110 |
case REPORTS_SUB_ENTITIES : |
111 |
$this->entity_restrict = getEntitySons($_SESSION["glpiactive_entity"]); |
112 |
break;
|
113 |
} |
114 |
} |
115 |
|
116 |
/**
|
117 |
* Display input
|
118 |
*/
|
119 |
public function displayStringCriteria() |
120 |
{ |
121 |
echo "<input type='text' name='".$this->getName()."' />"; |
122 |
} |
123 |
|
124 |
public function getSqlCriteriasRestriction($link = 'AND') |
125 |
{ |
126 |
return $link . " " . $this->getSqlField() . " = '" . $this->getParameterValue() . "' "; |
127 |
} |
128 |
} |
129 |
|
130 |
?>
|