public function _prepareLayout()
 {
     $settings = new Qualityunit_Liveagent_Helper_Settings();
     parent::_prepareLayout();
     $this->assignVariable('dialogCaption', Mage::helper('adminhtml')->__('LiveAgent - Live chat and helpdesk plugin for Magento'));
     $this->assignVariable('submitCaption', Mage::helper('adminhtml')->__('Save'));
     $this->assignVariable('formKey', Mage::getSingleton('core/session')->getFormKey());
     $this->assignVariable('saveUrlAction', $this->getUrl('*/*/post'));
     $settings = new Qualityunit_Liveagent_Helper_Settings();
     $code = htmlentities($settings->getOption(Qualityunit_Liveagent_Helper_Settings::BUTTON_CODE));
     $this->assignVariable('la-config-button-code', $this->getTextArea('la-config-button-code', $code, 10, 100, ' textarea'));
     $this->assignVariable('buttonCodeLabel', Mage::helper('adminhtml')->__('Button code'));
     $this->assignVariable('buttonCodeHelp', Mage::helper('adminhtml')->__('Place here the code from your LiveAgent admin panel'));
     $this->assignVariable('saveButtonCodeFlag', self::SAVE_BUTTON_CODE_ACTION_FLAG);
     $this->assignVariable('accountSectionLabel', Mage::helper('adminhtml')->__('Your account'));
     $this->assignVariable('accountUrlLabel', Mage::helper('adminhtml')->__('Account url'));
     $this->assignVariable('la-url', $settings->getOption(Qualityunit_Liveagent_Helper_Settings::LA_URL_SETTING_NAME));
     $this->assignVariable('loginLabel', Mage::helper('adminhtml')->__('login'));
     $this->assignVariable('loginUrl', $this->getLoginUrl($settings));
     $this->assignVariable('ChangeLabel', Mage::helper('adminhtml')->__('change'));
     $this->assignVariable('ChangeUrl', $this->getUrl('*/*/index', array('key' => $this->getRequest()->get('key'), 'action' => Qualityunit_Liveagent_Block_Account::CHANGE_ACCOUNT_ACTION_FLAG)));
     $this->assignVariable('integrationSectionLabel', Mage::helper('adminhtml')->__('Integration'));
     $this->assignVariable('contactLink', Mage::helper('adminhtml')->__('contact us'));
     $this->assignVariable('contactHelp', Mage::helper('adminhtml')->__('Do you need any help with this plugin? Feel free to'));
 }
 public function getRemoteApiUrl($url = null)
 {
     if ($url == null) {
         return $this->settingsModel->getOption(Qualityunit_Liveagent_Helper_Settings::LA_URL_SETTING_NAME) . '/api/index.php';
     } else {
         return $url . '/api/index.php';
     }
 }
 protected function getInputBox($name, $value)
 {
     $params = $this->getRequest()->getParams();
     if (isset($params[$name])) {
         return parent::getInputBox($name, base64_decode(trim($this->getRequest()->getParam($name))));
     }
     $settings = new Qualityunit_Liveagent_Helper_Settings();
     return parent::getInputBox($name, $settings->getOption($name));
 }
 public static function convertOldButton()
 {
     $settings = new Qualityunit_Liveagent_Helper_Settings();
     $setting = $settings->getOption(Qualityunit_Liveagent_Helper_Settings::BUTTON_CODE);
     if ($setting != '') {
         return;
     }
     $collection = Mage::getModel('liveagent/buttons')->getCollection();
     $buttonId = null;
     foreach ($collection as $button) {
         if ($buttonId === null && $button->getOnlinestatus() == 'Y' && $button->getContenttype() == 'F') {
             $buttonId = $button->getButtonid();
         }
         $button->delete();
     }
     if ($buttonId == null) {
         return;
     }
     $settings->saveButtonCodeForButtonId($buttonId);
 }
 private function checkButtonCodeIsEmpty()
 {
     if ($this->settings->getOption(Qualityunit_Liveagent_Helper_Settings::BUTTON_CODE) == null) {
         Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('adminhtml')->__('The chat button is currently disabled.'));
     }
 }