mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Merge pull request #394 from romainneutron/template-time-limits
[3.8] Template time limits
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
- BC Break : Removed `bin/console check:system` command, replaced by `bin/setup check:system`.
|
||||
- BC Break : Removed `bin/console system:upgrade` command, replaced by `bin/setup system:upgrade`.
|
||||
- BC break : Configuration simplification, optimized for performances.
|
||||
- BC Break : Time limits are now applied on templates application.
|
||||
|
||||
- SwiftMailer integration (replaces PHPMailer).
|
||||
- Emails now include an HTML view.
|
||||
|
@@ -389,11 +389,25 @@ class ACL implements cache_cacheableInterface
|
||||
$this->update_rights_to_base($base_id, $rights);
|
||||
}
|
||||
|
||||
$this->apply_template_time_limits($template_user, $base_ids);
|
||||
|
||||
$this->user->set_last_template($template_user);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function apply_template_time_limits(User_Interface $template_user, Array $base_ids)
|
||||
{
|
||||
foreach ($base_ids as $base_id) {
|
||||
$limited = $template_user->ACL()->get_limits($base_id);
|
||||
if (null !== $limited) {
|
||||
$this->set_limits($base_id, '1', $limited['dmin'], $limited['dmax']);
|
||||
} else {
|
||||
$this->set_limits($base_id, '0', $limited['dmin'], $limited['dmax']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
@@ -1555,7 +1569,7 @@ class ACL implements cache_cacheableInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
return ($this->_limited[$base_id]);
|
||||
return $this->_limited[$base_id];
|
||||
}
|
||||
|
||||
public function set_limits($base_id, $limit, DateTime $limit_from = null, DateTime $limit_to = null)
|
||||
|
@@ -81,6 +81,48 @@ class ACLTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($base_ids as $base_id) {
|
||||
$this->assertNull($cobaye->ACL()->get_limits($base_id));
|
||||
}
|
||||
|
||||
$template->delete();
|
||||
$cobaye->delete();
|
||||
}
|
||||
|
||||
public function testApply_model_with_time_limit()
|
||||
{
|
||||
$template = User_Adapter::create(self::$DI['app'], 'test_phpunit2', 'blabla2', 'test2@example.com', false);
|
||||
$template->set_template(self::$DI['user']);
|
||||
|
||||
$base_ids = array();
|
||||
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
$base_id = $collection->get_base_id();
|
||||
$base_ids[] = $base_id;
|
||||
}
|
||||
}
|
||||
$template->ACL()->give_access_to_base($base_ids);
|
||||
|
||||
$limit_from = new \DateTime('-1 day');
|
||||
$limit_to = new \DateTime('+1 day');
|
||||
|
||||
foreach ($base_ids as $base_id) {
|
||||
$template->ACL()->set_limits($base_id, 1, $limit_from, $limit_to);
|
||||
}
|
||||
|
||||
$cobaye = User_Adapter::create(self::$DI['app'], 'test_phpunit3', 'blabla3', 'test3@example.com', false);
|
||||
$cobaye->ACL()->apply_model($template, $base_ids);
|
||||
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
$base_id = $collection->get_base_id();
|
||||
$this->assertTrue($cobaye->ACL()->has_access_to_base($base_id));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($base_ids as $base_id) {
|
||||
$this->assertEquals(array('dmin' => $limit_from, 'dmax' => $limit_to), $cobaye->ACL()->get_limits($base_id));
|
||||
}
|
||||
|
||||
$template->delete();
|
||||
$cobaye->delete();
|
||||
}
|
||||
|
BIN
www/skins/icons/user_details_gray.png
Normal file
BIN
www/skins/icons/user_details_gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user