Fix story picture definition

This commit is contained in:
Romain Neutron
2012-09-14 11:43:08 +02:00
parent b5079ffacf
commit a8209d8c1c
3 changed files with 20 additions and 10 deletions

View File

@@ -77,7 +77,7 @@ return call_user_func(
$databox = \databox::get_instance((int) $sbas_id); $databox = \databox::get_instance((int) $sbas_id);
$record = new \record_adapter($sbas_id, $record_id); $record = new \record_adapter($sbas_id, $record_id);
if ( ! $session->is_authenticated()) { if (!$session->is_authenticated()) {
throw new \Exception_Session_NotAuthenticated(); throw new \Exception_Session_NotAuthenticated();
} }
@@ -90,20 +90,21 @@ return call_user_func(
if ($subdefObj->get_class() == 'thumbnail') { if ($subdefObj->get_class() == 'thumbnail') {
$all_access = true; $all_access = true;
} }
break;
} }
} }
} }
$user = \User_Adapter::getInstance($session->get_usr_id(), \appbox::get_instance($app['Core'])); $user = \User_Adapter::getInstance($session->get_usr_id(), \appbox::get_instance($app['Core']));
if ( ! $user->ACL()->has_access_to_subdef($record, $subdef)) { if (!$user->ACL()->has_access_to_subdef($record, $subdef)) {
throw new \Exception_UnauthorizedAction(); throw new \Exception_UnauthorizedAction();
} }
$stamp = false; $stamp = false;
$watermark = ! $user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark'); $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
if ($watermark && ! $all_access) { if ($watermark && !$all_access) {
$subdef_class = $databox $subdef_class = $databox
->get_subdef_structure() ->get_subdef_structure()
->get_subdef($record->get_type(), $subdef) ->get_subdef($record->get_type(), $subdef)
@@ -116,7 +117,7 @@ return call_user_func(
} }
} }
if ($watermark && ! $all_access) { if ($watermark && !$all_access) {
$em = $app['Core']->getEntityManager(); $em = $app['Core']->getEntityManager();
@@ -144,7 +145,7 @@ return call_user_func(
$record = \media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef); $record = \media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef);
if ( ! ($record instanceof \record_adapter)) if (!($record instanceof \record_adapter))
throw new \Exception('bad luck'); throw new \Exception('bad luck');
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
@@ -165,7 +166,7 @@ return call_user_func(
, function($label, $sbas_id, $record_id, $key, $subdef) use ($app, $session, $deliver_content) { , function($label, $sbas_id, $record_id, $key, $subdef) use ($app, $session, $deliver_content) {
$databox = \databox::get_instance((int) $sbas_id); $databox = \databox::get_instance((int) $sbas_id);
$record = \media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef); $record = \media_Permalink_Adapter::challenge_token($databox, $key, $record_id, $subdef);
if ( ! ($record instanceof \record_adapter)) if (!($record instanceof \record_adapter))
throw new \Exception('bad luck'); throw new \Exception('bad luck');
$watermark = $stamp = false; $watermark = $stamp = false;
@@ -173,7 +174,7 @@ return call_user_func(
if ($session->is_authenticated()) { if ($session->is_authenticated()) {
$user = \User_Adapter::getInstance($session->get_usr_id(), \appbox::get_instance($app['Core'])); $user = \User_Adapter::getInstance($session->get_usr_id(), \appbox::get_instance($app['Core']));
$watermark = ! $user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark'); $watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
if ($watermark) { if ($watermark) {

View File

@@ -198,6 +198,14 @@ class ACL implements cache_cacheableInterface
public function has_access_to_subdef(record_Interface $record, $subdef_name) public function has_access_to_subdef(record_Interface $record, $subdef_name)
{ {
if ($subdef_name == 'thumbnail') {
return true;
}
if ($record->is_grouping()) {
return true;
}
try { try {
$subdef_class = $record->get_databox()->get_subdef_structure() $subdef_class = $record->get_databox()->get_subdef_structure()
->get_subdef($record->get_type(), $subdef_name) ->get_subdef($record->get_type(), $subdef_name)
@@ -205,6 +213,7 @@ class ACL implements cache_cacheableInterface
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
$granted = false; $granted = false;
if ($subdef_class == databox_subdef::CLASS_THUMBNAIL) { if ($subdef_class == databox_subdef::CLASS_THUMBNAIL) {
@@ -215,7 +224,7 @@ class ACL implements cache_cacheableInterface
$granted = true; $granted = true;
} elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_right_on_base($record->get_base_id(), 'candwnldhd')) { } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_right_on_base($record->get_base_id(), 'candwnldhd')) {
$granted = true; $granted = true;
} elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record)) { } elseif ($subdef_class == databox_subdef::CLASS_DOCUMENT && $this->has_hd_grant($record)) {
$granted = true; $granted = true;
} }

View File

@@ -1053,7 +1053,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($type, $name); $subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($type, $name);
if ($this->has_subdef($name) && ! $this->get_subdef($name)->is_substituted()) { if ($this->has_subdef($name) && $this->get_subdef($name)->is_physically_present()) {
$path_file_dest = $this->get_subdef($name)->get_pathfile(); $path_file_dest = $this->get_subdef($name)->get_pathfile();
$this->get_subdef($name)->remove_file(); $this->get_subdef($name)->remove_file();