mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
@@ -15,6 +15,7 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,16 +43,26 @@ class MoveCollection implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/apply/', function(Application $app) {
|
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||||
$request = $app['request'];
|
$move = new RecordHelper\MoveCollection($app['Core'], $request);
|
||||||
$move = new RecordHelper\MoveCollection($app['Core'], $app['request']);
|
$success = false;
|
||||||
$move->execute($request);
|
|
||||||
$template = 'prod/actions/collection_submit.twig';
|
|
||||||
|
|
||||||
/* @var $twig \Twig_Environment */
|
try {
|
||||||
$twig = $app['Core']->getTwig();
|
$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;
|
return $controllers;
|
||||||
|
@@ -77,9 +77,14 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var <type>
|
* @var Symfony\Component\HttpFoundation\Request
|
||||||
*/
|
*/
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
protected $flatten_groupings = false;
|
protected $flatten_groupings = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -39,19 +39,44 @@ class MoveCollection extends RecordHelper
|
|||||||
*/
|
*/
|
||||||
protected $works_on_unique_sbas = true;
|
protected $works_on_unique_sbas = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destination collection id
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $baseIdDestination;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param \Alchemy\Phrasea\Core $core
|
* @param \Alchemy\Phrasea\Core $core
|
||||||
|
*
|
||||||
* @return MoveCollection
|
* @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();
|
$this->evaluate_destinations();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get destination collection id
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getBaseIdDestination()
|
||||||
|
{
|
||||||
|
return $this->baseIdDestination;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check which collections can receive the documents
|
* Check which collections can receive the documents
|
||||||
*
|
*
|
||||||
@@ -91,38 +116,23 @@ class MoveCollection extends RecordHelper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param http_request $request
|
|
||||||
* @return action_move
|
* @return action_move
|
||||||
*/
|
*/
|
||||||
public function execute(Request $request)
|
public function execute()
|
||||||
{
|
{
|
||||||
$appbox = \appbox::get_instance($this->core);
|
$appbox = \appbox::get_instance($this->core);
|
||||||
$user = $this->getCore()->getAuthenticatedUser();
|
$user = $this->getCore()->getAuthenticatedUser();
|
||||||
|
|
||||||
$baseId = $request->get('base_id');
|
|
||||||
|
|
||||||
$base_dest =
|
$base_dest =
|
||||||
$user->ACL()->has_right_on_base($baseId, 'canaddrecord') ?
|
$user->ACL()->has_right_on_base($this->baseIdDestination, 'canaddrecord') ?
|
||||||
$request->get('base_id') : false;
|
$this->baseIdDestination : false;
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_base($baseId, 'canaddrecord')) {
|
if ( ! $user->ACL()->has_right_on_base($this->baseIdDestination, 'canaddrecord')) {
|
||||||
throw new \Exception_Unauthorized(sprintf("%s do not have the permission to move records to %s", $user->get_login()));
|
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())
|
if ( ! $this->is_possible()) {
|
||||||
throw new Exception('This action is not 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = \collection::get_from_base_id($base_dest);
|
$collection = \collection::get_from_base_id($base_dest);
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
|
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'))) {
|
if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) {
|
||||||
throw new \InvalidArgumentException('Invalid file format');
|
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) {
|
switch ($pic_type) {
|
||||||
@@ -132,7 +147,7 @@ class appbox extends base
|
|||||||
$core['file-system']->remove($target);
|
$core['file-system']->remove($target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($target)) {
|
if (null === $target || null === $pathfile) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
{% endtrans %}
|
{% endtrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if action.is_possible() %}
|
{% if action.is_possible() %}
|
||||||
{% set countable = action.get_count_actionable() %}
|
{% set countable = action.get_count_actionable() %}
|
||||||
{% trans %}
|
{% trans %}
|
||||||
@@ -31,18 +32,14 @@
|
|||||||
{% endtrans %}
|
{% endtrans %}
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<select name="base_id">
|
<select name="base_id">
|
||||||
|
|
||||||
{% for base_id in action.available_destination() %}
|
{% for base_id in action.available_destination() %}
|
||||||
<option value="{{base_id}}">{{base_id|bas_names}}</option>
|
<option value="{{base_id}}">{{base_id|bas_names}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
{% if action.get_count_actionable_groupings() %}
|
{% if action.get_count_actionable_groupings() %}
|
||||||
<table style="border:#ff0000 1px solid;">
|
<table style="border:#ff0000 1px solid;">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -54,13 +51,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<input type="hidden" name="act" value="WORK">
|
<input type="hidden" name="act" value="WORK">
|
||||||
<input type="hidden" name="lst" value="{{ action.get_serialize_list() }}">
|
<input type="hidden" name="lst" value="{{ action.get_serialize_list() }}">
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -82,12 +77,31 @@
|
|||||||
base_id: $('select[name="base_id"]', $form).val(),
|
base_id: $('select[name="base_id"]', $form).val(),
|
||||||
chg_coll_son: coll_son
|
chg_coll_son: coll_son
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var buttonPanel = $dialog.getDomElement()
|
||||||
|
.closest('.ui-dialog')
|
||||||
|
.find('.ui-dialog-buttonpane');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/prod/records/movecollection/apply/",
|
url: "/prod/records/movecollection/apply/",
|
||||||
|
dataType: 'json',
|
||||||
data: datas,
|
data: datas,
|
||||||
|
beforeSend: function() {
|
||||||
|
$(":button:contains('" + language.valider + "')", buttonPanel)
|
||||||
|
.attr("disabled", true).addClass("ui-state-disabled");
|
||||||
|
},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
$dialog.Close();
|
$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);
|
$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