mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Fix ACL binary comparison
This commit is contained in:
@@ -223,7 +223,7 @@ class ACL implements cache_cacheableInterface
|
||||
|
||||
public function has_status_access_to_record(record_adapter $record)
|
||||
{
|
||||
return (Boolean) ('Ob' . $record->get_status() ^ $this->get_mask_xor($record->get_base_id()) & $this->get_mask_and($record->get_base_id()));
|
||||
return 0 === ((bindec($record->get_status()) ^ $this->get_mask_xor($record->get_base_id())) & $this->get_mask_and($record->get_base_id()));
|
||||
}
|
||||
|
||||
public function has_access_to_subdef(record_Interface $record, $subdef_name)
|
||||
@@ -1050,9 +1050,9 @@ class ACL implements cache_cacheableInterface
|
||||
$this->_rights_bas[$row['base_id']]['canreport']
|
||||
= $row['canreport'] == '1';
|
||||
$this->_rights_bas[$row['base_id']]['mask_and']
|
||||
= $row['mask_and'];
|
||||
= (int) $row['mask_and'];
|
||||
$this->_rights_bas[$row['base_id']]['mask_xor']
|
||||
= $row['mask_xor'];
|
||||
= (int) $row['mask_xor'];
|
||||
$this->_rights_bas[$row['base_id']]['modify_struct']
|
||||
= $row['modify_struct'] == '1';
|
||||
$this->_rights_bas[$row['base_id']]['manage']
|
||||
@@ -1551,6 +1551,8 @@ class ACL implements cache_cacheableInterface
|
||||
|
||||
unset($stmt);
|
||||
|
||||
$this->delete_data_from_cache(self::CACHE_RIGHTS_BAS);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -48,14 +48,40 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
}
|
||||
|
||||
public function testHasAccesToRecordStatus()
|
||||
{
|
||||
self::$DI['record_1']->set_binary_status(str_repeat('0', 32));
|
||||
|
||||
self::$object->set_masks_on_base(self::$DI['record_1']->get_base_id(), '10000', '10000', '0', '0');
|
||||
|
||||
self::$DI['record_1']->set_binary_status('10000');
|
||||
$this->assertFalse(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
|
||||
self::$DI['record_1']->set_binary_status('00000');
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
|
||||
self::$object->set_masks_on_base(self::$DI['record_1']->get_base_id(), '10000', '10000', '10000', '10000');
|
||||
|
||||
$this->assertFalse(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
|
||||
self::$DI['record_1']->set_binary_status('10000');
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
|
||||
self::$object->set_masks_on_base(self::$DI['record_1']->get_base_id(), '0', '0', '0', '0');
|
||||
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
self::$DI['record_1']->set_binary_status(str_repeat('0', 32));
|
||||
$this->assertTrue(self::$object->has_status_access_to_record(self::$DI['record_1']));
|
||||
}
|
||||
|
||||
public function testHasAccesToRecordFailsOnBase()
|
||||
{
|
||||
$this->assertFalse(self::$object->has_status_access_to_record(self::$DI['record_no_access']));
|
||||
$this->assertFalse(self::$object->has_access_to_record(self::$DI['record_no_access']));
|
||||
}
|
||||
|
||||
public function testHasAccesToRecordFailsOnStatus()
|
||||
{
|
||||
$this->assertFalse(self::$object->has_status_access_to_record(self::$DI['record_no_access_by_status']));
|
||||
$this->assertFalse(self::$object->has_access_to_record(self::$DI['record_no_access_by_status']));
|
||||
}
|
||||
|
||||
public function testApply_model()
|
||||
|
Reference in New Issue
Block a user