static function getActionsFor($itemtype, $field_num)
{
$searchopt =& self::getOptions($itemtype);
$actions = array('contains' => __('contains'), 'searchopt' => array());
if (isset($searchopt[$field_num])) {
$actions['searchopt'] = $searchopt[$field_num];
// Force search type
if (isset($actions['searchopt']['searchtype'])) {
// Reset search option
$actions = array();
$actions['searchopt'] = $searchopt[$field_num];
if (!is_array($actions['searchopt']['searchtype'])) {
$actions['searchopt']['searchtype'] = array($actions['searchopt']['searchtype']);
}
foreach ($actions['searchopt']['searchtype'] as $searchtype) {
switch ($searchtype) {
case "equals":
$actions['equals'] = __('is');
break;
case "notequals":
$actions['notequals'] = __('is not');
break;
case "contains":
$actions['contains'] = __('contains');
break;
case "under":
$actions['under'] = __('under');
break;
case "notunder":
$actions['notunder'] = __('not under');
break;
case "lessthan":
$actions['lessthan'] = __('before');
break;
case "morethan":
$actions['morethan'] = __('after');
break;
}
}
return $actions;
}
if (isset($searchopt[$field_num]['datatype'])) {
switch ($searchopt[$field_num]['datatype']) {
case 'count':
case 'number':
$opt = array('contains' => __('contains'), 'equals' => __('is'), 'notequals' => __('is not'), 'searchopt' => $searchopt[$field_num]);
// No is / isnot if no limits defined
if (!isset($searchopt[$field_num]['min']) && !isset($searchopt[$field_num]['max'])) {
unset($opt['equals']);
unset($opt['notequals']);
}
return $opt;
case 'bool':
return array('equals' => __('is'), 'notequals' => __('is not'), 'contains' => __('contains'), 'searchopt' => $searchopt[$field_num]);
case 'right':
return array('equals' => __('is'), 'notequals' => __('is not'), 'searchopt' => $searchopt[$field_num]);
case 'itemtypename':
return array('equals' => __('is'), 'notequals' => __('is not'), 'searchopt' => $searchopt[$field_num]);
case 'date':
case 'datetime':
case 'date_delay':
return array('equals' => __('is'), 'notequals' => __('is not'), 'lessthan' => __('before'), 'morethan' => __('after'), 'contains' => __('contains'), 'searchopt' => $searchopt[$field_num]);
}
}
// switch ($searchopt[$field_num]['table']) {
// case 'glpi_users_validation' :
// return array('equals' => __('is'),
// 'notequals' => __('is not'),
// 'searchopt' => $searchopt[$field_num]);
// }
switch ($searchopt[$field_num]['field']) {
case 'id':
return array('equals' => __('is'), 'notequals' => __('is not'), 'searchopt' => $searchopt[$field_num]);
case 'name':
case 'completename':
$actions = array('contains' => __('contains'), 'equals' => __('is'), 'notequals' => __('is not'), 'searchopt' => $searchopt[$field_num]);
// Specific case of TreeDropdown : add under
$itemtype_linked = getItemTypeForTable($searchopt[$field_num]['table']);
if ($itemlinked = getItemForItemtype($itemtype_linked)) {
if ($itemlinked instanceof CommonTreeDropdown) {
$actions['under'] = __('under');
$actions['notunder'] = __('not under');
}
return $actions;
}
}
}
return $actions;
}