Project

General

Profile

Bug #19310 » browse_links_readonly_v5.diff

Administrator Admin, 2008-09-10 10:29

View differences:

t3lib/class.t3lib_foldertree.php (working copy)
switch($val['type']) {
case 'user': $icon = 'gfx/i/_icon_ftp_user.gif'; break;
case 'group': $icon = 'gfx/i/_icon_ftp_group.gif'; break;
case 'readonly': $icon = 'gfx/i/_icon_ftp_readonly.gif'; break;
default: $icon = 'gfx/i/_icon_ftp.gif'; break;
}
......
if ($isOpen) {
// Set depth:
$depthD='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' alt="" />';
$this->getFolderTree($val['path'],999,$depthD);
$this->getFolderTree($val['path'], 999, $depthD, $val['type']);
}
// Add tree:
......
* @return integer The count of items on the level
* @see getBrowsableTree()
*/
function getFolderTree($files_path, $depth=999, $depthData='') {
function getFolderTree($files_path, $depth=999, $depthData='', $type='') {
// This generates the directory tree
$dirs = t3lib_div::get_dirs($files_path);
......
$nextCount=$this->getFolderTree(
$path,
$depth-1,
$this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : ''
$this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : '',
$type
);
$exp=1; // Set "did expand" flag
} else {
......
if ($this->makeHTML) {
$HTML=$depthData.$this->PMicon($row,$a,$c,$nextCount,$exp);
$icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
$icon = 'gfx/i/_icon_' .$webpath . 'folders' . ($type == 'readonly' ? '_ro' : '') . '.gif';
if ($val=='_temp_') {
$icon = 'gfx/i/sysf.gif';
$row['title']='TEMP';
......
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']);
}
?>
?>
typo3/browse_links.php (working copy)
if ($altMountPoints) {
$GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
$GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
$browser_readOnly = true;
}
break;
case 'file':
case 'filedrag':
case 'folder':
// Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
// Setting additional read-only browsing file mounts
$altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
if ($altMountPoints) {
$altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
foreach($altMountPoints as $filePathRelativeToFileadmindir) {
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
}
$GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
$browser_readOnly = true;
}
break;
break;
}
......
// if type was not rendered use default rendering functions
if(!$browserRendered) {
$this->browser = t3lib_div::makeInstance('browse_links');
$this->browser->init();
if ($browser_readOnly) {
$this->browser->readOnly = true;
}
$modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
list($modData, $store) = $this->browser->processSessionData($modData);
$GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
// Output the correct content according to $this->mode
switch((string)$this->mode) {
case 'rte':
typo3/class.browse_links.php (working copy)
protected $hookObjects = array();
var $readOnly = FALSE; // If set, all operations that changes something should be disabled. This is used for alternativeBrowsing file mounts (see options like "options.folderTree.altElementBrowserMountPoints" in browse_links.php).
/**
* object for t3lib_basicFileFunctions
*/
public $fileProcessor;
/**
......
// the script to link to
$this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
// init fileProcessor
$this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
// CurrentUrl - the current link url must be passed around if it exists
if ($this->mode == 'wizard') {
$currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
......
$pArr = explode('|',$this->bparams);
// Create upload/create folder forms, if a path is given:
$fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
$path=$this->expandFolder;
if (!$path || !@is_dir($path)) {
$path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
$path = $this->fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
}
if ($path!='/' && @is_dir($path) && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
if ($path!='/' && @is_dir($path)) {
$uploadForm=$this->uploadForm($path);
$createFolder=$this->createFolder($path);
} else {
......
// Init variable:
$parameters = explode('|', $this->bparams);
// Create upload/create folder forms, if a path is given:
$fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$fileProcessor->init(
$GLOBALS['FILEMOUNTS'],
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']
);
$path = $this->expandFolder;
if(!$path || !@is_dir($path)) {
$path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
$path = $this->fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
}
if($path != '/' && @is_dir($path)) {
$createFolder = $this->createFolder($path);
......
// Add the HTML for the record list to output variable:
$out.=$dblist->HTMLcode;
// Add support for fieldselectbox in singleTableMode
// Add support for fieldselectbox in singleTableMode
if ($dblist->table) {
$out.= $dblist->fieldSelectBox($dblist->table);
}
......
return $out;
}
/**
/**
* Render list of folders.
*
* @param array List of folders. See t3lib_div::get_dirs
......
<td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
</tr>';
// Fraverse files:
// Fraverse files:
while(list(,$filepath)=each($files)) {
$fI = pathinfo($filepath);
......
* @return boolean If the input path is found in the backend users filemounts, then return true.
*/
function checkFolder($folder) {
$fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
return $this->fileProcessor->checkPathAgainstMounts(ereg_replace('\/$', '', $folder) . '/') ? true : false;
}
return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
/**
* Checks, if a path is within a read-only mountpoint of the backend user
*
* @param string Absolute filepath
* @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return true.
*/
function isReadOnlyFolder($folder) {
return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(ereg_replace('\/$', '', $folder) . '/')]['type'] == 'readonly');
}
/**
......
*/
function uploadForm($path) {
global $BACK_PATH;
if ($this->isReadOnlyFolder($path)) return '';
$count=3;
// Create header, showing upload path:
......
*/
function createFolder($path) {
global $BACK_PATH;
if ($this->isReadOnlyFolder($path)) return '';
// Create header, showing upload path:
$header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
$code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
typo3/class.filelistfoldertree.php (working copy)
switch($val['type']) {
case 'user': $icon = 'gfx/i/_icon_ftp_user.gif'; break;
case 'group': $icon = 'gfx/i/_icon_ftp_group.gif'; break;
case 'readonly': $icon = 'gfx/i/_icon_ftp_readonly.gif'; break;
default: $icon = 'gfx/i/_icon_ftp.gif'; break;
}
......
// If the mount is expanded, go down:
if ($isOpen)
$this->getFolderTree($val['path'], 999);
$this->getFolderTree($val['path'], 999, $val['type']);
// Add tree:
$treeArr = array_merge($treeArr, $this->tree);
......
* @return integer The count of items on the level
* @see getBrowsableTree()
*/
function getFolderTree($files_path, $depth=999) {
function getFolderTree($files_path, $depth=999, $type='') {
// This generates the directory tree
$dirs = t3lib_div::get_dirs($files_path);
......
$nextCount = $this->getFolderTree(
$path,
$depth-1,
$this->makeHTML ? '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($a == $c ? 'blank' : 'line').'.gif','width="18" height="16"').' alt="" />' : ''
$this->makeHTML ? '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($a == $c ? 'blank' : 'line').'.gif','width="18" height="16"').' alt="" />' : '',
$type
);
$exp = 1; // Set "did expand" flag
} else {
......
if ($this->makeHTML) {
$HTML = $this->PMicon($row,$a,$c,$nextCount,$exp);
$icon = 'gfx/i/_icon_'.t3lib_BEfunc::getPathType_web_nonweb($path).'folders.gif';
$icon = 'gfx/i/_icon_' .$webpath . 'folders' . ($type == 'readonly' ? '_ro' : '') . '.gif';
if ($val == '_temp_') {
$icon = 'gfx/i/sysf.gif';
$row['title']='TEMP';
typo3/sysext/rtehtmlarea/mod3/browse_links.php (working copy)
class tx_rtehtmlarea_SC_browse_links {
public $mode = 'rte';
public $button = 'link';
public $readOnly = false;
protected $content = '';
/**
......
if ($altMountPoints) {
$GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
$GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
$this->readOnly = true;
}
// Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
$altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
if ($altMountPoints) {
$altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
}
$GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
$this->readOnly = true;
}
// Render type by user function
$browserRendered = false;
......
$browserRenderObj = t3lib_div::getUserObj($classRef);
if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
if ($browserRenderObj->isValid($this->mode, $this)) {
$browserRenderObj->readOnly = $this->readOnly;
$this->content .= $browserRenderObj->render($this->mode, $this);
$browserRendered = true;
break;
......
// If type was not rendered, use default rendering functions
if (!$browserRendered) {
$GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
$GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
$GLOBALS['SOBE']->browser->init();
$modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php','ses');
list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php (working copy)
$this->initConfiguration();
$this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
// init fileProcessor
$this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
// CurrentUrl - the current link url must be passed around if it exists
$this->curUrlArray = t3lib_div::_GP('curUrl');
if ($this->curUrlArray['all']) {
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_dam_browse_links.php (working copy)
$this->mode='rte';
}
// init fileProcessor
$this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
// init hook objects:
$this->hookObjects = array();
if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
......
// Initializing the action value, possibly removing blinded values etc:
$this->allowedItems = explode(',','page,file,url,mail,spec,upload');
if ($this->isReadOnlyFolder(tx_dam::path_makeAbsolute($this->damSC->path))) {
$this->allowedItems = array_diff($this->allowedItems, array('upload')); //remuve upload if filemount is readonly
}
//call hook for extra options
foreach($this->hookObjects as $hookObject) {
$this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php (working copy)
$this->act='magic';
}
// init fileProcessor
$this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
$RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
$RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
$this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
......
global $TYPO3_CONF_VARS, $TYPO3_DB;
$filearray = array();
//
//
// Use the current selection to create a query and count selected records
//
......
}
return $filearray;
}
}
/**
* [Describe function...]
......
$path = tx_dam::path_makeAbsolute($this->damSC->path);
if (!$path OR !@is_dir($path)) {
$fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
$path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
$path = $this->fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
}
if ($this->isReadOnlyFolder($path)) {
$this->allowedItems = array_diff($this->allowedItems, array('upload')); //remuve upload if filemount is readonly
}
$this->damSC->path = tx_dam::path_makeRelative($path); // mabe not needed
// Starting content:
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php (working copy)
$this->initConfiguration();
$this->initHookObjects();
// init fileProcessor
$this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
$this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
$this->allowedItems = $this->getAllowedItems('dragdrop,magic,plain,image', $this->buttonConfig);
reset($this->allowedItems);
if (!in_array($this->act,$this->allowedItems)) {
......
<td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
</tr>';
// Fraverse files:
// Fraverse files:
while(list(,$filepath)=each($files)) {
$fI = pathinfo($filepath);
typo3/sysext/rtehtmlarea/mod4/select_image.php (working copy)
class tx_rtehtmlarea_SC_select_image {
public $mode = 'rte';
public $button = 'image';
public $readOnly = false;
protected $content = '';
/**
......
if ($altMountPoints) {
$altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
}
$GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
$this->readOnly = true;
}
// Rendering type by user function
$browserRendered = false;
......
$browserRenderObj = t3lib_div::getUserObj($classRef);
if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
if ($browserRenderObj->isValid($this->mode, $this)) {
$browserRenderObj->readOnly = $this->readOnly;
$this->content .= $browserRenderObj->render($this->mode, $this);
$browserRendered = true;
break;
......
// If type was not rendered, use default rendering functions
if (!$browserRendered) {
$GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_select_image');
$GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
$GLOBALS['SOBE']->browser->init();
$modData = $GLOBALS['BE_USER']->getModuleData('select_image.php','ses');
list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
(1-1/6)