function writeTop($row) { global $LANG,$extraBEIcons,$Typo4,$Typo4_1; $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); // deleting all records in the same page $deleteAllRecords=t3lib_div::_GP('delete_record'); // the value is the name of a table, for example 'tt_address' if($deleteAllRecords) { $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($deleteAllRecords, 'deleted="0" AND pid="'.$this->id.'"', array('deleted' => 1)); // hook for handling relation tables if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords]) && is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['mm_'.$deleteAllRecords] as $classRef) { $hookObj= &t3lib_div::getUserObj($classRef); $hookName='mm_'.$deleteAllRecords; if (method_exists($hookObj,$hookName)) $hookObj->$hookName($this->id,$this->modTSconfig); } $hookObj=NULL;$hookName=NULL; } // special conditions if direct_mail has been installed in order to delete relations too (this could be put also using the previous mentioned hook) elseif($Typo4 && t3lib_extMgm::isLoaded('direct_mail')) { switch($deleteAllRecords) { CASE 'tt_address': $mm_table='sys_dmail_ttaddress_category_mm'; break; CASE 'tt_content': $mm_table='sys_dmail_ttcontent_category_mm'; break; CASE 'fe_users': $mm_table='sys_dmail_feuser_category_mm'; break; CASE 'sys_dmail_group': $mm_table='sys_dmail_group_mm'; break; } // if table has a mm table make extra queries if($mm_table) { $uidListLocal='-1'; // uid of tt_content record and related field in mm table $uidListForeign='-1'; // uid in category table and related field in mm table // delete relations for records in the main table (relates to the variable '$deleteAllRecords'), which has been marked as deleted in the current page if($this->modTSconfig['properties']['clearDeletedRelations']) { $query = array( 'SELECT' => 'uid', 'FROM' => $deleteAllRecords, 'WHERE' => 'deleted="1" AND pid="'.$this->id.'"', 'GROUPBY' => ''); $query = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query); while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)) { $uidListLocal .= ','.$row['uid']; } } // delete possible relations with unexisting items in the main table (lost relations to the table, which relates to the variable '$deleteAllRecords') and in the table 'sys_dmail_category' if($this->modTSconfig['properties']['deleteLostRelations']) { // check that uid_local has related row in the main table $MinItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MIN(uid_local)',$mm_table,'','', '', ''); $MinItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MinItem); $MinItem=$MinItem[0]; $MaxItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MAX(uid_local)',$mm_table,'','', '', ''); $MaxItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MaxItem); $MaxItem=$MaxItem[0]; $query = array( 'SELECT' => 'uid_local', 'FROM' => $mm_table, 'WHERE' => '', 'GROUPBY' => ''); $query = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query); // create an array of existing records in the mm table while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)) { $existMM[intval($row['uid_local'])]=true; } if($existMM) { for($i=$MinItem;$i<=$MaxItem;$i++) { if($existMM[$i] && !($this->modTSconfig['properties']['keepZeroValues'] && $i===0)) { // check only records, which are in the mm table, if they have correcponding record in the main table - keeping zero values relates with some functionality test $exists=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(uid)',$deleteAllRecords,'uid="'.$i.'"','', '', ''); $exists=$GLOBALS['TYPO3_DB']->sql_fetch_row($exists); $exists=$exists[0]; if(!$exists) $uidListLocal .= ','.$i; } } } // check that uid_foreing has related row in the 'sys_dmail_category' table $i=$MinItem=$MaxItem=$existMM=NULL; // reset variables $MinItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MIN(uid_foreign)',$mm_table,'','', '', ''); $MinItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MinItem); $MinItem=$MinItem[0]; $MaxItem=$GLOBALS['TYPO3_DB']->exec_SELECTquery('MAX(uid_foreign)',$mm_table,'','', '', ''); $MaxItem=$GLOBALS['TYPO3_DB']->sql_fetch_row($MaxItem); $MaxItem=$MaxItem[0]; $query = array( 'SELECT' => 'uid_foreign', 'FROM' => $mm_table, 'WHERE' => '', 'GROUPBY' => ''); $query = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query); // create an array of existing records in the mm table while($rowCat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)) { $existMM[intval($rowCat['uid_foreign'])]=true; } if($existMM) { for($i=$MinItem;$i<=$MaxItem;$i++) { if($existMM[$i] && !($this->modTSconfig['properties']['keepZeroValues'] && $i===0)) { // check only records, which are in the mm table, if they have if they have correcponding record in the table 'sys_dmail_category' - keeping zero values relates with some functionality test $existsForeign=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(uid)','sys_dmail_category','uid="'.$i.'"','', '', ''); $existsForeign=$GLOBALS['TYPO3_DB']->sql_fetch_row($existsForeign); $existsForeign=$existsForeign[0]; if(!$existsForeign) $uidListForeign .= ','.$i; } } } } // actual delete statement if($this->modTSconfig['properties']['clearDeletedRelations'] || $this->modTSconfig['properties']['deleteLostRelations']) $GLOBALS['TYPO3_DB']->exec_DELETEquery($mm_table,'uid_local IN ('.$uidListLocal.') OR uid_foreign IN ('.$uidListForeign.')'); } } }