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) { $uidList='0'; // 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)) { $uidList .= ','.$row['uid']; } } // delete possible relations with unexisting items in the main table (lost relations to the table, which relates to the variable '$deleteAllRecords') if($this->modTSconfig['properties']['deleteLostRelations']) { $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 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]) { // check only records, which are in mm table if they have correcponding record in the main table $exists=$GLOBALS['TYPO3_DB']->exec_SELECTquery('count(uid)',$deleteAllRecords,'uid="'.$i.'"','', '', ''); $exists=$GLOBALS['TYPO3_DB']->sql_fetch_row($exists); $exists=$exists[0]; if(!$exists) $uidList .= ','.$i; } } } } // actual delete statement if($this->modTSconfig['properties']['clearDeletedRelations'] || $this->modTSconfig['properties']['deleteLostRelations']) $GLOBALS['TYPO3_DB']->exec_DELETEquery($mm_table,'uid_local IN ('.$uidList.') OR uid_foreign=0'); } } }