Exemplo n.º 1
0
 /**
  * Initializes the Categorytree.
  */
 public function init()
 {
     parent::init();
     // Create the category leaf
     /**
      * Category leaf.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\Category $categoryLeaf
      */
     $categoryLeaf = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\Category');
     // Instantiate the categorydata, -view and set
     // the permission mask (or the string rep.)
     /**
      * Category data.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\CategoryData $categorydata
      */
     $categorydata = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\CategoryData');
     $categorydata->setPermsMask(BackendUtility::getPermMask($this->minCategoryPerms));
     /**
      * Category view.
      *
      * @var \CommerceTeam\Commerce\ViewHelpers\Browselinks\CategoryView $categoryview
      */
     $categoryview = GeneralUtility::makeInstance('CommerceTeam\\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 (GeneralUtility::inList($this->noClickList, 'CommerceTeam\\Commerce\\Tree\\Leaf\\Category')) {
         $categoryview->noOnclick();
     }
     $categoryLeaf->initBasic($categoryview, $categorydata);
     $this->addLeaf($categoryLeaf);
     // Add Product - Productleaf will be added to Categoryleaf
     /**
      * Product leaf.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\Product $productleaf
      */
     $productleaf = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\Product');
     /**
      * Product view.
      *
      * @var \CommerceTeam\Commerce\ViewHelpers\Browselinks\ProductView $productview
      */
     $productview = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\ViewHelpers\\Browselinks\\ProductView');
     // Configure the noOnclick for the leaf
     if (GeneralUtility::inList($this->noClickList, 'CommerceTeam\\Commerce\\Tree\\Leaf\\Product')) {
         $productview->noOnclick();
     }
     /**
      * Product data.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\ProductData $productData
      */
     $productData = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ProductData');
     $productleaf->initBasic($productview, $productData);
     $categoryLeaf->addLeaf($productleaf);
 }
Exemplo n.º 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
         \CommerceTeam\Commerce\Utility\BackendUtility::swapProductAttributes($swapWith, $id, $copy);
         // give Articles from swapWith to id
         \CommerceTeam\Commerce\Utility\BackendUtility::swapProductArticles($swapWith, $id, $copy);
     }
 }
Exemplo n.º 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 (CommerceTeam\\Commerce\\Tree\\Leaf\\View) gets passed invalid parameters.', COMMERCE_EXTKEY, 3);
         }
         return '';
     }
     // get the UID of the Products SysFolder
     $productPid = \CommerceTeam\Commerce\Utility\BackendUtility::getProductFolderUid();
     $res = '&id=' . $productPid . '&control[' . $this->table . '][uid]=' . $row['uid'];
     if ($this->realValues) {
         $res = $this->table . '_' . $row['uid'];
     }
     return $res;
 }
Exemplo n.º 4
0
 /**
  * Flag product translations as deleted for productList.
  *
  * @param array $productList Product list
  *
  * @return void
  */
 protected function deleteProductTranslationsByProductList(array $productList)
 {
     $updateValues = array('tstamp' => $GLOBALS['EXEC_TIME'], 'deleted' => 1);
     $this->getDatabaseConnection()->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) && !empty($articlesOfProduct)) {
             $translatedArticles = array_merge($translatedArticles, $articlesOfProduct);
         }
     }
     $translatedArticles = array_unique($translatedArticles);
     if (!empty($translatedArticles)) {
         $this->deletePricesByArticleList($translatedArticles);
         $this->deleteArticlesByArticleList($translatedArticles);
     }
 }
 /**
  * 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)));
 }
Exemplo n.º 6
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 = \CommerceTeam\Commerce\Utility\BackendUtility::getUidListFromList($catList);
         $catList = \CommerceTeam\Commerce\Utility\BackendUtility::extractFieldArray($catList, 'uid_foreign', true);
         \CommerceTeam\Commerce\Utility\BackendUtility::saveRelations($this->uid, $catList, 'tx_commerce_categories_parent_category_mm', true);
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 7
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 (SettingsFactory::getInstance()->getExtConf('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)) {
             $aRes = $database->sql_fetch_assoc($res);
             $aUid = $aRes['uid'];
         } else {
             // 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();
         }
         // check if the article has already a price
         $row = $database->exec_SELECTgetSingleRow('*', 'tx_commerce_article_prices', 'uid_article = ' . $productId);
         if (empty($row) && $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) && !empty($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) && !empty($articles)) {
                     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)) {
                                 $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) && !empty($articles)) {
                 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' => 'CommerceTeam\\Commerce\\Tree\\Leaf\\CategoryData', 'parent' => 'parent_category'), 'product' => array('dataClass' => 'CommerceTeam\\Commerce\\Tree\\Leaf\\ProductData', 'parent' => 'categories'));
            $newRecordLink = $this->scriptNewWizard . '?id=' . (int) $this->id;
            foreach ($controls as $controlData) {
                /**
                 * Tree data.
                 *
                 * @var \CommerceTeam\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 = \CommerceTeam\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 \CommerceTeam\Commerce\ViewHelpers\CategoryRecordList $dbList
         */
        $dbList = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\ViewHelpers\\CategoryRecordList');
        $dbList->backPath = $this->getBackPath();
        $dbList->script = BackendUtility::getModuleUrl('commerce_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 (!empty($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="' . $this->getBackPath() . '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);
    }
Exemplo n.º 9
0
 /**
  * Initializes the Categorytree.
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     // Create the category leaf
     /**
      * Category leaf.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\Category $categoryLeaf
      */
     $categoryLeaf = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\Category');
     // Instantiate the categorydata, -view and set
     // the permission mask (or the string rep.)
     /**
      * Category data.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\CategoryData $categorydata
      */
     $categorydata = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\CategoryData');
     $categorydata->setPermsMask(BackendUtility::getPermMask($this->minCategoryPerms));
     /**
      * Category view.
      *
      * @var \CommerceTeam\Commerce\Tree\Leaf\CategoryView $categoryview
      */
     $categoryview = GeneralUtility::makeInstance('CommerceTeam\\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->isNavigationFrame) {
         $categoryview->substituteRealValues();
     }
     // Configure the noOnclick for the leaf
     if (GeneralUtility::inList($this->noClickList, 'CommerceTeam\\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 \CommerceTeam\Commerce\Tree\Leaf\Product $productleaf
          */
         $productleaf = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\Product');
         /**
          * Article leaf.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\Article $articleleaf
          */
         $articleleaf = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\Article');
         /**
          * Product view.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\ProductView $productview
          */
         $productview = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ProductView');
         // Configure the noOnclick for the leaf
         if (GeneralUtility::inList($this->noClickList, 'CommerceTeam\\Commerce\\Tree\\Leaf\\Product')) {
             $productview->noOnclick();
         }
         /**
          * Article view.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\ArticleView $articleview
          */
         $articleview = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ArticleView');
         // Configure the noOnclick for the leaf
         if (GeneralUtility::inList($this->noClickList, 'CommerceTeam\\Commerce\\Tree\\Leaf\\Article')) {
             $articleview->noOnclick();
         }
         // Configure real values
         if (!$this->isNavigationFrame) {
             $productview->substituteRealValues();
             $articleview->substituteRealValues();
         }
         /**
          * Product data.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\ProductData $productData
          */
         $productData = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ProductData');
         $productleaf->initBasic($productview, $productData);
         /**
          * Article data.
          *
          * @var \CommerceTeam\Commerce\Tree\Leaf\ArticleData $articleData
          */
         $articleData = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Tree\\Leaf\\ArticleData');
         $articleleaf->initBasic($articleview, $articleData);
         $categoryLeaf->addLeaf($productleaf);
         // Do not show articles in simple mode.
         if (!$this->simpleMode) {
             $productleaf->addLeaf($articleleaf);
         }
     }
 }
Exemplo n.º 10
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 \CommerceTeam\Commerce\Domain\Model\Article $article
      */
     $article = GeneralUtility::makeInstance('CommerceTeam\\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'] = CommerceBackendUtility::checkPermissionsOnCategoryContent($parentCategories, array('editcontent'));
     return $rights;
 }
Exemplo n.º 11
0
 /**
  * Commits the given command.
  *
  * @param int    $uidClip   Uid of clipboard item
  * @param int    $uidTarget Uid of target
  * @param string $command   Command
  */
 protected function commitCommand($uidClip, $uidTarget, $command)
 {
     // First prepare user defined hooks
     $hooks = \CommerceTeam\Commerce\Factory\HookFactory::getHooks('Utility/DataHandlerUtility', 'commitCommand');
     // Hook: beforeCommit
     foreach ($hooks as $hookObj) {
         if (method_exists($hookObj, 'beforeCommit')) {
             $hookObj->beforeCommit($uidClip, $uidTarget, $command);
         }
     }
     // we got all info we need - commit command
     switch ($command) {
         case 'overwrite':
             BackendUtility::overwriteProduct($uidClip, $uidTarget, $this->locales);
             break;
         case 'pasteProduct':
             BackendUtility::copyProduct($uidClip, $uidTarget, false, $this->locales, $this->sorting);
             break;
         case 'pasteCategory':
             BackendUtility::copyCategory($uidClip, $uidTarget, $this->locales, $this->sorting);
             break;
         default:
             die('unknown command');
     }
     // Hook: afterCommit
     foreach ($hooks 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');
     }
 }
Exemplo n.º 12
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);
         }
     }
     $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;
 }
Exemplo n.º 13
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 = GeneralUtility::_GP('id') ? (int) GeneralUtility::_GP('id') : BackendUtility::getProductFolderUid();
     $this->returnUrl = GeneralUtility::_GP('returnUrl');
     // this to be accomplished from the caller: &edit['.$table.'][-'.$uid.']=new&
     $this->param = GeneralUtility::_GP('edit');
     $this->defVals = GeneralUtility::_GP('defVals');
     // Create instance of template class for output
     $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $this->doc->backPath = $this->getBackPath();
     $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;
     }
 }
Exemplo n.º 14
0
 /**
  * Order Status
  * Selects only the order folders from the pages List.
  *
  * @param array $data Data
  *
  * @return void
  */
 public function orderStatus(array &$data)
 {
     /*
      * Create folder if not existing
      */
     \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'));
 }
Exemplo n.º 15
0
 /**
  * Initializes the categorydata
  * Builds the Permission-Statement.
  *
  * @return void
  */
 public function init()
 {
     $this->whereClause = ' deleted = 0 AND ' . \CommerceTeam\Commerce\Utility\BackendUtility::getCategoryPermsClause($this->permsMask);
     $this->order = 'tx_commerce_categories.sorting ASC';
 }
 /**
  * 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 = \CommerceTeam\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) {
             $uid = $this->categoryUid;
             $this->doc->postCode .= $this->doc->wrapScriptTags('
                 setCheck("check[perms_user]", "data[tx_commerce_categories][' . $uid . '][perms_user]");
                 setCheck("check[perms_group]", "data[tx_commerce_categories][' . $uid . '][perms_group]");
                 setCheck("check[perms_everybody]", "data[tx_commerce_categories][' . $uid . '][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);
 }
Exemplo n.º 17
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 = CoreBackendUtility::getModTSconfig($this->pid, 'mod.commerce.category');
     if ($temp) {
         $moduleConfig = CoreBackendUtility::implodeTSParams($temp['properties']);
         $defaultTax = (int) $moduleConfig['defaultTaxValue'];
         if ($defaultTax > 0) {
             $articleData['tax'] = $defaultTax;
         }
     }
     $hookObject = \CommerceTeam\Commerce\Factory\HookFactory::getHook('Utility/ArticleCreatorUtility', 'createArticle');
     if (method_exists($hookObject, 'preinsert')) {
         $hookObject->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);
     $result = $database->exec_SELECTquery('*', 'tx_commerce_products', 'l18n_parent = ' . (int) $this->uid . ' AND deleted = 0');
     if ($database->sql_num_rows($result)) {
         // Only if there are products
         while ($localizedProducts = $database->sql_fetch_assoc($result)) {
             // walk thru and create articles
             $destLanguage = $localizedProducts['sys_language_uid'];
             // get the highest sorting
             $langIsoCode = CoreBackendUtility::getRecord('sys_language', (int) $destLanguage, 'static_lang_isocode');
             $langIdent = CoreBackendUtility::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;
 }