/** * * @param array $params * @param object $ref */ public function checkFullLanguagesAccess($params, $ref) { if (isset($params['recordLocalizationAccess']) && $params['recordLocalizationAccess']) { // so far the user had access to all existing overlay-languages return tx_languagevisibility_beservices::hasUserAccessToEditRecord($params['table'], $params['row']['uid']); } else { return $params['recordLocalizationAccess']; } }
/** * This methid is used to generate an infostructur array, which will be * renderd as a Form * * @param tx_languagevisibility_element $changeableElement * @param array $languageList * @param string $itemFormElName * @param boolean $isOverlay * @return unknown */ function _getLanguageInfoStructurListForElementAndLanguageList($changeableElement, $languageList, $itemFormElName, $isOverlay) { $visibility = t3lib_div::makeInstance('tx_languagevisibility_visibilityService'); $infosStruct = array(); foreach ($languageList as $language) { $infoitem = array('visible' => $visibility->isVisible($language, $changeableElement), 'languageTitle' => $language->getTitle($this->pageId), 'languageFlag' => $language->getFlagImg($this->pageId), 'hasTranslation' => $changeableElement->hasTranslation($language->getUid()), 'isTranslation' => $isOverlay, 'isVisible' => $visibility->isVisible($language, $changeableElement), 'visibilityDescription' => $visibility->getVisibilityDescription($language, $changeableElement)); //if there is no access to language - and localsettings exist, then do not show select box //this is to not be able as an translator to override languagesetting $currentSetting = $changeableElement->getLocalVisibilitySetting($language->getUid()); $currentOptionsForUserAndLanguage = tx_languagevisibility_beservices::getAvailableOptionsForLanguage($language, $isOverlay, $changeableElement); if ($currentSetting == '' || isset($currentOptionsForUserAndLanguage[$currentSetting])) { if ($isOverlay) { $defaultSelect = $changeableElement->getVisibilitySettingStoredInOverlayRecord($language->getUid()); $visibilityValue = $changeableElement->getVisibilitySettingStoredInDefaultRecord($language->getUid()); $visibilityString = $currentOptionsForUserAndLanguage[$visibilityValue]; } else { $defaultSelect = $changeableElement->getVisibilitySettingStoredInDefaultRecord($language->getUid()); $visibilityValue = $changeableElement->getVisibilitySettingStoredInOverlayRecord($language->getUid()); $visibilityString = $currentOptionsForUserAndLanguage[$visibilityValue]; } if ($this->isNewElement && $defaultSelect == '') { if ($this->modTSconfig['language.'][$language->getUid() . '.']['defaultVisibilityOnCreate'] != '') { $defaultSelect = $this->modTSconfig['language.'][$language->getUid() . '.']['defaultVisibilityOnCreate']; } } $selectBox = $this->_getSelectBox($language->getUid(), $currentOptionsForUserAndLanguage, $defaultSelect, $itemFormElName); } else { $selectBox = '<input type="hidden" name="' . $itemFormElName . '[' . $language->getUid() . ']" value="' . $currentSetting . '" ></input>(' . $currentSetting . ')'; } if ($isOverlay) { $infoitem['overlayVisibility'] = $selectBox; $infoitem['originalVisibility'] = $visibilityString; } else { $infoitem['overlayVisibility'] = $visibilityString; $infoitem['originalVisibility'] = $selectBox; } $infosStruct[] = $infoitem; } return $infosStruct; }
/** * This method is used to initialize new Elements with the default * * @param unknown_type $status * @param unknown_type $table * @param unknown_type $id * @param unknown_type $fieldArray * @param unknown_type $reference */ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, &$reference) { if (in_array($table, tx_languagevisibility_visibilityService::getSupportedTables())) { /** * Now we set the default visibility for elements which did not get a defaultvisibility array. * This can happen, if a user creates a new element AND the user has no access for the languagevisibility_field */ if ($status == 'new') { $row['uid'] = $reference->substNEWwithIDs[$id]; if ($fieldArray['pid'] == '-1') { $row = t3lib_BEfunc::getWorkspaceVersionOfRecord($fieldArray['t3ver_wsid'], $table, $row['uid'], $fields = '*'); } require_once t3lib_extMgm::extPath("languagevisibility") . 'class.tx_languagevisibility_beservices.php'; $newdata = array('tx_languagevisibility_visibility' => serialize(tx_languagevisibility_beservices::getDefaultVisibilityArray())); $where = "tx_languagevisibility_visibility = '' AND uid=" . $row['uid']; $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $where, $newdata); } tx_languagevisibility_cacheManager::getInstance()->flushAllCaches(); } }
/** * Simple test with a tt_content element and a translation. * The beService should return true, because an translation for * the element exists. * * @param void * @return void * @author Timo Schmidt <*****@*****.**> * @test */ public function canDetectTranslationsInAnyLanguage() { $this->importDataSet(dirname(__FILE__) . '/fixtures/canDetectTranslationsInAnyLanguage.xml'); $hasTranslation = tx_languagevisibility_beservices::hasTranslationInAnyLanguage(1, 'tt_content'); $this->assertTrue($hasTranslation, 'Determined no translations for a translated element'); }
/** * This method is used to create an visibility array with the default settings * for all languages. * * @return array */ public static function getDefaultVisibilityArray() { /* @var $languageRep tx_languagevisibility_languagerepository */ $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository'); $languageList = $languageRep->getLanguages(); $default = array(); foreach ($languageList as $language) { $options = tx_languagevisibility_beservices::getAvailableOptionsForLanguage($language); $default[$language->getUid()] = array_shift(array_keys($options)); } return $default; }
/** * This method is used to extend the tce_main process_cmdmap function. It provides the functionallity to * disallow users to move, cut or copy any element which has an overlay. Moving and Cutting of elements * with overlays is dangerous because the extisting overlays may also need to be moved. * * */ function process_cmdmap() { if (t3lib_extMgm::isLoaded('languagevisibility') && $this->isCutCopyAndMoveObservationEnabled()) { require_once t3lib_extMgm::extPath("languagevisibility") . 'patch/lib/class.tx_languagevisibility_commandMap.php'; //user has no rights to cut move copy or delete, therefore the commands need to be filtered $command_map = t3lib_div::makeInstance('tx_languagevisibility_commandMap'); $command_map->setMap($this->cmdmap); $command_elements = $command_map->getElementsByCommands(array('cut', 'move', 'copy', 'delete')); if (is_array($command_elements)) { foreach ($command_elements as $command_element) { try { //get row $table = $command_element['table']; $uid = $command_element['uid']; $row = tx_languagevisibility_daocommon::getRecord($uid, $table); $command = $command_element['cmd']; if (tx_languagevisibility_beservices::isOverlayRecord($row, $table)) { //current element is an overlay -> restrict cut copy and move in general -> filter the command map if (($command == 'move' || $command == 'cut' || $command == 'copy') && $this->isCutCopyAndMoveRestrictedForOverlays()) { $this->newlog('The command ' . $command . ' can not be applied on overlays', 1); //overlay records should no be move,copy or cutable but it should be possible to delete them //therefore we remove all elements which have the comment cut, copy or move $command_map->removeElement($command_element); } } else { //current element is no overlay if (!tx_languagevisibility_beservices::canCurrrentUserCutCopyMoveDelete()) { //if the record has any translation disallow move, cut, copy and delete $elementObj = tx_languagevisibility_beservices::getElement($uid, $table); if ($elementObj->hasAnyTranslationInAnyWorkspace()) { $command_map->removeElement($command_element); $this->newlog('You have no rights to apply the command ' . $command . ' on elements with overlays', 1); } } } } catch (Exception $e) { //element not supported by language visibility } } } //overwrite the internal map an process the base tce_main method $this->cmdmap = $command_map->getMap(); } //process parent method to use basic functionallity parent::process_cmdmap(); }