Created
December 10, 2011 23:05
-
-
Save sanderpotjer/1456932 to your computer and use it in GitHub Desktop.
Patch for [#24602] Users with create rights in a category but not component can't create subcategories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git administrator/components/com_categories/controllers/category.php administrator/components/com_categories/controllers/category.php | |
index 8c02b62c03e412732c5963bc1a99b2f9e7126f6b..cb879c7f2abfaca71318622d05d016a9df6cc86a 100644 | |
--- administrator/components/com_categories/controllers/category.php | |
+++ administrator/components/com_categories/controllers/category.php | |
@@ -53,7 +53,8 @@ class CategoriesControllerCategory extends JControllerForm | |
*/ | |
protected function allowAdd($data = array()) | |
{ | |
- return JFactory::getUser()->authorise('core.create', $this->extension); | |
+ $user = JFactory::getUser(); | |
+ return ($user->authorise('core.create', $this->extension) || count($user->getAuthorisedCategories($this->extension, 'core.create'))); | |
} | |
/** | |
diff --git administrator/components/com_categories/views/categories/view.html.php administrator/components/com_categories/views/categories/view.html.php | |
index 138d7b7690db6e3a742a9a0cf73fe4348484b7a0..a806dd95cf0d678f44b5050a2d2cd76013c8b570 100644 | |
--- administrator/components/com_categories/views/categories/view.html.php | |
+++ administrator/components/com_categories/views/categories/view.html.php | |
@@ -74,6 +74,7 @@ class CategoriesViewCategories extends JView | |
$component = $this->state->get('filter.component'); | |
$section = $this->state->get('filter.section'); | |
$canDo = null; | |
+ $user = JFactory::getUser(); | |
// Avoid nonsense situation. | |
if ($component == 'com_categories') { | |
@@ -112,7 +113,7 @@ class CategoriesViewCategories extends JView | |
// Prepare the toolbar. | |
JToolBarHelper::title($title, 'categories '.substr($component,4).($section?"-$section":'').'-categories'); | |
- if ($canDo->get('core.create')) { | |
+ if ($canDo->get('core.create') || (count($user->getAuthorisedCategories($component, 'core.create'))) > 0 ) { | |
JToolBarHelper::addNew('category.add'); | |
} | |
diff --git administrator/components/com_categories/views/category/view.html.php administrator/components/com_categories/views/category/view.html.php | |
index 758cf465b78d6c9217758187fb62fcf74ca28679..53dbf37d878394169868b062ec59e1b2da2ed851 100644 | |
--- administrator/components/com_categories/views/category/view.html.php | |
+++ administrator/components/com_categories/views/category/view.html.php | |
@@ -102,7 +102,7 @@ class CategoriesViewCategory extends JView | |
JToolBarHelper::title($title, 'category-'.($isNew?'add':'edit').' '.substr($component,4).($section?"-$section":'').'-category-'.($isNew?'add':'edit')); | |
// For new records, check the create permission. | |
- if ($isNew && $canDo->get('core.create')) { | |
+ if ($isNew && (count($user->getAuthorisedCategories($component, 'core.create')) > 0)) { | |
JToolBarHelper::apply('category.apply'); | |
JToolBarHelper::save('category.save'); | |
JToolBarHelper::save2new('category.save2new'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment