Skip to content

Commit

Permalink
Fix travis
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 2, 2018
1 parent 7e7d419 commit fec9a96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
28 changes: 16 additions & 12 deletions htdocs/user/class/user.class.php
Expand Up @@ -137,7 +137,7 @@ class User extends CommonObject

public $default_c_exp_tax_cat;
public $default_range;

public $fields=array(
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'),
Expand Down Expand Up @@ -434,7 +434,7 @@ function fetch($id='', $login='', $sid='', $loadpersonalconf=0, $entity=-1)
/**
* Add a right to the user
*
* @param int $rid id of permission to add
* @param int $rid Id of permission to add or 0 to add several permissions
* @param string $allmodule Add all permissions of module $allmodule
* @param string $allperms Add all permissions of module $allmodule, subperms $allperms only
* @param int $entity Entity to use
Expand Down Expand Up @@ -679,24 +679,28 @@ function clearrights()
/**
* Load permissions granted to user into object user
*
* @param string $moduletag Limit permission for a particular module ('' by default means load all permissions)
* @param string $moduletag Limit permission for a particular module ('' by default means load all permissions)
* @param int $forcereload Force reload of permissions even if they were already loaded (ignore cache)
* @return void
* @see clearrights, delrights, addrights
*/
function getrights($moduletag='')
function getrights($moduletag='', $forcereload=0)
{
global $conf;

if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag])
if (empty($forcereload))
{
// Le fichier de ce module est deja charge
return;
}
if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag])
{
// Rights for this module are already loaded, so we leave
return;
}

if ($this->all_permissions_are_loaded)
{
// Si les permissions ont deja ete charge pour ce user, on quitte
return;
if ($this->all_permissions_are_loaded)
{
// We already loaded all rights for this user, so we leave
return;
}
}

// Recuperation des droits utilisateurs + recuperation des droits groupes
Expand Down
13 changes: 6 additions & 7 deletions test/phpunit/SupplierProposalTest.php
Expand Up @@ -31,7 +31,7 @@

if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";
print "Load permissions for user nb 1 (that should be admin)\n";
$user->fetch(1);

//$user->addrights(0, 'supplier_proposal');
Expand Down Expand Up @@ -110,7 +110,12 @@ protected function setUp()

print __METHOD__."\n";
//print $db->getVersion()."\n";

// Set permission not set by default sql sample
$user->addrights(0, 'supplier_proposal');
$user->getrights('supplier_proposal', 1);
}

/**
* End phpunit tests
*
Expand All @@ -134,10 +139,6 @@ public function testSupplierProposalCreate()
$langs=$this->savlangs;
$db=$this->savdb;

var_dump($conf->supplier_proposal->enabled);
var_dump($user->rights->supplier_proposal);
$user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0

$localobject=new SupplierProposal($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
Expand Down Expand Up @@ -214,8 +215,6 @@ public function testSupplierProposalValid($localobject)
$langs=$this->savlangs;
$db=$this->savdb;

$user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0

$result=$localobject->valid($user);

print __METHOD__." id=".$localobject->id." result=".$result."\n";
Expand Down

0 comments on commit fec9a96

Please sign in to comment.