"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "inc/item_devices.class.php" between
glpi-9.3.3.tgz and glpi-9.4.0.tgz

About: GLPI is an IT and asset management software (Information Resource Manager).

item_devices.class.php  (glpi-9.3.3.tgz):item_devices.class.php  (glpi-9.4.0.tgz)
skipping to change at line 209 skipping to change at line 209
'id' => '80', 'id' => '80',
'table' => 'glpi_entities', 'table' => 'glpi_entities',
'field' => 'completename', 'field' => 'completename',
'name' => __('Entity'), 'name' => __('Entity'),
'datatype' => 'dropdown' 'datatype' => 'dropdown'
]; ];
return $tab; return $tab;
} }
public static function rawSearchOptionsToAdd($itemtype) {
global $CFG_GLPI;
$options = [];
$device_types = $CFG_GLPI['device_types'];
$main_joinparams = [
'jointype' => 'itemtype_item',
'specific_itemtype' => $itemtype
];
foreach ($device_types as $device_type) {
if (isset($CFG_GLPI['item' . strtolower($device_type) . '_types'])) {
$itemtypes = $CFG_GLPI['item' . strtolower($device_type) . '_types']
;
if ($itemtypes == '*' || in_array($itemtype, $itemtypes)) {
if (method_exists($device_type, 'rawSearchOptionsToAdd')) {
$options = array_merge(
$options,
$device_type::rawSearchOptionsToAdd(
$itemtype,
$main_joinparams
)
);
}
}
}
}
if (count($options)) {
//add title if there are options
$options = array_merge(
[[
'id' => 'devices',
'name' => _n('Component', 'Components', Session::get
PluralNumber())
]],
$options
);
}
return $options;
}
static function getSpecificValueToDisplay($field, $values, array $options = [ ]) { static function getSpecificValueToDisplay($field, $values, array $options = [ ]) {
if (!is_array($values)) { if (!is_array($values)) {
$values = [$field => $values]; $values = [$field => $values];
} }
switch ($field) { switch ($field) {
case 'items_id': case 'items_id':
if (isset($values['itemtype'])) { if (isset($values['itemtype'])) {
if (isset($options['comments']) && $options['comments']) { if (isset($options['comments']) && $options['comments']) {
$valueData = Dropdown::getDropdownName( $valueData = Dropdown::getDropdownName(
skipping to change at line 365 skipping to change at line 407
/** /**
* Get the Item_Device* a given item type can have * Get the Item_Device* a given item type can have
* *
* @param $itemtype the type of the item that we want to know its devices * @param $itemtype the type of the item that we want to know its devices
* *
* @since 0.85 * @since 0.85
* *
* @return array of Item_Device* * @return array of Item_Device*
**/ **/
static function getItemAffinities($itemtype) { static function getItemAffinities($itemtype) {
global $GLPI_CACHE;
if (!isset($_SESSION['glpi_item_device_affinities'])) { if (!$GLPI_CACHE->has('item_device_affinities')) {
$_SESSION['glpi_item_device_affinities'] = ['' => static ::getDeviceTyp $GLPI_CACHE->set('item_device_affinities', ['' => static::getDeviceType
es()]; s()]);
} }
$items_affinities = $GLPI_CACHE->get('item_device_affinities');
if (!isset($_SESSION['glpi_item_device_affinities'][$itemtype])) { if (!isset($items_affinities[$itemtype])) {
$afffinities = []; $afffinities = [];
foreach ($_SESSION['glpi_item_device_affinities'][''] as $item_id => $i tem_device) { foreach ($items_affinities[''] as $item_id => $item_device) {
if (in_array($itemtype, $item_device::itemAffinity()) || in_array('* ', $item_device::itemAffinity())) { if (in_array($itemtype, $item_device::itemAffinity()) || in_array('* ', $item_device::itemAffinity())) {
$afffinities[$item_id] = $item_device; $afffinities[$item_id] = $item_device;
} }
} }
$_SESSION['glpi_item_device_affinities'][$itemtype] = $afffinities; $items_affinities[$itemtype] = $afffinities;
$GLPI_CACHE->set('item_device_affinities', $items_affinities);
} }
return $_SESSION['glpi_item_device_affinities'][$itemtype]; return $items_affinities[$itemtype];
} }
/** /**
* Get all kind of items that can be used by Item_Device* * Get all kind of items that can be used by Item_Device*
* *
* @since 0.85 * @since 0.85
* *
* @return array of the available items * @return array of the available items
**/ **/
static function getConcernedItems() { static function getConcernedItems() {
skipping to change at line 712 skipping to change at line 757
if ($options['canedit']) { if ($options['canedit']) {
$group_checkbox_tag = (empty($peer_type) ? '__' : $peer_type); $group_checkbox_tag = (empty($peer_type) ? '__' : $peer_type);
$content = Html::getCheckbox(['criterion' $content = Html::getCheckbox(['criterion'
=> ['tag_for_massive' => ['tag_for_massive'
=> $group_che ckbox_tag]]); => $group_che ckbox_tag]]);
$delete_one = $table_group->addHeader('one', $content, $delete_ column, $delete_one = $table_group->addHeader('one', $content, $delete_ column,
$previous_column); $previous_column);
} }
$ctable = $this->getTable();
$criteria = [
'SELECT' => "$ctable.*",
'FROM' => $ctable
];
if ($is_device) { if ($is_device) {
$fk = 'items_id'; $fk = 'items_id';
// Entity restrict // Entity restrict
$leftjoin = ''; $leftjoin = '';
$where = ""; $where = "";
$criteria['WHERE'] = [
$this->getDeviceForeignKey() => $item->getID(),
"$ctable.itemtype" => $peer_type,
"$ctable.is_deleted" => 0
];
$criteria['ORDERBY'] = [
"$ctable.itemtype",
"$ctable.$fk"
];
if (!empty($peer_type)) { if (!empty($peer_type)) {
$leftjoin = "LEFT JOIN `".getTableForItemType($peer_type)."` $criteria['LEFT JOIN'] = [
ON (`".$this->getTable()."`.`items_id` = `".getTableForI getTableForItemType($peer_type) => [
temType($peer_type)."`.`id` 'ON' => [
AND `".$this->getTable()."`.`itemtype` = '$peer_type $ctable => 'items_id',
')"; getTableForItemType($peer_type) => 'id', [
$where = getEntitiesRestrictRequest(" AND", getTableForItemType($pee 'AND' => [
r_type)); "$ctable.itemtype" => $peer_type
]
]
]
]
];
$criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteri
a(getTableForItemType($peer_type));
} }
$query = "SELECT `".$this->getTable()."`.*
FROM `".$this->getTable()."`
$leftjoin
WHERE `".$this->getDeviceForeignKey()."` = '".$item->getID().
"'
AND `".$this->getTable()."`.`itemtype` = '$peer_type'
AND `".$this->getTable()."`.`is_deleted` = 0
$where
ORDER BY `".$this->getTable()."`.`itemtype`, `".$this->getTab
le()."`.`$fk`";
} else { } else {
$fk = $this->getDeviceForeignKey(); $fk = $this->getDeviceForeignKey();
$query = "SELECT * $criteria['WHERE'] = [
FROM `".$this->getTable()."` 'itemtype' => $item->getType(),
WHERE `itemtype` = '".$item->getType()."' 'items_id' => $item->getID(),
AND `items_id` = '".$item->getID()."' 'is_deleted' => 0
AND `is_deleted` = 0 ];
ORDER BY $fk"; $criteria['ORDERBY'] = $fk;
} }
if (!empty($peer_type)) { if (!empty($peer_type)) {
$peer = new $peer_type(); $peer = new $peer_type();
$peer->getEmpty(); $peer->getEmpty();
} else { } else {
$peer = null; $peer = null;
} }
foreach ($DB->request($query) as $link) {
$iterator = $DB->request($criteria);
while ($link = $iterator->next()) {
Session::addToNavigateListItems(static::getType(), $link["id"]); Session::addToNavigateListItems(static::getType(), $link["id"]);
$this->getFromDB($link['id']); $this->getFromDB($link['id']);
if ((is_null($peer)) || ($link[$fk] != $peer->getID())) { if ((is_null($peer)) || ($link[$fk] != $peer->getID())) {
if ($peer instanceof CommonDBTM) { if ($peer instanceof CommonDBTM) {
$peer->getFromDB($link[$fk]); $peer->getFromDB($link[$fk]);
} }
$current_row = $table_group->createRow(); $current_row = $table_group->createRow();
skipping to change at line 837 skipping to change at line 896
'items_id' => $link['id']])) { 'items_id' => $link['id']])) {
$content = [['function' => 'Infocom::showDisplayLink', $content = [['function' => 'Infocom::showDisplayLink',
'parameters' => [$this->getType(), $link['id' ]]]]; 'parameters' => [$this->getType(), $link['id' ]]]];
} else { } else {
$content = ''; $content = '';
} }
$current_row->addCell($infocom_column, $content, $spec_cell); $current_row->addCell($infocom_column, $content, $spec_cell);
$content = []; $content = [];
// The order is to be sure that specific documents appear first // The order is to be sure that specific documents appear first
$query = "SELECT `documents_id` $doc_iterator = $DB->request([
FROM `glpi_documents_items` 'SELECT' => 'documents_id',
WHERE (`itemtype` = '".$this->getType()."' AND `items_id` = ' 'FROM' => 'glpi_documents_items',
".$link['id']."') 'WHERE' => [
OR (`itemtype` = '".$this->getDeviceType()."' 'OR' => [
AND `items_id` = '".$link[$this->getDeviceForeignK 'AND' => [
ey()]."') 'itemtype' => $this->getType(),
ORDER BY `itemtype` = '".$this->getDeviceType()."'"; 'items_id' => $link['id']
]
],
'OR' => [
'AND' => [
'itemtype' => $this->getDeviceType(),
'items_id' => $link[$this->getDeviceForeignKey()]
]
]
],
'ORDER' => 'itemtype'
]);
$document = new Document(); $document = new Document();
foreach ($DB->request($query) as $document_link) { while ($document_link = $doc_iterator->next()) {
if ($document->can($document_link['documents_id'], READ)) { if ($document->can($document_link['documents_id'], READ)) {
$content[] = $document->getLink(); $content[] = $document->getLink();
} }
} }
$content = implode('<br>', $content); $content = implode('<br>', $content);
$current_row->addCell($document_column, $content, $spec_cell); $current_row->addCell($document_column, $content, $spec_cell);
if ($item->isDynamic()) { if ($item->isDynamic()) {
$previous_cell = $current_row->addCell($dynamics_column, $previous_cell = $current_row->addCell($dynamics_column,
Dropdown::getYesNo($link['is_ dynamic']), Dropdown::getYesNo($link['is_ dynamic']),
skipping to change at line 1082 skipping to change at line 1154
* @param $items_id * @param $items_id
* @param $unaffect * @param $unaffect
**/ **/
static function cleanItemDeviceDBOnItemDelete($itemtype, $items_id, $unaffect ) { static function cleanItemDeviceDBOnItemDelete($itemtype, $items_id, $unaffect ) {
global $DB; global $DB;
foreach (self::getItemAffinities($itemtype) as $link_type) { foreach (self::getItemAffinities($itemtype) as $link_type) {
$link = getItemForItemtype($link_type); $link = getItemForItemtype($link_type);
if ($link) { if ($link) {
if ($unaffect) { if ($unaffect) {
$query = "SELECT `id` $DB->update(
FROM `".$link->getTable()."` $link->getTable(), [
WHERE `itemtype` = '$itemtype' 'items_id' => 0,
AND `items_id` = '$items_id'"; 'itemtype' => ''
$input = ['items_id' => 0, ], [
'itemtype' => '']; 'items_id' => $items_id,
foreach ($DB->request($query) as $data) { 'itemtype' => $itemtype
$input['id'] = $data['id']; ]
$link->update($input); );
}
} else { } else {
$link->cleanDBOnItemDelete($itemtype, $items_id); $link->cleanDBOnItemDelete($itemtype, $items_id);
} }
} }
} }
} }
/** /**
* @since 0.85 * @since 0.85
* *
skipping to change at line 1265 skipping to change at line 1336
} }
if ($tooltip !== null) { if ($tooltip !== null) {
$comment_id = Html::cleanId("comment_".$field.$rand); $comment_id = Html::cleanId("comment_".$field.$rand);
$link_id = Html::cleanId("comment_link_".$field.$rand); $link_id = Html::cleanId("comment_link_".$field.$rand);
$options_tooltip = ['contentid' => $comment_id, $options_tooltip = ['contentid' => $comment_id,
'linkid' => $link_id, 'linkid' => $link_id,
'display' => false]; 'display' => false];
$out.= '&nbsp;'.Html::showToolTip($tooltip, $options_tooltip); $out.= '&nbsp;'.Html::showToolTip($tooltip, $options_tooltip);
} }
if ($protected) { if ($protected) {
$out.= '<span><i class="fa fa-eye pointer disclose" '; $out.= '<span><i class="far fa-eye pointer disclose" ';
$out.= 'onmousedown="showField(\'' . $field . $rand . '\')" '; $out.= 'onmousedown="showField(\'' . $field . $rand . '\')" ';
$out.= 'onmouseup="hideField(\'' . $field . $rand . '\')" '; $out.= 'onmouseup="hideField(\'' . $field . $rand . '\')" ';
$out.= 'onmouseout="hideField(\'' . $field . $rand . '\')"></i>'; $out.= 'onmouseout="hideField(\'' . $field . $rand . '\')"></i>';
$out.= '<i class="fa fa-clipboard pointer disclose" '; $out.= '<i class="fa fa-paste pointer disclose" ';
$out.= 'onclick="copyToClipboard(\'' . $field . $rand . '\')"></i >'; $out.= 'onclick="copyToClipboard(\'' . $field . $rand . '\')"></i >';
$out.= '</span>'; $out.= '</span>';
} }
echo $out; echo $out;
} else { } else {
echo NOT_AVAILABLE; echo NOT_AVAILABLE;
} }
echo "</td>"; echo "</td>";
$even ++; $even ++;
if (($even == $nb) && (($nb % 2) != 0) && $nb > 1) { if (($even == $nb) && (($nb % 2) != 0) && $nb > 1) {
 End of changes. 19 change blocks. 
55 lines changed or deleted 122 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)