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();
         }
     }
 }
Beispiel #2
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;
 }