public function testConnection() { $exportDirectory = $this->_fixBasePath($this->getDestination()->getPath()); $testResult = new Varien_Object(); // Check for forbidden folders $forbiddenFolders = array(Mage::getBaseDir('base'), Mage::getBaseDir('base') . DS . 'downloader'); foreach ($forbiddenFolders as $forbiddenFolder) { if (@realpath($exportDirectory) == $forbiddenFolder) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('It is not allowed to save export files in the directory you have specified. Please change the local export directory to be located in the ./var/ folder for example. Do not use the Magento root directory for example.')); } } if (!is_dir($exportDirectory) && !preg_match('/%exportid%/', $exportDirectory)) { // Try to create the directory. if (!@mkdir($exportDirectory)) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('The specified local directory does not exist. We could not create it either. Please make sure the parent directory is writable or create the directory manually: %s', $exportDirectory)); } else { $testResult->setDirectoryCreated(true); } } $this->_connection = @opendir($exportDirectory); if (!$this->_connection || @(!is_writable($exportDirectory))) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('Could not open local export directory for writing. Please make sure that we have rights to read and write in the directory: %s', $exportDirectory)); } if ($testResult->getDirectoryCreated()) { $testResult->setSuccess(true)->setMessage(Mage::helper('xtento_orderexport')->__('Local directory didn\'t exist and was created successfully. Connection tested successfully.')); if (!$this->getDestination()->getBackupDestination()) { $this->getDestination()->setLastResult($testResult->getSuccess())->setLastResultMessage($testResult->getMessage())->save(); } return $testResult; } else { $testResult->setSuccess(true)->setMessage(Mage::helper('xtento_orderexport')->__('Local directory exists and is writable. Connection tested successfully.')); if (!$this->getDestination()->getBackupDestination()) { $this->getDestination()->setLastResult($testResult->getSuccess())->setLastResultMessage($testResult->getMessage())->save(); } return $testResult; } }
/** * Fill Message Box by success and notice messages about results of user actions. * * @param Varien_Object $counter * @return void */ protected function _fillMessageBox($counter) { $session = Mage::getSingleton('catalog/session'); if ($counter->getNew()) { $session->addSuccess($this->__('%s tag(s) have been accepted for moderation.', $counter->getNew())); } if (count($counter->getExist())) { foreach ($counter->getExist() as $tagName) { $session->addNotice($this->__('Tag "%s" has already been added to the product.', $tagName)); } } if (count($counter->getSuccess())) { foreach ($counter->getSuccess() as $tagName) { $session->addSuccess($this->__('Tag "%s" has been added to the product.', $tagName)); } } if (count($counter->getRecurrence())) { foreach ($counter->getRecurrence() as $tagName) { $session->addSuccess($this->__('Tag "%s" has been rejected by administrator.', $tagName)); } } }