Beispiel #1
0
 /**
  * Return instance of current CMS connector
  *
  * @return \XLite\Module\CDev\DrupalConnector\Handler
  */
 protected function getHandler()
 {
     if (!isset($this->handler)) {
         $this->handler = \XLite\Module\CDev\DrupalConnector\Handler::getInstance();
         $this->handler->init();
     }
     return $this->handler;
 }
Beispiel #2
0
 /**
  * Clear list
  *
  * @return void
  */
 public function clearTopMessages()
 {
     parent::clearTopMessages();
     if (\XLite\Core\CMSConnector::isCMSStarted()) {
         \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->clearTopMessages();
     }
 }
Beispiel #3
0
 /**
  * Return Viewer object
  *
  * @return \XLite\View\Controller
  */
 public function getViewer()
 {
     $viewer = parent::getViewer();
     if ($this->isAJAXViewer() && \XLite\Core\Request::getInstance()->widgetConfId && \XLite\Module\CDev\DrupalConnector\Handler::isCMSStarted()) {
         $data = \XLite\Module\CDev\DrupalConnector\Drupal\Model::getInstance()->getBlock(\XLite\Core\Request::getInstance()->widgetConfId);
         if ($data && isset($data['options']) && is_array($data['options'])) {
             $viewer->setWidgetParams($data['options']);
         }
     }
     return $viewer;
 }
Beispiel #4
0
 /**
  * Constructor
  * FIXME: is it really needed?
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         // FIXME
         if (defined('LC_CONNECTOR_ROOT')) {
             $path = realpath(LC_CONNECTOR_ROOT . '/../..') . LC_DS;
             $this->filesRepositories[$path] = 'drupal root';
         }
     }
 }
Beispiel #5
0
 /**
  * Get stored profiel id
  *
  * @return integer
  */
 protected function getStoredProfileId()
 {
     $profileId = parent::getStoredProfileId();
     if (!$profileId && \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && !empty($GLOBALS['user']) && !empty($GLOBALS['user']->uid)) {
         $profileId = \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getProfileIdByCMSId($GLOBALS['user']->uid);
         if ($profileId) {
             // Save profile Id in session
             \XLite\Core\Session::getInstance()->profile_id = $profileId;
         }
     }
     return $profileId;
 }
Beispiel #6
0
 /**
  * Compose URL from target, action and additional params
  *
  * @param string $target    Page identifier OPTIONAL
  * @param string $action    Action to perform OPTIONAL
  * @param array  $params    Additional params OPTIONAL
  * @param string $interface Interface script OPTIONAL
  *
  * @return string
  */
 public static function buildURL($target = '', $action = '', array $params = array(), $interface = null, $forceCleanURL = false)
 {
     if ('' === $target) {
         $target = \XLite::TARGET_DEFAULT;
     }
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() || \XLite::CART_SELF == $interface && \XLite\Module\CDev\DrupalConnector\Core\Caller::getInstance()->isInitialized()) {
         $portal = \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getPortalByTarget($target);
         if ($portal) {
             // Drupal URL (portal)
             list($path, $args) = $portal->getDrupalArgs($target, $action, $params);
             $result = static::normalizeDrupalURL($path, $args);
         } else {
             // Drupal URL
             $result = static::buildDrupalURL($target, $action, $params);
         }
     } else {
         // Standalone URL
         $result = parent::buildURL($target, $action, $params, $interface);
     }
     return $result;
 }
Beispiel #7
0
 /**
  * Get URL path for Set-Cookie
  *
  * @param boolean $secure Secure protocol or not OPTIONAL
  *
  * @return string
  */
 protected function getCookiePath($secure = false)
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() ? base_path() : parent::getCookiePath();
 }
Beispiel #8
0
 /**
  * Check - display widget as link or as box
  *
  * @return boolean
  */
 public function isLink()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() ? drupal_is_front_page() : parent::isLink();
 }
Beispiel #9
0
 /**
  * Die if trying to access storefront and DrupalConnector module is enabled
  *
  * @return void
  */
 protected function checkStorefrontAccessability()
 {
     // Run parent method to make some "parent" changes.
     parent::checkStorefrontAccessability();
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS();
 }
Beispiel #10
0
 /**
  * Set CMS name property before profile creation
  *
  * @return void
  */
 protected function prepareCreate()
 {
     parent::prepareCreate();
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         $this->setCmsName(\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getCMSName());
     }
 }
Beispiel #11
0
 /**
  * Do not add additional message when delete profile via Drupal interface
  *
  * @return void
  */
 protected function addDataDeletedTopMessage()
 {
     if (!\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         parent::addDataDeletedTopMessage();
     }
 }
Beispiel #12
0
 /**
  * Initialization
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && static::isPortal()) {
         drupal_set_title(t('Orders'));
     }
 }
Beispiel #13
0
 /**
  * Skip profileId param correction for Drupal storefront 
  * 
  * @param integer $profileId Profile ID
  *  
  * @return integer
  */
 protected function correctProfileIdForURLParams($profileId)
 {
     if (!\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         $profileId = parent::correctProfileIdForURLParams($profileId);
     }
     return $profileId;
 }
Beispiel #14
0
 /**
  * Define query for findAllProfilesArray() method
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function defineAllProfilesArrayQuery()
 {
     $cnd = new \Doctrine\ORM\Query\Expr\Orx();
     $cnd->add('p.cms_name = :cmsName');
     $cnd->add('p.cms_name = \'\'');
     return $this->createQueryBuilder()->select('p.profile_id')->addSelect('p.login')->addSelect('p.cms_profile_id')->addSelect('p.cms_name')->andWhere('p.order is null')->andWhere($cnd)->setParameter('cmsName', \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getCMSName());
 }
Beispiel #15
0
 /**
  * Check if current page is the "Orders" portal
  *
  * @return boolean
  */
 protected static function isPortal()
 {
     return (bool) \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getPortalByPath('user/%/orders/%');
 }
Beispiel #16
0
 /**
  * Display widget as Drupal-specific
  *
  * @return boolean
  */
 protected function isDisplayDrupal()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && function_exists('googleanalytics_help') && $this->getAccount();
 }
Beispiel #17
0
 /**
  * Common method to register resources
  *
  * @param array  $data      Resource description
  * @param string $interface Interface OPTIONAL
  *
  * @return array
  */
 protected function prepareResource(array $data, $interface = null)
 {
     $data = parent::prepareResource($data, $interface);
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         $data['file'] = static::modifyResourcePath($data['file']);
     }
     return $data;
 }
Beispiel #18
0
 /**
  * Normalize request data
  *
  * @param mixed $request Request data
  *
  * @return mixed
  */
 protected function normalizeRequestData($request)
 {
     // Fix double-escaping problems caused by "magic quotes" for a stand-alone mode and admin side
     return \XLite\Module\CDev\DrupalConnector\Handler::isCMSStarted() ? $request : parent::normalizeRequestData($request);
 }
Beispiel #19
0
 /**
  * Display widget as Standalone-specific
  *
  * @return boolean
  */
 protected function isIncludeController()
 {
     return \XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\DrupalConnector\\Handler') && \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && function_exists('googleanalytics_theme');
 }
Beispiel #20
0
 /**
  * Make 'Status' field available when administrator modifies other user's profile
  *
  * @param array &$data Widget params
  *
  * @return void
  */
 protected function prepareFieldParamsStatus(&$data)
 {
     if (\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) {
         $data[\XLite\View\FormField\AFormField::PARAM_IS_ALLOWED_FOR_CUSTOMER] = true;
     }
 }
Beispiel #21
0
 /**
  * Get Terms and Conditions page URL
  *
  * @return string
  */
 public function getTermsURL()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() ? url(\XLite\Core\Config::getInstance()->Company->terms_url) : parent::getTermsURL();
 }
Beispiel #22
0
 /**
  * isCreateProfile
  *
  * @return boolean
  */
 protected function isCreateProfile()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && !empty(\XLite\Core\Request::getInstance()->create_profile);
 }
Beispiel #23
0
 /**
  * Create missed LiteCommerce accounts 
  * 
  * @return void
  */
 protected function createMissedLCAccounts()
 {
     foreach ($this->drupalAccounts as $k => $account) {
         if ($this->checkUserAccountsPerStepCounter()) {
             $profile = new \XLite\Model\Profile();
             $profile->setLogin($account->mail);
             $profile->setCmsProfileId($account->uid);
             $profile->setCmsName(\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->getCMSName());
             $profile->setStatus(1 === intval($account->status) ? 'E' : 'D');
             $pass = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->generatePassword();
             $profile->setPassword(md5($pass));
             $user = user_load($account->uid);
             if (user_access(\XLite\Module\CDev\DrupalConnector\Drupal\Profile::LC_DRUPAL_ADMIN_ROLE_NAME, $user)) {
                 $profile->setAccessLevel(\XLite\Core\Auth::getInstance()->getAdminAccessLevel());
             }
             $profile->create();
             unset($this->drupalAccounts[$k]);
         } else {
             break;
         }
     }
 }
Beispiel #24
0
 /**
  * Chech if widget is exported into Drupal and current form has its method = "GET"
  *
  * @return boolean
  */
 protected function isDrupalGetForm()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && 'get' == strtolower($this->getParam(self::PARAM_FORM_METHOD));
 }
Beispiel #25
0
 /**
  * Get log-off page URL
  *
  * @return string
  */
 public function getLogoffURL()
 {
     return \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() ? url('user/logout') : parent::getLogoffURL();
 }
Beispiel #26
0
 /**
  * Display widget as Standalone-specific
  *
  * @return boolean
  */
 protected function isDisplayStandalone()
 {
     return (!\XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\DrupalConnector\\Handler') || !\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) && \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics && \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_account;
 }