mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Change Rights needed for permalink state.
Add Translation key to phraseanet.pot
This commit is contained in:
@@ -48,14 +48,31 @@ class ToolsController extends Controller
|
|||||||
|
|
||||||
$acl = $this->getAclForUser();
|
$acl = $this->getAclForUser();
|
||||||
|
|
||||||
if ($acl->is_admin()) {
|
if ($acl->has_right('bas_chupub')
|
||||||
|
&& $acl->has_right_on_base($record->getBaseId(), 'canmodifrecord')
|
||||||
|
&& $acl->has_right_on_base($record->getBaseId(), 'imgtools')
|
||||||
|
) {
|
||||||
|
$databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType());
|
||||||
|
|
||||||
foreach ($subdefs as $subdef) {
|
foreach ($subdefs as $subdef) {
|
||||||
|
$label = $subdefName = $subdef->get_name();
|
||||||
if (null === $permalink = $subdef->get_permalink()) {
|
if (null === $permalink = $subdef->get_permalink()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('document' == $subdefName) {
|
||||||
|
$label = $this->app->trans('prod::tools: document');
|
||||||
|
} elseif (isset($databoxSubdefs[$subdefName])) {
|
||||||
|
if (!$acl->has_access_to_subdef($record, $subdefName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = $databoxSubdefs[$subdefName]->get_label($this->app['locale']);
|
||||||
|
}
|
||||||
$recordAccessibleSubdefs[] = array(
|
$recordAccessibleSubdefs[] = array(
|
||||||
'name' => $subdef->get_name(),
|
'name' => $subdef->get_name(),
|
||||||
'state' => $permalink->get_is_activated()
|
'state' => $permalink->get_is_activated(),
|
||||||
|
'label' => $label,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +308,6 @@ class ToolsController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a record share state
|
* Edit a record share state
|
||||||
* @param Application $app
|
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param $base_id
|
* @param $base_id
|
||||||
* @param $record_id
|
* @param $record_id
|
||||||
@@ -303,25 +319,26 @@ class ToolsController extends Controller
|
|||||||
$record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
|
$record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
|
||||||
$subdefName = (string)$request->request->get('name');
|
$subdefName = (string)$request->request->get('name');
|
||||||
$state = $request->request->get('state') == 'true' ? true : false;
|
$state = $request->request->get('state') == 'true' ? true : false;
|
||||||
$return = ['success' => false, 'message' => 'document type not found'];
|
|
||||||
|
|
||||||
$acl = $this->getAclForUser();
|
$acl = $this->getAclForUser();
|
||||||
if (!$acl->has_access_to_subdef($record, $subdefName) || !$acl->is_admin()) {
|
if (!$acl->has_right('bas_chupub')
|
||||||
|
|| !$acl->has_right_on_base($record->getBaseId(), 'canmodifrecord')
|
||||||
|
|| !$acl->has_right_on_base($record->getBaseId(), 'imgtools')
|
||||||
|
) {
|
||||||
$this->app->abort(403);
|
$this->app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subdefs = $record->get_subdefs();
|
$subdef = $record->get_subdef($subdefName);
|
||||||
|
|
||||||
foreach ($subdefs as $subdef) {
|
if (null === $permalink = $subdef->get_permalink()) {
|
||||||
if ($subdef->get_name($subdefName) === $subdefName) {
|
return $this->app->json(['success' => false, 'state' => false], 400);
|
||||||
$permalink = $subdef->get_permalink();
|
}
|
||||||
try {
|
|
||||||
$permalink->set_is_activated($state);
|
try {
|
||||||
$return = ['success' => true, 'state' => $permalink->get_is_activated()];
|
$permalink->set_is_activated($state);
|
||||||
} catch (\Exception $e) {
|
$return = ['success' => true, 'state' => $permalink->get_is_activated()];
|
||||||
$return = ['success' => false, 'state' => $permalink->get_is_activated()];
|
} catch (\Exception $e) {
|
||||||
}
|
$return = ['success' => false, 'state' => $permalink->get_is_activated()];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->app->json($return);
|
return $this->app->json($return);
|
||||||
|
@@ -308,36 +308,30 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if selectionLength == 1%}
|
{% if selectionLength == 1 and recordSubdefs is not empty %}
|
||||||
{% if recordSubdefs %}
|
<div id="tools-sharing" class="tabBox">
|
||||||
<div id="tools-sharing" class="tabBox">
|
<div class="well-large">
|
||||||
<div class="well-large">
|
{% for subdef in recordSubdefs %}
|
||||||
{% for subdef in recordSubdefs %}
|
<div class="row-fluid">
|
||||||
<div class="row-fluid">
|
<div class="span6">
|
||||||
<div class="span6">
|
<span class="status-marker {{ subdef.state ? 'status-active' : 'status-inactive' }}"></span>{{ subdef.label }}
|
||||||
<span class="status-marker {% if subdef.state %}status-active{% else %}status-inactive
|
|
||||||
{% endif %}"></span>{{ subdef.name }}
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<p class="text-right">
|
|
||||||
{% if subdef.state %}
|
|
||||||
<button type="button"
|
|
||||||
class="stateChange_button btn btn-inverse text-right"
|
|
||||||
data-name="{{ subdef.name }}"
|
|
||||||
data-state="{{ subdef.state }}">{{ "Disable document type sharing" | trans }}</button>
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
<button type="button" class="stateChange_button btn btn-inverse text-right"
|
|
||||||
data-name="{{ subdef.name }}"
|
|
||||||
data-state="{{ subdef.state }}">{{ "Enable document type sharing" | trans }}</button>
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
<div class="span6">
|
||||||
</div>
|
<p class="text-right">
|
||||||
|
<button type="button" class="stateChange_button btn btn-inverse text-right"
|
||||||
|
data-name="{{ subdef.name }}" data-state="{{ subdef.state }}">
|
||||||
|
{% if subdef.state %}
|
||||||
|
{{- "Disable document type sharing"|trans -}}
|
||||||
|
{% else %}
|
||||||
|
{{- "Enable document type sharing"|trans -}}
|
||||||
|
{% endif %}
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user