Index: mod1/class.tx_templavoila_mod1_wizards.php =================================================================== --- mod1/class.tx_templavoila_mod1_wizards.php (revision 27850) +++ mod1/class.tx_templavoila_mod1_wizards.php (working copy) @@ -59,7 +59,7 @@ * @package TYPO3 * @subpackage tx_templavoila */ - + require_once(PATH_t3lib.'class.t3lib_tceforms.php'); class tx_templavoila_mod1_wizards { @@ -253,6 +253,9 @@ $storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid); $tmplHTML = array(); + $disallowedPageTemplateItems = $this->getDisallowedTSconfigItemsByFieldName ($positionPid, 'tx_templavoila_ds'); + $disallowedDesignTemplateItems = $this->getDisallowedTSconfigItemsByFieldName ($positionPid, 'tx_templavoila_to'); + switch ($templateType) { case 'tmplobj': // Create the "Default template" entry @@ -265,12 +268,17 @@ $tTO = 'tx_templavoila_tmplobj'; $tDS = 'tx_templavoila_datastructure'; - $where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . - intval($storageFolderPID).' AND ' . $tDS . '.scope=1' . - $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . - t3lib_befunc::deleteClause ($tTO).t3lib_befunc::deleteClause ($tDS). - t3lib_BEfunc::versioningPlaceholderClause($tTO).t3lib_BEfunc::versioningPlaceholderClause($tDS); - + $where = $tTO . '.parent=0 AND ' . + $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . + ( $disallowedDesignTemplateItems ? $tTO . '.uid NOT IN(' . $disallowedDesignTemplateItems . ') AND ' : '' ) . + ( $disallowedPageTemplateItems ? $tDS . '.uid NOT IN(' . $disallowedPageTemplateItems . ') AND ' : '' ) . + $tDS . '.scope=1 ' . + $this->buildRecordWhere ($tTO) . + $this->buildRecordWhere ($tDS) . + t3lib_befunc::deleteClause ($tTO) . + t3lib_befunc::deleteClause ($tDS) . + t3lib_BEfunc::versioningPlaceholderClause($tTO) . + t3lib_BEfunc::versioningPlaceholderClause($tDS); $res = $TYPO3_DB->exec_SELECTquery ( $tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', @@ -385,7 +393,7 @@ $tce = t3lib_div::makeInstance('t3lib_TCEmain'); // set default TCA values specific for the page and user - $TCAdefaultOverride = t3lib_BEfunc::getModTSconfig($positionPid , 'TCAdefaults'); + $TCAdefaultOverride = t3lib_BEfunc::getModTSconfig($positionPid , 'TCAdefaults'); if (is_array($TCAdefaultOverride)) { $tce->setDefaultsFromUserTS($TCAdefaultOverride); @@ -414,7 +422,7 @@ /** * Create sql condition for given table to limit records according to user access. - * + * * @param string $table Table nme to fetch records from * @return string Condition or empty string */ @@ -425,7 +433,7 @@ foreach($GLOBALS['BE_USER']->userGroups as $group) { $items = t3lib_div::trimExplode(',', $group['tx_templavoila_access'], 1); foreach ($items as $ref) { - if (strstr($ref, $table)) { + if (strstr($ref, $table)) { $result[] = intval(substr($ref, $prefLen)); } } @@ -433,6 +441,32 @@ } return (count($result) > 0 ? ' AND ' . $table . '.uid NOT IN (' . implode(',', $result) . ') ' : ''); } + + + /** + * Extract the disallowed TCAFORM field values of $fieldName given field + * + * @param integer $parentPageId + * @param string field name of TCAFORM + * @access private + * @return string comma seperated list of integer + */ + function getDisallowedTSconfigItemsByFieldName($parentPageId, $fieldName) { + + $disallowPageTemplateItems = ''; + $disallowPageTemplateList = array(); + + // Get PageTSconfig for reduce the output of selectded template structs + $disallowPageTemplateStruct = t3lib_BEfunc::getModTSconfig(abs($parentPageId), 'TCEFORM.pages.' . $fieldName); + + if ( isset($disallowPageTemplateStruct['properties']['removeItems']) ) { + $disallowedPageTemplateList = $disallowPageTemplateStruct['properties']['removeItems']; + } + + $tmp_disallowedPageTemplateItems = array_unique(t3lib_div::intExplode(',', t3lib_div::expandList($disallowedPageTemplateList), TRUE)); + + return ( count($tmp_disallowedPageTemplateItems) ) ? implode(',', $tmp_disallowedPageTemplateItems) : '0'; + } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/templavoila/mod1/class.tx_templavoila_mod1_wizards.php']) {