Skip to content

Commit

Permalink
User with edit_own permission should be able to load Versions
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Jun 16, 2016
1 parent 3c1c8df commit 4b41620
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function addToolbar()
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
if ($this->state->params->get('save_history', 0) && ($user->authorise('core.edit') || $user->authorise('core.edit.own')))
{
JToolbarHelper::versions('com_banners.banner', $this->item->id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function addToolbar()
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
if ($this->state->params->get('save_history', 0) && ($user->authorise('core.edit') || $user->authorise('core.edit.own')))
{
JToolbarHelper::versions('com_banners.client', $this->item->id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function addToolbar()
JToolbarHelper::save2copy('contact.save2copy');
}

if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
if ($this->state->params->get('save_history', 0) && ($user->authorise('core.edit') || $user->authorise('core.edit.own')))
{
JToolbarHelper::versions('com_contact.contact', $this->item->id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function addToolbar()
JToolbarHelper::save2copy('article.save2copy');
}

if ($this->state->params->get('save_history', 0) && $canDo->get('core.edit'))
if ($this->state->params->get('save_history', 0) && ($canDo->get('core.edit') || $canDo->get('core.edit.own')))
{
JToolbarHelper::versions('com_content.article', $this->item->id);
}
Expand Down
30 changes: 21 additions & 9 deletions administrator/components/com_contenthistory/models/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,37 @@ public function getItems()
return false;
}

$user = JFactory::getUser();
// Access check
if (!JFactory::getUser()->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table1->ucm_item_id))
if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table1->ucm_item_id))
{
$return = true;
}
elseif ($user->authorise('core.edit.own', $contentTypeTable->type_alias . '.' . (int) $table1->ucm_item_id))
{
$return = true;
}
else
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));

return false;
}

// All's well, process the records
foreach (array($table1, $table2) as $table)
if ($return = true)
{
$object = new stdClass;
$object->data = ContenthistoryHelper::prepareData($table);
$object->version_note = $table->version_note;
$object->save_date = $table->save_date;
$result[] = $object;
}
foreach (array($table1, $table2) as $table)
{
$object = new stdClass;
$object->data = ContenthistoryHelper::prepareData($table);
$object->version_note = $table->version_note;
$object->save_date = $table->save_date;
$result[] = $object;
}

return $result;
return $result;
}
}

return false;
Expand Down
14 changes: 10 additions & 4 deletions administrator/components/com_contenthistory/models/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function delete(&$pks)
public function getItems()
{
$items = parent::getItems();
$user = JFactory::getUser();

if ($items === false)
{
Expand All @@ -171,15 +172,20 @@ public function getItems()
}

// Access check
if (!JFactory::getUser()->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $items[0]->ucm_item_id))
if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $items[0]->ucm_item_id))
{
return $items;
}
elseif ($user->authorise('core.edit.own', $contentTypeTable->type_alias . '.' . (int) $items[0]->ucm_item_id))
{
return $items;
}
else
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));

return false;
}

// All good, return the items array
return $items;
}

/**
Expand Down
24 changes: 18 additions & 6 deletions administrator/components/com_contenthistory/models/preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,32 @@ public function getItem()
return false;
}

$user = JFactory::getUser();
// Access check
if (!JFactory::getUser()->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table->ucm_item_id))
if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table->ucm_item_id))
{
$return = true;
}
elseif ($user->authorise('core.edit.own', $contentTypeTable->type_alias . '.' . (int) $table->ucm_item_id))
{
$return = true;
}
else
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));

return false;
}

// Good to go, finish processing the data
$result = new stdClass;
$result->save_date = $table->save_date;
$result->version_note = $table->version_note;
$result->data = ContenthistoryHelper::prepareData($table);
if ($return = true)
{
$result = new stdClass;
$result->save_date = $table->save_date;
$result->version_note = $table->version_note;
$result->data = ContenthistoryHelper::prepareData($table);

return $result;
return $result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function addToolbar()
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
if ($this->state->params->get('save_history', 0) && ($user->authorise('core.edit') || $user->authorise('core.edit.own')))
{
JToolbarHelper::versions('com_newsfeeds.newsfeed', $this->item->id);
}
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_tags/views/tag/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function addToolbar()
}
else
{
if ($this->state->params->get('save_history', 0) && $user->authorise('core.edit'))
if ($this->state->params->get('save_history', 0) && ($user->authorise('core.edit') || $user->authorise('core.edit.own')))
{
JToolbarHelper::versions('com_tags.tag', $this->item->id);
}
Expand Down

0 comments on commit 4b41620

Please sign in to comment.