Esempio n. 1
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');
 }
 /**
  * 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();
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
Esempio n. 5
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']);
 }
Esempio n. 6
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;
    }