PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ajax/searchoptionvalue.php

https://github.com/ardowz/Thesis-SideB
PHP | 248 lines | 141 code | 28 blank | 79 comment | 20 complexity | 30e039f3953f18675c382de1605a689e MD5 | raw file
  1. <?php
  2. /*
  3. * @version $Id: searchoptionvalue.php 14684 2011-06-11 06:32:40Z remi $
  4. -------------------------------------------------------------------------
  5. GLPI - Gestionnaire Libre de Parc Informatique
  6. Copyright (C) 2003-2011 by the INDEPNET Development Team.
  7. http://indepnet.net/ http://glpi-project.org
  8. -------------------------------------------------------------------------
  9. LICENSE
  10. This file is part of GLPI.
  11. GLPI is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15. GLPI is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with GLPI; if not, write to the Free Software Foundation, Inc.,
  21. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. --------------------------------------------------------------------------
  23. */
  24. // ----------------------------------------------------------------------
  25. // Original Author of file: Julien Dombre
  26. // Purpose of file:
  27. // ----------------------------------------------------------------------
  28. // Direct access to file
  29. if (strpos($_SERVER['PHP_SELF'],"searchoptionvalue.php")) {
  30. define('GLPI_ROOT','..');
  31. include (GLPI_ROOT."/inc/includes.php");
  32. header("Content-Type: text/html; charset=UTF-8");
  33. header_nocache();
  34. }
  35. if (!defined('GLPI_ROOT')) {
  36. die("Can not acces directly to this file");
  37. }
  38. checkLoginUser();
  39. if (isset($_REQUEST['searchtype'])) {
  40. $searchopt = unserialize(stripslashes($_REQUEST['searchopt']));
  41. $_REQUEST['value'] = rawurldecode(stripslashes($_REQUEST['value']));
  42. $addmeta = "";
  43. if (isset($_REQUEST['meta']) && $_REQUEST['meta']) {
  44. $addmeta = '2';
  45. }
  46. $inputname = 'contains'.$addmeta.'['.$_REQUEST['num'].']';
  47. $display = false;
  48. switch ($_REQUEST['searchtype']) {
  49. case "equals" :
  50. case "notequals" :
  51. case "morethan" :
  52. case "lessthan" :
  53. // Specific cases with linkfield
  54. // if (!$display && isset($searchopt['linkfield'])) {
  55. // // Specific cases
  56. // switch ($searchopt['table'].".".$searchopt['linkfield']) {
  57. // case "glpi_users_validation.users_id_validate" :
  58. // User::dropdown(array('name' => $inputname,
  59. // 'value' => $_REQUEST['value'],
  60. // 'comments' => false,
  61. // 'right' => 'validate_ticket'));
  62. // $display = true;
  63. // break;
  64. //
  65. // case "glpi_users_validation.users_id" :
  66. // User::dropdown(array('name' => $inputname,
  67. // 'value' => $_REQUEST['value'],
  68. // 'comments' => false,
  69. // 'right' => 'create_validation'));
  70. // $display = true;
  71. // break;
  72. // }
  73. // }
  74. // Specific cases with linkfield
  75. // if (!$display && isset($searchopt['linkfield'])) {
  76. // switch ($_REQUEST['itemtype'].".".$searchopt['linkfield']) {
  77. // case "Ticket.users_id_recipient" :
  78. // // case "Ticket.users_id" :
  79. // User::dropdown(array('name' => $inputname,
  80. // 'value' => $_REQUEST['value'],
  81. // 'right' => 'all'));
  82. // $display = true;
  83. // break;
  84. //
  85. // // case "Ticket.users_id_assign" :
  86. // // User::dropdown(array('name' => $inputname,
  87. // // 'value' => $_REQUEST['value'],
  88. // // 'right' => 'own_ticket'));
  89. // // $display = true;
  90. // // break;
  91. // }
  92. // }
  93. if (!$display && isset($searchopt['field'])) {
  94. // Specific cases
  95. switch ($searchopt['table'].".".$searchopt['field']) {
  96. case "glpi_tickets.status" :
  97. Ticket::dropdownStatus($inputname, $_REQUEST['value'], 1);
  98. $display = true;
  99. break;
  100. case "glpi_tickets.type" :
  101. Ticket::dropdownType($inputname, $_REQUEST['value']);
  102. $display = true;
  103. break;
  104. case "glpi_tickets.priority" :
  105. Ticket::dropdownPriority($inputname, $_REQUEST['value'], true, true);
  106. $display = true;
  107. break;
  108. case "glpi_tickets.impact" :
  109. Ticket::dropdownImpact($inputname, $_REQUEST['value'], true);
  110. $display = true;
  111. break;
  112. case "glpi_tickets.urgency" :
  113. Ticket::dropdownUrgency($inputname, $_REQUEST['value'], true);
  114. $display = true;
  115. break;
  116. case "glpi_tickets.global_validation" :
  117. TicketValidation::dropdownStatus($inputname, array('value' => $_REQUEST['value'],
  118. 'global' => true,
  119. 'all' => 1));
  120. $display =true;
  121. break;
  122. case "glpi_users.name" :
  123. User::dropdown(array('name' => $inputname,
  124. 'value' => $_REQUEST['value'],
  125. 'comments' => false,
  126. 'right' => isset($searchopt['filter'])?$searchopt['filter']
  127. :'all'));
  128. $display = true;
  129. break;
  130. case "glpi_ticketvalidations.status" :
  131. TicketValidation::dropdownStatus($inputname, array('value' => $_REQUEST['value'],
  132. 'all' => 1));
  133. $display = true;
  134. break;
  135. case "glpi_ticketsatisfactions.type" :
  136. Dropdown::showFromArray($inputname,
  137. array(1 => $LANG['satisfaction'][9],
  138. 2 => $LANG['satisfaction'][10]),
  139. array('value' => $_REQUEST['value']));
  140. $display = true;
  141. break;
  142. case "glpi_crontasks.state" :
  143. CronTask::dropdownState($inputname, $_REQUEST['value']);
  144. $display = true;
  145. break;
  146. }
  147. // Standard datatype usage
  148. if (!$display && isset($searchopt['datatype'])) {
  149. switch ($searchopt['datatype']) {
  150. case "bool" :
  151. Dropdown::showYesNo($inputname, $_REQUEST['value']);
  152. $display = true;
  153. break;
  154. case "right" :
  155. // No access not displayed because empty not take into account for search
  156. Profile::dropdownNoneReadWrite($inputname, $_REQUEST['value'], 1, 1, 1);
  157. $display = true;
  158. break;
  159. case "itemtypename" :
  160. Dropdown::dropdownUsedItemTypes($inputname,
  161. getItemTypeForTable($searchopt['table']),
  162. array('value' => $_REQUEST['value'],
  163. 'comments' => 0));
  164. $display = true;
  165. break;
  166. case "date" :
  167. case "date_delay" :
  168. showGenericDateTimeSearch($inputname, $_REQUEST['value'], false,
  169. (isset($searchopt['maybefuture'])
  170. && $searchopt['maybefuture']));
  171. $display = true;
  172. break;
  173. case "datetime" :
  174. showGenericDateTimeSearch($inputname, $_REQUEST['value'], true,
  175. (isset($searchopt['maybefuture'])
  176. && $searchopt['maybefuture']));
  177. $display = true;
  178. break;
  179. }
  180. }
  181. //Could display be handled by a plugin ?
  182. if (!$display && $plug = isPluginItemType(getItemTypeForTable($searchopt['table']))) {
  183. $function = 'plugin_'.$plug['plugin'].'_searchOptionsValues';
  184. if (function_exists($function)) {
  185. $params = array('name' => $inputname,
  186. 'searchtype' => $_REQUEST['searchtype'],
  187. 'searchoption' => $searchopt,
  188. 'value' => $_REQUEST['value']);
  189. $display = $function($params);
  190. }
  191. }
  192. // Standard field usage
  193. if (!$display) {
  194. switch ($searchopt['field']) {
  195. case "name" :
  196. case "completename" :
  197. Dropdown::show(getItemTypeForTable($searchopt['table']),
  198. array('value' => $_REQUEST['value'],
  199. 'name' => $inputname,
  200. 'comments' => 0));
  201. $display = true;
  202. break;
  203. }
  204. }
  205. }
  206. break; //case "lessthan" :
  207. }
  208. // Default case : text field
  209. if (!$display) {
  210. echo "<input type='text' size='13' name='$inputname' value=\"".
  211. cleanInputText($_REQUEST['value'])."\">";
  212. }
  213. }
  214. ?>