Example #1
0
 public function checkIfCaptchaEnabled()
 {
     if ($this->_enabled === null) {
         $this->_enabled = $this->checkIfFormAdditionalInfoAllowed() && Aitoc_Aitsys_Abstract_Service::get()->isModuleActive('Mage_Captcha');
     }
     return $this->_enabled;
 }
Example #2
0
 protected function _saveCustomerRequiredData()
 {
     if (!$this->_getOnepage()->getCustomerSession()->getCustomerId()) {
         return;
     }
     $data = $requiredData = $this->getRequest()->getPost();
     $customer = $this->_getOnepage()->getCustomerSession()->getCustomer();
     if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.5')) {
         $customerForm = Mage::getModel('customer/form');
         $customerForm->setFormCode('checkout_register')->setIsAjaxRequest(Mage::app()->getRequest()->isAjax());
         $customerForm->setEntity($customer);
         $customerRequest = $customerForm->prepareRequest($data);
         $customerFields = $customerForm->extractData($customerRequest);
     } else {
         $customerFields = array('firstname' => 'firstname', 'lastname' => 'lastname', 'email' => 'email', 'dob' => 'dob', 'taxvat' => 'taxvat', 'gender' => 'gender', 'suffix' => 'suffix', 'prefix' => 'prefix');
     }
     $requiredData = $this->getRequest()->getPost('billing');
     foreach ($requiredData as $fieldId => $value) {
         if (isset($customerFields[$fieldId])) {
             $customer->setData($fieldId, $value);
         }
     }
     $customer->save();
     $this->_getOnepage()->getQuote()->setCustomer($customer);
 }
 public function validateAction()
 {
     $key = Mage::app()->getRequest()->getParam('key');
     if ($key) {
         $value = Aitoc_Aitsys_Abstract_Service::get()->getLicenseHelper()->getValidationValue($key);
         echo $value;
     }
 }
Example #4
0
 public function isMessagesAvailable()
 {
     if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.4.2')) {
         return parent::isMessagesAvailable();
     } else {
         return Mage::helper('giftmessage/message')->isMessagesAvailable('quote', $this->getEntity());
     }
 }
Example #5
0
 /**
  *
  * @return boolean
  */
 public function checkIfEbizmartsSagePaySuiteActive()
 {
     try {
         return Aitoc_Aitsys_Abstract_Service::get()->isModuleActive('Ebizmarts_SagePaySuite');
     } catch (Exception $e) {
         return false;
     }
 }
Example #6
0
 /**
  * @return boolean
  */
 public function checkIfAitocAitcheckoutIsActive()
 {
     try {
         return (bool) Aitoc_Aitsys_Abstract_Service::get()->isModuleActive('Aitoc_Aitcheckout');
     } catch (Exception $e) {
     }
     return false;
 }
Example #7
0
 public function onModelSaveAfter($observer)
 {
     $model = $observer->getObject();
     if ($model instanceof Mage_SalesRule_Model_Rule) {
         if (isset($_POST['rule'])) {
             $oResource = Mage::getSingleton('core/resource');
             $sDisplayTable = $oResource->getTableName('aitoc_salesrule_display');
             $sTitlesTable = $oResource->getTableName('aitoc_salesrule_display_title');
             // delete items
             $oDb = Mage::getSingleton('core/resource')->getConnection('core_write');
             $oDb->delete($sDisplayTable, 'rule_id = ' . $model->getRuleId());
             // delete titles
             $oDb->delete($sTitlesTable, 'rule_id = ' . $model->getRuleId());
             $oReq = Mage::app()->getFrontController()->getRequest();
             $data = $oReq->getPost();
             if ($data) {
                 if (!empty($data['aitloyalty_customer_display_enable'])) {
                     Mage::helper('aitloyalty/legal')->setHasLoyaltyFeatures();
                     $aDBInfo = array('rule_id' => $model->getRuleId(), 'coupone_enable' => $data['aitloyalty_customer_display_coupon']);
                     $oDb->insert($sDisplayTable, $aDBInfo);
                     // insert titles
                     if (!empty($data['aitloyalty_customer_display_titles'])) {
                         foreach ($data['aitloyalty_customer_display_titles'] as $iStoreId => $sValue) {
                             $aDBInfo = array('rule_id' => $model->getRuleId(), 'store_id' => $iStoreId, 'value' => $sValue);
                             $oDb->insert($sTitlesTable, $aDBInfo);
                         }
                     }
                 }
             }
         }
         /* */
         if (Mage::helper('aitloyalty/legal')->getHasLoyaltyFeatures()) {
             $license = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense();
             $rulesInfo = Mage::helper('aitsys/license')->getRulesInfo($license);
             $licensedStores = Mage::getStoreConfig('aitsys/modules/Aitoc_Aitloyalty');
             if (!is_array($licensedStores)) {
                 $licensedStores = explode(',', $licensedStores);
             }
             $websiteIds = $model->getWebsiteIds();
             if (!is_array($websiteIds)) {
                 $websiteIds = explode(',', $websiteIds);
             }
             array_push($licensedStores, '');
             if (!$license->isInstalled()) {
                 Mage::helper('aitloyalty/legal')->setIsNotifyRestrictedFeatures();
             } elseif (null !== $rulesInfo['store']['licensed'] && $rulesInfo['store']['licensed'] < $rulesInfo['store']['total'] && count(array_diff($websiteIds, $licensedStores))) {
                 Mage::helper('aitloyalty/legal')->setIsNotifyRestrictedFeatures();
             }
         }
         if (Mage::helper('aitloyalty/legal')->getIsNotifyRestrictedFeatures()) {
             $session = Mage::getSingleton('core/session');
             $session->addWarning(Mage::helper('aitloyalty')->__('Aitoc Loyalty Program functionality is disabled for some stores in websites you specified'));
         }
         /**/
     }
 }
Example #8
0
 private function licenseMoreOrEqExistsStores()
 {
     $license = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense();
     $rulesInfo = Mage::helper('aitsys/license')->getRulesInfo($license);
     $licensedStores = explode(',', Mage::getStoreConfig('aitsys/modules/Aitoc_Aitloyalty'));
     if (null !== $rulesInfo['store']['licensed'] && $rulesInfo['store']['licensed'] >= $rulesInfo['store']['total']) {
         return true;
     }
     return false;
 }
Example #9
0
 /**
  * Removes some collected files
  * 
  * @return Aitoc_Aitsys_Model_Compiler_Rules
  */
 public function applyExcludeFilesRule()
 {
     foreach (array_keys($this->getCompileConfig()->getNode('exclude_files')->asArray()) as $exclusion) {
         $target = $this->getIncludeDir() . DS . $exclusion . '.php';
         if (@file_exists($target)) {
             Aitoc_Aitsys_Abstract_Service::get()->filesystem()->rmFile($target);
         }
     }
     return $this;
 }
 public function permissionsAction()
 {
     $mode = Mage::app()->getRequest()->getParam('mode');
     try {
         Aitoc_Aitsys_Abstract_Service::get()->filesystem()->permissonsChange($mode);
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('aitsys')->__('Write permissions were changed successfully'));
         // Aitoc_Aitsys_Abstract_Service::get()->getCache()->remove('aitsys_db_config'); // removed from 2.20
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aitsys')->__('There was an error while changing write permissions. Permissions were not changed.'));
     }
     $this->_redirect('*/index');
 }
Example #11
0
 public function isShow()
 {
     $customerSession = Mage::getSingleton('customer/session');
     if (!$customerSession->isLoggedIn()) {
         if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.4.1')) {
             return Mage::getStoreConfigFlag(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG);
         } else {
             return true;
         }
     }
     return false;
 }
 /**
  * Check if rule can be applied for custom actions
  *
  * @return  bool
  */
 protected static function _isUseCustomActions()
 {
     if (null === self::$_isUseCustomActions) {
         self::$_isUseCustomActions = true;
         $iStoreId = Mage::app()->getStore()->getId();
         $iSiteId = Mage::app()->getWebsite()->getId();
         /* */
         $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense()->getPerformer();
         $ruler = $performer->getRuler();
         if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
             self::$_isUseCustomActions = false;
         }
         /* */
     }
     return self::$_isUseCustomActions;
 }
 public function promostatsAction()
 {
     $iStoreId = Mage::app()->getStore()->getId();
     $iSiteId = Mage::app()->getWebsite()->getId();
     /* */
     $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense()->getPerformer();
     $ruler = $performer->getRuler();
     if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
         return $this->_redirect('customer/account/');
     }
     /* */
     $this->loadLayout();
     $this->_initLayoutMessages('customer/session');
     $this->getLayout()->getBlock('head')->setTitle($this->__('My Coupons'));
     $this->renderLayout();
 }
 public function setValidationFilter($websiteId, $customerGroupId, $couponCode = '', $now = null)
 {
     /* */
     $iStoreId = Mage::app()->getStore()->getId();
     $iSiteId = Mage::app()->getWebsite()->getId();
     $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitindividpromo')->getLicense()->getPerformer();
     $ruler = $performer->getRuler();
     if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
         return parent::setValidationFilter($websiteId, $customerGroupId, $couponCode);
     }
     /* */
     if (version_compare(Mage::getVersion(), '1.12.0.0', '>=')) {
         return parent::setValidationFilter($websiteId, $customerGroupId, $couponCode, $now);
     } else {
         return $this->_setValidationFilter14($websiteId, $customerGroupId, $couponCode, $now);
     }
 }
Example #15
0
 protected function _beforeSave()
 {
     $path = $this->getPath();
     $path = explode('/', $path);
     $moduleKey = array_pop($path);
     $tool = Aitoc_Aitsys_Abstract_Service::get();
     $helper = $tool->getHelper();
     $module = $tool->platform()->getModule($moduleKey);
     if (!$module) {
         Mage::throwException($helper->__($helper->getErrorText('seg_config_stores_module_not_found'), (string) $moduleKey));
     }
     $performer = $module->getLicense()->getPerformer();
     if (!$performer) {
         Mage::throwException($helper->__($helper->getErrorText('seg_config_module_license_not_found'), (string) $moduleKey));
     }
     $performer->filterStoreConfigValue($this->getValue());
 }
Example #16
0
 /**
  * 
  * @return Aitoc_Aitsys_Model_Platform
  */
 public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
         try {
             try {
                 self::$_instance->init();
             } catch (Exception $exc) {
                 self::$_instance->block();
                 throw $exc;
             }
         } catch (Aitoc_Aitsys_Model_Aitfilesystem_Exception $exc) {
             $msg = "Error in the file: %s. Probably it does not have write permissions.";
             self::$_instance->addAdminError(Aitoc_Aitsys_Abstract_Service::get()->getHelper()->__($msg, $exc->getMessage()));
         }
     }
     return self::$_instance;
 }
 public function addLink($name, $path, $label, $urlParams = array())
 {
     $isAddLink = true;
     if ('aitloyalty' == $name) {
         $iStoreId = Mage::app()->getStore()->getId();
         $iSiteId = Mage::app()->getWebsite()->getId();
         /* */
         $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense()->getPerformer();
         $ruler = $performer->getRuler();
         if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
             $isAddLink = false;
         }
         /* */
     }
     if ($isAddLink) {
         parent::addLink($name, $path, $label, $urlParams);
     }
     return $this;
 }
 public function setValidationFilter($websiteId, $customerGroupId, $couponCode = '', $now = null)
 {
     /* */
     $iStoreId = Mage::app()->getStore()->getId();
     $iSiteId = Mage::app()->getWebsite()->getId();
     $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitindividpromo')->getLicense()->getPerformer();
     $ruler = $performer->getRuler();
     if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
         return parent::setValidationFilter($websiteId, $customerGroupId, $couponCode);
     }
     /* */
     if (is_null($now)) {
         $now = Mage::getModel('core/date')->date('Y-m-d');
     }
     $this->addBindParam('code', $couponCode);
     $this->getSelect()->where('is_active=1');
     $this->getSelect()->where('find_in_set(?, website_ids)', (int) $websiteId);
     $iCustomerId = Mage::getSingleton('customer/session')->getCustomerId();
     $oResource = Mage::getSingleton('core/resource');
     $sTable = $oResource->getTableName('aitoc_salesrule_assign_cutomer');
     if ($sTable) {
         if (!$iCustomerId) {
             $iCustomerId = 0;
             // fix for create order by admin
             if ($_SESSION and isset($_SESSION['adminhtml_quote']) and isset($_SESSION['adminhtml_quote']['customer_id']) and $_SESSION['adminhtml_quote']['customer_id']) {
                 $iCustomerId = $_SESSION['adminhtml_quote']['customer_id'];
             }
         }
         $this->getSelect()->joinLeft(array('rc' => $sTable), 'main_table.rule_id = rc.entity_id AND rc.customer_id = ' . $iCustomerId);
         $sWhere = '(rc.entity_id IS NOT NULL) OR (find_in_set("' . (int) $customerGroupId . '", customer_group_ids))';
         $this->getSelect()->where($sWhere);
     }
     if (empty($couponCode)) {
         $this->getSelect()->where("code is null or code=''");
     } else {
         $this->getSelect()->where("code is null or code='' or code=:code");
     }
     $this->getSelect()->where('from_date is null or from_date<=?', $now);
     $this->getSelect()->where('to_date is null or to_date>=?', $now);
     $this->getSelect()->order('sort_order');
     return $this;
 }
Example #19
0
    protected function _copy($source, $target, $firstIteration = true)
    {
        parent::_copy($source, $target, $firstIteration);
        if (is_file($target) && file_exists($target)) {
            $platform = Aitoc_Aitsys_Abstract_Service::get()->platform();
            $dirs = $platform->getModuleDirs();
            foreach ($dirs as $dir) {
                if ($item = strstr($source, $dir)) {
                    if ($item != $dir) {
                        file_put_contents($target, '<?php class_exists("Mage_Adminhtml_Controller_Action"); require_once "' . $source . '";?>');
                        return $this;
                    }
                }
            }
            $name = pathinfo($target, PATHINFO_FILENAME);
            $loader = Aitoc_Aitsys_Model_Rewriter_Autoload::instance();
            if ($loader->hasClass($name)) {
                $path = $loader->getRewriteDir();
                $source = <<<SOURCE
<?php
class_exists("Mage_Adminhtml_Controller_Action");
function _{$name}_autoloader( \$class )
{
    foreach (glob('{$path}*') as \$path)
    {
        require_once \$path;
    }
}

if (defined('AITSYS_REWRITED')) return;
spl_autoload_register('_{$name}_autoloader');
_{$name}_autoloader(null);
spl_autoload_unregister('_{$name}_autoloader');
define('AITSYS_REWRITED',true);
SOURCE;
                file_put_contents($target, '');
            }
        }
        return $this;
    }
Example #20
0
 protected function _getModuleKey($alias)
 {
     if ($enable = Mage::app()->getRequest()->getPost('enable')) {
         $keys = array_keys($enable);
         if (is_array($keys) && !empty($keys)) {
             foreach ($keys as $modKey) {
                 if (false !== strpos($modKey, $alias)) {
                     return $modKey;
                 }
             }
         }
     } else {
         $service = Aitoc_Aitsys_Abstract_Service::get();
         foreach ($service->platform()->getModules() as $module) {
             $key = $module->getKey();
             if (false !== strpos($key, $alias)) {
                 return $key;
             }
         }
     }
     return '';
 }
 public function validate(Varien_Object $object)
 {
     if (!$this->getConditions()) {
         return true;
     }
     $bResult = false;
     $bMeetCond = false;
     foreach ($this->getConditions() as $cond) {
         if ($cond instanceof Aitoc_Aitloyalty_Model_Rule_Condition_Customer_Subselect) {
             $iStoreId = Mage::app()->getStore()->getId();
             $iSiteId = Mage::app()->getWebsite()->getId();
             /* */
             $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitloyalty')->getLicense()->getPerformer();
             $ruler = $performer->getRuler();
             if (!($ruler->checkRule('store', $iStoreId, 'store') || $ruler->checkRule('store', $iSiteId, 'website'))) {
                 return false;
             }
             /* */
             $bMeetCond = true;
             if ($this->getValue()) {
                 // If ALL/ANY of these conditions are TRUE
                 $bResult = $cond->validate($object) || false;
             } else {
                 // If ALL/ANY of these conditions are FALSE
                 $bResult = !($cond->validate($object) || false);
             }
         }
     }
     if ($bMeetCond) {
         if ('any' == $this->getAggregator()) {
             return $bResult || parent::validate($object);
         } else {
             return $bResult && parent::validate($object);
         }
     } else {
         return parent::validate($object);
     }
 }
 /**
  * 
  * @param $exc
  * @param string $format model|url 
  * @return unknown_type
  */
 public function getAvalibleScope(Exception $exc = null, $format = 'model')
 {
     $scope = 'stores';
     $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitemails')->getLicense()->getPerformer();
     $ruler = $performer->getRuler();
     $stores = $ruler->getAvailableStores();
     if (!$stores) {
         if ($exc) {
             throw $exc;
         } else {
             $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitemails')->getLicense()->getPerformer();
             $ruler = $performer->getRuler();
             $ruler->throwException();
         }
     }
     $stores = Mage::app()->getGroup(array_shift($stores))->getStores();
     $store = array_shift($stores);
     if ('url' == $format) {
         return array('scope' => $scope, 'scopeid' => $store->getCode());
     }
     $scopeId = $store->getId();
     return array($scope, $scopeId);
 }
Example #23
0
 public function applyAitocModuleActivate($moduleName)
 {
     $localDir = Aitoc_Aitsys_Abstract_Service::get()->filesystem()->getLocalDir();
     $moduleDir = $localDir . str_replace('_', '/', $moduleName);
     $configFile = $moduleDir . DS . 'etc' . DS . 'config.data.xml';
     if (file_exists($configFile)) {
         $config = simplexml_load_file($configFile);
     } else {
         $configFile = $moduleDir . DS . 'etc' . DS . 'config.xml';
         if (file_exists($configFile)) {
             $config = simplexml_load_file($configFile);
         }
     }
     if (!isset($config)) {
         return false;
     }
     //list($curVersion) = (array)$config->modules->$moduleName->version;
     if (isset($config->global) && isset($config->global->resources)) {
         foreach ($config->global->resources->children() as $key => $object) {
             if ($object->setup) {
                 $resourceName = $key;
                 break;
             }
         }
     }
     if (!isset($resourceName)) {
         return false;
     }
     $dbVersion = Mage::getResourceModel('core/resource')->getDBVersion($resourceName);
     $sqlFilesDir = $moduleDir . DS . 'sql' . DS . $resourceName;
     if (!is_dir($sqlFilesDir) || !is_readable($sqlFilesDir)) {
         return false;
     }
     // Read resource files
     $arrAvailableFiles = array();
     $sqlDir = dir($sqlFilesDir);
     while (false !== ($sqlFile = $sqlDir->read())) {
         $matches = array();
         if (preg_match('#^mysql4-activate-(.*)\\.(sql|php)$#i', $sqlFile, $matches)) {
             $arrAvailableFiles[$matches[1]] = $sqlFile;
         }
     }
     if (empty($arrAvailableFiles)) {
         return false;
     }
     foreach ($arrAvailableFiles as $version => $resourceFile) {
         if (version_compare($version, $dbVersion) > 0) {
             break;
         }
         $sqlFile = $sqlFilesDir . DS . $resourceFile;
         $fileType = pathinfo($resourceFile, PATHINFO_EXTENSION);
         // Execute SQL
         if ($this->_conn) {
             if (method_exists($this->_conn, 'disallowDdlCache')) {
                 $this->_conn->disallowDdlCache();
             }
             try {
                 switch ($fileType) {
                     case 'sql':
                         $sql = file_get_contents($sqlFile);
                         if ($sql != '') {
                             $result = $this->run($sql);
                         } else {
                             $result = true;
                         }
                         break;
                     case 'php':
                         $conn = $this->_conn;
                         $result = (include $sqlFile);
                         break;
                     default:
                         $result = false;
                 }
             } catch (Exception $e) {
                 echo "<pre>" . print_r($e, 1) . "</pre>";
                 throw Mage::exception('Mage_Core', Mage::helper('core')->__('Error in file: "%s" - %s', $sqlFile, $e->getMessage()));
             }
             if (method_exists($this->_conn, 'allowDdlCache')) {
                 $this->_conn->allowDdlCache();
             }
         }
     }
     self::$_hadUpdates = true;
     return true;
 }
Example #24
0
 /**
  * @return Aitoc_Aitsys_Abstract_Service
  */
 public function tool()
 {
     return Aitoc_Aitsys_Abstract_Service::get();
 }
 private static function _compareDirective($directive, $case, $etalon, $value, $end = null)
 {
     if ('=' != $directive && !$end && self::_compareDirective('=', $case, $etalon, $value)) {
         return true;
     }
     switch ($directive) {
         default:
         case '=':
             switch ($case) {
                 case '+':
                     Aitoc_Aitsys_Abstract_Service::get()->testMsg($value . '>=' . $etalon);
                     return $value >= $etalon;
                 case '-':
                     Aitoc_Aitsys_Abstract_Service::get()->testMsg($value . '<' . $etalon);
                     return $value < $etalon;
                 default:
                     Aitoc_Aitsys_Abstract_Service::get()->testMsg($value . '==' . $etalon);
                     return $value == $etalon;
             }
             break;
         case '<':
             switch ($case) {
                 case '+':
                     return $value < $etalon;
                 case '-':
                     return $value <= $etalon;
                 default:
                     return $value < $etalon;
             }
             break;
         case '>':
             switch ($case) {
                 case '+':
                     return $value > $etalon;
                 case '-':
                     return $value >= $etalon;
                 default:
                     return $value > $etalon;
             }
             break;
         case '>=':
             switch ($case) {
                 case '+':
                     return $value >= $etalon + 1;
                 case '-':
                     return $value > $etalon;
                 default:
                     return $value >= $etalon;
             }
             break;
         case '<=':
             switch ($case) {
                 case '+':
                     return $value < $etalon;
                 case '-':
                     return $value <= $etalon - 1;
                 default:
                     return $value <= $etalon;
             }
             break;
     }
 }
 public function categoryAction()
 {
     $categoryId = (int) $this->getRequest()->getQuery('cat');
     if (!$categoryId && Mage::helper('adjnav')->isCategoryCleared(true)) {
         $categoryId = (int) $this->getRequest()->getParam('id', false);
     }
     if (!$categoryId) {
         $categoryId = (int) $this->getRequest()->getParam('id', false);
     }
     if (!$categoryId) {
         $categoryId = Mage::getSingleton('catalog/session')->getAdjnavLastCategoryId();
     }
     if (!$categoryId) {
         $this->_forward('noRoute');
         return;
     }
     $category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($categoryId);
     Mage::register('current_category', $category);
     try {
         $this->loadLayout();
     } catch (Varien_Exception $e) {
         if (NULL !== strpos($e->getMessage(), 'addColumnCountLayoutDepend') && version_compare(Mage::getVersion(), '1.3.2', '<')) {
         } else {
             throw $e;
         }
     }
     $update = $this->getLayout()->getUpdate();
     if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.10')) {
         $design = Mage::getSingleton('catalog/design');
         $settings = $design->getDesignSettings($category);
         if ($settings->getCustomDesign()) {
             $design->applyCustomDesign($settings->getCustomDesign());
         }
         if ($layoutUpdates = $settings->getLayoutUpdates()) {
             if (is_array($layoutUpdates)) {
                 foreach ($layoutUpdates as $layoutUpdate) {
                     $update->addUpdate($layoutUpdate);
                 }
             }
         }
         if ($settings->getPageLayout()) {
             $this->getLayout()->helper('page/layout')->applyHandle($settings->getPageLayout());
         }
     } else {
         Mage::getModel('catalog/design')->applyDesign($category, Mage_Catalog_Model_Design::APPLY_FOR_CATEGORY);
         $this->_applyCustomDesignSettings($category, $update);
         if ($category->getPageLayout()) {
             $this->getLayout()->helper('page/layout')->applyTemplate($category->getPageLayout());
         }
     }
     $response = array();
     $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
     $cache = Mage::app()->getCache();
     $cacheKey = 'LayerBreadCrumbs_' . md5(date('Y-m-d') . 'TASLC') . '_' . $categoryId;
     if ($serialData = $cache->load($cacheKey)) {
         $response['breadcrumbs'] = unserialize($serialData);
     } else {
         if ($categoryId) {
             if (isset($_GET['q'])) {
                 $qString = "?q=" . $_GET['q'] . "&order=" . $_GET['order'] . "&no_cache=" . $_GET['no_cache'] . "&p=" . $_GET['p'];
             } else {
                 $qString = "?order=" . $_GET['order'] . "&no_cache=" . $_GET['no_cache'] . "&p=" . $_GET['p'];
             }
             $parentName = '';
             $cat = Mage::getModel('catalog/category')->load($categoryId);
             if ($cat->getLevel() > 2) {
                 $qString = $qString . "&cat=" . $cat->getParentId();
                 $parentCat = Mage::getModel('catalog/category')->load($cat->getParentId());
                 $parentName = $parentCat->getName();
                 $parentUrl = $parentCat->getUrl();
                 $childName = $cat->getName();
                 $childUrl = $qString . "&cat=" . $cat->getId();
             } else {
                 $qString = $qString . "&cat=" . $cat->getId();
                 $childName = $cat->getName();
                 $childUrl = $qString;
             }
             if ($breadcrumbs && $parentName != '') {
                 $breadcrumbs->addCrumb('home', array('label' => 'Home', 'title' => 'Go to Home Page', 'link' => Mage::getBaseUrl()))->addCrumb('parent', array('label' => $parentName, 'title' => $parentName, 'link' => $parentUrl))->addCrumb('child', array('label' => $childName, 'title' => $childName));
             } else {
                 $breadcrumbs->addCrumb('home', array('label' => 'Home', 'title' => 'Go to Home Page', 'link' => Mage::getBaseUrl()))->addCrumb('child', array('label' => $childName, 'title' => $childName));
             }
             $response['breadcrumbs'] = $this->getLayout()->getBlock('breadcrumbs')->toHtml();
         } else {
             $breadcrumbs->addCrumb('home', array('label' => 'Home', 'title' => 'Go to Home Page', 'link' => Mage::getBaseUrl()));
             $response['breadcrumbs'] = $this->getLayout()->getBlock('breadcrumbs')->toHtml();
         }
         $cache->save(serialize($response['breadcrumbs']), $cacheKey, array("CATALOG_BREADCRUMBS"), 86400);
     }
     $response['category_name'] = $category->getName();
     $response['products'] = $this->getLayout()->getBlock('products')->toHtml();
     $response['layer'] = $this->getLayout()->getBlock('layer')->toHtml();
     $response = Zend_Json::encode($response);
     $this->getResponse()->setBody($response);
 }
Example #27
0
 /**
  * 
  * @return Zend_Db_Adapter_Abstract
  */
 protected function _getReadConnection()
 {
     return Aitoc_Aitsys_Abstract_Service::get()->getReadConnection();
 }
 public function updatePostAction()
 {
     if ($this->_expireAjax()) {
         return;
     }
     if ($this->getRequest()->isPost()) {
         try {
             $currentStep = $this->getRequest()->getPost('step');
             $cartData = $this->getRequest()->getParam('cart');
             $oldData = $cartData;
             if (is_array($cartData)) {
                 $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
                 foreach ($cartData as $index => $data) {
                     if (isset($data['qty'])) {
                         $cartData[$index]['qty'] = $filter->filter($data['qty']);
                         $oldData[$index]['qty'] = $this->_getQuote()->getItemById($index)->getQty();
                     }
                 }
                 $cart = $this->_getCart();
                 if (!$cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
                     $this->_getQuote()->setCustomerId(null);
                 }
                 $this->_getQuote()->unsetData('messages');
                 if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.4.2')) {
                     $cartData = $cart->suggestItemsQty($cartData);
                 }
                 $cart->updateItems($cartData);
                 if (Mage::helper('aitcheckout')->isErrorQuoteItemQty()) {
                     //restoring old qty in cart
                     $cart->updateItems($oldData);
                     //don't allow to save quote and it's items, they can't be changed now
                     if (method_exists($this->_getQuote(), 'preventSaving')) {
                         $this->_getQuote()->preventSaving();
                     }
                     $message = Mage::helper('aitcheckout')->getLastErrorMessage();
                     //for lower magento version error message can be duplicated, so we update it with our one
                     if (!$message || version_compare(Mage::getVersion(), '1.6.0.0', '<')) {
                         $message = Mage::helper('aitcheckout')->__('Cannot update the item.');
                     }
                     Mage::throwException($message);
                 }
                 $cart->save();
             }
             if ($this->_expireAjax()) {
                 return;
             }
         } catch (Mage_Core_Exception $e) {
             $this->_getCart()->getCheckoutSession()->addError($e->getMessage());
         } catch (Exception $e) {
             $this->_getCart()->getCheckoutSession()->addException($e, Mage::helper('aitcheckout')->__('Cannot update shopping cart.'));
             Mage::logException($e);
         }
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($this->_extractStepOutput($currentStep)));
     }
 }
Example #29
0
 public function onCoreBlockAbstractToHtmlAfter($observer)
 {
     $block = $observer->getBlock();
     $transport = $observer->getTransport();
     $html = $transport->getHtml();
     if ($block instanceof Mage_Catalog_Block_Product_List) {
         $additionalHtml = '';
         if (Mage::helper('adjnav')->isPageAutoload() && $block->getToolbarBlock()->getLastPageNum() > 1) {
             if ($block->getToolbarBlock()->getCurrentPage() < $block->getToolbarBlock()->getLastPageNum()) {
                 $additionalHtml .= '<div class="adjnav-page-autoload-pholder"></div>';
             }
             $additionalHtml .= '<div class="adjnav-page-autoload-progress" style="display:none">' . '<img src="' . Mage::getDesign()->getSkinUrl('images/opc-ajax-loader.gif') . '" />' . Mage::helper('adjnav')->__('Loading...') . '</div>';
             $columnCount = false;
             $category = Mage::registry('current_category');
             if ($category) {
                 if (Aitoc_Aitsys_Abstract_Service::get()->isMagentoVersion('>=1.4')) {
                     $pageLayout = Mage::helper('adjnav')->getPageLayout($category);
                     $columnCount = $block->getColumnCountLayoutDepend($pageLayout);
                 }
             }
             if (!$columnCount) {
                 $columnCount = $block->getColumnCount('column_count');
             }
             $additionalHtml .= '<input id="adjnav-page-column-count" type="hidden" value="' . $columnCount . '"/>';
             $additionalHtml .= '<input id="adjnav-page-product-limit" type="hidden" value="' . $block->getToolbarBlock()->getLimit() . '"/>';
         }
         $transport->setHtml($html . $additionalHtml);
     }
 }
Example #30
0
 /**
  * Apply module sql file of appropriate type
  *
  * @param string $processType self::TYPE_AITOC_DB_STATE_*
  * @param string $moduleName like [Aitoc|AdjustWare]_[AitModuleName]
  * 
  * @return bool 
  */
 protected function _processStateSql($processType, $moduleName)
 {
     $localDir = Aitoc_Aitsys_Abstract_Service::get()->filesystem()->getLocalDir();
     $moduleDir = $localDir . str_replace('_', '/', $moduleName);
     // Attempt to locate and load module's main config file or its .data version
     $configFile = $moduleDir . DS . 'etc' . DS . 'config.data.xml';
     if (file_exists($configFile)) {
         $config = simplexml_load_file($configFile);
     } else {
         $configFile = $moduleDir . DS . 'etc' . DS . 'config.xml';
         if (file_exists($configFile)) {
             $config = simplexml_load_file($configFile);
         }
     }
     // Module config file not found
     if (!isset($config)) {
         return false;
     }
     if (isset($config->global) && isset($config->global->resources)) {
         foreach ($config->global->resources->children() as $key => $object) {
             if ($object->setup) {
                 $resourceName = $key;
                 break;
             }
         }
     }
     // There's no resource setup entities in the config file
     if (!isset($resourceName)) {
         return false;
     }
     $sqlFilesDir = $moduleDir . DS . 'sql' . DS . $resourceName;
     // Resource setup directory is empty
     if (!is_dir($sqlFilesDir) || !is_readable($sqlFilesDir)) {
         return false;
     }
     // Read resource files
     $arrAvailableFiles = array();
     $sqlDir = dir($sqlFilesDir);
     while (false !== ($sqlFile = $sqlDir->read())) {
         $matches = array();
         if (preg_match('#^mysql4-' . $processType . '-(.*)\\.(sql|php)$#i', $sqlFile, $matches)) {
             $arrAvailableFiles[$matches[1]] = $sqlFile;
         }
     }
     $sqlDir->close();
     // There are no appropriate state sql files in the resource directory
     if (empty($arrAvailableFiles)) {
         return false;
     }
     $dbVersion = Mage::getResourceModel('core/resource')->getDBVersion($resourceName);
     foreach ($arrAvailableFiles as $version => $resourceFile) {
         // Stop processing if state script is for the higher version of the module
         if (version_compare($version, $dbVersion) > 0) {
             break;
         }
         $sqlFile = $sqlFilesDir . DS . $resourceFile;
         $fileType = pathinfo($resourceFile, PATHINFO_EXTENSION);
         // Execute SQL
         if ($this->_conn) {
             if (method_exists($this->_conn, 'disallowDdlCache')) {
                 $this->_conn->disallowDdlCache();
             }
             try {
                 switch ($fileType) {
                     case 'sql':
                         $sql = file_get_contents($sqlFile);
                         if ($sql != '') {
                             $result = $this->run($sql);
                         } else {
                             $result = true;
                         }
                         break;
                     case 'php':
                         $conn = $this->_conn;
                         $result = (include $sqlFile);
                         break;
                     default:
                         $result = false;
                 }
             } catch (Exception $e) {
                 echo "<pre>" . print_r($e, 1) . "</pre>";
                 throw Mage::exception('Mage_Core', Mage::helper('core')->__('Error in file: "%s" - %s', $sqlFile, $e->getMessage()));
             }
             if (method_exists($this->_conn, 'allowDdlCache')) {
                 $this->_conn->allowDdlCache();
             }
         }
     }
     self::$_hadUpdates = true;
     return true;
 }