getActionsFor() static public method

static public getActionsFor ( $itemtype, $field_num )
$itemtype
$field_num
コード例 #1
0
ファイル: searchoption.php プロジェクト: JULIO8/respaldo_glpi
}
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkLoginUser();
// Non define case
//print_r($_POST);
if (isset($_POST["itemtype"]) && isset($_POST["field"])) {
    $addmeta = "";
    if (isset($_POST['meta']) && $_POST['meta']) {
        $addmeta = '2';
    } else {
        $_POST['meta'] = 0;
    }
    //    echo $_POST["itemtype"]."--".$_POST["field"]."--".$_POST['searchtype'];
    $actions = Search::getActionsFor($_POST["itemtype"], $_POST["field"]);
    // is it a valid action for type ?
    if (count($actions) && (empty($_POST['searchtype']) || !isset($actions[$_POST['searchtype']]))) {
        $tmp = $actions;
        unset($tmp['searchopt']);
        $_POST['searchtype'] = key($tmp);
        unset($tmp);
    }
    //    echo $_POST["itemtype"]."--".$_POST["field"]."--".$_POST['searchtype'];
    //    printcleanArray($actions);
    $randsearch = -1;
    $dropdownname = "searchtype{$addmeta}" . $_POST["itemtype"] . $_POST["num"];
    $searchopt = array();
    if (count($actions) > 0) {
        // get already get search options
        if (isset($actions['searchopt'])) {
コード例 #2
0
ファイル: api.class.php プロジェクト: glpi-project/glpi
 /**
  * List the searchoptions of provided itemtype. To use with searchItems function
  *
  * @param $itemtype     string    itemtype (class) of object
  * @param $params       array
  *
  * @return     array    all searchoptions of specified itemtype
  **/
 protected function listSearchOptions($itemtype, $params = array())
 {
     $this->initEndpoint();
     $soptions = Search::getOptions($itemtype);
     if (isset($params['raw'])) {
         return $soptions;
     }
     $cleaned_soptions = array();
     foreach ($soptions as $sID => $option) {
         if (is_int($sID)) {
             $available_searchtypes = Search::getActionsFor($itemtype, $sID);
             unset($available_searchtypes['searchopt']);
             $available_searchtypes = array_keys($available_searchtypes);
             $cleaned_soptions[$sID] = array('name' => $option['name'], 'table' => $option['table'], 'field' => $option['field'], 'datatype' => isset($option['datatype']) ? $option['datatype'] : "", 'available_searchtypes' => $available_searchtypes);
             $cleaned_soptions[$sID]['uid'] = $this->getSearchOptionUniqID($itemtype, $option);
         } else {
             $cleaned_soptions[$sID] = $option;
         }
     }
     return $cleaned_soptions;
 }