mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 23:43:12 +00:00
fix : status mask of user where not changed when applying a user template
nb: because a new user has all mask checked (all rights), a template will only UNCHECK boxes (remove rights): - unchecked boxes on template will be unchecked on user - checked boxes on template does nothing (left unchanged on user)
This commit is contained in:
@@ -298,6 +298,13 @@ class ACL implements cache_cacheableInterface
|
|||||||
$bas_to_acces = array();
|
$bas_to_acces = array();
|
||||||
$rights_to_give = array();
|
$rights_to_give = array();
|
||||||
|
|
||||||
|
$sbmap = array( // map masks (and+xor) of template to masks to apply to user on base (and_and, and_or, xor_and, xor_or)
|
||||||
|
'00'=>array('aa'=>'1', 'ao'=>'0', 'xa'=>'1', 'xo'=>'0'),
|
||||||
|
'01'=>array('aa'=>'1', 'ao'=>'0', 'xa'=>'1', 'xo'=>'0'),
|
||||||
|
'10'=>array('aa'=>'1', 'ao'=>'1', 'xa'=>'0', 'xo'=>'0'),
|
||||||
|
'11'=>array('aa'=>'1', 'ao'=>'1', 'xa'=>'1', 'xo'=>'1')
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($template_user->ACL()->get_granted_base() as $collection)
|
foreach ($template_user->ACL()->get_granted_base() as $collection)
|
||||||
{
|
{
|
||||||
$base_id = $collection->get_base_id();
|
$base_id = $collection->get_base_id();
|
||||||
@@ -317,6 +324,20 @@ class ACL implements cache_cacheableInterface
|
|||||||
$rights_to_give[$base_id][$right] = '1';
|
$rights_to_give[$base_id][$right] = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply sb : unchecked boxes on template will be unchecked on user
|
||||||
|
// checked boxes on template does nothing (left unchanged on user)
|
||||||
|
// get masks from 64 bits int AS DECIMAL STRING to BINARY STRING
|
||||||
|
$mand = substr(str_repeat('0', 64) . databox_status::dec2bin($template_user->ACL()->get_mask_and($base_id)), -64);
|
||||||
|
$mxor = substr(str_repeat('0', 64) . databox_status::dec2bin($template_user->ACL()->get_mask_xor($base_id)), -64);
|
||||||
|
$m = array('aa'=>'', 'ao'=>'', 'xa'=>'', 'xo'=>'');
|
||||||
|
for($i=0; $i<64; $i++)
|
||||||
|
{
|
||||||
|
$ax = $mand[$i].$mxor[$i];
|
||||||
|
foreach($m as $k=>$v)
|
||||||
|
$m[$k] .= $sbmap[$ax][$k];
|
||||||
|
}
|
||||||
|
$this->set_masks_on_base($base_id, $m['aa'], $m['ao'], $m['xa'], $m['xo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->give_access_to_base($bas_to_acces);
|
$this->give_access_to_base($bas_to_acces);
|
||||||
@@ -1401,7 +1422,6 @@ class ACL implements cache_cacheableInterface
|
|||||||
public function set_masks_on_base($base_id, $and_and, $and_or, $xor_and, $xor_or)
|
public function set_masks_on_base($base_id, $and_and, $and_or, $xor_and, $xor_or)
|
||||||
{
|
{
|
||||||
$vhex = array();
|
$vhex = array();
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'and_and' => $and_and,
|
'and_and' => $and_and,
|
||||||
'and_or' => $and_or,
|
'and_or' => $and_or,
|
||||||
@@ -1424,6 +1444,7 @@ class ACL implements cache_cacheableInterface
|
|||||||
$vhex[$name] .= dechex(bindec($valtmp));
|
$vhex[$name] .= dechex(bindec($valtmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE basusr
|
$sql = "UPDATE basusr
|
||||||
SET mask_and=((mask_and & " . $vhex['and_and'] . ") | " . $vhex['and_or'] . ")
|
SET mask_and=((mask_and & " . $vhex['and_and'] . ") | " . $vhex['and_or'] . ")
|
||||||
,mask_xor=((mask_xor & " . $vhex['xor_and'] . ") | " . $vhex['xor_or'] . ")
|
,mask_xor=((mask_xor & " . $vhex['xor_and'] . ") | " . $vhex['xor_or'] . ")
|
||||||
|
Reference in New Issue
Block a user