function damify($sAbsPath) { if ($this->useDam()) { global $PAGES_TYPES; if (!isset($PAGES_TYPES)) { require_once PATH_t3lib . 'stddb/tables.php'; } $bSimulatedUser = FALSE; global $BE_USER; // Simulate a be user to allow DAM to write in DB // see http://lists.typo3.org/pipermail/typo3-project-dam/2009-October/002751.html // and http://lists.netfielders.de/pipermail/typo3-project-dam/2006-August/000481.html if (!isset($BE_USER) || !is_object($BE_USER) || intval($GLOBALS["BE_USER"]->user["uid"]) === 0) { // no be_user available // we are using the one created for formidable+dam, named _formidable+dam $rSql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery("uid", "be_users", "LOWER(username)='_formidable+dam'"); if (($aRs = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($rSql)) !== FALSE) { // we found user _formidable+dam // simulating user unset($BE_USER); $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth'); $BE_USER->OS = TYPO3_OS; $BE_USER->setBeUserByUid($aRs["uid"]); $BE_USER->fetchGroupData(); $BE_USER->backendSetUC(); $GLOBALS['BE_USER'] = $BE_USER; $bSimulatedUser = TRUE; } else { $this->oForm->mayday("renderlet:UPLOAD[name=" . $this->_getName() . "] /dam/use is enabled; for DAM to operate properly, you have to create a backend-user named '_formidable+dam' with permissions on dam tables"); } } $mBefore = intval($GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"]); $GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"] = 1; tx_dam::notify_fileChanged($sAbsPath); // previous line don't work anymore for some obscure reason. // Error seems to be in tx_dam::index_autoProcess() // at line 1332 while checking config value of setup.indexing.auto // EDIT: works now, http://lists.typo3.org/pipermail/typo3-project-dam/2009-October/002749.html // EDIT2: temporarily forcing setup.indexing.auto to be active seems to be the best solution when writing this $GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"] = $mBefore; if ($bSimulatedUser === TRUE) { unset($BE_USER); unset($GLOBALS["BE_USER"]); } $oMedia = tx_dam::media_getForFile($sAbsPath); return $oMedia->meta["uid"]; } return basename($sAbsPath); }