diff --git a/src/administrator/components/com_weblinks/controllers/weblink.php b/src/administrator/components/com_weblinks/controllers/weblink.php index 08b74964152..825c05f71e8 100644 --- a/src/administrator/components/com_weblinks/controllers/weblink.php +++ b/src/administrator/components/com_weblinks/controllers/weblink.php @@ -60,21 +60,29 @@ protected function allowAdd($data = array()) protected function allowEdit($data = array(), $key = 'id') { $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - $categoryId = 0; - if ($recordId) + // Since there is no asset tracking, fallback to the component permissions. + if (!$recordId) { - $categoryId = (int) $this->getModel()->getItem($recordId)->catid; + return parent::allowEdit($data, $key); } - if ($categoryId) + // Get the item. + $item = $this->getModel()->getItem($recordId); + + // Since there is no item, return false. + if (empty($item)) { - // The category has been set. Check the category permissions. - return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId); + return false; } - // Since there is no asset tracking, revert to the component permissions. - return parent::allowEdit($data, $key); + $user = JFactory::getUser(); + + // Check if can edit own core.edit.own. + $canEditOwn = $user->authorise('core.edit.own', $this->option . '.category.' . (int) $item->catid) && $item->created_by == $user->id; + + // Check the category core.edit permissions. + return $canEditOwn || $user->authorise('core.edit', $this->option . '.category.' . (int) $item->catid); } /** diff --git a/src/administrator/components/com_weblinks/models/weblinks.php b/src/administrator/components/com_weblinks/models/weblinks.php index 2d65e54d6fd..65cf6e82e88 100644 --- a/src/administrator/components/com_weblinks/models/weblinks.php +++ b/src/administrator/components/com_weblinks/models/weblinks.php @@ -132,7 +132,7 @@ protected function getListQuery() $query->select( $this->getState( 'list.select', - 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' . + 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.created_by, ' . 'a.hits, a.state, a.access, a.ordering, a.language, a.publish_up, a.publish_down' ) ); diff --git a/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php b/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php index e0d443e69c9..a6befc7aeac 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php +++ b/src/administrator/components/com_weblinks/views/weblinks/tmpl/default.php @@ -86,7 +86,8 @@ cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?> authorise('core.create', 'com_weblinks.category.' . $item->catid); ?> authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?> - authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0; ?> + authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; ?> + authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?> authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?> @@ -121,7 +122,7 @@ checked_out) : ?> editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?> - + escape($item->title); ?> diff --git a/src/administrator/components/com_weblinks/views/weblinks/view.html.php b/src/administrator/components/com_weblinks/views/weblinks/view.html.php index 8487ae6e1dc..7e11f16d906 100644 --- a/src/administrator/components/com_weblinks/views/weblinks/view.html.php +++ b/src/administrator/components/com_weblinks/views/weblinks/view.html.php @@ -76,7 +76,7 @@ protected function addToolbar() JToolbarHelper::addNew('weblink.add'); } - if ($canDo->get('core.edit')) + if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) { JToolbarHelper::editList('weblink.edit'); }