ryxeo-glpi-git / htdocs / inc / knowbase.class.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (7 ko)
1 | 1c14bcc4 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: knowbase.class.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:
|
||
33 | // Purpose of file:
|
||
34 | // ----------------------------------------------------------------------
|
||
35 | |||
36 | if (!defined('GLPI_ROOT')){ |
||
37 | die("Sorry. You can't access directly to this file"); |
||
38 | } |
||
39 | |||
40 | // CLASSE knowledgebase
|
||
41 | |||
42 | class kbitem extends CommonDBTM { |
||
43 | |||
44 | /**
|
||
45 | * Constructor
|
||
46 | **/
|
||
47 | function kbitem () { |
||
48 | $this->table="glpi_kbitems"; |
||
49 | $this->type=KNOWBASE_TYPE; |
||
50 | $this->entity_assign=true; |
||
51 | $this->may_be_recursive=true; |
||
52 | } |
||
53 | |||
54 | /**
|
||
55 | * Actions done at the end of the getEmpty function
|
||
56 | *
|
||
57 | *@return nothing
|
||
58 | *
|
||
59 | **/
|
||
60 | function post_getEmpty () { |
||
61 | if (haveRight("faq","w") && !haveRight("knowbase","w")) { |
||
62 | $this->fields["faq"]=1; |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /**
|
||
67 | * Have I the right to "create" the Object
|
||
68 | *
|
||
69 | * overloaded function of CommonDBTM
|
||
70 | *
|
||
71 | * @return booleen
|
||
72 | **/
|
||
73 | function canCreate () { |
||
74 | return (haveRight("faq", "w") || haveRight("knowbase", "w")); |
||
75 | } |
||
76 | |||
77 | function prepareInputForAdd($input) { |
||
78 | |||
79 | global $LANG; |
||
80 | // set new date.
|
||
81 | $input["date"] = $_SESSION["glpi_currenttime"]; |
||
82 | // set author
|
||
83 | |||
84 | // set title for question if empty
|
||
85 | if(empty($input["question"])) $input["question"]=$LANG["common"][30]; |
||
86 | |||
87 | if (haveRight("faq","w")&&!haveRight("knowbase","w")) $input["faq"]=1; |
||
88 | if (!haveRight("faq","w")&&haveRight("knowbase","w")) $input["faq"]=0; |
||
89 | |||
90 | return $input; |
||
91 | } |
||
92 | |||
93 | |||
94 | function prepareInputForUpdate($input) { |
||
95 | global $LANG; |
||
96 | // set title for question if empty
|
||
97 | if(empty($input["question"])) $input["question"]=$LANG["common"][30]; |
||
98 | |||
99 | return $input; |
||
100 | } |
||
101 | |||
102 | |||
103 | /**
|
||
104 | * Print out an HTML "<form>" for knowbase item
|
||
105 | *
|
||
106 | *
|
||
107 | *
|
||
108 | *
|
||
109 | * @param $target
|
||
110 | * @param $ID
|
||
111 | * @return nothing (display the form)
|
||
112 | **/
|
||
113 | function showForm($target,$ID){ |
||
114 | |||
115 | // show kb item form
|
||
116 | |||
117 | global $LANG,$CFG_GLPI; |
||
118 | if (!haveRight("knowbase","w")&&!haveRight("faq","w")) return false; |
||
119 | |||
120 | $spotted = false; |
||
121 | if ($ID>0) { |
||
122 | if($this->can($ID,'r')) { |
||
123 | $spotted = true; |
||
124 | } |
||
125 | } else {
|
||
126 | $use_cache=false; |
||
127 | if ($this->getEmpty() && $this->can(-1,'w')){ |
||
128 | $spotted = true; |
||
129 | } |
||
130 | } |
||
131 | |||
132 | $canedit=$this->can($ID,'w'); |
||
133 | $canrecu=$this->can($ID,'recursive'); |
||
134 | |||
135 | if($canedit) { |
||
136 | |||
137 | echo "<div id='contenukb'>"; |
||
138 | |||
139 | echo "<script type=\"text/javascript\" src=\"".$CFG_GLPI["root_doc"]."/lib/tiny_mce/tiny_mce.js\"></script>"; |
||
140 | echo "<script language=\"javascript\" type=\"text/javascript\">"; |
||
141 | echo "tinyMCE.init({ |
||
142 | language : \"".$CFG_GLPI["languages"][$_SESSION["glpilanguage"]][3]."\", |
||
143 | mode : \"exact\",
|
||
144 | elements: \"answer\",
|
||
145 | plugins : \"table\",
|
||
146 | theme : \"advanced\",
|
||
147 | entity_encoding : \"numeric\",
|
||
148 | theme_advanced_toolbar_location : \"top\",
|
||
149 | theme_advanced_toolbar_align : \"left\",
|
||
150 | theme_advanced_buttons1 : \"bold,italic,underline,strikethrough,fontsizeselect,formatselect,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent\",
|
||
151 | theme_advanced_buttons2 : \"forecolor,backcolor,separator,hr,separator,link,unlink,anchor,separator,tablecontrols,undo,redo,cleanup,code,separator\",
|
||
152 | theme_advanced_buttons3 : \"\"});";
|
||
153 | echo "</script>"; |
||
154 | |||
155 | echo "<form method='post' id='form_kb' name='form_kb' action=\"$target\">"; |
||
156 | |||
157 | |||
158 | if (!empty($ID)) { |
||
159 | echo "<input type='hidden' name='ID' value=\"$ID\">\n"; |
||
160 | } |
||
161 | |||
162 | |||
163 | echo "<fieldset>"; |
||
164 | echo "<legend>".$LANG["knowbase"][13]."</legend>"; |
||
165 | echo "<div class='center'>".$LANG["knowbase"][6]; |
||
166 | dropdownValue("glpi_dropdown_kbcategories","categoryID",$this->fields["categoryID"]); |
||
167 | echo "</div></fieldset>"; |
||
168 | |||
169 | echo "<fieldset>"; |
||
170 | echo "<legend>".$LANG["knowbase"][14]."</legend>"; |
||
171 | echo "<div class='center'><textarea cols='80' rows='2' name='question' >".$this->fields["question"]."</textarea></div>"; |
||
172 | echo "</fieldset>"; |
||
173 | |||
174 | |||
175 | echo "<fieldset>"; |
||
176 | echo "<legend>".$LANG["knowbase"][15]."</legend><div class='center'>"; |
||
177 | echo "<textarea cols='80' rows='30' id='answer' name='answer' >".$this->fields["answer"]."</textarea></div>"; |
||
178 | |||
179 | echo "</fieldset>"; |
||
180 | |||
181 | |||
182 | echo "<br>\n"; |
||
183 | |||
184 | if (!empty($ID)) { |
||
185 | echo "<fieldset>"; |
||
186 | echo "<div class='baskb'>"; |
||
187 | if ($this->fields["author"]){ |
||
188 | echo $LANG["common"][37]." : ".getUserName($this->fields["author"],"1")." "; |
||
189 | } |
||
190 | |||
191 | |||
192 | |||
193 | echo "<span class='baskb_right' >"; |
||
194 | if ($this->fields["date_mod"]){ |
||
195 | echo $LANG["common"][26]." : ".convDateTime($this->fields["date_mod"])." "; |
||
196 | } |
||
197 | echo "</span><br />"; |
||
198 | |||
199 | if ($this->fields["date"]){ |
||
200 | echo $LANG["common"][27]." : ". convDateTime($this->fields["date"]); |
||
201 | } |
||
202 | |||
203 | echo "<span class='baskb_right'>"; |
||
204 | echo $LANG["knowbase"][26]." : ".$this->fields["view"]."</span></div>"; |
||
205 | |||
206 | |||
207 | echo "</fieldset>"; |
||
208 | } |
||
209 | echo "<p class='center'>"; |
||
210 | |||
211 | if (isMultiEntitiesMode()){
|
||
212 | echo $LANG["entity"][0].": "; |
||
213 | dropdownValue("glpi_entities", "FK_entities", $this->fields["FK_entities"],0); |
||
214 | |||
215 | echo " ".$LANG["entity"][9].": "; |
||
216 | if ($canrecu) { |
||
217 | dropdownYesNo("recursive",$this->fields["recursive"]); |
||
218 | } else {
|
||
219 | echo getYesNo($this->fields["recursive"]); |
||
220 | } |
||
221 | } |
||
222 | |||
223 | echo "<br /><br />" . $LANG["knowbase"][5].": "; |
||
224 | if (haveRight("faq","w")&&haveRight("knowbase","w")){ |
||
225 | dropdownYesNo('faq',$this->fields["faq"]); |
||
226 | } else {
|
||
227 | echo getYesNo($this->fields["faq"]); |
||
228 | } |
||
229 | echo "<br /><br />\n"; |
||
230 | |||
231 | if ($ID>0) { |
||
232 | echo "<input type='submit' class='submit' name='update' value=\"".$LANG["buttons"][7]."\"> <input type='reset' class='submit' value=\"".$LANG["buttons"][16]."\">"; |
||
233 | } else {
|
||
234 | echo "<input type='hidden' name='author' value=\"".$_SESSION['glpiID']."\">\n"; |
||
235 | echo "<input type='submit' class='submit' name='add' value=\"".$LANG["buttons"][8]."\"> <input type='reset' class='submit' value=\"".$LANG["buttons"][16]."\">"; |
||
236 | } |
||
237 | |||
238 | echo "</p>"; |
||
239 | echo "</form>"; |
||
240 | |||
241 | echo "</div>"; |
||
242 | return true; |
||
243 | |||
244 | } else { // Cannot edit |
||
245 | return false; |
||
246 | } |
||
247 | } // function showForm
|
||
248 | |||
249 | |||
250 | } // class kbitem
|
||
251 | |||
252 | ?> |