Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions administrator/components/com_banners/models/banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,17 @@ protected function batchClient($value, $pks, $contexts)
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->state != -2)
{
if ($record->state != -2)
{
return false;
}

if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
}
return false;
}

return parent::canDelete($record);
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
}

return parent::canDelete($record);
}

/**
Expand Down
21 changes: 8 additions & 13 deletions administrator/components/com_banners/models/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,17 @@ class BannersModelClient extends JModelAdmin
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->state != -2)
{
if ($record->state != -2)
{
return false;
}

$user = JFactory::getUser();

if (!empty($record->catid))
{
return $user->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
}
return false;
}

return $user->authorise('core.delete', 'com_banners');
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
}

return parent::canDelete($record);
}

/**
Expand Down
11 changes: 4 additions & 7 deletions administrator/components/com_contact/models/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ protected function batchUser($value, $pks, $contexts)
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->published != -2)
{
if ($record->published != -2)
{
return false;
}

return JFactory::getUser()->authorise('core.delete', 'com_contact.category.' . (int) $record->catid);
return false;
}

return JFactory::getUser()->authorise('core.delete', 'com_contact.category.' . (int) $record->catid);
}

/**
Expand Down
11 changes: 3 additions & 8 deletions administrator/components/com_content/models/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,12 @@ protected function batchMove($value, $pks, $contexts)
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->state != -2)
{
if ($record->state != -2)
{
return false;
}

return JFactory::getUser()->authorise('core.delete', 'com_content.article.' . (int) $record->id);
return false;
}

return false;
return JFactory::getUser()->authorise('core.delete', 'com_content.article.' . (int) $record->id);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function canEdit($record)
*/
protected function canDelete($record)
{
return canEdit($record);
return $this->canEdit($record);
}

/**
Expand Down
15 changes: 5 additions & 10 deletions administrator/components/com_fields/models/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,14 @@ public function cleanupValues($context, $itemId)
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->state != -2)
{
if ($record->state != -2)
{
return false;
}

$parts = FieldsHelper::extract($record->context);

return JFactory::getUser()->authorise('core.delete', $parts[0] . '.field.' . (int) $record->id);
return false;
}

return false;
$parts = FieldsHelper::extract($record->context);

return JFactory::getUser()->authorise('core.delete', $parts[0] . '.field.' . (int) $record->id);
}

/**
Expand Down
24 changes: 8 additions & 16 deletions administrator/components/com_menus/models/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,19 @@ class MenusModelItem extends JModelAdmin
*/
protected function canDelete($record)
{
$user = JFactory::getUser();

if (!empty($record->id))
if (empty($record->id) || $record->published != -2)
{
// Only delete trashed items
if ($record->published != -2)
{
return false;
}

$menuTypeId = 0;
return false;
}

if (!empty($record->menutype))
{
$menuTypeId = $this->getMenuTypeId($record->menutype);
}
$menuTypeId = 0;

return $user->authorise('core.delete', 'com_menus.menu.' . (int) $menuTypeId);
if (!empty($record->menutype))
{
$menuTypeId = $this->getMenuTypeId($record->menutype);
}

return false;
return JFactory::getUser()->authorise('core.delete', 'com_menus.menu.' . (int) $menuTypeId);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions administrator/components/com_menus/models/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class MenusModelMenu extends JModelForm
*/
protected function canDelete($record)
{
$user = JFactory::getUser();

return $user->authorise('core.delete', 'com_menus.menu.' . (int) $record->id);
return JFactory::getUser()->authorise('core.delete', 'com_menus.menu.' . (int) $record->id);
}

/**
Expand Down
10 changes: 3 additions & 7 deletions administrator/components/com_modules/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,14 @@ protected function batchMove($value, $pks, $contexts)
*/
protected function canEditState($record)
{
$user = JFactory::getUser();

// Check for existing module.
if (!empty($record->id))
{
return $user->authorise('core.edit.state', 'com_modules.module.' . (int) $record->id);
return JFactory::getUser()->authorise('core.edit.state', 'com_modules.module.' . (int) $record->id);
}

// Default to component settings if module not known.
else
{
return parent::canEditState('com_modules');
}
return parent::canEditState($record);
}

/**
Expand Down
33 changes: 10 additions & 23 deletions administrator/components/com_newsfeeds/models/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,17 @@ class NewsfeedsModelNewsfeed extends JModelAdmin
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->published != -2)
{
if ($record->published != -2)
{
return false;
}

$user = JFactory::getUser();
return false;
}

if (!empty($record->catid))
{
return $user->authorise('core.delete', 'com_newsfeed.category.' . (int) $record->catid);
}
else
{
return parent::canDelete($record);
}
if (!empty($record->catid))
{
return JFactory::getUser()->authorise('core.delete', 'com_newsfeed.category.' . (int) $record->catid);
}

return false;
return parent::canDelete($record);
}

/**
Expand All @@ -87,16 +78,12 @@ protected function canDelete($record)
*/
protected function canEditState($record)
{
$user = JFactory::getUser();

if (!empty($record->catid))
{
return $user->authorise('core.edit.state', 'com_newsfeeds.category.' . (int) $record->catid);
}
else
{
return parent::canEditState($record);
return JFactory::getUser()->authorise('core.edit.state', 'com_newsfeeds.category.' . (int) $record->catid);
}

return parent::canEditState($record);
}

/**
Expand Down
21 changes: 1 addition & 20 deletions administrator/components/com_redirect/models/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,7 @@ protected function canDelete($record)
return false;
}

$user = JFactory::getUser();

return $user->authorise('core.delete', 'com_redirect');
}

/**
* Method to test whether a record can have its state edited.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();

// Check the component since there are no categories or other assets.
return $user->authorise('core.edit.state', 'com_redirect');
return parent::canDelete($record);
}

/**
Expand Down
23 changes: 3 additions & 20 deletions administrator/components/com_tags/models/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,12 @@ class TagsModelTag extends JModelAdmin
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->published != -2)
{
if ($record->published != -2)
{
return false;
}

return parent::canDelete($record);
return false;
}
}

/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 3.1
*/
protected function canEditState($record)
{
return parent::canEditState($record);
return parent::canDelete($record);
}

/**
Expand Down
39 changes: 16 additions & 23 deletions components/com_config/model/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,32 +256,25 @@ protected function populateState()
*/
protected function canDelete($record)
{
if (!empty($record->id))
if (empty($record->id) || $record->published != -2)
{
if ($record->published != -2)
{
return false;
}

$user = JFactory::getUser();

return $user->authorise('core.delete', $this->option);
return false;
}
}

/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 3.2
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
return JFactory::getUser()->authorise('core.delete', $this->option);
}

return $user->authorise('core.edit.state', $this->option);
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 3.2
*/
protected function canEditState($record)
{
return JFactory::getUser()->authorise('core.edit.state', $this->option);
}
}