Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
[RESOLVED] FlaggingNotify doesn't work with 2.5, any ideas?
I would ask this on the plugin page itself but it is no longer maintained by the author.
FlaggingNotify doesn't work properly with 2.5 as every time you click Dismiss, the notification immediately re-appears.
When I click Dismiss, this shows in Chrome console: https://i.imgur.com/NGcs3F9.png?2
When I click into the link referenced in that Console error, I see this plugin error: https://prnt.sc/ik6evt
The plugin code is as follows:
<?php if (!defined('APPLICATION')) exit(); /** * * # FlaggingNotify # * * ### About ### * This plugin creates annoying persistent notification of flagged posts, to ensure they are dealt with, and can be dismissed within the notification. * * ### Sponsor ### * Special thanks to MCDE for making this happen. * */ // Define the plugin: $PluginInfo['FlaggingNotify'] = array( 'Name' => 'FlaggingNotify', 'Description' => 'This plugin creates annoying persistent notification of flagged posts, to ensure they are dealt with, and can be dismissed within the notification.', 'Version' => '0.2b', 'RequiredPlugins' => array('Flagging'=>'>=1.1.0'), 'Author' => "Paul Thomas", 'AuthorEmail' => 'dt01pqt_pt@yahoo.com', ); /* * Changelog: * v0.2b:Mon Feb 20 08:51:25 GMT 2012 * - change permission from Garden.Settings.Manage to Plugins.Flagging.Notify */ class FlaggingNotifyPlugin extends Gdn_Plugin { public function Base_BeforeControllerMethod_Handler($Sender) { if(!C('Plugins.Flagging.Enabled') || !Gdn::Session()->CheckPermission('Plugins.Flagging.Notify')) return; /** * get flags determine if still active, making a list */ $Flags = Gdn::SQL() ->Select('*') ->From('Flag') ->Where( array( 'NotifyDismiss'=>0, //'DiscussionID >'=>0 ) ) ->OrderBy('DateInserted', 'DESC') ->Get() ->Result(); $FlagList = array(); $DiscussionIDs = array(); $CommentIDs = array(); foreach($Flags As $Flag){ if(strtolower($Flag->ForeignType)=='comment') $CommentIDs[]=$Flag->ForeignID; else $DiscussionIDs[]=$Flag->ForeignID; } if(!empty($DiscussionIDs)) $Discussions = Gdn::SQL() ->Select('*') ->From('Discussion') ->WhereIn('DiscussionID',$DiscussionIDs) ->Get() ->Result(); else $Discussions=array(); if(!empty($CommentIDs)) $Comments = (empty($CommentIDs))? array() : Gdn::SQL() ->Select('*') ->From('Comment') ->WhereIn('CommentID',$CommentIDs) ->Where('DateDeleted',NULL) ->Get() ->Result(); else $Comments = array(); $DiscussionIDs = array(); $CommentIDs = array(); foreach($Discussions As $Discussion) $DiscussionIDs[]=$Discussion->DiscussionID; foreach($Comments As $Comment) $CommentIDs[]=$Comment->CommentID; foreach($Flags As $Flag){ if((in_array($Flag->ForeignID,$DiscussionIDs) && strtolower($Flag->ForeignType)=='discussion') || (strtolower($Flag->ForeignType)=='comment' && in_array($Flag->ForeignID,$CommentIDs))){ $FlagList[$Flag->ForeignURL]=$Flag; } } /** * With the discussion controller check if request is same as ForeignID and dismiss appropriately */ /*if($Sender->Controller()=='Discussion'){ $DissmisFlags=array(); $IsComment = strtolower($Sender->ControllerMethod())=='comment'; $Args=$Sender->ControllerArguments(); $ObjectID = !empty($Args) ? $Args[0] : 0; if(!$ObjectID) return; foreach($FlagList As $FlagItem){ if(($IsComment && $FlagItem->ForeignID==$ObjectID && strtolower($FlagItem->ForeignType)=='comment') || ($FlagItem->ForeignID==$ObjectID && strtolower($FlagItem->ForeignType)=='discussion')){ $DissmisFlags[$FlagItem->ForeignURL]=$FlagItem->ForeignURL; } } if(!empty($DissmisFlags)) Gdn::SQL()->Update('Flag')->Set('NotifyDismiss',1)->WhereIn('ForeignURL',$DissmisFlags)->Put(); }*/ /** * display notifications */ foreach($FlagList As $FlagItem){ $FlagName = substr($FlagItem->ForeignURL,strpos($FlagItem->ForeignURL,'/',1)); $Hash = strpos($FlagName,'#'); if($Hash!==FALSE) $FlagName = substr($FlagName,0,$Hash); $FlagText='<span class="InformSprite Flag"></span>'; $FlagText.=Anchor($FlagName,$FlagItem->ForeignURL).' '; $FlagText.=T('FlaggedBy', "Reported by: "). '<strong>'.Anchor($FlagItem->InsertName,'profile/'.$FlagItem->InsertUserID.'/'.$FlagItem->InsertName).'</strong> '; $FlagText.='<i>"'.$FlagItem->Comment.'"</i> '; /** * Allow to be dismissed from the notification */ $EncodedURL=URL('plugin/flagging/dismiss/'.str_replace('=','-',base64_encode($FlagItem->ForeignURL)),TRUE); $FlagText.=Anchor('Dismiss',$EncodedURL,array( 'onclick'=>'jQuery.get("'.$EncodedURL.'");jQuery(this).parent().remove();return false;', 'class'=>'Button', 'style'=>'color:#000;background: #f8f8f8;margin:0;') ); //if(!in_array($FlagItem->ForeignURL,$DissmisFlags)) Gdn::Controller()->InformMessage($FlagText,'HasSprite'); } } public function Base_BeforeDispatch_Handler($Sender){ if(C('Plugins.FlaggingNotify.Version')!=$this->PluginInfo['Version']) $this->Structure(); } public function Structure() { $Structure = Gdn::Structure(); $Structure ->Table('Flag') ->Column('NotifyDismiss', 'int(4)', 0) ->Set(); //Save Version for hot update @SaveToConfig('Plugins.FlaggingNotify.Version', $this->PluginInfo['Version']); } public function Setup() { $this->Structure(); } }
0
Comments
Could you change line 139 from jQuery.get to jQuery.post, see if it works again?
No luck. I did the edit, turned on/off plugin, cleared /cache/ and browser cache.
Got this: https://i.imgur.com/pgnxL3o.png?2 (403 instead of 405 this time)
Are you sure you have the correct Garden.Moderation.Manage permission necessary for the flagging plugin?
If you go to plugins/Flaggin/class.flagging.plugin.php, could you temporarely change "if (Gdn::session()->checkPermission('Garden.Moderation.Manage'))" to "if (true||Gdn::session()->checkPermission('Garden.Moderation.Manage'))" and see if that solves the issue?
This disables some security, so is not recommended as a permanent solution, but at least we'll know what the exact problem is if the 'fix' works.
I have no idea about that. But I tried the above code edit and it sadly didn't work.
This plugin is essential to me otherwise mods have to periodically check flags. I'm surprised this isn't part of the core.
Anyway, I'm happy to pay $50 to anyone who can make this plugin work on 2.5 (works on 2.3)
cc: @x00 in case you're still alive.
I've tested it in my setup, and it seems to work. Which curiously enough, it shouldn't.
It should have thrown the same exceptions as your setup, at least from what I now understand from the code. So good news: I think I understand what goes wrong, bad news: I can't test it properly.
Could you try to change line 139 to this?:
You can change the "if (true||Gdn::session()->checkPermission('Garden.Moderation.Manage'))" back to "if (Gdn::session()->checkPermission('Garden.Moderation.Manage'))" btw.
The problem is that the Flagging plugin now has increased security and requires a certain key, and the FlaggingNotifyPlugin should supply that key if it wants to work.
That worked, thank you so much @Caylus !
Please send me a PM with your email so I can Paypal you $50 as a gesture.