From d0fc37b957e71660f27b1b5ec7c73b7d3eb54b29 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 30 Dec 2011 11:40:21 +0100 Subject: [PATCH 1/3] Fix #134 : browsing a story --- lib/classes/basketCollection.class.php | 4 +++- lib/classes/record/preview.class.php | 3 +-- templates/web/prod/basket_element.twig | 2 +- templates/web/prod/results/record.html | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/classes/basketCollection.class.php b/lib/classes/basketCollection.class.php index 82f254b2ff..7cdf161f9d 100644 --- a/lib/classes/basketCollection.class.php +++ b/lib/classes/basketCollection.class.php @@ -151,7 +151,9 @@ class basketCollection $appbox = appbox::get_instance(); $conn = $appbox->get_connection(); $session = $appbox->get_session(); - $sql = 'SELECT ssel_id FROM sselnew WHERE usr_id = :usr_id'; + $sql = 'SELECT n.ssel_id FROM sselnew n, ssel s + WHERE s.ssel_id = n.ssel_id AND n.usr_id = :usr_id + AND n.usr_id = s.usr_id'; $stmt = $conn->prepare($sql); $stmt->execute(array(':usr_id' => $session->get_usr_id())); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/lib/classes/record/preview.class.php b/lib/classes/record/preview.class.php index 5f5cf88dc2..53cd339888 100644 --- a/lib/classes/record/preview.class.php +++ b/lib/classes/record/preview.class.php @@ -112,8 +112,7 @@ class record_preview extends record_adapter break; case "REG": $contId = explode('_', $contId); - $base_id = $contId[0]; - $sbas_id = phrasea::sbasFromBas($base_id); + $sbas_id = $contId[0]; $record_id = $contId[1]; $this->container = new record_adapter($sbas_id, $record_id); diff --git a/templates/web/prod/basket_element.twig b/templates/web/prod/basket_element.twig index c89927913d..cd3edcfebf 100644 --- a/templates/web/prod/basket_element.twig +++ b/templates/web/prod/basket_element.twig @@ -9,7 +9,7 @@ {% import 'common/thumbnail.html' as thumbnail %} {% set record = basket_element.get_record() %} -
{% if user.getPrefs('basket_title_display') == '1' %} diff --git a/templates/web/prod/results/record.html b/templates/web/prod/results/record.html index 14ed145861..92971c7475 100644 --- a/templates/web/prod/results/record.html +++ b/templates/web/prod/results/record.html @@ -13,7 +13,7 @@
+ onDblClick="openPreview('REG','0','{{record.get_serialize_key()}}');"> {% else %}
Date: Fri, 30 Dec 2011 11:59:31 +0100 Subject: [PATCH 2/3] Fix #135 : substitution of a story image --- lib/classes/media/subdef.class.php | 4 ++++ lib/classes/module/prod/route/records/edit.class.php | 4 ++-- lib/classes/record/adapter.class.php | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/classes/media/subdef.class.php b/lib/classes/media/subdef.class.php index d11a7ea94e..dae599d315 100644 --- a/lib/classes/media/subdef.class.php +++ b/lib/classes/media/subdef.class.php @@ -192,6 +192,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'deleted.png'; $this->is_physically_present = false; + $this->is_substituted = true; } if (!$row || !file_exists($this->path . $this->file)) { @@ -204,6 +205,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = 'regroup_thumb.png'; + $this->is_substituted = true; } else { @@ -217,6 +219,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/'; $this->file = str_replace('+', '%20', $mime) . '.png'; + $this->is_substituted = true; } $this->is_physically_present = false; if (!file_exists($this->path . $this->file)) @@ -225,6 +228,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $this->path = $registry->get('GV_RootPath') . 'www/skins/icons/'; $this->file = 'substitution.png'; + $this->is_substituted = true; } } diff --git a/lib/classes/module/prod/route/records/edit.class.php b/lib/classes/module/prod/route/records/edit.class.php index 926be31d8e..c7dd2df9f0 100644 --- a/lib/classes/module/prod/route/records/edit.class.php +++ b/lib/classes/module/prod/route/records/edit.class.php @@ -436,7 +436,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract try { $reg_record = $this->get_grouping_head(); - $reg_sbas_id = $reg_record->get_base_id(); + $reg_sbas_id = $reg_record->get_sbas_id(); $newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent')); @@ -452,7 +452,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract } catch (Exception $e) { - + } } diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 0614dd0f32..da8f587071 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -968,6 +968,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface try { $value = $this->get_subdef($name); + + if ($value->is_substituted()) + { + throw new Exception('Cannot replace a substitution'); + } + $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file(); unlink($original_file); } From ea0a54456754873a6d10ae46d1a92718274c7d5b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 30 Dec 2011 12:45:52 +0100 Subject: [PATCH 3/3] Removed bit.ly --- lib/classes/record/Interface.class.php | 2 - lib/classes/record/adapter.class.php | 48 ---------------------- templates/web/prod/preview/popularity.html | 8 ---- www/prod/share.php | 3 +- 4 files changed, 1 insertion(+), 60 deletions(-) diff --git a/lib/classes/record/Interface.class.php b/lib/classes/record/Interface.class.php index 1730c36fe7..a97c859d17 100644 --- a/lib/classes/record/Interface.class.php +++ b/lib/classes/record/Interface.class.php @@ -97,8 +97,6 @@ interface record_Interface public function get_reg_name(); - public function get_bitly_link(); - public function get_hd_file(); public function delete(); diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index da8f587071..9a8673306d 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1294,54 +1294,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface return $regname; } - /** - * - * @return string - */ - public function get_bitly_link() - { - - $registry = registry::get_instance(); - - if ($this->bitly_link !== null) - return $this->bitly_link; - - $this->bitly_link = false; - - if (trim($registry->get('GV_bitly_user')) == '' - && trim($registry->get('GV_bitly_key')) == '') - return $this->bitly_link; - - try - { - $short = new PHPShortener(); - $bitly = $short->encode($url . 'view/', 'bit.ly', $registry); - - if (preg_match('/^(http:\/\/)?(www\.)?([^\/]*)\/(.*)$/', $bitly, $results)) - { - if ($results[3] && $results[4]) - { - $hash = 'http://bit.ly/' . $results[4]; - $sql = 'UPDATE record SET bitly = :hash WHERE record_id = :record_id'; - - $connbas = connection::getPDOConnection($this->get_sbas_id()); - $stmt = $connbas->prepare($sql); - $stmt->execute(array(':hash' => $hash, ':record_id' => $this->get_record_id())); - $stmt->closeCursor(); - - $this->bitly_link = 'http://bit.ly/' . $hash; - } - } - } - catch (Exception $e) - { - unset($e); - } - $this->delete_data_from_cache(); - - return $this->bitly_link; - } - /** * * @param collection $collection diff --git a/templates/web/prod/preview/popularity.html b/templates/web/prod/preview/popularity.html index 86b56bd55d..b66e47694c 100644 --- a/templates/web/prod/preview/popularity.html +++ b/templates/web/prod/preview/popularity.html @@ -1,12 +1,4 @@ - {% if record.get_bitly_link() and user.ACL().has_right_on_base(record.get_base_id(), 'canreport') %} -
- {% trans 'preview::statistiques pour le lien' %} - - http://bit.ly/{{record.get_bitly_link()}}
- {% endif %} - {% if record.get_view_popularity() %}
{% trans 'preview::statistiques de visualisation pour le lien' %} diff --git a/www/prod/share.php b/www/prod/share.php index 01e7f6245b..da0ac5b38f 100644 --- a/www/prod/share.php +++ b/www/prod/share.php @@ -67,7 +67,6 @@ if (!$right) $sha256 = $record->get_sha256(); $type = $record->get_type(); -$bitly = $record->get_bitly_link(); $url = ''; @@ -114,7 +113,7 @@ if ($url != '') ?>