示例#1
0
 /**
  * Calculate product rights
  *
  * @param int $uid Uid
  * @param array $rights Rights
  *
  * @return array
  */
 protected function calculateProductRights($uid, array $rights)
 {
     $backendUser = $this->getBackendUser();
     // get all parent categories
     /**
      * Product
      *
      * @var Tx_Commerce_Domain_Model_Product $product
      */
     $product = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Product', $uid);
     $parentCategories = $product->getParentCategories();
     // store the rights in the flags
     $rights['delete'] = Tx_Commerce_Utility_BackendUtility::checkPermissionsOnCategoryContent($parentCategories, array('editcontent'));
     $rights['edit'] = $rights['delete'];
     $rights['new'] = $rights['delete'];
     $rights['copy'] = $this->rec['t3ver_state'] == 0 && $this->rec['sys_language_uid'] == 0;
     $rights['paste'] = $rights['overwrite'] = $this->rec['t3ver_state'] == 0 && $rights['delete'];
     // make sure we do not allowed to overwrite a product with itself
     if (count($this->clipObj->elFromTable('tx_commerce_products'))) {
         $set = 0;
         if ($this->clipObj->clipData[$this->clipObj->current]['el']['tx_commerce_products|' . $uid . '|' . $this->additionalParameter['category']]) {
             $set = 1;
             $this->clipObj->clipData[$this->clipObj->current]['el']['tx_commerce_products|' . $uid] = 1;
         }
         $clipRecord = $this->clipObj->getSelectedRecord();
         $rights['overwrite'] = $uid != $clipRecord['uid'] ? FALSE : $rights['overwrite'];
         if ($set) {
             unset($this->clipObj->clipData[$this->clipObj->current]['el']['tx_commerce_products|' . $uid]);
         }
     }
     $rights['version'] = $backendUser->check('modules', 'web_txversionM1') && ExtensionManagementUtility::isLoaded('version');
     $rights['review'] = $rights['version'] && $this->rec['t3ver_oid'] != 0 && ($this->rec['t3ver_stage'] == 0 || $this->rec['t3ver_stage'] == 1);
     return $rights;
 }
示例#2
0
 /**
  * Executing the posted actions ...
  *
  * @return void
  */
 public function main()
 {
     $backendUser = $this->getBackendUser();
     // Checking referer / executing
     $refInfo = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_REFERER'));
     $httpHost = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
     if ($httpHost != $refInfo['host'] && $this->vC != $backendUser->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
         // writelog($type, $action, $error, $details_nr, $details,
         // $data, $tablename, $recuid, $recpid)
         $backendUser->writelog(1, 2, 3, 0, 'Referer host "%s" and server host "%s" did not match and veriCode was not valid either!', array($refInfo['host'], $httpHost));
     } else {
         // get current item in clipboard
         $item = $this->clipObj->getSelectedRecord();
         $uidClip = $item['uid'];
         $uidTarget = 0;
         // check which command we actually want to execute
         $command = '';
         if (isset($this->CB['overwrite'])) {
             // overwrite a product
             $command = 'overwrite';
             $uidTarget = current(array_slice(explode('|', $this->CB['overwrite']), 1, 1));
         } elseif (isset($this->CB['paste'])) {
             // paste either a product into a category or a category into a category
             $command = $this->clipObj->getSelectedRecord('tx_commerce_categories', $uidClip) == NULL ? 'pasteProduct' : 'pasteCategory';
             $uidTarget = current(array_slice(explode('|', $this->CB['paste']), 1, 1));
         }
         if ($this->cmd == NULL) {
             // locale and sorting position haven't been chosen yet
             $this->showCopyWizard($uidClip, $uidTarget, $command);
         } else {
             $this->commitCommand($uidClip, $uidTarget, $command);
         }
     }
 }