diff --git a/VERSIONS_HOTLINE/178137 b/VERSIONS_HOTLINE/178137 new file mode 100644 index 0000000000000000000000000000000000000000..25597e731a18e299091042231c63a16ae2cd5660 --- /dev/null +++ b/VERSIONS_HOTLINE/178137 @@ -0,0 +1 @@ + - correctif #178137 : Compte lecteur : Vous pouvez maintenant supprimer les avis rattachés à des documents qui n'existent plus. \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Review.php b/library/templates/Intonation/Library/View/Wrapper/Review.php index 7c29d8e70e519aa37ce1dafda048f695fa484ec5..a9a287705b771309f3c80191eed1b655781db35f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Review.php +++ b/library/templates/Intonation/Library/View/Wrapper/Review.php @@ -166,8 +166,8 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra public function getActions() { - if (!$record = $this->_model->getFirstNotice()) - return []; + if ( ! $record = $this->_model->getFirstNotice()) + return $this->_belongsToCurrentUserActionDelete([]); $actions = [(new Intonation_Library_Link) ->setUrl($record->getAbsoluteUrl()) @@ -175,12 +175,15 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra ->setText($this->_('Voir le document')) ->setTitle($this->_('Voir le document %s', $record->getTitrePrincipal(' ')))]; - return $this->_belongsToCurrentUserActions($actions); + $actions = $this->_belongsToCurrentUserActionEdit($actions); + $actions = $this->_belongsToCurrentUserActionDelete($actions); + + return $actions; } - protected function _belongsToCurrentUserActions(array $actions) : array { - if (!$this->_model->belongsToCurrentUser()) + protected function _belongsToCurrentUserActionEdit(array $actions) : array { + if ( ! $this->_model->belongsToCurrentUser()) return $actions; $actions [] = (new Intonation_Library_Link) @@ -192,6 +195,14 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra ->setTitle($this->_('Modifier l\'avis %s', $this->_model->getEntete())) ->setPopup((null === $this->_authenticateProfile())); + return $actions; + } + + + protected function _belongsToCurrentUserActionDelete(array $actions) : array { + if ( ! $this->_model->belongsToCurrentUser()) + return $actions; + $actions [] = (new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'delete-review', diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php index b1b82aaf4d3994bf70fc57015d84e86bbff0c398..9f0c8f1d481e40a055a8674ed420bd0290e0ec95 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php @@ -20,8 +20,8 @@ */ -class Intonation_Library_View_Wrapper_ReviewInRecord extends Intonation_Library_View_Wrapper_Review { - +class Intonation_Library_View_Wrapper_ReviewInRecord + extends Intonation_Library_View_Wrapper_Review { public function getMainTitle() { return $this->_getMetaDataHTML(); @@ -68,6 +68,9 @@ class Intonation_Library_View_Wrapper_ReviewInRecord extends Intonation_Library_ public function getActions() { - return $this->_belongsToCurrentUserActions([]); + $actions = $this->_belongsToCurrentUserActionEdit([]); + $actions = $this->_belongsToCurrentUserActionDelete($actions); + + return $actions; } } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 46f8e165262efe821607f0150becf06346132af0..0cc8b74c4591e8364c5b3250cb676cbae6a67088 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -1041,6 +1041,7 @@ class TemplatesAbonneDispatchLargeNumberOfHoldsTest extends TemplatesIntonationA class TemplatesAbonneDispatchReviewsTest extends TemplatesIntonationAccountTestCase { + /** @test */ public function leRoiDesConsShouldBeDisplay() { $this->dispatch('/opac/abonne/mes-avis/id_profil/72'); @@ -1048,6 +1049,13 @@ class TemplatesAbonneDispatchReviewsTest extends TemplatesIntonationAccountTestC } + /** @test */ + public function avisCanBeDeleted() { + $this->dispatch('/opac/abonne/mes-avis/id_profil/72'); + $this->assertXPath('//a[@href="/abonne/delete-review/id_profil/72/id/4"]//div[text()="Supprimer"]'); + } + + /** @test */ public function donnerDesAvisLinkShouldBeDisplay() { Class_AvisNotice::find(4)->delete(); @@ -1066,6 +1074,34 @@ class TemplatesAbonneDispatchReviewsTest extends TemplatesIntonationAccountTestC +/* hotline : https://forge.afi-sa.net/issues/178137 */ +class TemplatesAbonneDispatchReviewsWithoutRecordTest extends TemplatesIntonationAccountTestCase { + + public function setUp() { + parent::setUp(); + + Class_Notice::find(20090)->delete(); + Class_Notice::clearCache(); + + $this->dispatch('/opac/abonne/mes-avis/id_profil/72'); + } + + + /** @test */ + public function leRoiDesConsShouldBeDisplay() { + $this->assertXPathContentContains('//div', 'Le Roi des cons sur son throne'); + } + + + /** @test */ + public function avisCanBeDeleted() { + $this->assertXPath('//a[@href="/abonne/delete-review/id_profil/72/id/4"]//div[text()="Supprimer"]'); + } +} + + + + class TemplatesAbonneDispatchConfigurationsTest extends TemplatesIntonationAccountTestCase { public function setUp() {