Skip to content

Commit

Permalink
CodeStyle / Redundant Code
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoLopesPT committed Jun 12, 2017
1 parent bd377db commit 8b48e98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 40 deletions.
Expand Up @@ -31,15 +31,18 @@ public function edit()
{
$model = $this->getModel('updatesites');

//Get the id of the UpdateSite that we are trying to edit
// Get the id of the UpdateSite that we are trying to edit
$recordId = $this->input->post->get('cid', array(), 'array')[0];

//Get the list of the Joomla Core UpdateSites
// Get the list of the Joomla Core UpdateSites
$joomlaUpdateSitesIds = $model->getJoomlaUpdateSitesIds(0);

// Get the $recordId name
$joomlaUpdateSiteName = reset($model->getJoomlaUpdateSitesNames(array($recordId)))->name;

if (in_array($recordId, $joomlaUpdateSitesIds))
{
$this->setMessage(\JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_DELETE_CANNOT_EDIT',reset($model->getJoomlaUpdateSitesNames(array($recordId)))->name), 'error');
$this->setMessage(\JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_DELETE_CANNOT_EDIT', $joomlaUpdateSiteName), 'error');

$this->setRedirect(
\JRoute::_(
Expand Down
34 changes: 0 additions & 34 deletions administrator/components/com_installer/Model/Updatesites.php
Expand Up @@ -119,40 +119,6 @@ public function publish(&$eid = array(), $value = 1)
return $result;
}

public function edit(&$eid = array(), $value = 1)
{
if (!\JFactory::getUser()->authorise('core.edit.state', 'com_installer'))
{
throw new \Exception(\JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
}

$result = true;

// Ensure eid is an array of extension ids
if (!is_array($eid))
{
$eid = array($eid);
}

// Get a table object for the extension type
$table = new \Joomla\CMS\Table\UpdateSite($this->getDbo());

// Enable the update site in the table and store it in the database
foreach ($eid as $i => $id)
{
$table->load($id);
$table->enabled = $value;

if (!$table->store())
{
$this->setError($table->getError());
$result = false;
}
}

return $result;
}

/**
* Deletes an update site.
*
Expand Down
Expand Up @@ -69,9 +69,9 @@ protected function addToolbar()
{
\JFactory::getApplication()->input->set('hidemainmenu', true);

//$user = \JFactory::getUser();
//$userId = $user->id;
//$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
// $user = \JFactory::getUser();
// $userId = $user->id;
// $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);

$checkedOut = false;

Expand Down

0 comments on commit 8b48e98

Please sign in to comment.