Fix travis

This commit is contained in:
Laurent Destailleur 2018-07-02 09:34:34 +02:00
parent 7e7d419e2d
commit fec9a96ad1
2 changed files with 22 additions and 19 deletions

View File

@ -137,7 +137,7 @@ class User extends CommonObject
public $default_c_exp_tax_cat; public $default_c_exp_tax_cat;
public $default_range; public $default_range;
public $fields=array( public $fields=array(
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), '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'), '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'),
@ -434,7 +434,7 @@ class User extends CommonObject
/** /**
* Add a right to the user * 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 $allmodule Add all permissions of module $allmodule
* @param string $allperms Add all permissions of module $allmodule, subperms $allperms only * @param string $allperms Add all permissions of module $allmodule, subperms $allperms only
* @param int $entity Entity to use * @param int $entity Entity to use
@ -679,24 +679,28 @@ class User extends CommonObject
/** /**
* Load permissions granted to user into object user * 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 * @return void
* @see clearrights, delrights, addrights * @see clearrights, delrights, addrights
*/ */
function getrights($moduletag='') function getrights($moduletag='', $forcereload=0)
{ {
global $conf; global $conf;
if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) if (empty($forcereload))
{ {
// Le fichier de ce module est deja charge if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag])
return; {
} // Rights for this module are already loaded, so we leave
return;
}
if ($this->all_permissions_are_loaded) if ($this->all_permissions_are_loaded)
{ {
// Si les permissions ont deja ete charge pour ce user, on quitte // We already loaded all rights for this user, so we leave
return; return;
}
} }
// Recuperation des droits utilisateurs + recuperation des droits groupes // Recuperation des droits utilisateurs + recuperation des droits groupes

View File

@ -31,7 +31,7 @@ require_once dirname(__FILE__).'/../../htdocs/supplier_proposal/class/supplier_p
if (empty($user->id)) 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->fetch(1);
//$user->addrights(0, 'supplier_proposal'); //$user->addrights(0, 'supplier_proposal');
@ -110,7 +110,12 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
print __METHOD__."\n"; print __METHOD__."\n";
//print $db->getVersion()."\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 * End phpunit tests
* *
@ -134,10 +139,6 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $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=new SupplierProposal($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$result=$localobject->create($user); $result=$localobject->create($user);
@ -214,8 +215,6 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$user->rights->supplier_proposal->creer = 1; // Not set after the reload of module done in 7.0
$result=$localobject->valid($user); $result=$localobject->valid($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";