diff --git a/src/administrator/components/com_weblinks/src/Table/WeblinkTable.php b/src/administrator/components/com_weblinks/src/Table/WeblinkTable.php index a92ff61..91feeff 100644 --- a/src/administrator/components/com_weblinks/src/Table/WeblinkTable.php +++ b/src/administrator/components/com_weblinks/src/Table/WeblinkTable.php @@ -91,7 +91,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT { $this->created_by = $user->id; } - + if (empty($this->hits)) { $this->hits = 0; @@ -113,7 +113,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT // Verify that the alias is unique $table = new WeblinkTable($this->getDbo()); - if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => (int)$this->catid)) + if ($table->load(array('language' => $this->language, 'alias' => $this->alias, 'catid' => (int) $this->catid)) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS')); diff --git a/src/administrator/components/com_weblinks/src/View/Weblink/HtmlView.php b/src/administrator/components/com_weblinks/src/View/Weblink/HtmlView.php index b97a9c9..5205886 100644 --- a/src/administrator/components/com_weblinks/src/View/Weblink/HtmlView.php +++ b/src/administrator/components/com_weblinks/src/View/Weblink/HtmlView.php @@ -28,9 +28,9 @@ use Joomla\CMS\Toolbar\ToolbarHelper; class HtmlView extends BaseHtmlView { /** - * The \JForm object + * The Form object * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ protected $form; @@ -44,7 +44,7 @@ class HtmlView extends BaseHtmlView /** * The model state * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $state; diff --git a/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php b/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php index a6f172a..110370f 100644 --- a/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php +++ b/src/administrator/components/com_weblinks/src/View/Weblinks/HtmlView.php @@ -36,21 +36,21 @@ class HtmlView extends BaseHtmlView /** * The pagination object * - * @var \JPagination + * @var \Joomla\CMS\Pagination\Pagination */ protected $pagination; /** * The model state * - * @var \JObject + * @var \Joomla\CMS\Object\CMSObject */ protected $state; /** * Form object for search filters * - * @var \JForm + * @var \Joomla\CMS\Form\Form */ public $filterForm; diff --git a/src/components/com_weblinks/src/Controller/WeblinkController.php b/src/components/com_weblinks/src/Controller/WeblinkController.php index 49f8d75..85f0d4f 100644 --- a/src/components/com_weblinks/src/Controller/WeblinkController.php +++ b/src/components/com_weblinks/src/Controller/WeblinkController.php @@ -79,7 +79,6 @@ class WeblinkController extends FormController protected function allowAdd($data = array()) { $categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('id'), 'int'); - $allow = null; if ($categoryId) { @@ -104,17 +103,33 @@ class WeblinkController extends FormController protected function allowEdit($data = array(), $key = 'id') { $recordId = (int) isset($data[$key]) ? $data[$key] : 0; - $categoryId = 0; - if ($recordId) + if (!$recordId) { - $categoryId = (int) $this->getModel()->getItem($recordId)->catid; + return false; } + $record = $this->getModel()->getItem($recordId); + $categoryId = (int) $record->catid; + if ($categoryId) { // The category has been set. Check the category permissions. - return $this->app->getIdentity()->authorise('core.edit', $this->option . '.category.' . $categoryId); + $user = $this->app->getIdentity(); + + // First, check edit permission + if ($user->authorise('core.edit', $this->option . '.category.' . $categoryId)) + { + return true; + } + + // Fallback on edit.own + if ($user->authorise('core.edit.own', $this->option . '.category.' . $categoryId) && $record->created_by == $user->id) + { + return true; + } + + return false; } // Since there is no asset tracking, revert to the component permissions. @@ -307,7 +322,6 @@ class WeblinkController extends FormController } // Redirect to the URL - // @todo: Probably should check for a valid http link if ($link->url) { $modelLink->hit($id); diff --git a/src/components/com_weblinks/src/Model/CategoryModel.php b/src/components/com_weblinks/src/Model/CategoryModel.php index 75843f0..e353110 100644 --- a/src/components/com_weblinks/src/Model/CategoryModel.php +++ b/src/components/com_weblinks/src/Model/CategoryModel.php @@ -103,9 +103,7 @@ class CategoryModel extends ListModel { if (!isset($this->_params)) { - $params = new Registry; - $params->loadString($item->params); - $item->params = $params; + $item->params = new Registry($item->params); } // Get the tags diff --git a/src/components/com_weblinks/src/Model/WeblinkModel.php b/src/components/com_weblinks/src/Model/WeblinkModel.php index 30dca7a..06fcc28 100644 --- a/src/components/com_weblinks/src/Model/WeblinkModel.php +++ b/src/components/com_weblinks/src/Model/WeblinkModel.php @@ -26,6 +26,14 @@ use Joomla\Registry\Registry; */ class WeblinkModel extends ItemModel { + /** + * Store loaded weblink items + * + * @var array + * @since 1.6 + */ + protected $_item = null; + /** * Model context string. * diff --git a/src/components/com_weblinks/src/View/Category/HtmlView.php b/src/components/com_weblinks/src/View/Category/HtmlView.php index 8b9eb62..d7eacf2 100644 --- a/src/components/com_weblinks/src/View/Category/HtmlView.php +++ b/src/components/com_weblinks/src/View/Category/HtmlView.php @@ -72,7 +72,6 @@ class HtmlView extends CategoryView protected function prepareDocument() { parent::prepareDocument(); - ; parent::addFeed(); diff --git a/src/components/com_weblinks/tmpl/category/default_items.php b/src/components/com_weblinks/tmpl/category/default_items.php index 2277c29..cc7ae12 100644 --- a/src/components/com_weblinks/tmpl/category/default_items.php +++ b/src/components/com_weblinks/tmpl/category/default_items.php @@ -23,10 +23,10 @@ $params = &$this->category->params; // Get the user object. $user = Factory::getApplication()->getIdentity(); -// Check if user is allowed to add/edit based on weblinks permissinos. -$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id); -$canCreate = $user->authorise('core.create', 'com_weblinks'); -$canEditState = $user->authorise('core.edit.state', 'com_weblinks'); +// Check if user is allowed to add/edit based on weblinks permission. +$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id); +$canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $this->category->id); +$canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $this->category->id); $n = count($this->items); $listOrder = $this->escape($this->state->get('list.ordering')); @@ -45,7 +45,7 @@ $listDirn = $this->escape($this->state->get('list.direction')); name="filter-search" id="filter-search" value="escape($this->state->get('list.filter')); ?>" - class="inputbox" onchange="document.adminForm.submit();" + onchange="document.adminForm.submit();" placeholder="" > @@ -79,7 +79,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
+
pagination->getPagesCounter(); ?>