From 919b2b80addf6088b4053a861d21ace36631f35f Mon Sep 17 00:00:00 2001 From: Miriam Ruiz Date: Sun, 6 Jun 2010 01:17:35 +0200 Subject: [PATCH] Add extension: category-hider-2.0.zip http://vanillaforums.org/addon/423/category-hider MD5=78fbbd5d5451f65592c9887d0e6dd91e SHA1=059440344f4105facd2a94a80f6ddf9655ba5d67 SHA256=9d29c2f96f6478c26d80d468dc99553478f8fb2a635d88eab2979515010479d6 --- extensions/CategoryHider/Readme.txt | 32 ++++++++++++++++ extensions/CategoryHider/default.php | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 extensions/CategoryHider/Readme.txt create mode 100644 extensions/CategoryHider/default.php diff --git a/extensions/CategoryHider/Readme.txt b/extensions/CategoryHider/Readme.txt new file mode 100644 index 0000000..5614d0c --- /dev/null +++ b/extensions/CategoryHider/Readme.txt @@ -0,0 +1,32 @@ +Category Hider +-------------- + +Version 2.0, By WallPhone + +Removes select categories from the discussions page + +Installation +============ + +In order for Vanilla to recognize an extension, it must be contained within it's +own directory within the extensions directory. So, once you have downloaded and +unzipped the extension files, you can then place the folder containing the +default.php file into your installation of Vanilla. The path to your extension's +default.php file should look like this: + +/path/to/vanilla/extensions/CategoryHider/default.php + +Now the extension may be enabled by going to the settings tab, the extensions +section, and checking the checkbox for the Category Hider extension. + +Keep in mind the extension only appears in the panel for any visitor with an +inactive session. + + +Configuration +============= + +Edit the category you wish to remove, and check the box found near the bottom to +hide that particular category. If the checkbox doesn't appear, ensure you are +using Vanilla 1.1.4 or later and the default theme. You can switch the theme back +and the categories will remain hidden. \ No newline at end of file diff --git a/extensions/CategoryHider/default.php b/extensions/CategoryHider/default.php new file mode 100644 index 0000000..53242b5 --- /dev/null +++ b/extensions/CategoryHider/default.php @@ -0,0 +1,72 @@ +SetDefinition('HiddenCats', 'Hidden categories'); +$Context->SetDefinition('HideThisCat', 'Hide this category from the main discussion grid'); + +if ( ('index.php' == $Context->SelfUrl) && + (isset($Context->Configuration['HiddenCategories'])) && + ($Context->Configuration['HiddenCategories'] != '0') && + (!in_array(ForceIncomingInt('CategoryID', 0), explode(',', $Context->Configuration['HiddenCategories']))) ) { + + function Category_HideFromDiscussions(&$DiscussionManager) { + $SB = &$DiscussionManager->DelegateParameters['SqlBuilder']; + $HiddenCategories = explode(',', $SB->Context->Configuration['HiddenCategories']); + + foreach ($HiddenCategories as $CurrentBlock) + $SB->AddWhere('t', 'CategoryID', '', $CurrentBlock, '<>', 'and', '', 0, 0); + } + $Context->AddToDelegate('DiscussionManager', 'PostGetDiscussionBuilder', 'Category_HideFromDiscussions'); + $Context->AddToDelegate('DiscussionManager', 'PreGetDiscussionCount', 'Category_HideFromDiscussions'); +} + +if ('settings.php' == $Context->SelfUrl) { + function AddCatOption(&$CF) { + $Checked = ( (isset($CF->Context->Configuration['HiddenCategories'])) && + in_array($CF->Category->CategoryID, explode(',', $CF->Context->Configuration['HiddenCategories'])) ) + ? 1 : 0; + + echo ' +
  • + '.$CF->Context->GetDefinition('HiddenCats').' + '. + GetDynamicCheckbox('HideThisCat', + 1, + $Checked, + '', + $CF->Context->GetDefinition('HideThisCat'), + '', + 'HideThisCat') .' +

  • '; + } + $Context->AddToDelegate('CategoryForm', 'PostRolesRender', 'AddCatOption'); + + function SaveHiddenCatValue(&$CF) { + $Hiddens = array(); + + if (isset($CF->Context->Configuration['HiddenCategories'])) + $Hiddens = explode(',', $CF->Context->Configuration['HiddenCategories']); + + if (ForceIncomingInt('HideThisCat', 0)) { + $Hiddens[] = $CF->Category->CategoryID; + } else { + for ($x = 0; $x < count($Hiddens); $x++) + if ($Hiddens[$x] == $CF->Category->CategoryID) $Hiddens[$x] = 0; + } + + $Hiddens = array_unique($Hiddens); + AddConfigurationSetting($CF->Context, 'HiddenCategories', implode(',', $Hiddens)); + } + $Context->AddToDelegate('CategoryForm', 'PostSaveCategory', 'SaveHiddenCatValue'); +} \ No newline at end of file -- 2.11.4.GIT