Commit ff63d94c authored by Georg Ringer's avatar Georg Ringer
Browse files

[BUGFIX] Enable BE search for multiple mountpoints

Backend search now allows search from all mounts of an editor.
If the root page is selected it will search in all mounts of the
backend user.

Change-Id: Ic462725bb4cba8100c5eeca5f7f47b5711ab2869
Resolves: #35073
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/23895
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
parent eb5febfe
......@@ -492,7 +492,6 @@ class BackendController {
'width' => 600,
'height' => 400
),
'firstWebmountPid' => intval($GLOBALS['WEBMOUNTS'][0])
);
$this->js .= '
TYPO3.configuration = ' . json_encode($t3Configuration) . ';
......
......@@ -179,8 +179,7 @@ TYPO3.BackendLiveSearch = Ext.extend(Ext.form.ComboBox, {
scope : this,
click : function () {
// go to db_list.php and search for given search value
// @todo the current selected page ID from the page tree is required, also we need the
// values of $GLOBALS['BE_USER']->returnWebmounts() to search only during the allowed pages
// @todo the current selected page ID from the page tree is required
TYPO3.ModuleMenu.App.showModule('web_list', this.getSearchResultsUrl(this.getValue()));
this.collapse();
}
......@@ -319,8 +318,7 @@ Ext.onReady(function() {
helpTitle: TYPO3.LLL.liveSearch.helpTitle,
emptyText: TYPO3.LLL.liveSearch.emptyText,
loadingText: TYPO3.LLL.liveSearch.loadingText,
listEmptyText: TYPO3.LLL.liveSearch.listEmptyText,
searchResultsPid: TYPO3.configuration.firstWebmountPid
listEmptyText: TYPO3.LLL.liveSearch.listEmptyText
});
TYPO3LiveSearch.applyToMarkup(Ext.get('live-search-box'));
......
......@@ -182,12 +182,12 @@ class RecordList {
$this->MCONF = $GLOBALS['MCONF'];
$this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
// GPvars:
$this->id = (int) GeneralUtility::_GP('id');
$this->id = (int)GeneralUtility::_GP('id');
$this->pointer = GeneralUtility::_GP('pointer');
$this->imagemode = GeneralUtility::_GP('imagemode');
$this->table = GeneralUtility::_GP('table');
$this->search_field = GeneralUtility::_GP('search_field');
$this->search_levels = GeneralUtility::_GP('search_levels');
$this->search_levels = (int)GeneralUtility::_GP('search_levels');
$this->showLimit = GeneralUtility::_GP('showLimit');
$this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
$this->clear_cache = GeneralUtility::_GP('clear_cache');
......@@ -317,8 +317,8 @@ class RecordList {
// This flag will prevent the clipboard panel in being shown.
// It is set, if the clickmenu-layer is active AND the extended view is not enabled.
$dblist->dontShowClipControlPanels = $GLOBALS['CLIENT']['FORMSTYLE'] && !$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers'];
// If there is access to the page, then render the list contents and set up the document template object:
if ($access) {
// If there is access to the page or root page is used for searching, then render the list contents and set up the document template object:
if ($access || ($this->id === 0 && $this->search_levels > 0 && strlen($this->search_field) > 0)) {
// Deleting records...:
// Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table.
if ($this->cmd == 'delete') {
......
......@@ -361,8 +361,8 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
}
}
if ($searchLevels > 0) {
$tree = $this->getTreeObject($this->id, $searchLevels, $this->perms_clause);
$pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($tree->ids));
$allowedMounts = $this->getSearchableWebmounts($this->id, $searchLevels, $this->perms_clause);
$pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($allowedMounts));
$this->pidSelect = 'pid IN (' . $pidList . ')';
} elseif ($searchLevels < 0) {
// Search everywhere
......@@ -933,8 +933,10 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
* @param string $perms_clause Select clause
* @return \TYPO3\CMS\Backend\Tree\View\PageTreeView instance with created list of ids.
* @todo Define visibility
* @deprecated Deprecated since 6.2, will be removed 2 versions later
*/
public function getTreeObject($id, $depth, $perms_clause) {
GeneralUtility::logDeprecatedFunction();
$tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
$tree->init('AND ' . $perms_clause);
$tree->makeHTML = 0;
......@@ -946,6 +948,37 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
return $tree;
}
/**
* Get all allowed mount pages to be searched in.
*
* @param integer $id Page id
* @param integer $depth Depth to go down
* @param string $perms_clause select clause
* @return array
*/
protected function getSearchableWebmounts($id, $depth, $perms_clause) {
/** @var \TYPO3\CMS\Backend\Tree\View\PageTreeView $tree */
$tree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
$tree->init('AND ' . $perms_clause);
$tree->makeHTML = 0;
$tree->fieldArray = array('uid', 'php_tree_stop');
$idList = array();
$allowedMounts = !$GLOBALS['BE_USER']->isAdmin() && $id === 0
? $GLOBALS['BE_USER']->returnWebmounts()
: array($id);
foreach ($allowedMounts as $allowedMount) {
$idList[] = $allowedMount;
if ($depth) {
$tree->getTree($allowedMount, $depth, '');
}
$idList = array_merge($idList, $tree->ids);
}
return $idList;
}
/**
* Redirects to TCEforms (alt_doc) if a record is just localized.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment