Пример #1
0
 /**
  * Initializes the Categorytree
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     // Create the category leaf
     /**
      * Category leaf
      *
      * @var Tx_Commerce_Tree_Leaf_Category $categoryLeaf
      */
     $categoryLeaf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_Category');
     // Instantiate the categorydata, -view and set
     // the permission mask (or the string rep.)
     /**
      * Category data
      *
      * @var Tx_Commerce_Tree_Leaf_CategoryData $categorydata
      */
     $categorydata = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_CategoryData');
     $categorydata->setPermsMask(Tx_Commerce_Utility_BackendUtility::getPermMask($this->minCategoryPerms));
     /**
      * Category view
      *
      * @var Tx_Commerce_ViewHelpers_Browselinks_CategoryView $categoryview
      */
     $categoryview = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_ViewHelpers_Browselinks_CategoryView');
     // disable the root onclick if the perms are set to editcontent
     // - this way we cannot select the root as a parent for any content item
     $categoryview->noRootOnclick($this->minCategoryPerms == 'editcontent');
     // Configure the noOnclick for the leaf
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->noClickList, 'Tx_Commerce_Tree_Leaf_Category')) {
         $categoryview->noOnclick();
     }
     $categoryLeaf->initBasic($categoryview, $categorydata);
     $this->addLeaf($categoryLeaf);
     // Add Product - Productleaf will be added to Categoryleaf
     /**
      * Product leaf
      *
      * @var Tx_Commerce_Tree_Leaf_Product $productleaf
      */
     $productleaf = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_Product');
     /**
      * Product view
      *
      * @var Tx_Commerce_ViewHelpers_Browselinks_ProductView $productview
      */
     $productview = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_ViewHelpers_Browselinks_ProductView');
     // Configure the noOnclick for the leaf
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->noClickList, 'Tx_Commerce_Tree_Leaf_Product')) {
         $productview->noOnclick();
     }
     /**
      * Product data
      *
      * @var Tx_Commerce_Tree_Leaf_ProductData $productData
      */
     $productData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ProductData');
     $productleaf->initBasic($productview, $productData);
     $categoryLeaf->addLeaf($productleaf);
 }
Пример #2
0
 /**
  * After versioning for tx_commerce_products, this also
  * 1) copies the Attributes (flex and mm)
  * 2) copies the Articles and keeps their relations
  *
  * @param string $table Tablename on which the swap happens
  * @param int $id Id of the LIVE Version to swap
  * @param int $swapWith Id of the Offline Version to swap with
  * @param int $swapIntoWorkspace If set, swaps online into workspace
  * 	instead of publishing out of workspace.
  *
  * @return void
  */
 public function processSwap_postProcessSwap($table, $id, $swapWith, $swapIntoWorkspace)
 {
     if ('tx_commerce_products' == $table) {
         $copy = !is_null($swapIntoWorkspace);
         // give Attributes from swapWith to id
         Tx_Commerce_Utility_BackendUtility::swapProductAttributes($swapWith, $id, $copy);
         // give Articles from swapWith to id
         Tx_Commerce_Utility_BackendUtility::swapProductArticles($swapWith, $id, $copy);
     }
 }
Пример #3
0
 /**
  * Returns the link from the tree used to jump to a destination
  *
  * @param array $row Array with the ID Information
  *
  * @return string
  */
 public function getJumpToParam(array $row)
 {
     if (!is_array($row)) {
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('getJumpToParam (Tx_Commerce_Tree_Leaf_View) gets passed invalid parameters.', COMMERCE_EXTKEY, 3);
         }
         return '';
     }
     // get the UID of the Products SysFolder
     $productPid = Tx_Commerce_Utility_BackendUtility::getProductFolderUid();
     $res = '&id=' . $productPid . '&control[' . $this->table . '][uid]=' . $row['uid'];
     if ($this->realValues) {
         $res = $this->table . '_' . $row['uid'];
     }
     return $res;
 }
Пример #4
0
 /**
  * Simply returns the value of an attribute of an article.
  *
  * @param array $parameter Parameter
  *
  * @return string
  */
 public function displayAttributeValue(array $parameter)
 {
     $database = $this->getDatabaseConnection();
     // attribute value uid
     $aUid = $parameter['fieldConf']['config']['aUid'];
     $relRes = $database->exec_SELECTquery('uid_valuelist,default_value,value_char', 'tx_commerce_articles_article_attributes_mm', 'uid_local=' . (int) $parameter['row']['uid'] . ' AND uid_foreign=' . (int) $aUid);
     $attributeData = $this->belib->getAttributeData($aUid, 'has_valuelist,multiple,unit');
     $relationData = NULL;
     if ($attributeData['multiple'] == 1) {
         while ($relData = $database->sql_fetch_assoc($relRes)) {
             $relationData[] = $relData;
         }
     } else {
         $relationData = $database->sql_fetch_assoc($relRes);
     }
     return htmlspecialchars(strip_tags($this->belib->getAttributeValue($parameter['row']['uid'], $aUid, 'tx_commerce_articles_article_attributes_mm', $relationData, $attributeData)));
 }
Пример #5
0
 /**
  * Flag product translations as deleted for productList
  *
  * @param array $productList Product list
  *
  * @return void
  */
 protected function deleteProductTranslationsByProductList(array $productList)
 {
     $database = $this->getDatabaseConnection();
     $updateValues = array('tstamp' => $GLOBALS['EXEC_TIME'], 'deleted' => 1);
     $database->exec_UPDATEquery('tx_commerce_products', 'l18n_parent IN (' . implode(',', $productList) . ')', $updateValues);
     $translatedArticles = array();
     foreach ($productList as $productId) {
         $articlesOfProduct = $this->belib->getArticlesOfProductAsUidList($productId);
         if (is_array($articlesOfProduct) && count($articlesOfProduct)) {
             $translatedArticles = array_merge($translatedArticles, $articlesOfProduct);
         }
     }
     $translatedArticles = array_unique($translatedArticles);
     if (count($translatedArticles)) {
         $this->deletePricesByArticleList($translatedArticles);
         $this->deleteArticlesByArticleList($translatedArticles);
     }
 }
Пример #6
0
 /**
  * Saves all relations between products and his attributes
  *
  * @param int $productId The UID of the product
  * @param array $fieldArray Field array
  *
  * @return void
  */
 protected function saveProductRelations($productId, array $fieldArray = NULL)
 {
     $productId = (int) $productId;
     // first step is to save all relations between this product and all attributes
     // of this product.
     // We don't have to check for any parent categories, because the attributes
     // from them should already be saved for this product.
     $database = $this->getDatabaseConnection();
     // create an article and a new price for a new product
     if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']['simpleMode'] && $productId != NULL) {
         // search for an article of this product
         $res = $database->exec_SELECTquery('*', 'tx_commerce_articles', 'uid_product = ' . $productId, '', '', 1);
         $aRes = array();
         if ($database->sql_num_rows($res) == 0) {
             // create a new article if no one exists
             $pRes = $database->exec_SELECTquery('title', 'tx_commerce_products', 'uid = ' . $productId, '', '', 1);
             $productData = $database->sql_fetch_assoc($pRes);
             $database->exec_INSERTquery('tx_commerce_articles', array('pid' => $fieldArray['pid'], 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'uid_product' => $productId, 'article_type_uid' => 1, 'title' => $productData['title']));
             $aUid = $database->sql_insert_id();
         } else {
             $aRes = $database->sql_fetch_assoc($res);
             $aUid = $aRes['uid'];
         }
         // check if the article has already a price
         $res = $database->exec_SELECTquery('*', 'tx_commerce_article_prices', 'uid_article = ' . $aUid, '', '', 1);
         if ($database->sql_num_rows($res) == 0 && $aRes['sys_language_uid'] < 1) {
             // create a new price if no one exists
             $database->exec_INSERTquery('tx_commerce_article_prices', array('pid' => $fieldArray['pid'], 'uid_article' => $aUid, 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME']));
         }
     }
     $delete = TRUE;
     if (isset($fieldArray['categories'])) {
         $catList = array();
         $res = $database->exec_SELECTquery('uid_foreign', 'tx_commerce_products_categories_mm', 'uid_local = ' . $productId);
         while ($sres = $database->sql_fetch_assoc($res)) {
             $catList[] = $sres['uid_foreign'];
         }
         $paList = $this->belib->getAttributesForCategoryList($catList);
         $uidList = $this->belib->extractFieldArray($paList, 'uid_foreign', TRUE, array('uid_correlationtype'));
         $this->belib->saveRelations($productId, $uidList, 'tx_commerce_products_attributes_mm', FALSE, FALSE);
         $this->belib->updateXML('attributes', 'tx_commerce_products', $productId, 'product', $catList);
         $delete = FALSE;
     }
     $articles = FALSE;
     if (isset($fieldArray['attributes'])) {
         // get all correlation types
         $correlationTypeList = $this->belib->getAllCorrelationTypes();
         $paList = array();
         // extract all attributes from FlexForm
         $ffData = GeneralUtility::xml2array($fieldArray['attributes']);
         if (is_array($ffData)) {
             $this->belib->mergeAttributeListFromFFData($ffData['data']['sDEF']['lDEF'], 'ct_', $correlationTypeList, $productId, $paList);
         }
         // get the list of uid_foreign and save relations for this category
         $uidList = $this->belib->extractFieldArray($paList, 'uid_foreign', TRUE, array('uid_correlationtype'));
         // get all ct4 attributes
         $ct4Attributes = array();
         if (is_array($uidList)) {
             foreach ($uidList as $uidItem) {
                 if ($uidItem['uid_correlationtype'] == 4) {
                     $ct4Attributes[] = $uidItem['uid_foreign'];
                 }
             }
         }
         $this->belib->saveRelations($productId, $uidList, 'tx_commerce_products_attributes_mm', $delete, FALSE);
         /**
          * Rebuild the XML (last param set to true)
          * Fixes that l10n of products had invalid XML attributes
          */
         $this->belib->updateXML('attributes', 'tx_commerce_products', $productId, 'product', $correlationTypeList, TRUE);
         // update the XML for this product, we remove everything that is not
         // set for current attributes
         $pXml = $database->exec_SELECTquery('attributesedit', 'tx_commerce_products', 'uid = ' . $productId);
         $pXml = $database->sql_fetch_assoc($pXml);
         if (!empty($pXml['attributesedit'])) {
             $pXml = GeneralUtility::xml2array($pXml['attributesedit']);
             if (is_array($pXml['data']['sDEF']['lDEF'])) {
                 foreach (array_keys($pXml['data']['sDEF']['lDEF']) as $key) {
                     $data = array();
                     $uid = $this->belib->getUIdFromKey($key, $data);
                     if (!in_array($uid, $ct4Attributes)) {
                         unset($pXml['data']['sDEF']['lDEF'][$key]);
                     }
                 }
             }
             if (is_array($pXml) && is_array($pXml['data']) && is_array($pXml['data']['sDEF'])) {
                 $pXml = GeneralUtility::array2xml($pXml, '', 0, 'T3FlexForms');
                 $fieldArray['attributesedit'] = $pXml;
             }
         }
         // now get all articles that where created from this product
         $articles = $this->belib->getArticlesOfProduct($productId);
         // build relation table
         if (is_array($articles) && count($articles)) {
             $uidList = $this->belib->extractFieldArray($paList, 'uid_foreign', TRUE);
             foreach ($articles as $article) {
                 $this->belib->saveRelations($article['uid'], $uidList, 'tx_commerce_articles_article_attributes_mm', TRUE, FALSE);
             }
         }
     }
     $updateArrays = array();
     // update all articles of this product
     if (!empty($fieldArray['attributesedit'])) {
         $ffData = (array) GeneralUtility::xml2array($fieldArray['attributesedit']);
         if (is_array($ffData['data']) && is_array($ffData['data']['sDEF']['lDEF'])) {
             // get articles if they are not already there
             if (!$articles) {
                 $articles = $this->belib->getArticlesOfProduct($productId);
             }
             // update this product
             $articleRelations = array();
             $counter = 0;
             foreach ($ffData['data']['sDEF']['lDEF'] as $ffDataItemKey => $ffDataItem) {
                 $counter++;
                 $attributeKey = $this->belib->getUidFromKey($ffDataItemKey, $keyData);
                 $attributeData = $this->belib->getAttributeData($attributeKey, 'has_valuelist,multiple');
                 // check if the attribute has more than one value, if that is true,
                 // we have to create a relation for each value
                 if ($attributeData['multiple'] == 1) {
                     // if we have a multiple valuelist we need to handle the attributes a little
                     // bit different first we delete all existing attributes
                     $database->exec_DELETEquery('tx_commerce_products_attributes_mm', 'uid_local = ' . $productId . ' AND uid_foreign = ' . $attributeKey);
                     // now explode the data
                     $attributeValues = GeneralUtility::trimExplode(',', $ffDataItem['vDEF'], TRUE);
                     foreach ($attributeValues as $attributeValue) {
                         // The first time an attribute value is selected, TYPO3 returns them
                         // INCLUDING an empty value! This would cause an unnecessary entry in the
                         // database, so we have to filter this here.
                         if (empty($attributeValue)) {
                             continue;
                         }
                         $updateData = $this->belib->getUpdateData($attributeData, $attributeValue, $productId);
                         $database->exec_INSERTquery('tx_commerce_products_attributes_mm', array_merge(array('uid_local' => $productId, 'uid_foreign' => $attributeKey, 'uid_correlationtype' => 4), $updateData[0]));
                     }
                 } else {
                     // update a simple valuelist and normal attributes as usual
                     $updateArrays = $this->belib->getUpdateData($attributeData, $ffDataItem['vDEF'], $productId);
                     $database->exec_UPDATEquery('tx_commerce_products_attributes_mm', 'uid_local = ' . $productId . ' AND uid_foreign = ' . $attributeKey, $updateArrays[0]);
                 }
                 // update articles
                 if (is_array($articles) && count($articles) > 0) {
                     foreach ($articles as $article) {
                         if ($attributeData['multiple'] == 1) {
                             // if we have a multiple valuelist we need to handle the attributes a little
                             // bit different first we delete all existing attributes
                             $database->exec_DELETEquery('tx_commerce_articles_article_attributes_mm', 'uid_local = ' . $article['uid'] . ' AND uid_foreign = ' . $attributeKey);
                             // now explode the data
                             $attributeValues = GeneralUtility::trimExplode(',', $ffDataItem['vDEF'], TRUE);
                             $attributeCount = 0;
                             $attributeValue = '';
                             foreach ($attributeValues as $attributeValue) {
                                 if (empty($attributeValue)) {
                                     continue;
                                 }
                                 $attributeCount++;
                                 $updateData = $this->belib->getUpdateData($attributeData, $attributeValue, $productId);
                                 $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', array_merge(array('uid_local' => $article['uid'], 'uid_foreign' => $attributeKey, 'uid_product' => $productId, 'sorting' => $counter), $updateData[1]));
                             }
                             // create at least an empty relation if no attributes where set
                             if ($attributeCount == 0) {
                                 $updateData = $this->belib->getUpdateData(array(), $attributeValue, $productId);
                                 $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', array_merge(array('uid_local' => $article['uid'], 'uid_foreign' => $attributeKey, 'uid_product' => $productId, 'sorting' => $counter), $updateData[1]));
                             }
                         } else {
                             // if the article has already this attribute, we have to insert so try
                             // to select this attribute for this article
                             $res = $database->exec_SELECTquery('uid_local, uid_foreign', 'tx_commerce_articles_article_attributes_mm', 'uid_local = ' . $article['uid'] . ' AND uid_foreign = ' . $attributeKey);
                             if ($database->sql_num_rows($res) > 0) {
                                 $database->exec_UPDATEquery('tx_commerce_articles_article_attributes_mm', 'uid_local = ' . $article['uid'] . ' AND uid_foreign = ' . $attributeKey, array_merge($updateArrays[1], array('sorting' => $counter)));
                             } else {
                                 $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', array_merge($updateArrays[1], array('uid_local' => $article['uid'], 'uid_product' => $productId, 'uid_foreign' => $attributeKey, 'sorting' => $counter)));
                             }
                         }
                         $relArray = $updateArrays[0];
                         $relArray['uid_foreign'] = $attributeKey;
                         if (!in_array($relArray, $articleRelations)) {
                             $articleRelations[] = $relArray;
                         }
                         $this->belib->updateArticleHash($article['uid']);
                     }
                 }
             }
             // Finally update the Felxform for this Product
             $this->belib->updateArticleXML($articleRelations, FALSE, NULL, $productId);
             // And add those datas from the database to the articles
             if (is_array($articles) && count($articles) > 0) {
                 foreach ($articles as $article) {
                     $thisArticleRelations = $this->belib->getAttributesForArticle($article['uid']);
                     $this->belib->updateArticleXML($thisArticleRelations, FALSE, $article['uid'], NULL);
                 }
             }
         }
     }
     // Check if we do have some localized products an call the method recursivly
     $resLocalised = $database->exec_SELECTquery('uid', 'tx_commerce_products', 'deleted = 0 and l18n_parent = ' . $productId);
     while ($rowLocalised = $database->sql_fetch_assoc($resLocalised)) {
         $this->saveProductRelations($rowLocalised['uid'], $fieldArray);
     }
 }
    /**
     * Main function, starting the rendering of the list.
     *
     * @return void
     */
    public function main()
    {
        $language = $this->getLanguageService();
        $newRecordIcon = '';
        // Link for creating new records:
        if (!$this->modTSconfig['properties']['noCreateRecordsLink']) {
            $controls = array('category' => array('dataClass' => 'Tx_Commerce_Tree_Leaf_CategoryData', 'parent' => 'parent_category'), 'product' => array('dataClass' => 'Tx_Commerce_Tree_Leaf_ProductData', 'parent' => 'categories'));
            $newRecordLink = $this->scriptNewWizard . '?id=' . (int) $this->id;
            foreach ($controls as $controlData) {
                /**
                 * Tree data
                 *
                 * @var Tx_Commerce_Tree_Leaf_Data $treeData
                 */
                $treeData = GeneralUtility::makeInstance($controlData['dataClass']);
                $treeData->init();
                if ($treeData->getTable()) {
                    $newRecordLink .= '&edit[' . $treeData->getTable() . '][-' . $this->categoryUid . ']=new';
                    $newRecordLink .= '&defVals[' . $treeData->getTable() . '][' . $controlData['parent'] . ']=' . $this->categoryUid;
                }
            }
            $newRecordIcon = '
				<!--
					Link for creating a new record:
				-->
				<a href="' . htmlspecialchars($newRecordLink . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . '">' . IconUtility::getSpriteIcon('actions-document-new', array('title' => $language->getLL('editPage', 1))) . '</a>';
        }
        // Access check...
        // The page will show only if there is a valid page
        // and if this page may be viewed by the user
        if ($this->categoryUid) {
            $this->pageinfo = Tx_Commerce_Utility_BackendUtility::readCategoryAccess($this->categoryUid, $this->perms_clause);
        } else {
            $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->getBackendUser()->getPagePermsClause(1));
        }
        $access = is_array($this->pageinfo);
        // Apply predefined values for hidden checkboxes
        // Set predefined value for DisplayBigControlPanel:
        if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') {
            $this->MOD_SETTINGS['bigControlPanel'] = TRUE;
        } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') {
            $this->MOD_SETTINGS['bigControlPanel'] = FALSE;
        }
        // Set predefined value for Clipboard:
        if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') {
            $this->MOD_SETTINGS['clipBoard'] = TRUE;
        } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') {
            $this->MOD_SETTINGS['clipBoard'] = FALSE;
        }
        // Set predefined value for LocalizationView:
        if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') {
            $this->MOD_SETTINGS['localization'] = TRUE;
        } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') {
            $this->MOD_SETTINGS['localization'] = FALSE;
        }
        // Initialize the dblist object:
        /**
         * Category record list
         *
         * @var $dbList Tx_Commerce_ViewHelpers_CategoryRecordList
         */
        $dbList = GeneralUtility::makeInstance('Tx_Commerce_ViewHelpers_CategoryRecordList');
        $dbList->backPath = $GLOBALS['BACK_PATH'];
        $dbList->script = BackendUtility::getModuleUrl('txcommerceM1_category', array(), '');
        /**
         * Backend utility
         *
         * @var \CommerceTeam\Commerce\Utility\BackendUserUtility $utility
         */
        $utility = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Utility\\BackendUserUtility');
        $dbList->calcPerms = $utility->calcPerms((array) BackendUtility::getRecord('tx_commerce_categories', $this->categoryUid));
        $dbList->thumbs = $this->getBackendUser()->uc['thumbnailsByDefault'];
        $dbList->returnUrl = $this->returnUrl;
        $dbList->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0;
        $dbList->localizationView = $this->MOD_SETTINGS['localization'];
        $dbList->showClipboard = 1;
        $dbList->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView'];
        $dbList->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView'];
        $dbList->hideTables = $this->modTSconfig['properties']['hideTables'];
        $dbList->hideTranslations = $this->modTSconfig['properties']['hideTranslations'];
        $dbList->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.'];
        $dbList->alternateBgColors = $this->modTSconfig['properties']['alternateBgColors'] ? 1 : 0;
        $dbList->allowedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], TRUE);
        $dbList->deniedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], TRUE);
        $dbList->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0;
        $dbList->pageRow = $this->pageinfo;
        $dbList->counter++;
        $dbList->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => '');
        $dbList->modTSconfig = $this->modTSconfig;
        $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']);
        $dbList->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode;
        $dbList->newRecordIcon = $newRecordIcon;
        $dbList->parentUid = $this->categoryUid;
        $dbList->tableList = 'tx_commerce_categories,tx_commerce_products';
        // Clipboard is initialized:
        // Start clipboard
        /**
         * Clipboard
         *
         * @var \TYPO3\CMS\Backend\Clipboard\Clipboard $clipObj
         */
        $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
        $dbList->clipObj = $clipObj;
        // Initialize - reads the clipboard content from the user session
        $dbList->clipObj->initializeClipboard();
        // Clipboard actions are handled:
        // CB is the clipboard command array
        $clipboard = GeneralUtility::_GET('CB');
        if ($this->cmd == 'setCB') {
            // CBH is all the fields selected for the clipboard, CBC is the checkbox fields
            // which were checked. By merging we get a full array of checked/unchecked
            // elements This is set to the 'el' array of the CB after being parsed so only
            // the table in question is registered.
            $clipboard['el'] = $dbList->clipObj->cleanUpCBC(array_merge((array) GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), $this->cmd_table);
        }
        if (!$this->MOD_SETTINGS['clipBoard']) {
            // If the clipboard is NOT shown, set the pad to 'normal'.
            $clipboard['setP'] = 'normal';
        }
        // Execute commands.
        $dbList->clipObj->setCmd($clipboard);
        // Clean up pad
        $dbList->clipObj->cleanCurrent();
        // Save the clipboard content
        $dbList->clipObj->endClipboard();
        // This flag will prevent the clipboard panel in being shown.
        // It is set, the clickmenu-layer is active AND the extended
        // view is not enabled.
        $dbList->dontShowClipControlPanels = !$this->MOD_SETTINGS['bigControlPanel'] && $dbList->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
        if ($access || $this->id === 0 && $this->search_levels > 0 && strlen($this->search_field) > 0) {
            // Deleting records...:
            // Has not to do with the clipboard but is simply the delete action. The
            // clipboard object is used to clean up the submitted entries to only the
            // selected table.
            if ($this->cmd == 'delete') {
                $items = $dbList->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), $this->cmd_table, 1);
                if (count($items)) {
                    $cmd = array();
                    foreach ($items as $iK => $_) {
                        $iKparts = explode('|', $iK);
                        $cmd[$iKparts[0]][$iKparts[1]]['delete'] = 1;
                    }
                    /**
                     * Data handler
                     *
                     * @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce
                     */
                    $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
                    $tce->stripslashes_values = 0;
                    $tce->start(array(), $cmd);
                    $tce->process_cmdmap();
                    if (isset($cmd['pages'])) {
                        BackendUtility::setUpdateSignal('updateFolderTree');
                    }
                    $tce->printLogErrorMessages(GeneralUtility::getIndpEnv('REQUEST_URI'));
                }
            }
            // Initialize the listing object, dblist, for rendering the list:
            $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
            $dbList->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit);
            $dbList->setDispFields();
            $dbList->perms_clause = $this->perms_clause;
            // Render versioning selector:
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) {
                $dbList->HTMLcode .= $this->doc->getVersionSelector($this->id);
            }
            $dbList->parentUid = $this->categoryUid;
            // Render the list of tables:
            $dbList->generateList();
            $listUrl = $dbList->listURL();
            // Add JavaScript functions to the page:
            $this->doc->JScode = $this->doc->wrapScriptTags('
				function jumpExt(URL,anchor) {	//
					var anc = anchor?anchor:"";
					window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc;
					return false;
				}
				function jumpSelf(URL) {	//
					window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:"");
					return false;
				}

				function setHighlight(id) {	//
					top.fsMod.recentIds["web"]=id;
					top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank;	// For highlighting

					if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
						top.content.nav_frame.refresh_nav();
					}
				}
				' . $this->doc->redirectUrls($listUrl) . '
				' . $dbList->CBfunctions() . '
				function editRecords(table,idList,addParams,CBflag) {	//
					window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '&edit["+table+"]["+idList+"]=edit"+addParams;
				}
				function editList(table,idList) {	//
					var list="";

						// Checking how many is checked, how many is not
					var pointer=0;
					var pos = idList.indexOf(",");
					while (pos!=-1) {
						if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) {
							list+=idList.substr(pointer,pos-pointer)+",";
						}
						pointer=pos+1;
						pos = idList.indexOf(",",pointer);
					}
					if (cbValue(table+"|"+idList.substr(pointer))) {
						list+=idList.substr(pointer)+",";
					}

					return list ? list : idList;
				}

				if (top.fsMod) {
					top.fsMod.recentIds["web"] = ' . $this->id . ';
					top.fsMod.recentIds["commerce"] = ' . $this->categoryUid . ';
				}
			');
            // Setting up the context sensitive menu:
            $this->doc->getContextMenuCode();
        }
        // access
        // Begin to compile the whole page, starting out with page header:
        $this->body = $this->doc->header($this->pageinfo['title']);
        $this->body .= '<form action="' . htmlspecialchars($dbList->listURL()) . '" method="post" name="dblistForm">';
        $this->body .= $dbList->HTMLcode;
        $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>';
        // If a listing was produced, create the page footer with search form etc:
        if ($dbList->HTMLcode) {
            // Making field select box (when extended view for a single table is enabled):
            if ($dbList->table) {
                $this->body .= $dbList->fieldSelectBox($dbList->table);
            }
            // Adding checkbox options for extended listing and clipboard display:
            $this->body .= '

					<!--
						Listing options for extended view, clipboard and localization view
					-->
					<div id="typo3-listOptions">
						<form action="" method="post">';
            $functionParameter = array('id' => $this->id);
            if ($this->categoryUid) {
                $functionParameter['control[tx_commerce_categories][uid]'] = $this->categoryUid;
            }
            // Add "display bigControlPanel" checkbox:
            if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') {
                $this->body .= BackendUtility::getFuncCheck($functionParameter, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"');
                $this->body .= '<label for="checkLargeControl">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $language->getLL('largeControl', TRUE)) . '</label><br />';
            }
            // Add "clipboard" checkbox:
            if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable' && $dbList->showClipboard) {
                $this->body .= BackendUtility::getFuncCheck($functionParameter, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"');
                $this->body .= '<label for="checkShowClipBoard">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $language->getLL('showClipBoard', TRUE)) . '</label><br />';
            }
            // Add "localization view" checkbox:
            if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') {
                $this->body .= BackendUtility::getFuncCheck($functionParameter, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"');
                $this->body .= '<label for="checkLocalization">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $language->getLL('localization', TRUE)) . '</label><br />';
            }
            $this->body .= '
						</form>
					</div>';
        }
        // Printing clipboard if enabled
        if ($this->MOD_SETTINGS['clipBoard'] && $dbList->showClipboard && ($dbList->HTMLcode || $dbList->clipObj->hasElements())) {
            $this->body .= '<div class="db_list-dashboard">' . $dbList->clipObj->printClipboard() . '</div>';
        }
        // Search box:
        if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dbList->HTMLcode || $dbList->searchString !== '')) {
            $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $language->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE));
            $this->body .= '<div class="db_list-searchbox">' . $this->doc->section($sectionTitle, $dbList->getSearchBox(), FALSE, TRUE, FALSE, TRUE) . '</div>';
        }
        // Additional footer content
        $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook'];
        if (is_array($footerContentHook)) {
            foreach ($footerContentHook as $hook) {
                $params = array();
                $this->body .= GeneralUtility::callUserFunction($hook, $params, $this);
            }
        }
        $docHeaderButtons = $dbList->getButtons($this->pageinfo);
        if (!$this->categoryUid) {
            $docHeaderButtons['edit'] = '';
        }
        $categoryInfo = $this->categoryUid ? $this->getCategoryInfo($this->pageinfo) : $this->getPageInfo($this->pageinfo);
        $categoryPath = $this->categoryUid ? $this->getCategoryPath($this->pageinfo) : $this->getPagePath($this->pageinfo);
        $markers = array('CSH' => $docHeaderButtons['csh'], 'CATPATH' => $categoryPath, 'CATINFO' => $categoryInfo, 'CONTENT' => $this->body, 'EXTRACONTAINERCLASS' => $this->table ? 'singletable' : '');
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render('DB list', $this->content);
    }
Пример #8
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']);
 }
Пример #9
0
    /**
     * Commits the given command
     *
     * @param int $uidClip Uid of clipboard item
     * @param int $uidTarget Uid of target
     * @param string $command Command
     *
     * @return void
     */
    protected function commitCommand($uidClip, $uidTarget, $command)
    {
        // First prepare user defined objects (if any)
        // for hooks which extend this function:
        $hookObjectsArr = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['commitCommandClass'])) {
            \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/mod_cce/class.tx_commerce_cce_db.php\'][\'storeDataToDatabase\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Utility/DataHandlerUtility.php\'][\'commitCommand\']
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['commitCommandClass'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['commitCommand'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['commitCommand'] as $classRef) {
                $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
            }
        }
        // Hook: beforeCommit
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'beforeCommit')) {
                $hookObj->beforeCommit($uidClip, $uidTarget, $command);
            }
        }
        // we got all info we need - commit command
        switch ($command) {
            case 'overwrite':
                Tx_Commerce_Utility_BackendUtility::overwriteProduct($uidClip, $uidTarget, $this->locales);
                break;
            case 'pasteProduct':
                Tx_Commerce_Utility_BackendUtility::copyProduct($uidClip, $uidTarget, FALSE, $this->locales, $this->sorting);
                break;
            case 'pasteCategory':
                Tx_Commerce_Utility_BackendUtility::copyCategory($uidClip, $uidTarget, $this->locales, $this->sorting);
                break;
            default:
                die('unknown command');
        }
        // Hook: afterCommit
        foreach ($hookObjectsArr as $hookObj) {
            if (method_exists($hookObj, 'afterCommit')) {
                $hookObj->afterCommit($uidClip, $uidTarget, $command);
            }
        }
        // Update page tree?
        if ($this->uPT && (isset($this->data['tx_commerce_categories']) || isset($this->cmd['tx_commerce_categories'])) && (isset($this->data['tx_commerce_products']) || isset($this->cmd['tx_commerce_products']))) {
            \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updateFolderTree');
        }
    }
Пример #10
0
    /**
     * Creates an article in the database and all needed releations to attributes
     * and values. It also creates a new prices and assignes it to the new article.
     *
     * @param array $parameter Parameter
     * @param string $key The key in the POST var array
     *
     * @return int Returns the new articleUid if success
     */
    protected function createArticle(array $parameter, $key)
    {
        $database = $this->getDatabaseConnection();
        // get the create data
        $data = GeneralUtility::_GP('createData');
        $hash = '';
        if (is_array($data)) {
            $data = $data[$key];
            $hash = md5($data);
            $data = unserialize($data);
        }
        $database->debugOutput = 1;
        $database->store_lastBuiltQuery = TRUE;
        // get the highest sorting
        $sorting = $database->exec_SELECTgetSingleRow('uid, sorting', 'tx_commerce_articles', 'uid_product = ' . $this->uid, '', 'sorting DESC', 1);
        $sorting = is_array($sorting) && isset($sorting['sorting']) ? $sorting['sorting'] + 20 : 0;
        // create article data array
        $articleData = array('pid' => $this->pid, 'crdate' => time(), 'title' => strip_tags($this->createArticleTitleFromAttributes($parameter, (array) $data)), 'uid_product' => (int) $this->uid, 'sorting' => $sorting, 'article_attributes' => count($this->attributes['rest']) + count($data), 'attribute_hash' => $hash, 'article_type_uid' => 1);
        $temp = BackendUtility::getModTSconfig($this->pid, 'mod.commerce.category');
        if ($temp) {
            $moduleConfig = BackendUtility::implodeTSParams($temp['properties']);
            $defaultTax = (int) $moduleConfig['defaultTaxValue'];
            if ($defaultTax > 0) {
                $articleData['tax'] = $defaultTax;
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_articlecreator.php']['preinsert'])) {
            GeneralUtility::deprecationLog('
				hook
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/class.tx_commerce_articlecreator.php\'][\'preinsert\']
				is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
				$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/lib/class.tx_commerce_basket.php\'][\'createArticlePreInsert\']
			');
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/class.tx_commerce_articlecreator.php']['preinsert'] as $classRef) {
                $hookObj =& GeneralUtility::getUserObj($classRef);
                if (method_exists($hookObj, 'preinsert')) {
                    $hookObj->preinsert($articleData);
                }
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/ArticleCreatorUtility.php']['createArticlePreInsert'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/ArticleCreatorUtility.php']['createArticlePreInsert'] as $classRef) {
                $hookObj =& GeneralUtility::getUserObj($classRef);
                if (method_exists($hookObj, 'preinsert')) {
                    $hookObj->preinsert($articleData);
                }
            }
        }
        // create the article
        $database->exec_INSERTquery('tx_commerce_articles', $articleData);
        $articleUid = $database->sql_insert_id();
        // create a new price that is assigned to the new article
        $database->exec_INSERTquery('tx_commerce_article_prices', array('pid' => $this->pid, 'crdate' => time(), 'tstamp' => time(), 'uid_article' => $articleUid));
        // now write all relations between article and attributes into the database
        $relationBaseData = array('uid_local' => $articleUid);
        $createdArticleRelations = array();
        $relationCreateData = $relationBaseData;
        $productsAttributesRes = $database->exec_SELECTquery('sorting, uid_local, uid_foreign', 'tx_commerce_products_attributes_mm', 'uid_local = ' . (int) $this->uid);
        $attributesSorting = array();
        while ($productsAttributes = $database->sql_fetch_assoc($productsAttributesRes)) {
            $attributesSorting[$productsAttributes['uid_foreign']] = $productsAttributes['sorting'];
        }
        if (is_array($data)) {
            foreach ($data as $selectAttributeUid => $selectAttributeValueUid) {
                $relationCreateData['uid_foreign'] = $selectAttributeUid;
                $relationCreateData['uid_valuelist'] = $selectAttributeValueUid;
                $relationCreateData['sorting'] = $attributesSorting[$selectAttributeUid];
                $createdArticleRelations[] = $relationCreateData;
                $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', $relationCreateData);
            }
        }
        if (is_array($this->attributes['rest'])) {
            foreach ($this->attributes['rest'] as $attribute) {
                if (empty($attribute['attributeData']['uid'])) {
                    continue;
                }
                $relationCreateData = $relationBaseData;
                $relationCreateData['sorting'] = $attribute['sorting'];
                $relationCreateData['uid_foreign'] = $attribute['attributeData']['uid'];
                if ($attribute['uid_correlationtype'] == 4) {
                    $relationCreateData['uid_product'] = $this->uid;
                }
                $relationCreateData['default_value'] = '';
                $relationCreateData['value_char'] = '';
                $relationCreateData['uid_valuelist'] = $attribute['uid_valuelist'];
                if (!$this->belib->isNumber($attribute['default_value'])) {
                    $relationCreateData['default_value'] = $attribute['default_value'];
                } else {
                    $relationCreateData['value_char'] = $attribute['default_value'];
                }
                $createdArticleRelations[] = $relationCreateData;
                $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', $relationCreateData);
            }
        }
        // update the article
        // we have to write the xml datastructure for this article. This is needed
        // to have the correct values inserted on first call of the article.
        $this->belib->updateArticleXML($createdArticleRelations, FALSE, $articleUid);
        // Now check, if the parent Product is already lokalised, so creat Article in
        // the lokalised version Select from Database different localisations
        $resOricArticle = $database->exec_SELECTquery('*', 'tx_commerce_articles', 'uid=' . (int) $articleUid . ' and deleted = 0');
        $origArticle = $database->sql_fetch_assoc($resOricArticle);
        $resLocalizedProducts = $database->exec_SELECTquery('*', 'tx_commerce_products', 'l18n_parent = ' . (int) $this->uid . ' AND deleted = 0');
        if ($resLocalizedProducts && $database->sql_num_rows($resLocalizedProducts) > 0) {
            // Only if there are products
            while ($localizedProducts = $database->sql_fetch_assoc($resLocalizedProducts)) {
                // walk thru and create articles
                $destLanguage = $localizedProducts['sys_language_uid'];
                // get the highest sorting
                $langIsoCode = BackendUtility::getRecord('sys_language', (int) $destLanguage, 'static_lang_isocode');
                $langIdent = BackendUtility::getRecord('static_languages', (int) $langIsoCode['static_lang_isocode'], 'lg_typo3');
                $langIdent = strtoupper($langIdent['lg_typo3']);
                // create article data array
                $articleData = array('pid' => $this->pid, 'crdate' => time(), 'title' => $parameter['title'], 'uid_product' => $localizedProducts['uid'], 'sys_language_uid' => $localizedProducts['sys_language_uid'], 'l18n_parent' => $articleUid, 'sorting' => $sorting['sorting'] + 20, 'article_attributes' => count($this->attributes['rest']) + count($data), 'attribute_hash' => $hash, 'article_type_uid' => 1, 'attributesedit' => $this->belib->buildLocalisedAttributeValues($origArticle['attributesedit'], $langIdent));
                // create the article
                $database->exec_INSERTquery('tx_commerce_articles', $articleData);
                $localizedArticleUid = $database->sql_insert_id();
                // get all relations to attributes from the old article and copy them
                // to new article
                $res = $database->exec_SELECTquery('*', 'tx_commerce_articles_article_attributes_mm', 'uid_local = ' . (int) $origArticle['uid'] . ' AND uid_valuelist = 0');
                while ($origRelation = $database->sql_fetch_assoc($res)) {
                    $origRelation['uid_local'] = $localizedArticleUid;
                    $database->exec_INSERTquery('tx_commerce_articles_article_attributes_mm', $origRelation);
                }
                $this->belib->updateArticleXML($createdArticleRelations, FALSE, $localizedArticleUid);
            }
        }
        return $articleUid;
    }
Пример #11
0
 /**
  * Constructor function for the class
  *
  * @return void
  */
 public function init()
 {
     $backendUser = $this->getBackendUser();
     $language = $this->getLanguageService();
     // page-selection permission clause (reading)
     $this->permsClause = $backendUser->getPagePermsClause(1);
     // Setting GPvars:
     // The page id to operate from
     $this->id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id') ? (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id') : Tx_Commerce_Utility_BackendUtility::getProductFolderUid();
     $this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl');
     // this to be accomplished from the caller: &edit['.$table.'][-'.$uid.']=new&
     $this->param = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('edit');
     $this->defVals = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('defVals');
     // Create instance of template class for output
     $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->JScode = '';
     $this->head = $language->getLL('newRecordGeneral', 1);
     // Creating content
     $this->content = '';
     $this->content .= $this->doc->startPage($this->head);
     $this->content .= $this->doc->header($this->head);
     // Id a positive id is supplied, ask for the page record
     // with permission information contained:
     if ($this->id > 0) {
         $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->permsClause);
     }
     // If a page-record was returned, the user had read-access to the page.
     if ($this->pageinfo['uid']) {
         // Get record of parent page
         $this->pidInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $this->pageinfo['pid']);
         // Checking the permissions for the user with regard to the
         // parent page: Can he create new pages, new content record, new page after?
         if ($backendUser->doesUserHaveAccess($this->pageinfo, 16)) {
             $this->newContentInto = 1;
         }
     } elseif ($backendUser->isAdmin()) {
         // Admins can do it all
         $this->newContentInto = 1;
     } else {
         // People with no permission can do nothing
         $this->newContentInto = 0;
     }
 }
Пример #12
0
 /**
  * Calculate article rights
  *
  * @param int $uid Uid
  * @param array $rights Rights
  *
  * @return array
  */
 protected function calculateArticleRights($uid, array $rights)
 {
     // get all parent categories for the parent product
     /**
      * Article
      *
      * @var Tx_Commerce_Domain_Model_Article $article
      */
     $article = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Article', $uid);
     // get the parent categories of the product
     $parentCategories = $article->getParentProduct()->getParentCategories();
     // store the rights in the flags
     $rights['edit'] = $rights['delete'] = Tx_Commerce_Utility_BackendUtility::checkPermissionsOnCategoryContent($parentCategories, array('editcontent'));
     return $rights;
 }
Пример #13
0
 /**
  * Initializes the Categorytree
  *
  * @return void
  */
 public function init()
 {
     // Call parent constructor
     parent::init();
     // Create the category leaf
     /**
      * Category leaf
      *
      * @var Tx_Commerce_Tree_Leaf_Category $categoryLeaf
      */
     $categoryLeaf = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_Category');
     // Instantiate the categorydata, -view and set
     // the permission mask (or the string rep.)
     /**
      * Category data
      *
      * @var Tx_Commerce_Tree_Leaf_CategoryData $categorydata
      */
     $categorydata = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_CategoryData');
     $categorydata->setPermsMask(Tx_Commerce_Utility_BackendUtility::getPermMask($this->minCategoryPerms));
     /**
      * Category view
      *
      * @var Tx_Commerce_Tree_Leaf_CategoryView $categoryview
      */
     $categoryview = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_CategoryView');
     // disable the root onclick if the perms are set to editcontent
     // this way we cannot select the root as a parent for any content item
     $categoryview->noRootOnclick($this->minCategoryPerms == 'editcontent');
     // Configure real values
     if ($this->realValues) {
         $categoryview->substituteRealValues();
     }
     // Configure the noOnclick for the leaf
     if (GeneralUtility::inList($this->noClickList, 'Tx_Commerce_Tree_Leaf_Category')) {
         $categoryview->noOnclick();
     }
     $categoryLeaf->initBasic($categoryview, $categorydata);
     $this->addLeaf($categoryLeaf);
     // Add Product and Article Leafs if wanted
     // - Productleaf will be added to Categoryleaf,
     // - Articleleaf will be added to Productleaf
     if (!$this->bare) {
         /**
          * Product leaf
          *
          * @var Tx_Commerce_Tree_Leaf_Product $productleaf
          */
         $productleaf = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_Product');
         /**
          * Article leaf
          *
          * @var Tx_Commerce_Tree_Leaf_Article $articleleaf
          */
         $articleleaf = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_Article');
         /**
          * Product view
          *
          * @var Tx_Commerce_Tree_Leaf_ProductView $productview
          */
         $productview = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ProductView');
         // Configure the noOnclick for the leaf
         if (GeneralUtility::inList($this->noClickList, 'Tx_Commerce_Tree_Leaf_Product')) {
             $productview->noOnclick();
         }
         // Configure real values
         if ($this->realValues) {
             $productview->substituteRealValues();
         }
         /**
          * Article view
          *
          * @var Tx_Commerce_Tree_Leaf_ArticleView $articleview
          */
         $articleview = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ArticleView');
         // Configure the noOnclick for the leaf
         if (GeneralUtility::inList($this->noClickList, 'Tx_Commerce_Tree_Leaf_Article')) {
             $articleview->noOnclick();
         }
         // Configure real values
         if ($this->realValues) {
             $articleview->substituteRealValues();
         }
         /**
          * Product data
          *
          * @var Tx_Commerce_Tree_Leaf_ProductData $productData
          */
         $productData = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ProductData');
         $productleaf->initBasic($productview, $productData);
         /**
          * Article data
          *
          * @var Tx_Commerce_Tree_Leaf_ArticleData $articleData
          */
         $articleData = GeneralUtility::makeInstance('Tx_Commerce_Tree_Leaf_ArticleData');
         $articleleaf->initBasic($articleview, $articleData);
         $categoryLeaf->addLeaf($productleaf);
         // Do not show articles in simple mode.
         if (!$this->simpleMode) {
             $productleaf->addLeaf($articleleaf);
         }
     }
 }
    /**
     * Main function, creating the content for the access editing forms/listings
     *
     * @return void
     */
    public function main()
    {
        $backendUser = $this->getBackendUser();
        $language = $this->getLanguageService();
        // Access check...
        // The page will show only if there is a valid page and if this page
        // may be viewed by the user
        if ($this->categoryUid) {
            $this->pageinfo = Tx_Commerce_Utility_BackendUtility::readCategoryAccess($this->categoryUid, $this->perms_clause);
        } else {
            $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
        }
        $access = is_array($this->pageinfo);
        // Checking access:
        if ($this->categoryUid && $access || $backendUser->isAdmin() && !$this->categoryUid) {
            if ($backendUser->isAdmin() && !$this->categoryUid) {
                $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
            }
            // This decides if the editform (tceAction) can and will be drawn:
            $this->editingAllowed = $this->pageinfo['perms_userid'] == $backendUser->user['uid'] || $backendUser->isAdmin();
            $this->edit = $this->edit && $this->editingAllowed;
            // If $this->edit then these functions are called in the end of the page...
            if ($this->edit) {
                $this->doc->postCode .= $this->doc->wrapScriptTags('
					setCheck("check[perms_user]", "data[tx_commerce_categories][' . $this->categoryUid . '][perms_user]");
					setCheck("check[perms_group]", "data[tx_commerce_categories][' . $this->categoryUid . '][perms_group]");
					setCheck("check[perms_everybody]", "data[tx_commerce_categories][' . $this->categoryUid . '][perms_everybody]");
				');
            }
            // Draw the HTML page header.
            $this->content .= $this->doc->header($language->getLL('permissions') . ($this->edit ? ': ' . $language->getLL('Edit') : ''));
            $vContent = $this->doc->getVersionSelector($this->categoryUid, 1);
            if ($vContent) {
                $this->content .= $this->doc->section('', $vContent);
            }
            // Main function, branching out:
            if (!$this->edit) {
                $this->notEdit();
            } else {
                $this->doEdit();
            }
            $docHeaderButtons = $this->getButtons();
            $markers['CSH'] = $docHeaderButtons['csh'];
            $markers['FUNC_MENU'] = BackendUtility::getFuncMenu($this->id, 'SET[mode]', $this->MOD_SETTINGS['mode'], $this->MOD_MENU['mode']);
            $markers['CONTENT'] = $this->content;
            // Build the <body> for the module
            $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        } else {
            // If no access or if ID == zero
            $this->content .= $this->doc->header($language->getLL('permissions'));
        }
        // Renders the module page
        $this->content = $this->doc->render($language->getLL('permissions'), $this->content);
    }
Пример #15
0
 /**
  * Initializes the categorydata
  * Builds the Permission-Statement
  *
  * @return void
  */
 public function init()
 {
     $this->whereClause = ' deleted = 0 AND ' . Tx_Commerce_Utility_BackendUtility::getCategoryPermsClause($this->permsMask);
     $this->order = 'tx_commerce_categories.sorting ASC';
 }
Пример #16
0
 /**
  * Carries out the move of the category to the new parent
  * Permissions are NOT checked, this MUST be done beforehand
  *
  * @param int $uid UID of the move target
  * @param string $op Operation of move (can be 'after' or 'into')
  *
  * @return bool TRUE if the move was successful, FALSE if not
  */
 public function move($uid, $op = 'after')
 {
     if ($op == 'into') {
         // the $uid is a future parent
         $parentUid = $uid;
     } else {
         return FALSE;
     }
     // Update parent_category
     $set = $this->databaseConnection->updateRecord($this->uid, array('parent_category' => $parentUid));
     // Only update relations if parent_category was successfully set
     if ($set) {
         $catList = array($parentUid);
         $catList = Tx_Commerce_Utility_BackendUtility::getUidListFromList($catList);
         $catList = Tx_Commerce_Utility_BackendUtility::extractFieldArray($catList, 'uid_foreign', TRUE);
         Tx_Commerce_Utility_BackendUtility::saveRelations($this->uid, $catList, 'tx_commerce_categories_parent_category_mm', TRUE);
     } else {
         return FALSE;
     }
     return TRUE;
 }
Пример #17
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;
    }