From 7e804f2ff001f5dfa0e632e98100b66fb93466b1 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Wed, 1 Aug 2012 19:04:31 +0200 Subject: [PATCH 01/12] fix #852 remove candidat links when user has no access to thesaurus module --- templates/web/prod/index.html.twig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index b8735ae550..7aeb6c6e0c 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -178,7 +178,9 @@
From 74c1c5da4fba9f982f675e56bad17889b6b0505e Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Wed, 1 Aug 2012 18:43:33 +0200 Subject: [PATCH 02/12] fix #855 fix carriage return push form textarea unable form submission with submit event --- www/prod/jquery.Feedback.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/www/prod/jquery.Feedback.js b/www/prod/jquery.Feedback.js index 75101042bb..c8947c3555 100644 --- a/www/prod/jquery.Feedback.js +++ b/www/prod/jquery.Feedback.js @@ -186,14 +186,6 @@ var $dialog = p4.Dialog.Create(options, 2); - $dialog.getDomElement().bind("keypress", function(event){ - if(event.which){ - if(event.which==13){ - return false; - } - } - }); - var $FeedBackForm = $('form[name="FeedBackForm"]', $container); var callback = function(rendered){ @@ -204,6 +196,9 @@ $('textarea[name="message"]', $dialog.getDomElement()).val($('textarea[name="message"]', $FeedBackForm).val()); $('.' + $this.Context, $dialog.getDomElement()).show(); + $('form', $dialog.getDomElement()).submit(function() { + return false; + }); }; p4.Mustache.Render('Feedback-SendForm', { From 75bfca84c4127bdb5aa5c00dd124119f7a690f1e Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 21 Aug 2012 17:52:13 +0200 Subject: [PATCH 03/12] Fix #853 Add default phrasea sort to classic --- lib/classes/phrasea.class.php | 2 +- www/client/index.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/classes/phrasea.class.php b/lib/classes/phrasea.class.php index 9e3db359e0..6c5832dd5e 100644 --- a/lib/classes/phrasea.class.php +++ b/lib/classes/phrasea.class.php @@ -135,7 +135,7 @@ class phrasea $parm["datemax"] = ''; $parm["recordtype"] = ''; $parm["datefield"] = ''; - $parm["sort"] = ''; + $parm["sort"] = $registry->get('GV_phrasea_sort'); $parm["stemme"] = ''; $parm["dateminfield"] = array(); $parm["datemaxfield"] = array(); diff --git a/www/client/index.php b/www/client/index.php index cfe09e6da4..09e0994a18 100644 --- a/www/client/index.php +++ b/www/client/index.php @@ -286,6 +286,9 @@ if ($registry->get('GV_client_coll_ckbox') === 'popup') { id="search_type_docs" name="search_type" /> id="search_type_group" name="search_type" /> + + +
From 44941f962a3cef4ee292a09dd83739c648f6fda7 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 21 Aug 2012 17:59:10 +0200 Subject: [PATCH 04/12] Fix #854: Multi fields in defaults structures as set as mono --- lib/classes/databox.class.php | 4 +++- lib/conf.d/data_templates/en-simple.xml | 2 +- lib/conf.d/data_templates/fr-simple.xml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 0f84bc5883..0761adba69 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -858,7 +858,9 @@ class databox extends base ) ) ? $type : databox_field::TYPE_STRING; - $meta_struct_field = databox_field::create($this, $fname, false); + $multi = isset($field['multi']) ? (Boolean) $field['multi'] : false; + + $meta_struct_field = databox_field::create($this, $fname, $multi); $meta_struct_field ->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0) ->set_indexable(isset($field['index']) ? $field['index'] : '1') diff --git a/lib/conf.d/data_templates/en-simple.xml b/lib/conf.d/data_templates/en-simple.xml index d96d3ced22..59ad3eb7a1 100644 --- a/lib/conf.d/data_templates/en-simple.xml +++ b/lib/conf.d/data_templates/en-simple.xml @@ -301,7 +301,7 @@ - + diff --git a/lib/conf.d/data_templates/fr-simple.xml b/lib/conf.d/data_templates/fr-simple.xml index fc22eff384..3b01aafcec 100755 --- a/lib/conf.d/data_templates/fr-simple.xml +++ b/lib/conf.d/data_templates/fr-simple.xml @@ -301,7 +301,7 @@ - + From ed4d7e9c879188afd1ff1e26a35021d1d6177ed2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 21 Aug 2012 18:43:59 +0200 Subject: [PATCH 05/12] Fix #861 : Story image substitution --- lib/Alchemy/Phrasea/Helper/Record/Edit.php | 3 +++ lib/classes/record/adapter.class.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Helper/Record/Edit.php b/lib/Alchemy/Phrasea/Helper/Record/Edit.php index 41939c2b39..2f20d6dcaf 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Edit.php @@ -448,6 +448,9 @@ class Edit extends RecordHelper throw new \Exception('A reg image must come from image data'); foreach ($newsubdef_reg->get_subdefs() as $name => $value) { + if ( ! in_array($name, array('thumbnail', 'preview'))) { + continue; + } $media = $this->core['mediavorus']->guess(new \SplFileInfo($value->get_pathfile())); $reg_record->substitute_subdef($name, $media); } diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 0d4ef4c25c..72b367fce7 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1049,7 +1049,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface $meta_writable = true; } else { - $subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($this->get_type(), $name); + $type = $this->is_grouping() ? 'image' : $this->get_type(); + + $subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($type, $name); if ($this->has_subdef($name) && ! $this->get_subdef($name)->is_substituted()) { From 1cca981ac1ff3a1919398c1570441aff4741ed47 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 29 Aug 2012 14:12:35 +0200 Subject: [PATCH 06/12] Fix bug, business field not retrieved through the ::get_field method --- lib/classes/caption/record.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/caption/record.class.php b/lib/classes/caption/record.class.php index d7be28fac5..0b08ed8ad8 100644 --- a/lib/classes/caption/record.class.php +++ b/lib/classes/caption/record.class.php @@ -202,7 +202,7 @@ class caption_record implements caption_interface, cache_cacheableInterface */ public function get_field($fieldname) { - foreach ($this->get_fields() as $meta_struct_id => $field) { + foreach ($this->get_fields(null, true) as $meta_struct_id => $field) { if ($field->get_name() == $fieldname) { return $field; } From 7262de6b5d045a5f9c78b3b558f76807e7a3c8b5 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 29 Aug 2012 14:12:59 +0200 Subject: [PATCH 07/12] Fix business attributes in the XML structure --- lib/classes/databox.class.php | 3 ++- lib/classes/databox/field.class.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/classes/databox.class.php b/lib/classes/databox.class.php index 0761adba69..a033b0659b 100644 --- a/lib/classes/databox.class.php +++ b/lib/classes/databox.class.php @@ -393,7 +393,7 @@ class databox extends base public static function create(appbox &$appbox, connection_pdo &$connection, \SplFileInfo $data_template, registryInterface $registry) { if ( ! file_exists($data_template->getRealPath())) { - throw new \InvalidArgumentException(); + throw new \InvalidArgumentException($data_template->getRealPath() . " does not exist"); } $credentials = $connection->get_credentials(); @@ -866,6 +866,7 @@ class databox extends base ->set_indexable(isset($field['index']) ? $field['index'] : '1') ->set_separator(isset($field['separator']) ? $field['separator'] : '') ->set_required((isset($field['required']) && $field['required'] == 1)) + ->set_business((isset($field['business']) && $field['business'] == 1)) ->set_type($type) ->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '') ->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0')) diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index c49e350e60..f9158e5f07 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -392,6 +392,7 @@ class databox_field implements cache_cacheableInterface $meta->setAttribute('required', $this->required ? '1' : '0'); $meta->setAttribute('multi', $this->multi ? '1' : '0'); $meta->setAttribute('report', $this->report ? '1' : '0'); + $meta->setAttribute('business', $this->Business ? '1' : '0'); $meta->setAttribute('type', $this->type); $meta->setAttribute('tbranch', $this->tbranch); if ($this->multi) { From 23ba5b03dcf4519621a388221d97908667abd3fe Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 29 Aug 2012 14:20:37 +0200 Subject: [PATCH 08/12] Add tag freshness as query argument for thumbnail (solves poor browsers etag support) --- templates/web/common/thumbnail.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/web/common/thumbnail.html b/templates/web/common/thumbnail.html index 826381702c..be1caaa4d6 100644 --- a/templates/web/common/thumbnail.html +++ b/templates/web/common/thumbnail.html @@ -91,6 +91,7 @@ "{{d_width}}", "{{d_height}}", "9.0.0", false, false, {menu: "false",flashvars: "playerID=2&autostart=yes&noinfo=yes&animation=no&remaining=yes&soundFile={{url}}", movie: "/include/jslibs/audio-player/player.swf", allowFullScreen :"true",wmode: "transparent"}, false); {% else %} + {% set url = url ~ '?tag=' ~ thumbnail.getEtag() %} From d44c6fe6b3728b72fd0231f6e9659fa04edab2ff Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 29 Aug 2012 15:45:30 +0200 Subject: [PATCH 09/12] Fix #864 : Upgrade from 3.5 fails --- lib/classes/module/console/systemUpgrade.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/classes/module/console/systemUpgrade.class.php b/lib/classes/module/console/systemUpgrade.class.php index 730b214d42..277b889d72 100644 --- a/lib/classes/module/console/systemUpgrade.class.php +++ b/lib/classes/module/console/systemUpgrade.class.php @@ -39,6 +39,8 @@ class module_console_systemUpgrade extends Command protected function doExecute(InputInterface $input, OutputInterface $output) { + require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php'; + $old_connexion_file = __DIR__ . '/../../../../config/connexion.inc'; $old_config_file = __DIR__ . '/../../../../config/config.inc'; @@ -68,7 +70,9 @@ class module_console_systemUpgrade extends Command } } - $this->checkSetup(); + if ( ! $Core->getConfiguration()->isInstalled()) { + throw new \RuntimeException('Phraseanet must be set-up (no connexion.inc / no config.inc)'); + } $output->write('Phraseanet is going to be upgraded', true); $dialog = $this->getHelperSet()->get('dialog'); From def3a2b293ba4ff93fbee59d91d0f0e7d75a19b2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 29 Aug 2012 16:15:53 +0200 Subject: [PATCH 10/12] Fix #865 : add route in API for scheduler infos --- lib/Alchemy/Phrasea/Application/Api.php | 21 ++++++++- lib/classes/API/V1/adapter.class.php | 27 ++++++++++++ lib/classes/task/manager.class.php | 7 +++ .../Phrasea/Application/ApiAbstract.inc | 44 +++++++++++++++++++ 4 files changed, 97 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index eb9208d54b..bccdc1aaa1 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -187,10 +187,27 @@ return call_user_func(function() { } }; + /** + * Get scheduler informations + * + * Route : /monitor/scheduler/ + * + * Method : GET + * + * Parameters : + * + */ + $route = '/monitor/scheduler/'; + $app->get( + $route, function(Application $app, Request $request) { + return $app['api']->get_scheduler($app)->get_response(); + } + )->before($mustBeAdmin); + /** * Get all tasks information * - * Route : /monitor/phraseanet/ + * Route : /monitor/tasks/ * * Method : GET * @@ -208,7 +225,7 @@ return call_user_func(function() { * ******************************************************************* * Get task informations * - * Route : /monitor/phraseanet/ + * Route : /monitor/task/{task_id}/ * * Method : GET * diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index b8b4a732ee..839de2a02f 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -94,6 +94,33 @@ class API_V1_adapter extends API_V1_Abstract return $this->version; } + /** + * Return an array of key-values informations about scheduler + * + * @param Application $app The silex application + * @return \API_V1_result + */ + public function get_scheduler(Application $app) + { + $result = new \API_V1_result($app['request'], $this); + + $appbox = \appbox::get_instance($app['Core']); + $taskManager = new \task_manager($appbox); + $ret = $taskManager->getSchedulerState(); + + $ret['state'] = $ret['status']; + + unset($ret['qdelay'], $ret['status']); + + if (null !== $ret['updated_on']) { + $ret['updated_on'] = $ret['updated_on']->format(DATE_ATOM); + } + + $result->set_datas(array('scheduler' => $ret)); + + return $result; + } + /** * Get a list of phraseanet tasks * diff --git a/lib/classes/task/manager.class.php b/lib/classes/task/manager.class.php index a504498b04..6f4d7e4505 100755 --- a/lib/classes/task/manager.class.php +++ b/lib/classes/task/manager.class.php @@ -119,6 +119,7 @@ class task_manager $appbox = appbox::get_instance(\bootstrap::getCore()); $sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay + , schedqtime AS updated_on , schedstatus AS status FROM sitepreff"; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute(); @@ -139,6 +140,12 @@ class task_manager fclose($schedlock); } + if ($ret['updated_on'] == '0000-00-00 00:00:00') { + $ret['updated_on'] = null; + } else { + $ret['updated_on'] = new \DateTime($ret['updated_on']); + } + if ($pid === NULL && $ret['status'] !== 'stopped') { // auto fix $this->appbox->get_connection()->exec('UPDATE sitepreff SET schedstatus=\'stopped\''); diff --git a/tests/Alchemy/Phrasea/Application/ApiAbstract.inc b/tests/Alchemy/Phrasea/Application/ApiAbstract.inc index 0ccae8c728..25adba3436 100644 --- a/tests/Alchemy/Phrasea/Application/ApiAbstract.inc +++ b/tests/Alchemy/Phrasea/Application/ApiAbstract.inc @@ -194,6 +194,10 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $content = $this->unserialize($this->client->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); + $this->client->request('GET', '/monitor/scheduler/', array(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $content = $this->unserialize($this->client->getResponse()->getContent()); + $this->assertEquals(401, $content['meta']['http_code']); + $this->client->request('GET', '/monitor/task/1/', array(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); $content = $this->unserialize($this->client->getResponse()->getContent()); $this->assertEquals(401, $content['meta']['http_code']); @@ -247,6 +251,46 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } } + /** + * Route GET /API/V1/monitor/scheduler + * @covers API_V1_adapter::get_scheduler + */ + public function testGetScheduler() + { + $appbox = \appbox::get_instance(\bootstrap::getCore()); + if (null === self::$adminToken) { + $this->markTestSkipped('there is no user with admin rights'); + } + $this->setToken(self::$adminToken); + + $route = '/monitor/scheduler/'; + $this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE')); + + $this->client->request('GET', $route, array(), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + $content = $this->unserialize($this->client->getResponse()->getContent()); + + $this->evaluateResponse200($this->client->getResponse()); + $this->evaluateMeta200($content); + $response = $content['response']; + + $this->assertInternalType('array', $response['scheduler']); + + $this->assertArrayHasKey('state', $response['scheduler']); + $this->assertArrayHasKey('pid', $response['scheduler']); + $this->assertArrayHasKey('updated_on', $response['scheduler']); + + $this->assertEquals(3, count($response['scheduler'])); + + if (null !== $response['scheduler']['updated_on']) { + $this->assertDateAtom($response['scheduler']['updated_on']); + } + if (null !== $response['scheduler']['pid']) { + $this->assertTrue(is_int($response['scheduler']['pid'])); + } + + $this->assertTrue('' !== $response['scheduler']['state']); + } + protected function evaluateGoodTask($task) { $this->assertArrayHasKey('id', $task); From 9b6fcf58c99608180c980851ba20ab1415bda626 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 31 Aug 2012 15:37:26 +0200 Subject: [PATCH 11/12] Fix #868 Status are not applicate when uploading a file --- lib/Alchemy/Phrasea/Controller/Prod/Upload.php | 4 ++-- tests/Alchemy/Phrasea/Controller/Prod/UploadTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index 0525b4cf05..7592902408 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -201,8 +201,8 @@ class Upload implements ControllerProviderInterface $postStatus = $request->get('status'); - if (isset($postStatus[$collection->get_sbas_id()]) && is_array($postStatus[$collection->get_sbas_id()])) { - $postStatus = $postStatus[$collection->get_sbas_id()]; + if (isset($postStatus[$collection->get_base_id()]) && is_array($postStatus[$collection->get_base_id()])) { + $postStatus = $postStatus[$collection->get_base_id()]; $status = ''; foreach (range(0, 63) as $i) { diff --git a/tests/Alchemy/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Phrasea/Controller/Prod/UploadTest.php index 92451faa4f..640a99b1a2 100644 --- a/tests/Alchemy/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Phrasea/Controller/Prod/UploadTest.php @@ -248,7 +248,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $params = array( 'base_id' => self::$collection->get_base_id(), 'forceAction' => \Alchemy\Phrasea\Border\Manager::FORCE_RECORD, - 'status' => array( self::$collection->get_sbas_id() => array( 4 => 1)), + 'status' => array( self::$collection->get_base_id() => array( 4 => 1)), ); $files = array( From c38061bd3d3c08c2ffb761ea2024bb5346a8ff3b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 31 Aug 2012 16:32:05 +0200 Subject: [PATCH 12/12] Add patch for 3.7.1 --- lib/classes/patch/371.class.php | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/classes/patch/371.class.php diff --git a/lib/classes/patch/371.class.php b/lib/classes/patch/371.class.php new file mode 100644 index 0000000000..3e5857b58b --- /dev/null +++ b/lib/classes/patch/371.class.php @@ -0,0 +1,66 @@ +release; + } + + public function require_all_upgrades() + { + return false; + } + + /** + * + * @return Array + */ + public function concern() + { + return $this->concern; + } + + /** + * @param base $databox + */ + public function apply(base &$databox) + { + foreach($databox->get_meta_structure() as $databox_field) { + $databox_field->save(); + } + } +} +