mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
@@ -15,6 +15,7 @@ use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
||||
|
||||
/**
|
||||
@@ -42,16 +43,26 @@ class MoveCollection implements ControllerProviderInterface
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/apply/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
$move = new RecordHelper\MoveCollection($app['Core'], $app['request']);
|
||||
$move->execute($request);
|
||||
$template = 'prod/actions/collection_submit.twig';
|
||||
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||
$move = new RecordHelper\MoveCollection($app['Core'], $request);
|
||||
$success = false;
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
try {
|
||||
$move->execute();
|
||||
$success = true;
|
||||
$msg = _('Records have been successfuly moved');
|
||||
} catch (\Exception_Unauthorized $e) {
|
||||
$msg = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination()));
|
||||
} catch (\Exception $e) {
|
||||
$msg = _('An error occured');
|
||||
}
|
||||
|
||||
return $twig->render($template, array('action' => $move, 'message' => ''));
|
||||
$datas = array(
|
||||
'success' => $success,
|
||||
'message' => $msg
|
||||
);
|
||||
|
||||
return new JsonResponse($datas);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -77,9 +77,14 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
||||
|
||||
/**
|
||||
*
|
||||
* @var <type>
|
||||
* @var Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $flatten_groupings = false;
|
||||
|
||||
/**
|
||||
|
@@ -39,19 +39,44 @@ class MoveCollection extends RecordHelper
|
||||
*/
|
||||
protected $works_on_unique_sbas = true;
|
||||
|
||||
/**
|
||||
* Destination collection id
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $baseIdDestination;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Alchemy\Phrasea\Core $core
|
||||
*
|
||||
* @return MoveCollection
|
||||
*/
|
||||
public function __construct(Core $core, Request $Request)
|
||||
public function __construct(Core $core, Request $request)
|
||||
{
|
||||
parent::__construct($core, $Request);
|
||||
$this->baseIdDestination = $request->get('base_id');
|
||||
|
||||
if ($request->get("chg_coll_son") == "1") {
|
||||
$this->flatten_groupings = true;
|
||||
}
|
||||
|
||||
parent::__construct($core, $request);
|
||||
|
||||
$this->evaluate_destinations();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get destination collection id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBaseIdDestination()
|
||||
{
|
||||
return $this->baseIdDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check which collections can receive the documents
|
||||
*
|
||||
@@ -91,38 +116,23 @@ class MoveCollection extends RecordHelper
|
||||
|
||||
/**
|
||||
*
|
||||
* @param http_request $request
|
||||
* @return action_move
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
public function execute()
|
||||
{
|
||||
$appbox = \appbox::get_instance($this->core);
|
||||
$user = $this->getCore()->getAuthenticatedUser();
|
||||
|
||||
$baseId = $request->get('base_id');
|
||||
|
||||
$base_dest =
|
||||
$user->ACL()->has_right_on_base($baseId, 'canaddrecord') ?
|
||||
$request->get('base_id') : false;
|
||||
$user->ACL()->has_right_on_base($this->baseIdDestination, 'canaddrecord') ?
|
||||
$this->baseIdDestination : false;
|
||||
|
||||
if ( ! $user->ACL()->has_right_on_base($baseId, 'canaddrecord')) {
|
||||
throw new \Exception_Unauthorized(sprintf("%s do not have the permission to move records to %s", $user->get_login()));
|
||||
if ( ! $user->ACL()->has_right_on_base($this->baseIdDestination, 'canaddrecord')) {
|
||||
throw new \Exception_Unauthorized(sprintf("user id %s does not have the permission to move records to %s", $user->get_id(), \phrasea::bas_names($this->baseIdDestination)));
|
||||
}
|
||||
|
||||
if ( ! $this->is_possible())
|
||||
throw new Exception('This action is not possible');
|
||||
|
||||
if ($request->get("chg_coll_son") == "1") {
|
||||
foreach ($this->selection as $record) {
|
||||
if ( ! $record->is_grouping())
|
||||
continue;
|
||||
foreach ($record->get_children() as $child) {
|
||||
if ( ! $user->ACL()->has_right_on_base(
|
||||
$child->get_base_id(), 'candeleterecord'))
|
||||
continue;
|
||||
$this->selection->add_element($child);
|
||||
}
|
||||
}
|
||||
if ( ! $this->is_possible()) {
|
||||
throw new \Exception('This action is not possible');
|
||||
}
|
||||
|
||||
$collection = \collection::get_from_base_id($base_dest);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
|
||||
use MediaAlchemyst\Specification\Image as ImageSpecification;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -101,6 +102,20 @@ class appbox extends base
|
||||
if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) {
|
||||
throw new \InvalidArgumentException('Invalid file format');
|
||||
}
|
||||
|
||||
//resize collection logo
|
||||
$imageSpec = new ImageSpecification();
|
||||
$imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
|
||||
$imageSpec->setDimensions(120, 24);
|
||||
|
||||
try {
|
||||
$core['media-alchemyst']
|
||||
->open($pathfile->getPathname())
|
||||
->turninto($pathfile->getPathname(), $imageSpec)
|
||||
->close();
|
||||
} catch (\MediaAlchemyst\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
switch ($pic_type) {
|
||||
@@ -132,7 +147,7 @@ class appbox extends base
|
||||
$core['file-system']->remove($target);
|
||||
}
|
||||
|
||||
if (is_null($target)) {
|
||||
if (null === $target || null === $pathfile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -366,7 +381,7 @@ class appbox extends base
|
||||
|
||||
$upgrader->add_steps_complete(1);
|
||||
|
||||
if(version_compare($from_version, '3.1') < 0) {
|
||||
if (version_compare($from_version, '3.1') < 0) {
|
||||
$upgrader->addRecommendation(_('Your install requires data migration, please execute the following command'), 'bin/upgrader --from=3.1');
|
||||
} elseif (version_compare($from_version, '3.5') < 0) {
|
||||
$upgrader->addRecommendation(_('Your install requires data migration, please execute the following command'), 'bin/upgrader --from=3.5');
|
||||
|
@@ -24,6 +24,7 @@
|
||||
{% endtrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if action.is_possible() %}
|
||||
{% set countable = action.get_count_actionable() %}
|
||||
{% trans %}
|
||||
@@ -31,18 +32,14 @@
|
||||
{% endtrans %}
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<select name="base_id">
|
||||
|
||||
{% for base_id in action.available_destination() %}
|
||||
<option value="{{base_id}}">{{base_id|bas_names}}</option>
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
{% if action.get_count_actionable_groupings() %}
|
||||
<table style="border:#ff0000 1px solid;">
|
||||
<tr>
|
||||
@@ -54,19 +51,17 @@
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<input type="hidden" name="act" value="WORK">
|
||||
<input type="hidden" name="lst" value="{{ action.get_serialize_list() }}">
|
||||
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function(){
|
||||
|
||||
$dialog = p4.Dialog.get(1);
|
||||
|
||||
@@ -78,16 +73,35 @@
|
||||
|
||||
var coll_son = $('input[name="chg_coll_son"]:checked', $form).length > 0 ? '1' : '0';
|
||||
var datas = {
|
||||
lst:$('input[name="lst"]', $form).val(),
|
||||
base_id:$('select[name="base_id"]', $form).val(),
|
||||
chg_coll_son:coll_son
|
||||
lst: $('input[name="lst"]', $form).val(),
|
||||
base_id: $('select[name="base_id"]', $form).val(),
|
||||
chg_coll_son: coll_son
|
||||
};
|
||||
|
||||
var buttonPanel = $dialog.getDomElement()
|
||||
.closest('.ui-dialog')
|
||||
.find('.ui-dialog-buttonpane');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/records/movecollection/apply/",
|
||||
dataType: 'json',
|
||||
data: datas,
|
||||
beforeSend: function() {
|
||||
$(":button:contains('" + language.valider + "')", buttonPanel)
|
||||
.attr("disabled", true).addClass("ui-state-disabled");
|
||||
},
|
||||
success: function(data){
|
||||
$dialog.Close();
|
||||
if(data.success) {
|
||||
humane.info(data.message);
|
||||
} else {
|
||||
humane.error(data.message);
|
||||
}
|
||||
},
|
||||
complete: function(){
|
||||
$(":button:contains('" + language.valider + "')", buttonPanel)
|
||||
.attr("disabled", false).removeClass("ui-state-disabled");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,6 +109,5 @@
|
||||
};
|
||||
|
||||
$dialog.setOption('buttons', buttons);
|
||||
|
||||
});
|
||||
</script>
|
||||
});
|
||||
</script>
|
||||
|
@@ -1,22 +0,0 @@
|
||||
<html lang="{{session.get_I18n()}}">
|
||||
<head>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/prod/{{user.getPrefs('css')}}/prodcolor.css," />
|
||||
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jquery.p4.modal.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="body" class="bodyprofile" style="overflow:hidden; padding:0px; margin:0px;">
|
||||
<div class="boxCloser" onclick="parent.hideDwnl();">{%trans 'boutton::fermer' %}</div>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#colls">{%trans 'prod::collection::Changer de collection' %}</a></li>
|
||||
</ul>
|
||||
<div id="colls" class="tabBox">
|
||||
<div style="text-align:center;margin:30px 0px;">
|
||||
{{message}}
|
||||
<input class="input-button" type="button" value="{%trans 'boutton::fermer' %}" onclick="parent.hideDwnl();" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user