/**
  * Initializing the module
  *
  * @return void
  */
 public function init()
 {
     $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.xml');
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         Tx_Commerce_Utility_FolderUtility::initFolders();
         $this->id = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     // Initialize the listing object, dblist, for rendering the list:
     $this->pointer = max(min(GeneralUtility::_GP('pointer'), 100000), 0);
     $this->imagemode = GeneralUtility::_GP('imagemode');
     $this->table = GeneralUtility::_GP('table');
     $this->search_field = GeneralUtility::_GP('search_field');
     $this->search_levels = GeneralUtility::_GP('search_levels');
     $this->showLimit = (int) GeneralUtility::_GP('showLimit');
     $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
     $this->clear_cache = (bool) GeneralUtility::_GP('clear_cache');
     $this->cmd = GeneralUtility::_GP('cmd');
     $this->cmd_table = GeneralUtility::_GP('cmd_table');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = Tx_Commerce_Utility_BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     $this->clearCache();
     // Set up menus:
     $this->menuConfig();
 }
 /**
  * Initialization of the class
  *
  * @return void
  */
 public function init()
 {
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     if (!$this->id) {
         Tx_Commerce_Utility_FolderUtility::initFolders();
         $this->id = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'Commerce', 0, 'Commerce')));
     }
     $this->edit = GeneralUtility::_GP('edit');
     $this->return_id = GeneralUtility::_GP('return_id');
     $this->lastEdited = GeneralUtility::_GP('lastEdited');
     // Setting GPvars:
     $controlParams = GeneralUtility::_GP('control');
     if ($controlParams) {
         $controlArray = current($controlParams);
         $this->categoryUid = (int) $controlArray['uid'];
     }
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = Tx_Commerce_Utility_BackendUtility::getCategoryPermsClause(1);
     $this->initPage();
     // Set up menus:
     $this->menuConfig();
 }
 /**
  * Initialization
  *
  * @return void
  */
 public function init()
 {
     $this->getLanguageService()->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_orders.xml');
     $this->getLanguageService()->includeLLFile('EXT:lang/locallang_mod_web_list.php');
     // Setting GPvars:
     $this->id = (int) GeneralUtility::_GP('id');
     // Find the right pid for the Ordersfolder
     $this->orderPid = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')));
     if ($this->id == $this->orderPid) {
         $this->id = 0;
     }
     // Initialize the listing object, dblist, for rendering the list:
     $this->pointer = max(min(GeneralUtility::_GP('pointer'), 100000), 0);
     $this->imagemode = GeneralUtility::_GP('imagemode');
     $this->table = GeneralUtility::_GP('table');
     $this->search_field = GeneralUtility::_GP('search_field');
     $this->search_levels = GeneralUtility::_GP('search_levels');
     $this->showLimit = (int) GeneralUtility::_GP('showLimit');
     $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
     $this->clear_cache = (bool) GeneralUtility::_GP('clear_cache');
     $this->cmd = GeneralUtility::_GP('cmd');
     $this->cmd_table = GeneralUtility::_GP('cmd_table');
     // Module name;
     $this->MCONF = $GLOBALS['MCONF'];
     // Page select clause:
     $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
     $this->initPage();
     $this->clearCache();
     // Set up menus:
     $this->menuConfig();
 }
Example #4
0
 /**
  * Sets the default user rights, based on the
  * <User-Rights in the commerce-products folder
  *
  * @return int
  */
 public function createDefaultRights()
 {
     $database = $this->getDatabaseConnection();
     $countRecords = 0;
     /**
      * Get data from folder
      */
     list($modPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce');
     list($prodPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $modPid);
     $resrights = $database->exec_SELECTquery('perms_userid, perms_groupid, perms_user, perms_group, perms_everybody', 'pages', 'uid = ' . $prodPid);
     $data = $database->sql_fetch_assoc($resrights);
     $result = $database->exec_SELECTquery('uid', 'tx_commerce_categories', 'perms_user = 0 OR perms_group = 0 OR perms_everybody = 0');
     while ($row = $database->sql_fetch_assoc($result)) {
         $database->exec_UPDATEquery('tx_commerce_categories', 'uid = ' . $row['uid'], $data);
         $countRecords++;
     }
     return ++$countRecords;
 }
    /**
     * Initialization
     *
     * @return void
     */
    public function init()
    {
        $language = $this->getLanguageService();
        $language->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_statistic.xml');
        $language->includeLLFile('EXT:lang/locallang_mod_web_list.php');
        parent::init();
        $this->extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf'];
        $this->excludePids = $this->extConf['excludeStatisticFolders'] != '' ? $this->extConf['excludeStatisticFolders'] : 0;
        $this->statistics = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Utility_StatisticsUtility');
        $this->statistics->init($this->extConf['excludeStatisticFolders'] != '' ? $this->extConf['excludeStatisticFolders'] : 0);
        $this->orderPageId = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')));
        /**
         * If we get an id via GP use this, else use the default id
         */
        $this->id = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
        if (!$this->id) {
            $this->id = $this->orderPageId;
        }
        $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        $this->doc->docType = 'xhtml_trans';
        $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html');
        if (!$this->doc->moduleTemplate) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('cannot set moduleTemplate', 'commerce', 2, array('backpath' => $this->doc->backPath, 'filename from TBE_STYLES' => $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html'], 'full path' => $this->doc->backPath . $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html']));
            $templateFile = PATH_TXCOMMERCE_REL . 'Resources/Private/Backend/mod_index.html';
            $this->doc->moduleTemplate = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL(PATH_site . $templateFile);
        }
        $this->doc->form = '<form action="" method="POST" name="editform">';
        // JavaScript
        $this->doc->JScode = $this->doc->wrapScriptTags('
			script_ended = 0;
			function jumpToUrl(URL) {
				document.location = URL;
			}
		');
        $this->doc->postCode = $this->doc->wrapScriptTags('
			script_ended = 1;
			if (top.fsMod) {
				top.fsMod.recentIds["web"] = ' . (int) $this->id . ';
			}
		');
    }
Example #6
0
    /**
     * Initializes the folders for tx_commerce
     *
     * @return void
     */
    public static function initFolders()
    {
        /**
         * Folder Creation
         *
         * @todo Get list from Order folders from TS
         */
        list($modPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce');
        list($prodPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $modPid);
        Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Attributes', 'commerce', $modPid);
        list($orderPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'commerce', $modPid);
        Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Incoming', 'commerce', $orderPid);
        Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Working', 'commerce', $orderPid);
        Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Waiting', 'commerce', $orderPid);
        Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Delivered', 'commerce', $orderPid);
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatefolder'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/class.tx_commerce_create_folder.php\'][\'postcreatefolder\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0 as no method was used
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatefolder'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        // Create System Product for payment and other things.
        $now = time();
        $addArray = array('tstamp' => $now, 'crdate' => $now, 'pid' => $prodPid);
        $database = self::getDatabaseConnection();
        // handle payment types
        // create the category if it not exists
        $res = $database->exec_SELECTquery('uid', 'tx_commerce_categories', 'uname = \'SYSTEM\' AND parent_category = \'\' AND deleted=0');
        $catUid = $database->sql_fetch_assoc($res);
        $catUid = $catUid['uid'];
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['precreatesyscategory'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/class.tx_commerce_create_folder.php\'][\'precreatesyscategory\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0 as no method was used
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['precreatesyscategory'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        if (!$res || (int) $catUid == 0) {
            $catArray = $addArray;
            $catArray['title'] = 'SYSTEM';
            $catArray['uname'] = 'SYSTEM';
            $database->exec_INSERTquery('tx_commerce_categories', $catArray);
            $catUid = $database->sql_insert_id();
        }
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatesyscategory'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/class.tx_commerce_create_folder.php\'][\'postcreatesyscategory\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0 as no method was used
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatesyscategory'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['SYSPRODUCTS'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['SYSPRODUCTS'] as $type => $_) {
                self::makeSystemCatsProductsArtcilesAndPrices($catUid, strtoupper($type), $addArray);
            }
        }
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatediliveryarticles'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/class.tx_commerce_create_folder.php\'][\'postcreatediliveryarticles\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0 as no method was used
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_create_folder.php']['postcreatediliveryarticles'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
    }
Example #7
0
 /**
  * Initialiation of the class
  *
  * @todo Check with User Permissions
  * @return void
  */
 public function init()
 {
     $backendUser = $this->getBackendUser();
     // Setting GPvars:
     $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
     $this->cMR = GeneralUtility::_GP('cMR');
     $this->setTemporaryDatabaseMount = GeneralUtility::_GP('setTempDBmount');
     // Generate Folder if necessary
     Tx_Commerce_Utility_FolderUtility::initFolders();
     // Create page tree object:
     $this->pagetree = GeneralUtility::makeInstance('Tx_Commerce_Tree_OrderTree');
     $this->pagetree->ext_IconMode = $backendUser->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
     $this->pagetree->ext_showPageId = $backendUser->getTSConfigVal('options.pageTree.showPageIdWithTitle');
     $this->pagetree->addField('alias');
     $this->pagetree->addField('shortcut');
     $this->pagetree->addField('shortcut_mode');
     $this->pagetree->addField('mount_pid');
     $this->pagetree->addField('mount_pid_ol');
     $this->pagetree->addField('nav_hide');
     $this->pagetree->addField('url');
     // Temporary DB mounts:
     $this->pagetree->MOUNTS = array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce'));
     $this->initializeTemporaryDatabaseMount();
     // Setting highlight mode:
     $this->doHighlight = !$backendUser->getTSConfigVal('options.pageTree.disableTitleHighlight');
 }
Example #8
0
 /**
  * Handle adress data
  *
  * @param string $type Session type
  *
  * @return int uid of user
  */
 public function handleAddress($type)
 {
     $database = $this->getDatabaseConnection();
     if (!is_array($this->sessionData[$type])) {
         return 0;
     }
     $hookObjectsArr = $this->getHookObjectArray('handleAddress');
     $config = $this->conf[$type . '.'];
     $fieldList = $this->parseFieldList($config['sourceFields.']);
     if (is_array($fieldList)) {
         foreach ($fieldList as $fieldName) {
             $dataArray[$fieldName] = $this->sessionData[$type][$fieldName];
         }
     }
     // Check if a uid is set, so address handling can be used.
     // Only possible if user is logged in
     if ($this->sessionData[$type]['uid'] && $GLOBALS['TSFE']->loginUser) {
         $uid = $this->sessionData[$type]['uid'];
     } else {
         // Create
         if (isset($this->conf['addressPid'])) {
             $dataArray['pid'] = $this->conf['addressPid'];
         } else {
             $modPid = 0;
             list($commercePid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders($this->extKey, $this->extKey, $modPid);
             $dataArray['pid'] = $commercePid;
         }
         if (isset($GLOBALS['TSFE']->fe_user->user['uid'])) {
             $dataArray[$config['userConnection']] = $GLOBALS['TSFE']->fe_user->user['uid'];
         } else {
             // Create new user if no user is logged in and the option is set
             if ($this->conf['createNewUsers']) {
                 // Added some changes for
                 // 1) using email as username by default
                 // 2) fill in new fields in table
                 // 3) provide data for usermail
                 // 4) use billing as default type
                 $feuData = array();
                 $feuData['pid'] = $this->conf['userPID'];
                 $feuData['usergroup'] = $this->conf['userGroup'];
                 $feuData['tstamp'] = time();
                 if ($this->conf['randomUser']) {
                     $feuData['username'] = substr($this->sessionData['billing']['name'], 0, 2) . substr($this->sessionData['billing']['surname'], 0, 4) . substr(uniqid(rand()), 0, 4);
                 } else {
                     $feuData['username'] = $this->sessionData['billing']['email'];
                 }
                 // uses either the typed in password (if configured) or a random password
                 // default is random
                 if (isset($config['dontUseRandomPassword']) && $config['dontUseRandomPassword'] && isset($this->sessionData['billing']['password'])) {
                     $password = $this->sessionData['billing']['password'];
                 } else {
                     $password = substr(uniqid(rand()), 0, 6);
                 }
                 $feuData['password'] = $this->getHashedSaltedPassword($password);
                 $feuData['email'] = $this->sessionData['billing']['email'];
                 $feuData['name'] = $this->sessionData['billing']['name'] . ' ' . $this->sessionData['billing']['surname'];
                 $feuData['first_name'] = $this->sessionData['billing']['name'];
                 $feuData['last_name'] = $this->sessionData['billing']['surname'];
                 $hookObjectsArr = $this->getHookObjectArray('handleAddress');
                 foreach ($hookObjectsArr as $hookObj) {
                     if (method_exists($hookObj, 'preProcessUserData')) {
                         $hookObj->preProcessUserData($feuData, $this);
                     }
                 }
                 $database->exec_INSERTquery('fe_users', $feuData);
                 $dataArray[$config['userConnection']] = $database->sql_insert_id();
                 $GLOBALS['TSFE']->fe_user->user['uid'] = $dataArray[$config['userConnection']];
                 foreach ($hookObjectsArr as $hookObj) {
                     if (method_exists($hookObj, 'postProcessUserData')) {
                         $hookObj->postProcessUserData($feuData, $this);
                     }
                 }
                 $this->userData = $feuData;
             }
         }
         $dataArray[$config['sourceLimiter.']['field']] = $config['sourceLimiter.']['value'];
         // unsets the fields that are not present in tt_adress before inserting them
         if (isset($config['tt_adressExcludeFields']) && $config['tt_adressExcludeFields'] != '') {
             $ttAdressExcludeFields = GeneralUtility::trimExplode(',', $config['tt_adressExcludeFields']);
             foreach ($ttAdressExcludeFields as $excludeField) {
                 unset($dataArray[$excludeField]);
             }
         }
         // First address should be main address by default
         $dataArray['tx_commerce_is_main_address'] = 1;
         foreach ($hookObjectsArr as $hookObj) {
             if (method_exists($hookObj, 'preProcessAddressData')) {
                 $dataArray = $hookObj->preProcessAddressData($dataArray, $this);
             }
         }
         $database->exec_INSERTquery('tt_address', $dataArray);
         $uid = $database->sql_insert_id();
     }
     return $uid;
 }
Example #9
0
 /**
  * Preprocess article
  *
  * @param array $incomingFieldArray Incoming field array
  * @param int $id Id
  *
  * @return array
  */
 protected function preProcessArticle(array $incomingFieldArray, $id)
 {
     $database = $this->getDatabaseConnection();
     $this->updateArticleAttributeRelations($incomingFieldArray, $id);
     // create a new price if the checkbox was toggled get pid of article
     $pricesCount = is_numeric($incomingFieldArray['create_new_scale_prices_count']) ? (int) $incomingFieldArray['create_new_scale_prices_count'] : 0;
     $pricesSteps = is_numeric($incomingFieldArray['create_new_scale_prices_steps']) ? (int) $incomingFieldArray['create_new_scale_prices_steps'] : 0;
     $pricesStartamount = is_numeric($incomingFieldArray['create_new_scale_prices_startamount']) ? (int) $incomingFieldArray['create_new_scale_prices_startamount'] : 0;
     if ($pricesCount > 0 && $pricesSteps > 0 && $pricesStartamount > 0) {
         // somehow hook is used two times sometime. So switch off new creating.
         $incomingFieldArray['create_new_scale_prices_count'] = 0;
         // get pid
         list($commercePid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce');
         list($productPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $commercePid);
         // set some status vars
         $myScaleAmountStart = $pricesStartamount;
         $myScaleAmountEnd = $pricesStartamount + $pricesSteps - 1;
         // create the different prices
         for ($myScaleCounter = 1; $myScaleCounter <= $pricesCount; $myScaleCounter++) {
             $insertArr = array('pid' => $productPid, 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'uid_article' => $id, 'fe_group' => $incomingFieldArray['create_new_scale_prices_fe_group'], 'price_scale_amount_start' => $myScaleAmountStart, 'price_scale_amount_end' => $myScaleAmountEnd);
             $database->exec_INSERTquery('tx_commerce_article_prices', $insertArr);
             // @todo update articles XML
             $myScaleAmountStart += $pricesSteps;
             $myScaleAmountEnd += $pricesSteps;
         }
     }
     return $incomingFieldArray;
 }
Example #10
0
 /**
  * Get available language uids of product folder
  *
  * @return array
  */
 protected function getLocale()
 {
     list($commercePid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce');
     list($productPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $commercePid);
     $database = $this->getDatabaseConnection();
     $locale = array_keys((array) $database->exec_SELECTgetRows('sys_language_uid', 'pages_language_overlay', 'pid = ' . $productPid, '', '', '', 'sys_language_uid'));
     return $locale;
 }
 /**
  * Initialization
  *
  * @return void
  */
 public function init()
 {
     $this->getLanguageService()->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_systemdata.xml');
     $this->id = reset(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce'));
 }
 /**
  * This method creates a dynaflex field configuration from the submitted
  * database entry. The variable "configData" contains the complete dynaflex
  * configuration of the field and the data that where maybe fetched from
  * the database.
  *
  * We have to fill the fields
  *
  * $config['name']
  * $config['label']
  * $config['config']
  *
  * @param array $aData The data array contains in element "row" the dataset
  * 	of the table we're creating
  * @param array $config The config array is the dynaflex fieldconfiguration.
  * @param bool $fetchFromDatabase If true the attribute data is fetched
  * 	from database
  * @param bool $onlyDisplay If true the field is not an input field but
  * 	is displayed
  *
  * @return array The modified dynaflex configuration
  */
 public function getAttributeEditField(array $aData, array &$config, $fetchFromDatabase = TRUE, $onlyDisplay = FALSE)
 {
     // first of all, fetch data from attribute table
     if ($fetchFromDatabase) {
         $aData = $this->belib->getAttributeData($aData['row']['uid_foreign'], 'uid, title, has_valuelist, multiple, unit, deleted');
     }
     if ($aData['deleted'] == 1) {
         return array();
     }
     /**
      * Try to detect article UID since there is currently no way to get the
      * data from the method and get language_uid from article
      */
     $sysLanguageUid = 0;
     $getPostedit = GeneralUtility::_GPmerged('edit');
     if (is_array($getPostedit['tx_commerce_articles'])) {
         $articleUid = array_keys($getPostedit['tx_commerce_articles']);
         if ($articleUid[0] > 0) {
             $temporaryData = BackendUtility::getRecord('tx_commerce_articles', $articleUid[0], 'sys_language_uid');
             $sysLanguageUid = (int) $temporaryData['sys_language_uid'];
         }
     } elseif (is_array($getPostedit['tx_commerce_products'])) {
         $articleUid = array_keys($getPostedit['tx_commerce_products']);
         if ($articleUid[0] > 0) {
             $temporaryData = BackendUtility::getRecord('tx_commerce_products', $articleUid[0], 'sys_language_uid');
             $sysLanguageUid = (int) $temporaryData['sys_language_uid'];
         }
     }
     // set label and name
     $config['label'] = $aData['title'];
     $config['name'] = 'attribute_' . $aData['uid'];
     // get the value
     if ($onlyDisplay) {
         $config['config']['type'] = 'user';
         $config['config']['userFunc'] = 'tx_commerce_attributeEditor->displayAttributeValue';
         $config['config']['aUid'] = $aData['uid'];
         return $config;
     }
     /**
      * Get PID to select only the Attribute Values in the correct PID
      */
     Tx_Commerce_Utility_FolderUtility::initFolders();
     $modPid = current(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce'));
     Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $modPid);
     $attrPid = current(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Attributes', 'commerce', $modPid));
     if ($aData['has_valuelist'] == 1) {
         $config['config'] = array('type' => 'select', 'foreign_table' => 'tx_commerce_attribute_values', 'foreign_table_where' => 'AND attributes_uid=' . (int) $aData['uid'] . ' and tx_commerce_attribute_values.pid=' . (int) $attrPid . ' ORDER BY value', 'size' => 1, 'minitems' => 0, 'maxitems' => 1, 'items' => array(array('', 0)));
         if ((int) $aData['multiple'] == 1) {
             // create a selectbox for multiple selection
             $config['config']['multiple'] = 1;
             $config['config']['size'] = 5;
             $config['config']['maxitems'] = 100;
             unset($config['config']['items']);
         }
     } else {
         // the field should be a simple input field
         if ($aData['unit'] != '') {
             $config['label'] .= ' (' . $aData['unit'] . ')';
         }
         $config['config'] = array('type' => 'input');
     }
     // Dont display in lokalised version Attributes with valuelist
     if ($aData['has_valuelist'] == 1 && $sysLanguageUid != 0) {
         $config['config']['type'] = '';
         return FALSE;
     }
     return $config;
 }
Example #13
0
 /**
  * Returns the UID of the Product Folder
  *
  * @return int UID
  */
 public static function getProductFolderUid()
 {
     list($modPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce');
     list($prodPid) = Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Products', 'commerce', $modPid);
     return $prodPid;
 }
Example #14
0
 /**
  * Order Status
  * Selects only the order folders from the pages List
  *
  * @param array $data Data
  *
  * @return void
  */
 public function orderStatus(array &$data)
 {
     /**
      * Create folder if not existing
      */
     Tx_Commerce_Utility_FolderUtility::initFolders();
     /**
      * Create a new data item array
      */
     $data['items'] = array();
     // Find the right pid for the Ordersfolder
     list($orderPid) = array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce'));
     /**
      * Get the pages below $order_pid
      */
     /**
      * Check if the Current PID is below $orderPid,
      * id is below orderPid we could use the parent of
      * this record to build up the select Drop Down
      * otherwhise use the default PID
      */
     $localOrderPid = $data['row']['pid'];
     $rootline = BackendUtility::BEgetRootLine($localOrderPid);
     $rootlinePids = array();
     foreach ($rootline as $pages) {
         if (isset($pages['uid'])) {
             $rootlinePids[] = $pages['uid'];
         }
     }
     if (in_array($orderPid, $rootlinePids)) {
         $database = $this->getDatabaseConnection();
         $result = $database->exec_SELECTquery('pid ', 'pages', 'uid = ' . $localOrderPid . BackendUtility::deleteClause('pages'), '', 'sorting');
         if ($database->sql_num_rows($result) > 0) {
             while ($row = $database->sql_fetch_assoc($result)) {
                 $orderPid = $row['pid'];
             }
             $database->sql_free_result($result);
         }
     }
     $data['items'] = Tx_Commerce_Utility_BackendUtility::getOrderFolderSelector($orderPid, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']['OrderFolderRecursiveLevel']);
 }
 /**
  * Initialization
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     $language = $this->getLanguageService();
     $language->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_systemdata.xml');
     $this->database = $this->getDatabaseConnection();
     $this->language = $this->getLanguageService();
     $this->user = $this->getBackendUser();
     $this->id = $this->modPid = (int) reset(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Commerce', 'commerce'));
     $this->attributePid = (int) reset(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Attributes', 'commerce', $this->modPid));
     $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
     $this->pageRow = BackendUtility::readPageAccess($this->id, $this->perms_clause);
     $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $this->doc->backPath = $GLOBALS['BACK_PATH'];
     $this->doc->docType = 'xhtml_trans';
     $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html');
     if (!$this->doc->moduleTemplate) {
         GeneralUtility::devLog('cannot set moduleTemplate', 'commerce', 2, array('backpath' => $this->doc->backPath, 'filename from TBE_STYLES' => $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html'], 'full path' => $this->doc->backPath . $GLOBALS['TBE_STYLES']['htmlTemplates']['mod_index.html']));
         $templateFile = PATH_TXCOMMERCE_REL . 'Resources/Private/Backend/mod_index.html';
         $this->doc->moduleTemplate = GeneralUtility::getURL(PATH_site . $templateFile);
     }
 }
Example #16
0
    /**
     * Make query array
     *
     * @param string $table Table
     * @param int $id Id
     * @param string $addWhere Additional where
     * @param string $fieldList Field list
     *
     * @return array
     */
    public function makeQueryArray($table, $id, $addWhere = '', $fieldList = '*')
    {
        $database = $this->getDatabaseConnection();
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) {
                $hookObjectsArr[] = GeneralUtility::getUserObj($classRef);
            }
        }
        // Set ORDER BY:
        $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? 'ORDER BY ' . $table . '.' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
        if ($this->sortField) {
            if (in_array($this->sortField, $this->makeFieldList($table, 1))) {
                $orderBy = 'ORDER BY ' . $table . '.' . $this->sortField;
                if ($this->sortRev) {
                    $orderBy .= ' DESC';
                }
            }
        }
        // Set LIMIT:
        $limit = '';
        if ($this->iLimit) {
            $limit = ($this->firstElementNumber ? $this->firstElementNumber . ',' : '') . ($this->iLimit + 1);
        }
        // Filtering on displayable pages (permissions):
        $pC = $table == 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : '';
        if ($id > 0) {
            $pidWhere = ' AND tx_commerce_orders.pid=' . $id;
        } else {
            Tx_Commerce_Utility_FolderUtility::initFolders();
            // Find the right pid for the Ordersfolder
            $orderPid = current(array_unique(Tx_Commerce_Domain_Repository_FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')));
            $orderFolders = Tx_Commerce_Utility_BackendUtility::getOrderFolderSelector($orderPid, PHP_INT_MAX);
            $list = array();
            foreach ($orderFolders as $orderFolder) {
                $list[] = $orderFolder[1];
            }
            $pidWhere = ' AND tx_commerce_orders.pid in (' . implode(',', $list) . ')';
        }
        // Adding search constraints:
        $search = $this->makeSearchString($table);
        $queryParts = array('SELECT' => 'DISTINCT tx_commerce_order_articles.order_id, delivery_table.order_id AS order_number,
				tx_commerce_order_articles.article_type_uid, tx_commerce_order_articles.title AS payment,
				delivery_table.title AS delivery, tx_commerce_orders.uid, tx_commerce_orders.pid, tx_commerce_orders.crdate,
				tx_commerce_orders.tstamp, tx_commerce_orders.order_id, tx_commerce_orders.sum_price_gross,
				tt_address.tx_commerce_address_type_id, tt_address.company, tt_address.name, tt_address.surname,
				tt_address.address, tt_address.zip, tt_address.city, tt_address.email, tt_address.phone AS phone_1,
				tt_address.mobile AS phone_2, tx_commerce_orders.cu_iso_3_uid, tx_commerce_orders.tstamp,
				tx_commerce_orders.uid AS articles, tx_commerce_orders.comment, tx_commerce_orders.internalcomment,
				tx_commerce_orders.order_type_uid AS order_type_uid_noName, static_currencies.cu_iso_3', 'FROM' => 'tx_commerce_orders, tt_address, tx_commerce_order_articles,
				tx_commerce_order_articles AS delivery_table, static_currencies', 'WHERE' => 'static_currencies.uid = tx_commerce_orders.cu_iso_3_uid
				AND delivery_table.order_id = tx_commerce_orders.order_id
				AND tx_commerce_order_articles.order_id = tx_commerce_orders.order_id
				AND tx_commerce_order_articles.article_type_uid = ' . PAYMENTARTICLETYPE . '
				AND delivery_table.article_type_uid = ' . DELIVERYARTICLETYPE . '
				AND tx_commerce_orders.deleted = 0
				AND tx_commerce_orders.cust_deliveryaddress = tt_address.uid' . ' ' . $pC . ' ' . $addWhere . $pidWhere . ' ' . $search, 'GROUPBY' => '', 'ORDERBY' => $database->stripOrderBy($orderBy), 'LIMIT' => $limit);
        // get Module TSConfig
        $moduleConfig = BackendUtility::getModTSconfig($id, 'mod.txcommerceM1_orders');
        if ($moduleConfig['properties']['delProdUid']) {
            GeneralUtility::deprecationLog('mod.txcommerceM1_orders.delProdUid is deprecated since commerce 1.0.0, this setting will be removed in commerce
				 1.4.0, please use mod.txcommerceM1_orders.deliveryProductUid instead');
        }
        if ($moduleConfig['properties']['payProdUid']) {
            GeneralUtility::deprecationLog('mod.txcommerceM1_orders.payProdUid is deprecated since commerce 1.0.0, this setting will be removed in commerce
				 1.4.0, please use mod.txcommerceM1_orders.paymentProductUid instead');
        }
        $deliveryProductUid = $moduleConfig['properties']['deliveryProductUid'] ? $moduleConfig['properties']['deliveryProductUid'] : 0;
        $deliveryProductUid = $moduleConfig['properties']['delProdUid'] ? $moduleConfig['properties']['delProdUid'] : $deliveryProductUid;
        if ($deliveryProductUid > 0) {
            $deliveryArticles = Tx_Commerce_Utility_BackendUtility::getArticlesOfProductAsUidList($deliveryProductUid);
            if (count($deliveryArticles)) {
                $queryParts['WHERE'] .= ' AND delivery_table.article_uid IN (' . implode(',', $deliveryArticles) . ') ';
            }
        }
        $paymentProductUid = $moduleConfig['properties']['paymentProductUid'] ? $moduleConfig['properties']['paymentProductUid'] : 0;
        $paymentProductUid = $moduleConfig['properties']['payProdUid'] ? $moduleConfig['properties']['payProdUid'] : $paymentProductUid;
        if ($paymentProductUid > 0) {
            $paymentArticles = Tx_Commerce_Utility_BackendUtility::getArticlesOfProductAsUidList($paymentProductUid);
            if (count($paymentArticles)) {
                $queryParts['WHERE'] .= ' AND delivery_table.article_uid IN (' . implode(',', $paymentArticles) . ') ';
            }
        }
        // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'makeQueryArray_post')) {
                $parameter = array('orderBy' => $orderBy, 'limit' => $limit, 'pC' => $pC, 'search' => $search);
                $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $parameter);
            }
        }
        return $queryParts;
    }