Beispiel #1
0
 /**
  * Processes uploads
  *
  * @param mixed $file            
  * @return void
  */
 public function createAction(Tx_Feupload_Domain_Model_File $file)
 {
     $ffunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
     $path = $ffunc->getUniqueName($_FILES['tx_feupload_upload']['name']['file']['file'], t3lib_div::getFileAbsFileName('uploads/feupload/'));
     t3lib_div::upload_copy_move($_FILES['tx_feupload_upload']['tmp_name']['file']['file'], $path);
     $file->setFile(basename($path));
     if ($GLOBALS['TSFE']->fe_user->user) {
         // This is because $GLOBALS['TSFE']->fe_user is of type
         // tslib_feUserAuth
         // and $GLOBALS['TSFE']->fe_user->user is an array.
         $owner = $this->frontendUserRepository->findByUid($GLOBALS["TSFE"]->fe_user->user['uid']);
         $file->setOwner($owner);
     }
     $visibility = $_POST['tx_feupload_upload']['visibility'];
     $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['feupload']);
     $defaultVisibility = $extConf['defaultFileVisibility'];
     // globalVisibilty set? ignore user preference
     if (!empty($defaultVisibility) and in_array($defaultVisibility, array('public', 'login', 'groups'))) {
         $visibility = $defaultVisibility;
     }
     switch ($visibility) {
         case 'public':
             $file->setVisibility(0);
             break;
         case 'login':
             $file->setVisibility(-2);
             break;
         case 'groups':
             $file->setVisibility(1);
             foreach ($_POST['tx_feupload_upload']['groups'] as $groupId) {
                 $group = $this->frontendUserGroupRepository->findByUid($groupId);
                 if ($group) {
                     $file->addFrontendUserGroup($group);
                 }
             }
             break;
     }
     if ((bool) $this->userTS['appendGroups']) {
         $groupIds = explode(',', $this->userTS['appendGroups']);
         foreach ($groupIds as $groupId) {
             $group = $this->frontendUserGroupRepository->findByUid($groupId);
             if ($group) {
                 $file->addFrontendUserGroup($group);
             }
         }
     }
     /* @var $sessionHandler Tx_Feupload_Session_Folder */
     $sessionHandler = t3lib_div::makeInstance('Tx_Feupload_Session_Folder');
     $file->setFolder($sessionHandler->getCurrentFolder());
     $this->fileRepository->add($file);
     $this->flashMessageContainer->add(Tx_Extbase_Utility_Localization::translate('LLL:EXT:feupload/Resources/Private/Language/locallang.xml:flash.ok.file.uploaded.content'), Tx_Extbase_Utility_Localization::translate('LLL:EXT:feupload/Resources/Private/Language/locallang.xml:flash.ok.file.uploaded.title'), t3lib_FlashMessage::OK);
     $this->redirect('new');
 }