/** * 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) { \CommerceTeam\Commerce\Utility\FolderUtility::initFolders(); $this->id = current(array_unique(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 = \CommerceTeam\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) { \CommerceTeam\Commerce\Utility\FolderUtility::initFolders(); $this->id = current(array_unique(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 = \CommerceTeam\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(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(); }
/** * Initializes the folders for tx_commerce. * * @return void */ public static function initFolders() { /* * Folder Creation * * @todo Get list from Order folders from TS */ list($modPid) = FolderRepository::initFolders('Commerce', 'commerce'); list($prodPid) = FolderRepository::initFolders('Products', 'commerce', $modPid); FolderRepository::initFolders('Attributes', 'commerce', $modPid); list($orderPid) = FolderRepository::initFolders('Orders', 'commerce', $modPid); FolderRepository::initFolders('Incoming', 'commerce', $orderPid); FolderRepository::initFolders('Working', 'commerce', $orderPid); FolderRepository::initFolders('Waiting', 'commerce', $orderPid); FolderRepository::initFolders('Delivered', 'commerce', $orderPid); // 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']; 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(); } $sysProducts = SettingsFactory::getInstance()->getConfiguration('SYSPRODUCTS'); if (is_array($sysProducts)) { foreach ($sysProducts as $type => $_) { self::makeSystemCatsProductsArtcilesAndPrices($catUid, strtoupper($type), $addArray); } } }
/** * 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'); $this->MCONF = $GLOBALS['MCONF']; parent::init(); $this->statistics = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Utility\\StatisticsUtility'); $this->statistics->init((int) SettingsFactory::getInstance()->getExtConf('excludeStatisticFolders')); $this->orderPageId = current(array_unique(\CommerceTeam\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) GeneralUtility::_GP('id'); if (!$this->id) { $this->id = $this->orderPageId; } $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $this->getBackPath(); $this->doc->docType = 'xhtml_trans'; $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html'); $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 . '; } '); }
/** * Returns the UID of the Product Folder. * * @return int UID */ public static function getProductFolderUid() { list($modPid) = FolderRepository::initFolders('Commerce', 'commerce'); list($prodPid) = FolderRepository::initFolders('Products', 'commerce', $modPid); return $prodPid; }
/** * Get available language uids of product folder. * * @return array */ protected function getLocale() { list($commercePid) = FolderRepository::initFolders('Commerce', 'commerce'); list($productPid) = 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; }
/** * Preprocess article. * * @param array $incomingFieldArray Incoming field array * @param int $id Id * * @return array */ protected function preProcessArticle(array $incomingFieldArray, $id) { $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) = FolderRepository::initFolders('Commerce', 'commerce'); list($productPid) = 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); $this->getDatabaseConnection()->exec_INSERTquery('tx_commerce_article_prices', $insertArr); // @todo update articles XML $myScaleAmountStart += $pricesSteps; $myScaleAmountEnd += $pricesSteps; } } return $incomingFieldArray; }
/** * Handle adress data. * * @param string $type Session type * * @return int uid of user */ public function handleAddress($type) { if (!is_array($this->sessionData[$type])) { return 0; } $database = $this->getDatabaseConnection(); $hooks = HookFactory::getHooks('Controller/CheckoutController', 'handleAddress'); $config = $this->conf[$type . '.']; // Check if a uid is set, so address handling can be used. // Only possible if user is logged in if ($this->sessionData[$type]['uid'] && $this->getFrontendController()->loginUser) { $uid = $this->sessionData[$type]['uid']; } else { // Create $dataArray = array('tstamp' => time(), 'tx_commerce_is_main_address' => 1); // Address folder if (isset($this->conf['addressPid'])) { $dataArray['pid'] = $this->conf['addressPid']; } else { $modPid = 0; list($commercePid) = FolderRepository::initFolders($this->extKey, $this->extKey, $modPid); $dataArray['pid'] = $commercePid; } // Address fields $fieldList = $this->parseFieldList($config['sourceFields.']); if (is_array($fieldList)) { foreach ($fieldList as $fieldName) { $dataArray[$fieldName] = $this->sessionData[$type][$fieldName]; } } if (isset($this->getFrontendUser()->user['uid'])) { $dataArray[$config['userConnection']] = $this->getFrontendUser()->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('pid' => $this->conf['userPID'], 'tstamp' => $GLOBALS['EXEC_TIME'], 'usergroup' => $this->conf['userGroup'], 'email' => $this->sessionData['billing']['email'], 'name' => $this->sessionData['billing']['name'] . ' ' . $this->sessionData['billing']['surname'], 'first_name' => $this->sessionData['billing']['name'], 'last_name' => $this->sessionData['billing']['surname']); // Username 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); foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'preProcessUserData')) { $hookObj->preProcessUserData($feuData, $this); } } $database->exec_INSERTquery('fe_users', $feuData); $dataArray[$config['userConnection']] = $database->sql_insert_id(); $this->getFrontendUser()->user['uid'] = $dataArray[$config['userConnection']]; foreach ($hooks 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]); } } foreach ($hooks 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; }
/** * Initiation of the class. * * @return void * @todo Check with User Permissions */ 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 \CommerceTeam\Commerce\Utility\FolderUtility::initFolders(); // Create page tree object: $this->pagetree = GeneralUtility::makeInstance('CommerceTeam\\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(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce')); $this->initializeTemporaryDatabaseMount(); // Setting highlight mode: $this->doHighlight = !$backendUser->getTSConfigVal('options.pageTree.disableTitleHighlight'); }
/** * Initialization. * * @return void */ public function init() { parent::init(); $language = $this->getLanguageService(); $language->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_systemdata.xml'); $this->id = $this->modPid = (int) reset(FolderRepository::initFolders('Commerce', 'commerce')); $this->attributePid = (int) reset(FolderRepository::initFolders('Attributes', 'commerce', $this->modPid)); $this->MCONF = $GLOBALS['MCONF']; $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 = $this->getBackPath(); $this->doc->docType = 'xhtml_trans'; $this->doc->setModuleTemplate(PATH_TXCOMMERCE . 'Resources/Private/Backend/mod_index.html'); }
/** * 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); } } $tableControl = SettingsFactory::getInstance()->getTcaValue($table . '.ctrl'); // Set ORDER BY: $orderBy = $tableControl['sortby'] ? 'ORDER BY ' . $table . '.' . $tableControl['sortby'] : $tableControl['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 { \CommerceTeam\Commerce\Utility\FolderUtility::initFolders(); // Find the right pid for the Ordersfolder $orderPid = current(array_unique(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Orders', 'Commerce', 0, 'Commerce'))); $orderFolders = \CommerceTeam\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); // specialhandling of search for joins if ($search) { $searchParts = GeneralUtility::trimExplode('OR', $search); foreach ($searchParts as &$part) { $part = str_replace('LOWER(', 'LOWER(' . $table . '.', $part); $part = str_replace('LOWER(' . $table . '.\'', 'LOWER(\'', $part); } $search = implode(' OR ', $searchParts); } $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.commerce_orders'); $deliveryProductUid = $moduleConfig['properties']['deliveryProductUid'] ? $moduleConfig['properties']['deliveryProductUid'] : 0; if ($deliveryProductUid > 0) { $deliveryArticles = \CommerceTeam\Commerce\Utility\BackendUtility::getArticlesOfProductAsUidList($deliveryProductUid); if (!empty($deliveryArticles)) { $queryParts['WHERE'] .= ' AND delivery_table.article_uid IN (' . implode(',', $deliveryArticles) . ') '; } } $paymentProductUid = $moduleConfig['properties']['paymentProductUid'] ? $moduleConfig['properties']['paymentProductUid'] : 0; if ($paymentProductUid > 0) { $paymentArticles = \CommerceTeam\Commerce\Utility\BackendUtility::getArticlesOfProductAsUidList($paymentProductUid); if (!empty($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; }
/** * Initialization. * * @return void */ public function init() { $this->getLanguageService()->includeLLFile('EXT:commerce/Resources/Private/Language/locallang_mod_systemdata.xml'); $this->id = reset(\CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Commerce', 'commerce')); }
/** * 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 */ \CommerceTeam\Commerce\Utility\FolderUtility::initFolders(); /* * Create a new data item array */ $data['items'] = array(); // Find the right pid for the Ordersfolder list($orderPid) = array_unique(\CommerceTeam\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)) { /** * Page repository. * * @var \CommerceTeam\Commerce\Domain\Repository\PageRepository $pageRepository */ $pageRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\PageRepository'); $page = $pageRepository->findByUid($localOrderPid); if (!empty($page)) { $orderPid = $page['pid']; } } $data['items'] = \CommerceTeam\Commerce\Utility\BackendUtility::getOrderFolderSelector($orderPid, SettingsFactory::getInstance()->getExtConf('OrderFolderRecursiveLevel')); }
/** * 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 */ FolderUtility::initFolders(); $modPid = current(FolderRepository::initFolders('Commerce', 'commerce')); FolderRepository::initFolders('Products', 'commerce', $modPid); $attrPid = current(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; }
/** * Sets the default user rights, based on the * User-Rights in the commerce-products folder. * * @return int */ public function createDefaultRights() { $database = $this->getDatabaseConnection(); $countRecords = 1; /* * Get data from folder */ list($modPid) = \CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Commerce', 'commerce', 0, '', false); list($prodPid) = \CommerceTeam\Commerce\Domain\Repository\FolderRepository::initFolders('Products', 'commerce', $modPid, '', false); $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; }