Beispiel #1
0
 /**
  * After database product handling.
  *
  * @param string $status Status
  * @param string $table Table
  * @param string|int $id Id
  * @param array $fieldArray Field array
  * @param DataHandler $pObj Parent object
  *
  * @return void
  */
 protected function afterDatabaseProduct($status, $table, $id, array $fieldArray, DataHandler $pObj)
 {
     // if fieldArray has been unset, do not save anything, but load dynaflex config
     if (!empty($fieldArray)) {
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $id);
         $product->loadData();
         if (isset($fieldArray['categories'])) {
             $catList = $this->belib->getUidListFromList(explode(',', $fieldArray['categories']));
             $catList = $this->belib->extractFieldArray($catList, 'uid_foreign', true);
             // get id of the live placeholder instead if such exists
             $relId = $status != 'new' && $product->getPid() == '-1' ? $product->getT3verOid() : $id;
             $this->belib->saveRelations($relId, $catList, 'tx_commerce_products_categories_mm', true, false);
         }
         // if the live shadow is saved, the product relations have to be saved
         // to the versioned version
         if ($status == 'new' && $fieldArray['pid'] == '-1') {
             ++$id;
         }
         $this->saveProductRelations($id, $fieldArray);
     }
     // sometimes the array is unset because only the checkbox "create new article"
     // has been checked if that is the case and we have the rights, create the
     // articles so we check if the product is already created and if we have edit
     // rights on it
     if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
         // check permissions
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $id);
         $parentCategories = $product->getParentCategories();
         // check existing categories
         if (!\CommerceTeam\Commerce\Utility\BackendUtility::checkPermissionsOnCategoryContent($parentCategories, array('editcontent'))) {
             $pObj->newlog('You dont have the permissions to create a new article.', 1);
         } else {
             // init the article creator
             /**
              * Article creator.
              *
              * @var \CommerceTeam\Commerce\Utility\ArticleCreatorUtility $articleCreator
              */
             $articleCreator = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Utility\\ArticleCreatorUtility');
             $articleCreator->init($id, $this->belib->getProductFolderUid());
             $datamap = $pObj->datamap[$table][$this->unsubstitutedId ? $this->unsubstitutedId : $id];
             if (is_array($datamap) && !empty($datamap)) {
                 // create new articles
                 $articleCreator->createArticles($datamap);
             }
             // update articles if new attributes were added
             $articleCreator->updateArticles();
         }
     }
 }
 /**
  * Proprocess article.
  *
  * @param string $command Command
  * @param int $articleUid Article uid
  *
  * @return void
  */
 protected function preProcessArticle(&$command, &$articleUid)
 {
     if ($command == 'localize') {
         $command = '';
         $this->error('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:article.localization');
     } elseif ($command == 'delete') {
         /**
          * Article.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Article $article
          */
         $article = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Article', $articleUid);
         $article->loadData();
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = $article->getParentProduct();
         // check if product or if translated the translation parent category
         if (!current($product->getParentCategories())) {
             $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $product->getL18nParent());
         }
         if (!\CommerceTeam\Commerce\Utility\BackendUtility::checkPermissionsOnCategoryContent($product->getParentCategories(), array('editcontent'))) {
             // Log the error
             $this->pObj->log('tx_commerce_articles', $articleUid, 3, 0, 1, 'Attempt to ' . $command . ' record without ' . $command . '-permissions');
             // Set id to 0 (reference!) to prevent delete of the record
             $articleUid = 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;
 }