Skip to content

Commit

Permalink
fix deprecated Condition should be an array
Browse files Browse the repository at this point in the history
  • Loading branch information
amma35 committed Aug 8, 2018
1 parent 67fe96c commit f6a9102
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
3 changes: 1 addition & 2 deletions front/hash.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@

$hash = 0;
$hash_id = 0;
$restrict = "`entities_id` = '" . $_SESSION['glpiactive_entity'] . "'";
$dbu = new DbUtils();
$restrict = ["entities_id" => $_SESSION['glpiactive_entity']];
$hashes = $dbu->getAllDataFromTable("glpi_plugin_accounts_hashes", $restrict);
if (!empty($hashes)) {
foreach ($hashes as $hashe) {
Expand Down
11 changes: 6 additions & 5 deletions inc/account.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function showForm($ID, $options = []) {
$hashclass = new PluginAccountsHash();
$dbu = new DbUtils();

$restrict = $dbu->getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', '', $hashclass->maybeRecursive());
$restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '', '', $hashclass->maybeRecursive());
if ($ID < 1 && $dbu->countElementsInTable("glpi_plugin_accounts_hashes", $restrict) == 0) {
echo "<div class='center'>" . __('There is no encryption key for this entity', 'accounts') . "<br><br>";
echo "<a href='" . Toolbox::getItemTypeSearchURL('PluginAccountsAccount') . "'>";
Expand Down Expand Up @@ -460,7 +460,8 @@ public function showForm($ID, $options = []) {
//hash
$hash = 0;
$hash_id = 0;
$restrict = $dbu->getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', $this->getEntityID(), $hashclass->maybeRecursive());
$restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '',
$this->getEntityID(), $hashclass->maybeRecursive());
$hashes = $dbu->getAllDataFromTable("glpi_plugin_accounts_hashes", $restrict);
if (!empty($hashes)) {
foreach ($hashes as $hashe) {
Expand Down Expand Up @@ -858,9 +859,9 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT
foreach ($ma->items as $itemtype => $myitem) {
foreach ($myitem as $key => $value) {
if (!$dbu->countElementsInTable('glpi_plugin_accounts_accounts_items',
"itemtype='$itemtype'
AND items_id='$key'
AND plugin_accounts_accounts_id='" . $input['plugin_accounts_accounts_id'] . "'")) {
["itemtype" => $itemtype,
"items_id" => $key,
"plugin_accounts_accounts_id" => $input['plugin_accounts_accounts_id']])) {
$myvalue['plugin_accounts_accounts_id'] = $input['plugin_accounts_accounts_id'];
$myvalue['itemtype'] = $itemtype;
$myvalue['items_id'] = $key;
Expand Down
14 changes: 7 additions & 7 deletions inc/account_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,21 @@ private static function countForAccount(PluginAccountsAccount $item) {
}
$dbu = new DbUtils();
return $dbu->countElementsInTable('glpi_plugin_accounts_accounts_items',
"`itemtype` IN ('$types')
AND `plugin_accounts_accounts_id` = '" . $item->getID() . "'");
["plugin_accounts_accounts_id" => $item->getID()],
["IN" => ["itemtype" => $types]
]);
}


/**
* @param CommonDBTM $item
* @return int
*/
private static function countForItem(CommonDBTM $item) {
static function countForItem(CommonDBTM $item) {
$dbu = new DbUtils();
return $dbu->countElementsInTable('glpi_plugin_accounts_accounts_items',
"`itemtype`='" . $item->getType() . "'
AND `items_id` = '" . $item->getID() . "'");
["itemtype" => $item->getType(),
"items_id" => $item->getID()]);
}

/**
Expand Down Expand Up @@ -587,8 +588,7 @@ static function showForItem(CommonDBTM $item, $withtemplate = '') {
$hashclass = new PluginAccountsHash();
$hash_id = 0;
$hash = 0;
$restrict = $dbu->getEntitiesRestrictRequest(" ",
"glpi_plugin_accounts_hashes",
$restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes",
'',
$item->getEntityID(),
$hashclass->maybeRecursive());
Expand Down
4 changes: 2 additions & 2 deletions inc/aeskey.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function checkIfAesKeyExists($plugin_accounts_hashes_id) {
if ($plugin_accounts_hashes_id) {
$dbu = new DbUtils();
$devices = $dbu->getAllDataFromTable("glpi_plugin_accounts_aeskeys",
"`plugin_accounts_hashes_id` = '$plugin_accounts_hashes_id' ");
["plugin_accounts_hashes_id" => $plugin_accounts_hashes_id]);
if (!empty($devices)) {
foreach ($devices as $device) {
$aeskey = $device["name"];
Expand Down Expand Up @@ -165,7 +165,7 @@ public function defineTabs($options = []) {
*/
public function showForm($ID, $options = []) {
$dbu = new DbUtils();
$restrict = $dbu->getEntitiesRestrictRequest(" ", "glpi_plugin_accounts_hashes", '', '', $this->h->maybeRecursive());
$restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes", '', '', $this->h->maybeRecursive());
if ($dbu->countElementsInTable("glpi_plugin_accounts_hashes", $restrict) == 0) {
echo "<div class='center red'>" . __('Encryption key modified', 'accounts') . "</div></br>";
}
Expand Down
3 changes: 1 addition & 2 deletions inc/hash.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ public function showForm($ID, $options = []) {
return false;
}
$dbu = new DbUtils();
$restrict = $dbu->getEntitiesRestrictRequest(" ",
"glpi_plugin_accounts_hashes",
$restrict = $dbu->getEntitiesRestrictCriteria("glpi_plugin_accounts_hashes",
'', '', $this->maybeRecursive());

if ($ID < 1
Expand Down
8 changes: 5 additions & 3 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static function initProfile() {
//Add new rights in glpi_profilerights table
foreach ($profile->getAllRights(true) as $data) {
if ($dbu->countElementsInTable("glpi_profilerights",
"`name` = '" . $data['field'] . "'") == 0) {
["name" => $data['field']]) == 0) {
ProfileRight::addProfileRights([$data['field']]);
}
}
Expand Down Expand Up @@ -338,11 +338,13 @@ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = f
$dbu = new DbUtils();
foreach ($rights as $right => $value) {
if ($dbu->countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) {
["profiles_id" => $profiles_id,
"name" => $right]) && $drop_existing) {
$profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]);
}
if (!$dbu->countElementsInTable('glpi_profilerights',
"`profiles_id`='$profiles_id' AND `name`='$right'")) {
["profiles_id" => $profiles_id,
"name" => $right])) {
$myright['profiles_id'] = $profiles_id;
$myright['name'] = $right;
$myright['rights'] = $value;
Expand Down

0 comments on commit f6a9102

Please sign in to comment.