/** * 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(); } } }
/** * 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; }
/** * 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; } }