Merge with 3.7

This commit is contained in:
Romain Neutron
2012-10-30 11:27:50 +01:00
13 changed files with 134 additions and 14 deletions

View File

@@ -0,0 +1,12 @@
binaries:
php_binary: ''
convert_binary: ''
composite_binary: ''
swf_extract_binary: ''
pdf2swf_binary: ''
swf_render_binary: ''
unoconv_binary: ''
ffmpeg_binary: ''
ffprobe_binary: ''
mp4box_binary: ''
pdftotext_binary: ''

View File

@@ -272,6 +272,7 @@ class Install extends Command
'ffprobe_binary' => $this->executableFinder->find('ffprobe', $this->executableFinder->find('avprobe')),
'mp4box_binary' => $this->executableFinder->find('MP4Box'),
'pdftotext_binary' => $this->executableFinder->find('pdf2text'),
'ghostscript_binary' => $this->executableFinder->find('gs'),
);
}
}

View File

@@ -36,6 +36,7 @@ class Push implements ControllerProviderInterface
, 'lastname' => $user->get_lastname()
, 'email' => $user->get_email()
, 'display_name' => $user->get_display_name()
, 'subtitle' => sprintf('%s, %s', $user->get_job(), $user->get_company())
);
};
}

View File

@@ -130,7 +130,7 @@ class Query implements ControllerProviderInterface
$options->set_min_date($request->request->get('datemin'));
$options->set_max_date($request->request->get('datemax'));
$options->set_date_fields(explode('|', $request->request->get('datefield')));
$options->set_sort($request->request->get('sort'), $request->request->get('ord', PHRASEA_ORDER_DESC));
$options->set_sort($request->request->get('sort'), $request->request->get('ord', \searchEngine_options::SORT_MODE_DESC));
$options->set_use_stemming($request->request->get('stemme'));
$form = serialize($options);

View File

@@ -209,6 +209,8 @@ class Records implements ControllerProviderInterface
));
$basketElementsRepository = $app['EM']->getRepository('\Entities\BasketElement');
$StoryWZRepository = $app['EM']->getRepository('\Entities\StoryWZ');
$deleted = array();
foreach ($records as $record) {
@@ -220,6 +222,12 @@ class Records implements ControllerProviderInterface
$deleted[] = $element->getRecord($app)->get_serialize_key();
}
$attachedStories = $StoryWZRepository->findByRecord($record);
foreach ($attachedStories as $attachedStory) {
$app['EM']->remove($attachedStory);
}
$record->delete();
$deleted[] = $record->get_serialize_key();
} catch (\Exception $e) {

View File

@@ -443,6 +443,25 @@ class Login implements ControllerProviderInterface
*/
public function displayRegisterForm(Application $app, Request $request)
{
$captchaSys = '';
if ($app['phraseanet.registry']->get('GV_captchas')
&& $app['phraseanet.registry']->get('GV_captcha_private_key')
&& $app['phraseanet.registry']->get('GV_captcha_public_key')) {
require_once __DIR__ . '/../../../../../lib/vendor/recaptcha/recaptchalib.php';
$captchaSys = '<div style="margin:0;width:330px;">
<div id="recaptcha_image" style="margin:10px 0px 5px"></div>
<div style="text-align:left;margin:0 0px 5px;width:300px;">
<a href="javascript:Recaptcha.reload()" class="link">' . _('login::captcha: obtenir une autre captcha') . '</a>
</div>
<div style="text-align:left;width:300px;">
<span class="recaptcha_only_if_image">' . _('login::captcha: recopier les mots ci dessous') . ' : </span>
<input name="recaptcha_response_field" id="recaptcha_response_field" value="" type="text" style="width:180px;"/>
</div>' . recaptcha_get_html($app['phraseanet.registry']->get('GV_captcha_public_key')) . '</div>';
}
$login = new \login();
if (false === $login->register_enabled($app)) {
return $app->redirect('/login/?notice=no-register-available');
@@ -482,20 +501,23 @@ class Login implements ControllerProviderInterface
}
}
$arrayVerif = $this->getRegisterFieldConfiguration($app);
return $app['twig']->render('login/register.html.twig', array(
'inscriptions' => giveMeBases($app),
'parms' => $request->query->all(),
'needed' => $needed,
'arrayVerif' => $arrayVerif,
'demandes' => $request->query->get('demand', array()),
'lng' => $app['locale']
'inscriptions' => giveMeBases($app),
'parms' => $request->query->all(),
'needed' => $needed,
'arrayVerif' => $arrayVerif,
'demandes' => $request->query->get('demand', array()),
'lng' => $app['locale'],
'captcha_system' => $captchaSys,
));
}
/**
* Get the register form
* Do the registration
*
* @param Application $app A Silex application where the controller is mounted on
* @param Request $request The current request
@@ -503,6 +525,28 @@ class Login implements ControllerProviderInterface
*/
public function register(Application $app, Request $request)
{
$captchaOK = true;
if ($app['phraseanet.registry']->get('GV_captchas')
&& $request->request->get('GV_captcha_private_key')
&& $request->request->get('GV_captcha_public_key')
&& $request->request->get("recaptcha_challenge_field")
&& $request->request->get("recaptcha_response_field")) {
$checkCaptcha = recaptcha_check_answer(
$app['phraseanet.registry']->get('GV_captcha_private_key'),
$request->server->get('REMOTE_ADDR'),
$request->request->get["recaptcha_challenge_field"],
$request->request->get["recaptcha_response_field"]
);
$captchaOK = $checkCaptcha->is_valid;
}
if (!$captchaOK) {
return $app->redirect($app['url_generator']->generate('login_register', array(
'error' => $captcha
)));
}
$arrayVerif = $this->getRegisterFieldConfiguration($app);
$parameters = $request->request->all();
@@ -555,7 +599,9 @@ class Login implements ControllerProviderInterface
}
if (sizeof($needed) > 0) {
return $app->redirect(sprintf('/register/?%s', http_build_query(array('needed' => $needed))));
return $app->redirect($app['url_generator']->generate('login_register', array(
'needed' => $needed
)));
}
require_once($app['phraseanet.registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php');

View File

@@ -104,4 +104,30 @@ class StoryWZRepository extends EntityRepository
return $story;
}
public function findByRecord(\record_adapter $Story)
{
$dql = 'SELECT s FROM Entities\StoryWZ s WHERE s.sbas_id = :sbas_id
AND s.record_id = :record_id';
$query = $this->_em->createQuery($dql);
$query->setParameters(array(
'sbas_id' => $Story->get_sbas_id(),
'record_id' => $Story->get_record_id(),
));
$stories = $query->getResult();
foreach ($stories as $key => $story) {
try {
$record = $story->getRecord();
} catch (\Exception_Record_AdapterNotFound $e) {
$this->getEntityManager()->remove($story);
$this->getEntityManager()->flush();
unset($stories[$key]);
}
}
return $stories;
}
}

View File

@@ -19,6 +19,7 @@ use Alchemy\Phrasea\Application;
function deleteRecord(Application $app, $lst, $del_children)
{
$BE_repository = $app['EM']->getRepository('\Entities\BasketElement');
$StoryWZ_repository = $em->getRepository('\Entities\StoryWZ');
$ACL = $app['phraseanet.user']->ACL();
@@ -77,6 +78,12 @@ function deleteRecord(Application $app, $lst, $del_children)
}
$ret[] = $record->get_serialize_key();
$attachedStories = $StoryWZ_repository->findByRecord($record);
foreach ($attachedStories as $attachedStory) {
$em->remove($attachedStory);
}
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach ($basket_elements as $basket_element) {

View File

@@ -90,7 +90,7 @@ class patch_373 implements patchInterface
'GV_pdftotext' => 'pdftotext_binary',
);
$binaries = array();
$binaries = array('ghostscript_binary' => '');
foreach ($Regbinaries as $name) {
$stmt->execute(array(':key' => $name));

View File

@@ -61,7 +61,9 @@ class registry implements registryInterface
$binaries = $app['phraseanet.configuration']->getBinaries();
if (isset($binaries['binaries'])) {
foreach ($binaries['binaries'] as $name => $path) {
$this->cache->save($name, $path);
if ($path) {
$this->cache->save($name, $path);
}
}
}
}

View File

@@ -95,6 +95,15 @@
{% endblock %}
{% block content %}
{% if captcha_system != '' %}
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'custom',
tabindex : 3,
lang : '{{ app['locale'] }}'
};
</script>
{% endif %}
<form id="register" class="form-horizontal" name="creation" action="/login/register/" method="POST">
<div id="form_register_table" style="font-size: 11px; margin: 0 auto;">
<div class="control-group">
@@ -283,6 +292,14 @@
<p class="form_alert help-block">{{ needed['form_zip'] is defined ? needed['form_zip'] : '' }}</p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="captcha_protecion">
{% trans 'Robots SPAM protection :l' %}
</label>
<div class="controls">
{{ captcha_system | raw }}
</div>
</div>
<hr />
</div><!-- /form_register_table -->

View File

@@ -120,7 +120,7 @@ $options->set_sort($parm['sort'], $parm['ord']);
$options->set_use_stemming($parm['stemme']);
if ($parm['ord'] === NULL)
$parm['ord'] = PHRASEA_ORDER_DESC;
$parm['ord'] = \searchEngine_options::SORT_MODE_DESC;
else
$parm['ord'] = (int) $parm['ord'];

View File

@@ -105,7 +105,7 @@ $user = User_Adapter::getInstance($usr_id, $app);
}
</style>
</head>
<body class="PNB" style="overflow:hidden;">
<body class="PNB" style="width:100%;height:100%;overflow:hidden;">
<div id="container" style="position:absolute;top:0;left:0;overflow:hidden;width:100%;height:100%;">
<?php
@@ -285,7 +285,7 @@ if ($app['phraseanet.registry']->get('GV_client_coll_ckbox') === 'popup') {
<input type="hidden" name="sort" value="<?php echo $app['phraseanet.registry']->get('GV_phrasea_sort'); ?>"/>
<input type="hidden" name="ord" id="searchOrd" value="<?php echo PHRASEA_ORDER_DESC ?>" />
<input type="hidden" name="ord" id="searchOrd" value="<?php echo \searchEngine_options::SORT_MODE_DESC ?>" />
</div>
<div>