Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Feb 24, 2025
1 parent 984bf01 commit 6511477
Showing 1 changed file with 0 additions and 126 deletions.
126 changes: 0 additions & 126 deletions src/RuleDefineItemtypeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,134 +43,8 @@ class RuleDefineItemtypeCollection extends RuleCollection
public static $rightname = 'rule_import';
public $menu_option = 'defineasset';

/*public function defineTabs($options = [])
{
$ong = parent::defineTabs();
$this->addStandardTab(__CLASS__, $ong, $options);
return $ong;
}*/

/*public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
global $CFG_GLPI;
if (!$withtemplate) {
switch ($item::class) {
case self::class:
$ong = [];
$types = $CFG_GLPI['ruleimportasset_types'];
foreach ($types as $type) {
if (class_exists($type)) {
$ong[$type] = $type::getTypeName();
}
}
$ong['_global'] = __('Global');
return $ong;
}
}
return '';
}*/

public function getTitle()
{
return __('Rules to define inventoried itemtype');
}

/*public function collectionFilter($criteria, $options = [])
{
// current tab
$active_tab = $options['_glpi_tab'] ?? Session::getActiveTab($this->getType());
$current_tab = str_replace(__CLASS__ . '$', '', $active_tab);
$tabs = $this->getTabNameForItem($this);
if (!isset($tabs[$current_tab])) {
return $criteria;
}
$criteria['LEFT JOIN']['glpi_rulecriterias AS crit'] = [
'ON' => [
'crit' => 'rules_id',
'glpi_rules' => 'id'
]
];
$criteria['GROUPBY'] = ['glpi_rules.id'];
if ($current_tab != '_global') {
$where = [
'crit.criteria' => 'itemtype',
'crit.pattern' => getSingular($current_tab)
];
$criteria['WHERE'] += $where;
} else {
if (!is_array($criteria['SELECT'])) {
$criteria['SELECT'] = [$criteria['SELECT']];
}
$criteria['SELECT'][] = QueryFunction::count(
expression: QueryFunction::if(
condition: ['crit.criteria' => 'itemtype'],
true_expression: QueryFunction::if(
condition: ['crit.pattern' => array_keys($tabs)],
true_expression: new QueryExpression('1'),
false_expression: new QueryExpression('null')
),
false_expression: new QueryExpression('null')
),
alias: 'is_itemtype'
);
$where = [];
$criteria['HAVING'] = ['is_itemtype' => 0];
}
return $criteria;
}*/

/*public function getMainTabLabel()
{
return __('All');
}*/

/*public function prepareInputDataForProcess($input, $params)
{
$refused_id = $params['refusedequipments_id'] ?? null;
if ($refused_id === null) {
return $input;
}
$refused = new RefusedEquipment();
if ($refused->getFromDB($refused_id) && ($inventory_file = $refused->getInventoryFileName()) !== null) {
$inventory_request = new \Glpi\Inventory\Request();
$contents = file_get_contents($inventory_file);
$inventory_request
->testRules()
->handleRequest($contents);
$inventory = $inventory_request->getInventory();
$invitem = $inventory->getMainAsset();
// sanitize input
if ($input['itemtype'] == 0) {
unset($input['itemtype']);
}
foreach ($input as $key => $value) {
if (empty($value)) {
unset($input[$key]);
}
}
$data = $invitem->getData();
$rules_input = $invitem->prepareAllRulesInput($data[0]);
// keep user values if any
$input += $rules_input;
} else {
trigger_error(
sprintf('Invalid RefusedEquipment "%s" or inventory file missing', $refused_id),
E_USER_WARNING
);
$contents = '';
}
return $input;
}*/
}

0 comments on commit 6511477

Please sign in to comment.