Skip to content

Commit

Permalink
[DigiriskElement] fix: change sql field rank by ranks because in mysq…
Browse files Browse the repository at this point in the history
…l 8 rank is reserved
  • Loading branch information
nicolas-eoxia committed Mar 1, 2022
1 parent 45780e3 commit 3fa2564
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions class/digiriskelement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DigiriskElement extends CommonObject
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => '1', 'position' => 120, 'notnull' => -1, 'visible' => -2,),
'fk_parent' => array('type' => 'integer', 'label' => 'ParentElement', 'enabled' => '1', 'position' => 130, 'notnull' => 1, 'visible' => 1, 'default' => 0,),
'fk_standard' => array('type' => 'integer', 'label' => 'Standard', 'enabled' => '1', 'position' => 140, 'notnull' => 1, 'visible' => 0, 'default' => 1,),
'rank' => array('type' => 'integer', 'label' => 'Order', 'enabled' => '1', 'position' => 150, 'notnull' => 1, 'visible' => 0),
'ranks' => array('type' => 'integer', 'label' => 'Order', 'enabled' => '1', 'position' => 150, 'notnull' => 1, 'visible' => 0),
);

public $rowid;
Expand All @@ -117,7 +117,7 @@ class DigiriskElement extends CommonObject
public $fk_user_modif;
public $fk_parent;
public $fk_standard;
public $rank;
public $ranks;

/**
* Constructor
Expand Down Expand Up @@ -626,7 +626,7 @@ public function getNomUrl($withpicto = 0, $option = '', $addlabel = 0, $moreinpo
*/
public function getTrashList()
{
$objects = $this->fetchAll('', 'rank');
$objects = $this->fetchAll('', 'ranks');
if (is_array($objects)) {
$recurse_tree = recurse_tree($this->id, 0, $objects);
$ids = [];
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ public function init($options = '')
$digiriskelement->ref = $trashRef;
$digiriskelement->label = $langs->trans('HiddenElements');
$digiriskelement->element_type = 'groupment';
$digiriskelement->rank = 0;
$digiriskelement->ranks = 0;
$digiriskelement->description = $langs->trans('TrashGroupment');
$digiriskelement->status = 0;
$trash_id = $digiriskelement->create($user);
Expand Down
4 changes: 2 additions & 2 deletions lib/digiriskdolibarr_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,9 @@ function digiriskHeader($title = '', $help_url = '', $arrayofjs = array(), $arra
//Body navigation digirisk
$object = new DigiriskElement($db);
if ($conf->global->DIGIRISKDOLIBARR_SHOW_HIDDEN_DIGIRISKELEMENT) {
$objects = $object->fetchAll('', 'rank', 0, 0);
$objects = $object->fetchAll('', 'ranks', 0, 0);
} else {
$objects = $object->fetchAll('', 'rank', 0, 0, array('customsql' => 'status > 0'));
$objects = $object->fetchAll('', 'ranks', 0, 0, array('customsql' => 'status > 0'));
}

$results = array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ CREATE TABLE llx_digiriskdolibarr_digiriskelement(
fk_user_modif integer,
fk_parent integer DEFAULT 0 NOT NULL,
fk_standard integer DEFAULT 1 NOT NULL,
`rank` integer
`ranks` integer
) ENGINE=innodb;
3 changes: 2 additions & 1 deletion sql/update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ ALTER TABLE llx_digiriskdolibarr_accident ADD accident_location text;
ALTER TABLE llx_digiriskdolibarr_accident CHANGE `external_accident` `external_accident` SMALLINT(6) NULL DEFAULT '1';
-- ALTER TABLE llx_digiriskdolibarr_digiriskelement_extrafields ADD entity integer DEFAULT 1 NOT NULL;


-- 9.1.0
ALTER TABLE `llx_digiriskdolibarr_digiriskelement` CHANGE `rank` `ranks` INT(11) NULL DEFAULT NULL;
6 changes: 3 additions & 3 deletions test/phpunit/DigiriskElementUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testDigiriskElementCreate()
$localobject->description = "TestDescriptionDigiriskElement";
$localobject->element_type = 'groupment';
$localobject->photo = 'test.png';
$localobject->rank = 1;
$localobject->ranks = 1;
$localobject->fk_user_creat = $user->id ? $user->id : 1;
$localobject->fk_user_modif = $user->id ? $user->id : 1;
$localobject->fk_parent = 0;
Expand Down Expand Up @@ -259,7 +259,7 @@ public function testDigiriskElementUpdate($localobject)
$localobject->description = "UpdatedTestDescriptionDigiriskElement";
$localobject->element_type = 'groupment';
$localobject->photo = 'newtest.png';
$localobject->rank = 1;
$localobject->ranks = 1;
$localobject->fk_user_creat = $user->id ? $user->id : 1;
$localobject->fk_user_modif = $user->id ? $user->id : 1;
$localobject->fk_parent = 0;
Expand All @@ -286,7 +286,7 @@ public function testDigiriskElementUpdate($localobject)
$this->assertSame($localobject->description, $newobject->description);
$this->assertSame($localobject->element_type, $newobject->element_type);
$this->assertSame($localobject->photo, $newobject->photo);
$this->assertSame($localobject->rank, $newobject->rank);
$this->assertSame($localobject->ranks, $newobject->ranks);
$this->assertEquals($localobject->fk_user_creat, $newobject->fk_user_creat);
$this->assertEquals($localobject->fk_user_modif, $newobject->fk_user_modif);
$this->assertEquals($localobject->fk_parent, $newobject->fk_parent);
Expand Down
4 changes: 2 additions & 2 deletions view/digiriskelement/digiriskelement_organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
foreach ($array_ids as $id) {
$digiriskelement = new DigiriskElement($db);
$digiriskelement->fetch((int) $id);
$digiriskelement->rank = $i + 1;
$digiriskelement->ranks = $i + 1;
$digiriskelement->fk_parent = $array_parent_ids[$i];

$digiriskelement->update($user);
Expand Down Expand Up @@ -138,7 +138,7 @@
?>
<div id="cardContent" value="">
<?php
$objects = $object->fetchAll('', 'rank', 0, 0, array('customsql' => 'status > 0'));
$objects = $object->fetchAll('', 'ranks', 0, 0, array('customsql' => 'status > 0'));
if (is_array($objects)) {
$results = recurse_tree(0, 0, $objects);
} else {
Expand Down

0 comments on commit 3fa2564

Please sign in to comment.