Problem : Following/Unfollow vs. GetOptions
Please help me.
I'm rewriting my SubCategories plugin (for a much cleaner and proper coding) and there's this problem bugging me since 2.0.18.1 and it's still there in 2.0.18.2
Say you click on Unfollow (in the Options button drop down menu), and get back to any page which list the unfollowed category as a subcategory (other than the All Categories page).
If you click on the Options button again, it still shows "Unfollow".
In a Category object, there's a field named Following and also Unfollow
I suppose these two are supposed to be negating each other.
But that is not the case.
Below is a screenshot of a var_dump of a category object
Unfollow => '1' and Following => true. A category already unfollowed still shows options to Unfollow where it should say Follow.
the file with codes responsible for it, /applications/vanilla/views/categories/helper_functions.php, says
// Follow/Unfollow category. if (!GetValue('Following', $Category)) $Options .= ''.Anchor(T('Follow'), "/vanilla/category/follow?categoryid=$CategoryID&value=1&tkey=$TKey").''; else $Options .= ''.Anchor(T('Unfollow'), "/vanilla/category/follow?categoryid=$CategoryID&value=0&tkey=$TKey").'';
It makes decision on what to show in the Options menu based on the value of 'Following', meanwhile the CategoryController that it refers store the change into 'Unfollow'.
/applications/vanilla/controllers/class.categorycontroller.php says :
public function Follow($CategoryID, $Value, $TKey) { if (Gdn::Session()->ValidateTransientKey($TKey)) { $this->CategoryModel->SaveUserTree($CategoryID, array('Unfollow' => !(bool)$Value)); } if ($this->DeliveryType() == DELIVERY_TYPE_ALL) Redirect('/categories/all'); $this->Render(); }
for my plugin, in the current version I copied GetOptions into my plugin and make the required adjustment.
I hope the next release GetOptions could use "Unfollowing" instead.
I'm all done rewriting the plugin except regarding this matter ....
The old one if used with 2.0.18.2 will show all the subcategories below list of discussions.
I don't want to copy GetOptions into my files like before.