Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / knowbase.function.php @ b67d8923

Historique | Voir | Annoter | Télécharger (18,1 ko)

1
<?php
2
/*
3
 * @version $Id: knowbase.function.php 7882 2009-01-23 18:24:05Z 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

    
41
// FUNCTIONS knowledgebase
42

    
43

    
44

    
45
/**
46
 * Print out an HTML "<form>" for Search knowbase item
47
 *
48
 * @param $target where to go
49
 * @param $contains search pattern
50
 * @param $parentID category ID
51
 * @param $faq display on faq ?
52
 * @return nothing (display the form)
53
 **/
54
function searchFormKnowbase($target,$contains,$parentID=0,$faq=0){
55
        global $LANG,$CFG_GLPI;
56
        
57
        if ($CFG_GLPI["public_faq"] == 0&&!haveRight("knowbase","r")&&!haveRight("faq","r")) return false;
58
        
59
        echo "<div>";
60
        echo "<table class='center-h'><tr><td>";
61
        
62
        
63
        echo "<form method=get action=\"".$target."\">";
64
        echo "<table border='0' class='tab_cadre'>";
65

    
66
        echo "<tr ><th colspan='2'>".$LANG["search"][0].":</th></tr>";
67
        echo "<tr class='tab_bg_2' align='center'><td><input type='text' size='30' name=\"contains\" value=\"". stripslashes($contains) ."\" ></td>";
68
        
69
        echo "<td><input type='submit' value=\"".$LANG["buttons"][0]."\" class='submit' ></td></tr>";
70

    
71
        echo "</table></form>";
72
        
73
        echo "</td>";
74
        
75
        // Category select not for anonymous FAQ
76
        if (isset($_SESSION["glpiID"])&&!$faq){
77
                echo "<td><form method=get action=\"".$target."\">";
78
                echo "<table border='0' class='tab_cadre'>";
79
                echo "<tr ><th colspan='2'>".$LANG["buttons"][43]."</th></tr>";
80
                echo "<tr class='tab_bg_2'><td class='center'>";
81
                echo $LANG["common"][36]." : &nbsp; &nbsp;";
82
                dropdownValue("glpi_dropdown_kbcategories","parentID",$parentID);
83
                // ----***** TODO Dropdown qui affiche uniquement les categories contenant une FAQ
84
                
85
                echo "</td><td><input type='submit' value=\"".$LANG["buttons"][2]."\" class='submit' ></td></tr>";
86
        
87
                echo "</table></form></td>";
88
        } 
89
        
90
        echo "</tr></table></div>";
91

    
92

    
93
}
94

    
95

    
96

    
97

    
98
/**
99
 * Show KB categories
100
 *
101
 * @param $target where to go
102
 * @param $parentID category ID
103
 * @param $faq display on faq ?
104
 * @return nothing (display the form)
105
 **/
106
function showKbCategoriesFirstLevel($target,$parentID=0,$faq=0){
107

    
108
        global $DB,$LANG,$CFG_GLPI;
109
        
110
        if($faq){
111
                if ($CFG_GLPI["public_faq"] == 0 && !haveRight("faq","r")) return false;        
112
                
113
                // Get All FAQ categories
114
                if (!isset($_SESSION['glpi_faqcategories'])){
115
                        $_SESSION['glpi_faqcategories']=array();
116
                        $query="SELECT DISTINCT categoryID FROM glpi_kbitems WHERE (glpi_kbitems.faq = '1')";
117
                        if ($result=$DB->query($query)){
118
                                if ($DB->numrows($result)){
119
                                        while ($data=$DB->fetch_array($result)){
120
                                                if (!in_array($data['categoryID'],$_SESSION['glpi_faqcategories'])){
121
                                                        $_SESSION['glpi_faqcategories'][]=$data['categoryID'];
122
                                                        $_SESSION['glpi_faqcategories']=array_merge($_SESSION['glpi_faqcategories'],getAncestorsOfTreeItem('glpi_dropdown_kbcategories',$data['categoryID']));
123
                                                }
124
                                        }
125
                                }
126
                                if (count($_SESSION['glpi_faqcategories'])){
127
                                        $tmp='(';
128
                                        $first=true;
129
                                        foreach ($_SESSION['glpi_faqcategories'] as $key => $val){
130
                                                if ($first) $first=false;
131
                                                else $tmp.=',';
132
                                                $tmp.=$val;
133
                                        }
134
                                        $tmp.=')';
135
                                        $_SESSION['glpi_faqcategories']=$tmp;
136
                                }
137

    
138
                        }
139
                        
140
                }
141
                $query = "SELECT DISTINCT glpi_dropdown_kbcategories.* FROM glpi_dropdown_kbcategories WHERE ID IN ".$_SESSION['glpi_faqcategories']." AND  (glpi_dropdown_kbcategories.parentID = '$parentID') ORDER  BY name ASC";
142
        }else{
143
                if (!haveRight("knowbase","r")) return false;
144
                $query = "SELECT * FROM glpi_dropdown_kbcategories WHERE  (glpi_dropdown_kbcategories.parentID = '$parentID') ORDER  BY name ASC";
145
        }
146

    
147
        /// Show category
148
        if ($result=$DB->query($query)){
149
                echo "<table class='tab_cadre_central'  >";
150
                echo "<tr><td colspan='3'><a  href=\"".$target."\"><img alt='' src='".$CFG_GLPI["root_doc"]."/pics/folder-open.png'  class='bottom'></a>";
151

    
152
                // Display Category
153
                if ($parentID!=0){
154
                        $tmpID=$parentID;
155
                        $todisplay="";
156
                        while ($tmpID!=0){
157
                                $query2="SELECT * FROM glpi_dropdown_kbcategories WHERE ID='$tmpID'";
158
                                $result2=$DB->query($query2);
159
                                if ($DB->numrows($result2)==1){        
160
                                        $data=$DB->fetch_assoc($result2);
161
                                        $tmpID=$data["parentID"];
162
                                        $todisplay="<a href='$target?parentID=".$data["ID"]."'>".$data["name"]."</a>".(empty($todisplay)?"":" > ").$todisplay;
163
                                } else $tmpID=0;
164
//                                echo getDropdownName("glpi_dropdown_kbcategories",$parentID,"")."</td></tr>";
165
                        }
166
                        echo " > ".$todisplay;
167
                }
168
                
169
                if ($DB->numrows($result)>0){
170
                        
171
                        
172
                                $i=0;
173
                        while ($row=$DB->fetch_array($result)){
174
                                        // on affiche les résultats sur trois colonnes
175
                                        if ($i%3==0) { echo "<tr>";}
176
                                        $ID = $row["ID"];
177
                                        echo "<td class='tdkb_result'>";
178
                                
179
                                        echo "<img alt='' src='".$CFG_GLPI["root_doc"]."/pics/folder.png'  hspace=\"5\" > <strong><a  href=\"".$target."?parentID=".$row["ID"]."\">".$row["name"]."</a></strong>\n";
180
                                        echo "<div class='kb_resume'>".resume_text($row['comments'],60)."</div>";
181
                        
182
                                if($i%3==2) { echo "</tr>\n"; }
183
                                
184
                                $i++;
185
                        }
186
                        
187
                }
188
        echo "<tr><td colspan='3'>&nbsp;</td></tr></table><br>";
189

    
190
        } 
191

    
192
}
193

    
194

    
195

    
196
/**
197
*Print out list kb item
198
*
199
* @param $target where to go
200
* @param $contains search pattern
201
* @param $start where to start
202
* @param $parentID category ID
203
* @param $faq display on faq ?
204
**/
205
function showKbItemList($target,$contains,$start,$parentID,$faq=0){
206
        // Lists kb  Items
207

    
208
        global $DB,$CFG_GLPI, $LANG;
209
        
210
        
211
        
212
        $where="";
213

    
214
        // Build query
215
        if (isset($_SESSION["glpiID"])){
216
                $where = getEntitiesRestrictRequest("", "glpi_kbitems", "", "", true) . " AND "; 
217
        } else {
218
                // Anonymous access
219
                if (isMultiEntitiesMode()){
220
                        $where = "(glpi_kbitems.FK_entities=0 AND glpi_kbitems.recursive=1) AND ";
221
                }
222
        }        
223

    
224
        if ($faq){ // helpdesk
225
                $where .= " (glpi_kbitems.faq = '1') AND ";
226
        }
227
        
228
        
229
        if (strlen($contains)) { // il s'agit d'une recherche 
230
                $search=unclean_cross_side_scripting_deep($contains);
231
                $where.="MATCH(glpi_kbitems.question,glpi_kbitems.answer) AGAINST('$search' IN BOOLEAN MODE) ";
232
                
233
        } else { // Il ne s'agit pas d'une recherche, on browse by category
234
        
235
                $where.="(glpi_kbitems.categoryID = '$parentID') ";
236
        }
237
        
238
        
239
        if (!$start) {
240
                $start = 0;
241
        }
242

    
243
        $query = "SELECT  *  FROM glpi_kbitems";
244
  // $query.= " LEFT JOIN glpi_users  ON (glpi_users.ID = glpi_kbitems.author) ";
245
        $query.=" WHERE $where ORDER BY glpi_kbitems.question ASC";
246
        //echo $query;
247
        
248

    
249
        // Get it from database        
250
        if ($result = $DB->query($query)) {
251
                $numrows =  $DB->numrows($result);
252

    
253
                // Limit the result, if no limit applies, use prior result
254
                if ($numrows > $_SESSION["glpilist_limit"]&&!isset($_GET['export_all'])) {
255
                        $query_limit = $query ." LIMIT ".intval($start).",".intval($_SESSION["glpilist_limit"])." ";
256
                        $result_limit = $DB->query($query_limit);
257
                        $numrows_limit = $DB->numrows($result_limit);
258
                } else {
259
                        $numrows_limit = $numrows;
260
                        $result_limit = $result;
261
                }
262

    
263
                if ($numrows_limit>0) {
264

    
265
                        // Set display type for export if define
266
                        $output_type=HTML_OUTPUT;
267
                        if (isset($_GET["display_type"]))
268
                                $output_type=$_GET["display_type"];
269

    
270
                        // Pager
271
                        $parameters="start=$start&amp;parentID=$parentID&amp;contains=$contains&amp;faq=$faq";
272
                        if ($output_type==HTML_OUTPUT){
273
                                printPager($start,$numrows,$_SERVER['PHP_SELF'],$parameters,KNOWBASE_TYPE);
274
                        }
275

    
276
                        $nbcols=1;
277
                        // Display List Header
278
                        echo displaySearchHeader($output_type,$numrows_limit+1,$nbcols);
279

    
280
                        if ($output_type!=HTML_OUTPUT){
281
                                $header_num=1;
282
                                echo displaySearchHeaderItem($output_type,$LANG["knowbase"][3],$header_num);
283
                                echo displaySearchHeaderItem($output_type,$LANG["knowbase"][4],$header_num);
284
                        }
285

    
286
                        // Num of the row (1=header_line)
287
                        $row_num=1;
288
                        for ($i=0; $i < $numrows_limit; $i++) {
289
                                $data=$DB->fetch_array($result_limit);
290

    
291
                                // Column num
292
                                $item_num=1;
293
                                $row_num++;
294

    
295
                                echo displaySearchNewLine($output_type,$i%2);
296

    
297
                                if ($output_type==HTML_OUTPUT){
298
                                        echo displaySearchItem($output_type,"<div class='kb'><a ".($data['faq']?" class='pubfaq' ":" class='knowbase' ")." href=\"".$target."?ID=".$data["ID"]."\">".resume_text($data["question"],80)."</a></div><div class='kb_resume'>".resume_text(html_clean(unclean_cross_side_scripting_deep($data["answer"])),600)."</div>",$item_num,$row_num);
299
                                } else {
300
                                        echo displaySearchItem($output_type,$data["question"],$item_num,$row_num);
301
                                        echo displaySearchItem($output_type,html_clean(unclean_cross_side_scripting_deep(utf8_html_entity_decode($data["answer"]))),$item_num,$row_num);
302
                                }
303
                                // le cumul de fonction me plait pas TODO à optimiser.
304
                                
305
                                                
306

    
307
                                // End Line
308
                                echo displaySearchEndLine($output_type);
309
                        }
310

    
311
                        // Display footer
312
                        if ($output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){
313
                                echo displaySearchFooter($output_type,getDropdownName("glpi_dropdown_kbcategories",$parentID));
314
                        } else {
315
                                echo displaySearchFooter($output_type);
316
                        }
317
                        echo "<br>";
318
                        if ($output_type==HTML_OUTPUT) {
319
                                printPager($start,$numrows,$_SERVER['PHP_SELF'],$parameters,KNOWBASE_TYPE);
320
                        }
321

    
322
                } else {
323
                        if ($parentID!=0) {echo "<div class='center'><strong>".$LANG["search"][15]."</strong></div>";}
324
                }
325
        }
326

    
327
}
328

    
329

    
330

    
331
/**
332
 * Print out lists of recent and popular kb/faq
333
 *
334
 * @param $target where to go on action
335
 * @param $faq display only faq
336
 * @return nothing (display table)
337
 **/
338
function showKbViewGlobal($target,$faq=0){
339
        
340
        echo "<div>";
341
        echo "<table class='center-h' width='950px'><tr><td align='center' valign='middle'>";
342
                        
343
        showKbRecentPopular($target,"recent",$faq);
344
                
345
        echo "</td><td align='center' valign='middle'>";
346
                
347
        showKbRecentPopular($target,"popular",$faq);
348
                
349
        echo "</td></tr>";
350
                                
351
        echo "</table>";
352
        echo "</div>";
353
}
354
/**
355
 * Print out list recent or popular kb/faq
356
 *
357
 * @param $target where to go on action
358
 * @param $type type : recent / popular
359
 * @param $faq display only faq
360
 * @return nothing (display table)
361
 **/
362
function showKbRecentPopular($target,$type,$faq=0){
363
        
364
        global $DB,$CFG_GLPI, $LANG;
365
        
366
        
367
        if ($type=="recent"){
368
                $orderby="ORDER BY date DESC";
369
                $title=$LANG["knowbase"][29];
370
        }else {
371
                $orderby="ORDER BY view DESC";
372
                $title=$LANG["knowbase"][30];
373
        }
374
                
375
        $faq_limit="";
376
        if (isset($_SESSION["glpiID"])){
377
                $faq_limit .= getEntitiesRestrictRequest(" WHERE ", "glpi_kbitems", "", "", true); 
378
        } else {
379
                // Anonymous access
380
                if (isMultiEntitiesMode()){
381
                        $faq_limit .= " WHERE (glpi_kbitems.FK_entities=0 AND glpi_kbitems.recursive=1)";
382
                } else {
383
                        $faq_limit .= " WHERE 1";
384
                }
385
        }        
386

    
387
        if($faq){ // FAQ
388
                $faq_limit.=" AND (glpi_kbitems.faq = '1')";
389
        } 
390

    
391
        $query = "SELECT  *  FROM glpi_kbitems $faq_limit $orderby";
392
        //echo $query;
393
        $result = $DB->query($query);
394
        $number = $DB->numrows($result);
395

    
396
        if ($number > 0) {
397
                echo "<table class='tab_cadrehov'>";
398

    
399
                echo "<tr><th>".$title."</th></tr>";
400
        
401
                while ($data=$DB->fetch_array($result)) {
402
                        echo "<tr class='tab_bg_2'><td class='left'><a ".($data['faq']?" class='pubfaq' ":" class='knowbase' ")." href=\"".$target."?ID=".$data["ID"]."\">".resume_text($data["question"],80)."</a></td></tr>";
403
                }
404
                echo "</table>";
405
        }
406
}
407
        
408
        
409

    
410

    
411

    
412
/**
413
 * Print out an HTML Menu for knowbase item
414
 *
415
 * @param $ID
416
 * @return nothing (display the form)
417
 **/
418
function kbItemMenu($ID)
419
{
420
        global $LANG, $CFG_GLPI;
421

    
422
        $ki= new kbitem;        
423

    
424
        if (!$ki->can($ID,'r')) {
425
                return false;
426
        }
427

    
428
        $edit=$ki->can($ID,'w');
429
        $isFAQ = $ki->fields["faq"];
430

    
431
        $editFAQ=haveRight("faq","w");
432

    
433
        echo "<table class='tab_cadre_fixe' cellpadding='10' ><tr><th colspan='3'>";
434

    
435
        if($isFAQ) {
436
                echo $LANG["knowbase"][10]."</th></tr>\n";
437
        } else {
438
                echo $LANG["knowbase"][11]."</th></tr>\n";
439
        }
440

    
441
        if ($edit) {
442
                echo "<tr>";
443
                
444
                if ($editFAQ) {
445
                        if($isFAQ) {
446
                                echo "<td align='center' width=\"33%\"><a class='icon_nav_move' href=\"".$CFG_GLPI["root_doc"]."/front/knowbase.form.php?ID=$ID&amp;removefromfaq=yes\"><img  src=\"".$CFG_GLPI["root_doc"]."/pics/faqremove.png\" alt='".$LANG["knowbase"][7]."' title='".$LANG["knowbase"][7]."'></a></td>\n";
447
                        } else {
448
                                echo "<td align='center' width=\"33%\"><a  class='icon_nav_move' href=\"".$CFG_GLPI["root_doc"]."/front/knowbase.form.php?ID=$ID&amp;addtofaq=yes\"><img  src=\"".$CFG_GLPI["root_doc"]."/pics/faqadd.png\" alt='".$LANG["knowbase"][5]."' title='".$LANG["knowbase"][5]."'></a></td>\n";
449
                        }
450
                }
451
                
452
                echo "<td align='center' width=\"34%\"><a class='icon_nav_move' href=\"".$CFG_GLPI["root_doc"]."/front/knowbase.form.php?ID=$ID&amp;modify=yes\"><img  src=\"".$CFG_GLPI["root_doc"]."/pics/faqedit.png\" alt='".$LANG["knowbase"][8]."' title='".$LANG["knowbase"][8]."'></a></td>\n";
453
                echo "<td align='center' width=\"33%\"><a class='icon_nav_move' href=\"javascript:confirmAction('".addslashes($LANG["common"][55])."','".$CFG_GLPI["root_doc"]."/front/knowbase.form.php?ID=$ID&amp;delete=yes')\"><img  src=\"".$CFG_GLPI["root_doc"]."/pics/faqdelete.png\" alt='".$LANG["knowbase"][9]."' title='".$LANG["knowbase"][9]."'></a></td>";
454

    
455
                echo "</tr>\n";
456
        } 
457

    
458
        echo "</table>\n";
459
}
460

    
461

    
462

    
463

    
464
/**
465
 * Print out (html) show item : question and answer
466
 *
467
 * @param $ID integer
468
 * @param $linkauthor display author link
469
 * 
470
 * @return nothing (display item : question and answer)
471
 **/
472
function ShowKbItemFull($ID,$linkauthor=true){
473
        // show item : question and answer
474

    
475
        global $DB,$LANG,$CFG_GLPI;
476

    
477
        if (!haveRight("user","r")) $linkauthor=false;
478
        
479
        $ki= new kbitem;        
480

    
481
        if ($ki->getFromDB($ID)){
482
                if ($ki->fields["faq"]){
483
                        if ($CFG_GLPI["public_faq"] == 0&&!haveRight("faq","r")&&!haveRight("knowbase","r")) return false;        
484
                }
485
                else 
486
                        if (!haveRight("knowbase","r")) return false;        
487
        
488
                //update counter view
489
                $query="UPDATE glpi_kbitems SET view=view+1 WHERE ID = '$ID'";
490
                $DB->query($query);
491
        
492
        
493
        
494
                $categoryID = $ki->fields["categoryID"];
495
                $fullcategoryname = getTreeValueCompleteName("glpi_dropdown_kbcategories",$categoryID);
496
        
497

    
498
                echo "<table class='tab_cadre_fixe' cellpadding='10' ><tr><th colspan='2'>";
499
                
500
                echo $LANG["common"][36].": <a href='".$CFG_GLPI["root_doc"]."/front/".(isset($_SESSION['glpiactiveprofile'])&&$_SESSION['glpiactiveprofile']['interface']=="central"?"knowbase.php":"helpdesk.faq.php")."?parentID=$categoryID'>".$fullcategoryname."</a></th></tr>";
501
        
502
                if (!($CFG_GLPI["cache"]->start($ID."_".$_SESSION["glpilanguage"],"GLPI_".$ki->type))) {
503
                
504
                        echo "<tr class='tab_bg_3'><td class='left' colspan='2'><h2>";
505
                        echo ($ki->fields["faq"]) ? "".$LANG["knowbase"][3]."" : "".$LANG["knowbase"][14]."";
506
                        echo "</h2>";
507
                
508
                        echo $ki->fields["question"];
509
                
510
                        echo "</td></tr>\n";
511
                        echo "<tr  class='tab_bg_3'><td class='left' colspan='2'><h2>";
512
                        echo ($ki->fields["faq"]) ? "".$LANG["knowbase"][4]."" : "".$LANG["knowbase"][15]."";
513
                        echo "</h2>\n";
514
                
515
                        $answer = unclean_cross_side_scripting_deep($ki->fields["answer"]);
516
                
517
                        echo "<div id='kbanswer'>".$answer."</div>";
518
                        echo "</td></tr>";
519
                
520
                        echo "<tr><th class='tdkb'>";
521
                        if($ki->fields["author"]){
522
                                echo $LANG["common"][37]." : ";
523
                                // Integer because true may be 2 and getUserName return array
524
                                if ($linkauthor){
525
                                        $linkauthor=1;
526
                                } else {
527
                                        $linkauthor=0;
528
                                }
529

    
530
                                echo getUserName($ki->fields["author"],$linkauthor);
531

    
532
                                echo "&nbsp;&nbsp;|&nbsp;&nbsp;  ";
533
                        }
534
                        if($ki->fields["date"]){
535
                                echo $LANG["knowbase"][27]." : ". convDateTime($ki->fields["date"]);
536
                        }        
537
                
538
                        echo "</th><th class='tdkb'>";
539
                        if($ki->fields["date_mod"]){
540
                                echo  $LANG["common"][26]." : ".convDateTime($ki->fields["date_mod"])."&nbsp;&nbsp;|&nbsp;&nbsp; ";
541
                        }
542
                        echo $LANG["knowbase"][26]." : ".$ki->fields["view"]."</th></tr>";
543
                
544
                        echo "</table><br>";
545
                        
546
                        $CFG_GLPI["cache"]->end();
547
                }
548
                return true;        
549
        } else return false;
550
}
551

    
552

    
553
//*******************
554
// Gestion de la  FAQ
555
//******************
556

    
557

    
558

    
559
/**
560
 * Add kb item to the public FAQ
561
 *
562
 * 
563
 * @param $ID integer
564
 *
565
 * 
566
 * @return nothing 
567
 **/
568
function KbItemaddtofaq($ID)
569
{
570
        global $DB;
571
        $DB->query("UPDATE glpi_kbitems SET faq='1' WHERE ID='$ID'");
572
}
573

    
574
/**
575
 * Remove kb item from the public FAQ
576
 *
577
 * 
578
 * @param $ID integer
579
 *
580
 * 
581
 * @return nothing 
582
 **/
583
function KbItemremovefromfaq($ID)
584
{
585
        global $DB;
586
        $DB->query("UPDATE glpi_kbitems SET faq='0' WHERE ID='$ID'");
587
}
588

    
589

    
590

    
591
/**
592
 * 
593
 * get FAQ Categories
594
 * 
595
 * 
596
 *
597
 * 
598
 * @return $catNumbers
599
 **/
600
/* NOT_USED
601
function getFAQCategories()
602
{
603

604
        global $DB;        
605

606
        $query = "SELECT DISTINCT glpi_dropdown_kbcategories.* FROM glpi_kbitems LEFT JOIN glpi_dropdown_kbcategories ON (glpi_kbitems.categoryID = glpi_dropdown_kbcategories.ID) WHERE (glpi_kbitems.faq = '1')";
607
        $toprocess=array();
608
        $catNumbers = array();
609

610
        if ($result=$DB->query($query)){
611
                if ($DB->numrows($result)>0){
612
                        while ($row=$DB->fetch_array($result)){
613
                                $catNumbers[]=$row["ID"];
614
                        }
615
                        $DB->data_seek($result,0);
616
                        while ($row=$DB->fetch_array($result)){
617
                                if($row["parentID"]&&!in_array($row["parentID"], $toprocess)){
618
                                        $toprocess[]=$row["parentID"];
619
                                }
620
                        }
621

622
                }
623
        }
624
        while (count($toprocess)){
625
                $query2="SELECT DISTINCT * FROM glpi_dropdown_kbcategories WHERE '0'='1' ";
626
                foreach ($toprocess as $key)
627
                        $query2.=  " OR ID = '$key' ";
628
        
629
                $toprocess=array();
630

631
                if ($result=$DB->query($query2)){
632
                        if ($DB->numrows($result)>0){
633
                                while ($row=$DB->fetch_array($result)){
634
                                        if(!in_array($row["ID"], $catNumbers)){
635
                                                $catNumbers[]=$row["ID"];
636
                                                if($row["parentID"]&&!in_array($row["parentID"], $toprocess)){
637
                                                        $toprocess[]=$row["parentID"];
638
                                                }
639
                                        }
640
                                }
641
                        }
642
                }
643
        }
644

645
        
646

647
        return($catNumbers);
648

649
}
650
*/
651
        
652
?>
Redmine Appliance - Powered by TurnKey Linux