Example #1
0
 public function render(Varien_Object $row)
 {
     $configuration = array();
     if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_LOCAL) {
         $configuration['directory'] = $row->getPath();
     }
     if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_FTP || $row->getType() == Xtento_OrderExport_Model_Destination::TYPE_SFTP) {
         $configuration['server'] = $row->getHostname() . ':' . $row->getPort();
         $configuration['username'] = $row->getUsername();
         $configuration['path'] = $row->getPath();
     }
     if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_EMAIL) {
         $configuration['from'] = $row->getEmailSender();
         $configuration['to'] = $row->getEmailRecipient();
         $configuration['subject'] = $row->getEmailSubject();
     }
     if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_CUSTOM) {
         $configuration['class'] = $row->getCustomClass();
     }
     if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_WEBSERVICE) {
         $configuration['class'] = 'Webservice';
         $configuration['function'] = $row->getCustomFunction();
     }
     if (!empty($configuration)) {
         $configurationHtml = '';
         foreach ($configuration as $key => $value) {
             $configurationHtml .= Mage::helper('xtento_orderexport')->__(ucfirst($key)) . ': <i>' . Mage::helper('xtcore/core')->escapeHtml($value) . '</i><br/>';
         }
         return $configurationHtml;
     } else {
         return '---';
     }
 }
 protected function _checkPost($requireAccessToken = true)
 {
     if (Mage::helper('storealerts')->isDebug() || Mage::app()->getStore()->isCurrentlySecure()) {
         if ($data = $this->getRequest()->getPost()) {
             $dataObj = new Varien_Object();
             $dataObj->setData($data);
             $deviceToken = $dataObj->getDeviceToken();
             $name = $dataObj->getName();
             $username = $dataObj->getUsername();
             $password = $dataObj->getPassword();
             $accessToken = $requireAccessToken ? $dataObj->getAccessToken() : true;
             if ($deviceToken && $username && $password && $accessToken) {
                 $admin = Mage::helper('storealerts')->login($username, $password);
                 if ($admin->getId()) {
                     try {
                         $datetime = date("Y-m-d H:i:s");
                         $preference = Mage::getModel('extensions_store_storealerts/preference');
                         $preference->load($admin->getId());
                         if (!$preference->getId()) {
                             $preference->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
                         }
                         $dataObj->setPreference($preference);
                         $device = Mage::getModel('extensions_store_storealerts/device');
                         $device->load($deviceToken, 'device_token');
                         if (!$device->getId()) {
                             $device->setName($name)->setDeviceToken($deviceToken)->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
                         }
                         $dataObj->setDevice($device);
                         $result['error'] = false;
                         $result['data'] = $dataObj;
                     } catch (Exception $e) {
                         $result['error'] = true;
                         $result['data'] = $e->getMessage();
                     }
                 } else {
                     $result['error'] = true;
                     $result['data'] = 'Could not login admin';
                 }
             } else {
                 $result['error'] = true;
                 $result['data'] = 'No device token, username, password or access token.';
             }
         } else {
             $result['error'] = true;
             $result['data'] = 'No admin login credentials posted.';
         }
     } else {
         $result['error'] = true;
         $result['data'] = 'Request is not over HTTPS.';
     }
     if ($result['error'] === true) {
         $errorMessage = $result['data'];
         Mage::helper('storealerts')->log($errorMessage);
     }
     return $result;
 }
Example #3
0
 public function download(Varien_Object $connectionInfo, $target)
 {
     $file = $connectionInfo->getFile();
     $this->_log($this->_getLog()->__("Connecting to FTP server %s", $connectionInfo->getHost()));
     $ftp = new Varien_Io_Ftp();
     $ftp->open(array('host' => $connectionInfo->getHost(), 'user' => $connectionInfo->getUsername(), 'password' => $connectionInfo->getPassword(), 'timeout' => $connectionInfo->hasTimeout() ? $connectionInfo->getTimeout() : 10, 'passive' => $connectionInfo->hasPassive() ? $connectionInfo->getPassive() : true, 'ssl' => $connectionInfo->hasSsl() ? $connectionInfo->getSsl() : null, 'file_mode' => $connectionInfo->hasFileMode() ? $connectionInfo->getFileMode() : null));
     if (!is_writable(Mage::getBaseDir() . DS . $target)) {
         Mage::throwException($this->_getLog()->__("Can not write file %s to %s, folder not writable (doesn't exist?)", $connectionInfo->getFile(), $target));
     }
     $this->_log($this->_getLog()->__("Downloading file %s from %s, to %s", $connectionInfo->getFile(), $connectionInfo->getHost(), $target));
     $targetPath = $this->_getTargetPath($target, basename($file));
     $ftp->read($file, $targetPath);
     $ftp->close();
 }
Example #4
0
 /**
  * Code partially taken from the old Zopim Live Chat Module
  * A lot has been improved but can still better be improved
  * @todo split into several actions if possible
  */
 public function accountAction()
 {
     $this->loadLayout();
     $chatAccountBlock = $this->getLayout()->getBlock('zopim_account');
     $key = Mage::getStoreConfig('chat/chatconfig/key');
     $username = Mage::getStoreConfig('chat/chatconfig/username');
     $salt = Mage::getStoreConfig('chat/chatconfig/salt');
     $zopimObject = new Varien_Object(array('key' => $key, 'username' => $username, 'salt' => $salt));
     $error = array();
     $gotologin = 0;
     if ($this->getRequest()->getParam('deactivate') == "yes") {
         $zopimObject->setSalt(null);
         $zopimObject->setKey('zopim');
     } else {
         if ($this->getRequest()->getParam('zopimusername') != "") {
             // logging in
             $zopimusername = $this->getRequest()->getParam('zopimusername');
             $zopimpassword = $this->getRequest()->getParam('zopimpassword');
             $logindata = array("email" => $zopimusername, "password" => $zopimpassword);
             $loginresult = Zend_Json::decode(Mage::helper('chat')->doPostRequest(Diglin_Chat_Helper_Data::ZOPIM_LOGIN_URL, $logindata));
             if (isset($loginresult["error"])) {
                 $error["login"] = $this->__("<b>Could not log in to Zopim. Please check your login details. If problem persists, try connecting without SSL enabled.</b>");
                 $gotologin = 1;
                 $zopimObject->setSalt(null);
             } elseif (isset($loginresult["salt"])) {
                 $zopimObject->setUsername($zopimusername);
                 $zopimObject->setSalt($loginresult["salt"]);
                 $account = Zend_Json::decode(Mage::helper('chat')->doPostRequest(Diglin_Chat_Helper_Data::ZOPIM_GETACCOUNTDETAILS_URL, array("salt" => $loginresult["salt"])));
                 if (isset($account)) {
                     $zopimObject->setKey($account["account_key"]);
                 }
             } else {
                 $zopimObject->setSalt(null);
                 $error["login"] = $this->__("<b>Could not log in to Zopim. We were unable to contact Zopim servers. Please check with your server administrator to ensure that <a href='http://www.php.net/manual/en/book.curl.php'>PHP Curl</a> is installed and permissions are set correctly.</b>");
             }
         } else {
             if ($this->getRequest()->getParam('zopimfirstname') != "") {
                 $createdata = array("email" => $this->getRequest()->getParam('zopimnewemail'), "first_name" => $this->getRequest()->getParam('zopimfirstname'), "last_name" => $this->getRequest()->getParam('zopimlastname'), "display_name" => $this->getRequest()->getParam('zopimfirstname') . " " . $this->getRequest()->getParam('zopimlastname'), "aref_id" => '477070', "eref" => "", "source" => "magento", "recaptcha_challenge_field" => $this->getRequest()->getParam('recaptcha_challenge_field'), "recaptcha_response_field" => $this->getRequest()->getParam('recaptcha_response_field'));
                 $signupresult = Zend_Json::decode(Mage::helper('chat')->doPostRequest(Diglin_Chat_Helper_Data::ZOPIM_SIGNUP_URL, $createdata));
                 if (isset($signupresult["error"])) {
                     $error["auth"] = $this->__("Error during activation: <b>" . $signupresult["error"] . "</b> Please try again.");
                 } else {
                     if (isset($signupresult["account_key"])) {
                         $message = $this->__("<b>Thank you for signing up. Please check your mail for your password to complete the process. </b>");
                         $gotologin = 1;
                     } else {
                         if (isset($signupresult['url'])) {
                             $message = $this->__('<b>Thank you for signing up. Please click on <button onclick="%s"><span><span>this button</span></span></button> to complete the process.</b>', "window.open('" . $signupresult['url'] . "')");
                             $gotologin = 1;
                         } else {
                             $error["auth"] = $this->__("<b>Could not activate account. The Magento installation was unable to contact Zopim servers. Please check with your server administrator to ensure that <a href='http://www.php.net/manual/en/book.curl.php'>PHP Curl</a> is installed and permissions are set correctly.</b>");
                         }
                     }
                 }
             }
         }
     }
     if ($zopimObject->getKey() != "" && $zopimObject->getKey() != "zopim") {
         if (isset($account)) {
             $accountDetails = $account;
         } else {
             $accountDetails = Zend_Json::decode(Mage::helper('chat')->doPostRequest(Diglin_Chat_Helper_Data::ZOPIM_GETACCOUNTDETAILS_URL, array("salt" => $zopimObject->getSalt())));
         }
         if (!isset($accountDetails) || isset($accountDetails["error"])) {
             $gotologin = 1;
             $error["auth"] = $this->__('Account no longer linked! We could not verify your Zopim account. Please check your password and try again.');
         } else {
             $chatAccountBlock->setIsAuthenticated(true);
         }
     }
     if (isset($error["auth"])) {
         $this->_getSession()->addError($error["auth"]);
     } else {
         if (isset($error["login"])) {
             $this->_getSession()->addError($error["login"]);
         } else {
             if (isset($message)) {
                 $this->_getSession()->addSuccess($message);
             }
         }
     }
     if ($chatAccountBlock->getIsAuthenticated()) {
         if ($accountDetails["package_id"] == "trial") {
             $accountDetails["package_id"] = "Free Lite Package + 14 Days Full-features";
         } else {
             $accountDetails["package_id"] .= " Package";
         }
     } else {
         if ($this->getRequest()->getParam('zopimfirstname')) {
             $chatAccountBlock->setWasChecked('checked');
         }
         if (!$chatAccountBlock->getIsAuthenticated() && $gotologin != 1) {
             $chatAccountBlock->setShowSignup('showSignup(1);');
         } else {
             $chatAccountBlock->setShowSignup('showSignup(0);');
         }
     }
     $chatAccountBlock->setUsername($zopimObject->getUsername());
     if (isset($accountDetails)) {
         $chatAccountBlock->setAccountDetails($accountDetails["package_id"]);
     }
     // Save values into configuration
     $config = Mage::getConfig();
     if ($zopimObject->getKey() && $zopimObject->getKey() != 'zopim') {
         $config->saveConfig('chat/chatconfig/enabled', 1, 'default', 0);
     }
     if ($zopimObject->getKey() == 'zopim') {
         $zopimObject->setKey(null);
         $config->saveConfig('chat/chatconfig/enabled', 0, 'default', 0);
     }
     $config->saveConfig('chat/chatconfig/key', $zopimObject->getKey(), 'default', 0);
     $config->saveConfig('chat/chatconfig/username', $zopimObject->getUsername(), 'default', 0);
     $config->saveConfig('chat/chatconfig/salt', $zopimObject->getSalt(), 'default', 0);
     Mage::app()->cleanCache(array(Mage_Core_Model_Config::CACHE_TAG));
     $this->_initLayoutMessages('adminhtml/session');
     $this->renderLayout();
 }
Example #5
0
 /**
  * Get current user name
  * 
  * @return string
  */
 public function getCurrentUser()
 {
     $user = new Varien_Object(array('username' => ''));
     if ($adminUser = Mage::getModel('admin/session')->getUser()) {
         $user->setUsername($adminUser->getUsername());
     }
     Mage::dispatchEvent('inp_get_current_username', array('user' => $user));
     return $user->getUsername();
 }