From fd4bc5ba592fe0751b57f591a6f75bd808d624a8 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Wed, 12 Oct 2011 23:01:15 -0500 Subject: [PATCH 1/5] Add message types to distinguish errors --- .../components/com_patchtester/controllers/pull.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_patchtester/controllers/pull.php b/administrator/components/com_patchtester/controllers/pull.php index 78d6d2b9..e4d75837 100644 --- a/administrator/components/com_patchtester/controllers/pull.php +++ b/administrator/components/com_patchtester/controllers/pull.php @@ -22,10 +22,12 @@ public function apply() $model = $this->getModel('pull'); if ($model->apply(JRequest::getVar('pull_id'))) { $msg = 'Patch successfully applied'; + $type = 'message'; } else { $msg = $model->getError(); + $type = 'error'; } - $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg); + $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type); } public function revert() @@ -33,10 +35,12 @@ public function revert() $model = $this->getModel('pull'); if ($model->revert(JRequest::getVar('pull_id'))) { $msg = 'Patch successfully reverted'; + $type = 'message'; } else { $msg = 'Patch did not revert'; + $type = 'error'; } - $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg); + $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type); } } From edc9f41ff32bdc908aa19916abe3dbdd6503f778 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Wed, 12 Oct 2011 23:15:09 -0500 Subject: [PATCH 2/5] Fix language keys mixed up --- .../language/en-GB/en-GB.com_patchtester.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index 7791b2e4..2c56a4a7 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -7,7 +7,7 @@ COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the reposit COM_PATCHTESTER_CONFLICT="The patch could not be applied because it conflicts with a previously applied patch" COM_PATCHTESTER_COMPONENT_LABEL="Patch Tester" COM_PATCHTESTER_COMPONENT_DESC="Patch Tester Configuration Values" -COM_PATCHTESTER_FIELD_ORG_DESC="Github Username" -COM_PATCHTESTER_FIELD_ORG_LABEL="Name of account on Github of which to monitor pull requests" -COM_PATCHTESTER_FIELD_REPO_DESC="Github Repository" -COM_PATCHTESTER_FIELD_REPO_LABEL="Name of repository on Github of which to monitor pull requests" +COM_PATCHTESTER_FIELD_ORG_LABEL="Github Username" +COM_PATCHTESTER_FIELD_ORG_DESC="Name of account on Github of which to monitor pull requests" +COM_PATCHTESTER_FIELD_REPO_LABEL="Github Repository" +COM_PATCHTESTER_FIELD_REPO_DESC="Name of repository on Github of which to monitor pull requests" From 5a4226413fc10ef6e65b2334c74c2c2670ef060c Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Thu, 13 Oct 2011 00:29:08 -0500 Subject: [PATCH 3/5] Fix Backup not created when deleting files --- administrator/components/com_patchtester/models/pull.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_patchtester/models/pull.php b/administrator/components/com_patchtester/models/pull.php index d62b17d3..626e84fd 100644 --- a/administrator/components/com_patchtester/models/pull.php +++ b/administrator/components/com_patchtester/models/pull.php @@ -25,7 +25,7 @@ class PatchtesterModelPull extends JModel protected function populateState() { // Initialise variables. - $app = JFactory::getApplication('administrator'); +// $app = JFactory::getApplication('administrator'); // Load the parameters. $params = JComponentHelper::getParams('com_patchtester'); @@ -33,7 +33,7 @@ protected function populateState() $this->setState('github_user', $params->get('org')); $this->setState('github_repo', $params->get('repo')); - parent::populateState(); +// parent::populateState(); } @@ -140,7 +140,7 @@ public function apply($id) foreach ($files AS $file) { // we only create a backup if the file already exists - if (file_exists(JPATH_ROOT . '/' . $file->new) && ($file->action == 'modified' || $file->action == 'deleted')) { + if ($file->action == 'deleted' || (file_exists(JPATH_ROOT . '/' . $file->new) && $file->action == 'modified')) { JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt'); } From 2bdffb5bc6286d171b55a2f46cb01ce9ec47e679 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Thu, 13 Oct 2011 00:47:11 -0500 Subject: [PATCH 4/5] Fix language keys mixed up --- .../language/en-GB/en-GB.com_patchtester.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index f762f6ac..6550d0eb 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -7,8 +7,8 @@ COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the reposit COM_PATCHTESTER_CONFLICT="The patch could not be applied because it conflicts with a previously applied patch" COM_PATCHTESTER_COMPONENT_LABEL="Patch Tester" COM_PATCHTESTER_COMPONENT_DESC="Patch Tester Configuration Values" -COM_PATCHTESTER_FIELD_ORG_DESC="Github Username" -COM_PATCHTESTER_FIELD_ORG_LABEL="Name of account on Github of which to monitor pull requests" -COM_PATCHTESTER_FIELD_REPO_DESC="Github Repository" -COM_PATCHTESTER_FIELD_REPO_LABEL="Name of repository on Github of which to monitor pull requests" +COM_PATCHTESTER_FIELD_ORG_LABEL="Github Username" +COM_PATCHTESTER_FIELD_ORG_DESC="Name of account on Github of which to monitor pull requests" +COM_PATCHTESTER_FIELD_REPO_LABEL="Github Repository" +COM_PATCHTESTER_FIELD_REPO_DESC="Name of repository on Github of which to monitor pull requests" COM_PATCHTESTER_JOOMLACODE_ISSUE="Joomlacode Issue" From 3babe57078ba4c3f2c017733c71b79161e92ebc4 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Thu, 13 Oct 2011 11:44:25 -0500 Subject: [PATCH 5/5] Remove commented line, formatting --- .../com_patchtester/models/pull.php | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/administrator/components/com_patchtester/models/pull.php b/administrator/components/com_patchtester/models/pull.php index 626e84fd..b3f1384d 100644 --- a/administrator/components/com_patchtester/models/pull.php +++ b/administrator/components/com_patchtester/models/pull.php @@ -15,27 +15,23 @@ class PatchtesterModelPull extends JModel { - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @since 1.6 - */ - protected function populateState() - { - // Initialise variables. -// $app = JFactory::getApplication('administrator'); - - // Load the parameters. - $params = JComponentHelper::getParams('com_patchtester'); - $this->setState('params', $params); - $this->setState('github_user', $params->get('org')); - $this->setState('github_repo', $params->get('repo')); - -// parent::populateState(); - } + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @since 1.6 + */ + protected function populateState() + { + // Load the parameters. + $params = JComponentHelper::getParams('com_patchtester'); + $this->setState('params', $params); + $this->setState('github_user', $params->get('org')); + $this->setState('github_repo', $params->get('repo')); + parent::populateState(); + } protected function parsePatch($patch) { @@ -112,7 +108,7 @@ public function apply($id) $http = new JHttp; $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . - $pull->head->ref . '/' . $file->new; + $pull->head->ref . '/' . $file->new; // if the backup file already exists, we can't apply the patch