Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topicsubscription Button wird erst nach System-Cache leeren aktualisiert #261

Open
ibpdd opened this issue Dec 3, 2018 · 2 comments
Open

Comments

@ibpdd
Copy link

ibpdd commented Dec 3, 2018

Hallo,

wenn man im Topic auf "Abonnieren" klickt, verändert sich der Button erst auf "nicht mehr abonnieren" wenn der System- Cache geleert wird.

Wie ändert man das?

Grüße Philipp

@j-boettcher
Copy link

Ich hatte das gleiche Problem und habe es dann umgeschrieben.

From b7a6de5c50bbd67ca38063c82b3b3936e020d232 Mon Sep 17 00:00:00 2001
From: Severin Breitkopf [email protected]
Date: Sun, 6 Jan 2019 23:22:26 +0100
Subject: [PATCH] fix: subscribe and unsubscribe button state


.../Classes/Controller/AbstractController.php | 15 ++++++++--
.../ViewHelpers/User/IfSubscribedViewHelper.php | 35 ++++++++++------------
.../Private/Partials/Standard/AjaxURL.html | 4 +--
.../Templates/Bootstrap/Ajax/ForumMenu.html | 2 +-
.../Templates/Bootstrap/Ajax/TopicListMenu.html | 2 +-
.../Private/Templates/Standard/Ajax/ForumMenu.html | 2 +-
.../Templates/Standard/Ajax/TopicListMenu.html | 2 +-
7 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/typo3conf/ext/typo3_forum/Classes/Controller/AbstractController.php b/typo3conf/ext/typo3_forum/Classes/Controller/AbstractController.php
index 56229e3..16fe477 100644
--- a/typo3conf/ext/typo3_forum/Classes/Controller/AbstractController.php
+++ b/typo3conf/ext/typo3_forum/Classes/Controller/AbstractController.php
@@ -29,6 +29,7 @@ use Mittwald\Typo3Forum\Domain\Model\User\FrontendUser;
use Mittwald\Typo3Forum\Utility\Localization;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;

abstract class AbstractController extends ActionController {

@@ -82,9 +83,17 @@ abstract class AbstractController extends ActionController {
*/
protected $context = self::CONTEXT_WEB;

  • /*
    • METHODS
  • */
  • /**

  • * @param ViewInterface $view
    
  • */
    
  • protected function initializeView(ViewInterface $view)

  • {

  •    parent::initializeView($view);
    
  •    $this->view->assign('currentUser', $this->getCurrentUser());
    
  • }

  • /*

  • * METHODS
    
  • */
    

    /**
    *
    diff --git a/typo3conf/ext/typo3_forum/Classes/ViewHelpers/User/IfSubscribedViewHelper.php b/typo3conf/ext/typo3_forum/Classes/ViewHelpers/User/IfSubscribedViewHelper.php
    index 54e2fd1..eda27d2 100644
    --- a/typo3conf/ext/typo3_forum/Classes/ViewHelpers/User/IfSubscribedViewHelper.php
    +++ b/typo3conf/ext/typo3_forum/Classes/ViewHelpers/User/IfSubscribedViewHelper.php
    @@ -48,35 +48,30 @@ class IfSubscribedViewHelper extends IfViewHelper
    {
    parent::initializeArguments();
    $this->registerArgument('object', SubscribeableInterface::class, 'Object to check', true);

  •    $this->registerArgument('user', FrontendUser::class, 'className which object has to be', false, null);
    
  •    $this->registerArgument('user', FrontendUser::class, 'className which object has to be', true);
    

    }

    /**

  • * @return string
    
  • * @return SubscribeableInterface
    */
    
  • public function render()
  • protected function getSubscribeableObject()
    {
  •    $object = $this->getSubscribeableObject();
    
  •    $user = $this->arguments['user'];
    
  •    if ($user === null) {
    
  •        $user = $this->frontendUserRepository->findCurrent();
    
  •    }
    
  •    foreach ($object->getSubscribers() as $subscriber) {
    
  •        if ($subscriber->getUid() == $user->getUid()) {
    
  •            return $this->renderThenChild();
    
  •        }
    
  •    }
    
  •    return $this->renderElseChild();
    
  •    return $this->arguments['object'];
    

    }

    /**

  • * @return SubscribeableInterface
    
  • * This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
    
  • *
    
  • * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
    
  • * @return bool
    */
    
  • protected function getSubscribeableObject()
  • protected static function evaluateCondition($arguments = null)
    {
  •    return $this->arguments['object'];
    
  •    foreach ($arguments['object']->getSubscribers() as $subscriber) {
    
  •        if ($subscriber->getUid() == (int)$GLOBALS['TSFE']->fe_user->user['uid']) {
    
  •            return true;
    
  •        }
    
  •    }
    
  •    return false;
    
    }
    }
    diff --git a/typo3conf/ext/typo3_forum/Resources/Private/Partials/Standard/AjaxURL.html b/typo3conf/ext/typo3_forum/Resources/Private/Partials/Standard/AjaxURL.html
    index 8c1e6a5..c949400 100644
    --- a/typo3conf/ext/typo3_forum/Resources/Private/Partials/Standard/AjaxURL.html
    +++ b/typo3conf/ext/typo3_forum/Resources/Private/Partials/Standard/AjaxURL.html
    @@ -1,5 +1,5 @@
<script> currentPageUid = "{f:cObject(typoscriptObjectPath: 'lib.pageUid')}"; - typo3_forum_ajaxUrl = "{f:uri.action(action: 'main', controller: 'Ajax', arguments:{format:'json'}, additionalParams:{eID:'typo3_forum'}) -> f:format.htmlentitiesDecode()}"; - typo3_forum_ajaxUrl_helpful = "{f:uri.action(action: '__typo3_forum_action__', controller: 'Post', arguments:{post:'__typo3_forum_post__'}, additionalParams:{eID:'__typo3_forum_eid__'}) -> f:format.htmlentitiesDecode()}"; + typo3_forum_ajaxUrl = "{f:uri.action(noCacheHash: 'true', action: 'main', controller: 'Ajax', arguments:{format:'json'}, additionalParams:{eID:'typo3_forum'}) -> f:format.htmlentitiesDecode()}"; + typo3_forum_ajaxUrl_helpful = "{f:uri.action(noCacheHash: 'true', action: '__typo3_forum_action__', controller: 'Post', arguments:{post:'__typo3_forum_post__'}, additionalParams:{eID:'__typo3_forum_eid__'}) -> f:format.htmlentitiesDecode()}"; </script>

diff --git a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/ForumMenu.html b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/ForumMenu.html
index ecfbf81..53a1842 100644
--- a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/ForumMenu.html
+++ b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/ForumMenu.html
@@ -18,7 +18,7 @@

<mmf:authentication.ifLoggedIn>
	<li>
  •   	<mmf:user.ifSubscribed object="{forum}">
    
  •   	<mmf:user.ifSubscribed object="{forum}" user="{currentUser}">
      		<f:then>
      			<f:link.action noCacheHash="1" controller="User" action="subscribe" arguments="{forum: forum, unsubscribe: 1}">
      				<i class="tx-typo3forum-icon-16-unsubscribe"></i> {f:translate(key:'Button_Unsubscribe')}
    

diff --git a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/TopicListMenu.html b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/TopicListMenu.html
index ef6ddab..6e82371 100644
--- a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/TopicListMenu.html
+++ b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Bootstrap/Ajax/TopicListMenu.html
@@ -19,7 +19,7 @@

<mmf:authentication.ifLoggedIn>
	<li>
  •   	<mmf:user.ifSubscribed object="{topic}">
    
  •   	<mmf:user.ifSubscribed object="{topic}" user="{currentUser}">
      		<f:then>
      			<f:link.action noCacheHash="1" controller="User" action="subscribe" arguments="{topic: topic, unsubscribe: 1}">
      				<i class="tx-typo3forum-icon-16-unsubscribe"></i>
    

diff --git a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/ForumMenu.html b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/ForumMenu.html
index 0873441..e716d6a 100644
--- a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/ForumMenu.html
+++ b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/ForumMenu.html
@@ -21,7 +21,7 @@

 <mmf:authentication.ifLoggedIn>
     <li>
  •        <mmf:user.ifSubscribed object="{forum}">
    
  •        <mmf:user.ifSubscribed object="{forum}" user="{currentUser}">
               <f:then>
                   <f:link.action noCacheHash="1" controller="User" action="subscribe" arguments="{forum: forum, unsubscribe: 1}">
                       <i class="tx-typo3forum-icon-16-unsubscribe"></i> {f:translate(key:'Button_Unsubscribe')}
    

diff --git a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/TopicListMenu.html b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/TopicListMenu.html
index c6e42a2..c7c7882 100644
--- a/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/TopicListMenu.html
+++ b/typo3conf/ext/typo3_forum/Resources/Private/Templates/Standard/Ajax/TopicListMenu.html
@@ -19,7 +19,7 @@

 <mmf:authentication.ifLoggedIn>
     <li>
  •        <mmf:user.ifSubscribed object="{topic}">
    
  •        <mmf:user.ifSubscribed object="{topic}" user="{currentUser}">
               <f:then>
                   <f:link.action noCacheHash="1" controller="User" action="subscribe" arguments="{topic: topic, unsubscribe: 1}">
                       <i class="tx-typo3forum-icon-16-unsubscribe"></i>
    

--
2.10.5

@mgrundkoetter
Copy link

@Locke80 can you please open a PR or post a formatted diff/patch instead of an email? Also, there is an email address in your post, you probably don't want to have this posted publicly here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants