/** * Saves the channel userdata in PEAR config * * @param Faett_Manager_Model_Channel $channel * The channel to get Data from * @return */ protected function _beforeSave(Faett_Manager_Model_Channel $channel) { // set username and password in pear config if both are set if ($channel->getUsername() && $channel->getNewPassword()) { $this->_service->setUsername($channel->getUsername(), $channel->getUrl()); $this->_service->setPassword($channel->getNewPassword(), $channel->getUrl()); } // save new password as hash if new password is set if ($channel->getNewPassword()) { $channel->setPassword($channel->hashPassword($channel->getNewPassword())); } }
public function saveAction() { if ($data = $this->getRequest()->getPost()) { $model = Mage::getModel('manager/channel'); $model->setData($data)->setId($this->getRequest()->getParam('id')); try { if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) { $model->setCreatedTime(now())->setUpdateTime(now()); } else { $model->setUpdateTime(now()); } $model->save(); $opts = array(); $params = array($model->getUrl()); $this->_service->channelDiscover($opts, $params); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('manager')->__('200.success.channel-saved')); Mage::getSingleton('adminhtml/session')->setFormData(false); if ($this->getRequest()->getParam('back')) { $this->_redirect('*/*/edit', array('id' => $model->getId())); return; } $this->_redirect('*/*/'); return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); Mage::getSingleton('adminhtml/session')->setFormData($data); $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id'))); return; } } Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manager')->__('200.error.channel-id-not-in-request')); $this->_redirect('*/*/'); }
/** * Runs the passed PEAR command for the package * with the id passed in the request. * * @param string $command The command to run * @param int $id The id of the package to do something with * @return string The name of the package the command was executed for */ private function _runCommand($command = 'install') { // load the ID of the package to initialize and the package itself $id = $this->getRequest()->getParam('id'); $package = Mage::getModel('manager/package'); $package->load($id); // initialize the options for the PEAR installer $opts = array(); // initialize the parameters for the PEAR installer $params = array($config = Mage::helper('manager')->getChannelAsString($package)); // check the passed command switch ($command) { case Faett_Core_Interfaces_Service::COMMAND_INSTALL: if ((bool) Mage::getStoreConfig('manager/global/force')) { $opts['force'] = true; } $this->_service->install($opts, $params); break; case Faett_Core_Interfaces_Service::COMMAND_UPGRADE: if ((bool) Mage::getStoreConfig('manager/global/force')) { $opts['force'] = true; } $this->_service->upgrade($opts, $params); break; case Faett_Core_Interfaces_Service::COMMAND_UNINSTALL: $this->_service->uninstall($opts, $params); break; default: throw Faett_Manager_Exception_InvalidCommandException::create(Mage::helper('manager')->__('201.error.invalid-command', $command, $this->_getConfigUrl())); } // load the package information $info = $this->_service->packageInfo($package->getName(), $package->getChannel()->getAlias()); // load the installed version if (array_key_exists('installed', $info)) { $package->setVersionInstalled($versionInstalled = $info['installed']); } // load the latest version if (is_array($info['releases'])) { $package->setVersionLatest($versionLatest = reset(array_keys($info['releases']))); } // set the package state $package->setState(Mage::helper('manager')->getPackageState($package)); // update the package $package->save(); // log a message with the message logged by PEAR Mage::log($this->_service->getUI()->getLogText()); // return the package name return $package->getName(); }
/** * Return the password of the channel, registered by Faett_Manager * in the Magento internal PEAR repository. * * @param Faett_Manager_Package_Interfaces_Information * The package information to return the password for * @return string The username for the channel */ protected function _getPassword(Faett_Manager_Package_Interfaces_Information $information) { return $this->_service->getPassword($this->_getChannel($information)->getUrl()); }