/** * 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 (count($fieldArray)) { /** * Product * * @var Tx_Commerce_Domain_Model_Product $product */ $product = GeneralUtility::makeInstance('Tx_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 Tx_Commerce_Domain_Model_Product $product */ $product = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $id); $parentCategories = $product->getParentCategories(); // check existing categories if (!Tx_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 Tx_Commerce_Utility_ArticleCreatorUtility $articleCreator */ $articleCreator = GeneralUtility::makeInstance('Tx_Commerce_Utility_ArticleCreatorUtility'); $articleCreator->init($id, $this->belib->getProductFolderUid()); // create new articles $articleCreator->createArticles($pObj->datamap[$table][$this->unsubstitutedId ? $this->unsubstitutedId : $id]); // update articles if new attributes were added $articleCreator->updateArticles(); } } }
/** * 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; }