/** * Move lost DAM records to the DAM sysfolder. * This is a maintance function. * * @param integer $pid If set this PID will be used as storage sysfolder for the lost folder. * @param boolean $forceAll If true (default) all DAM records will be moved not only the ony with pid=0. * @return void */ function collectLostRecords($pid = NULL, $forceAll = true) { $pid = $pid ? $pid : tx_dam_db::getPid(); if ($pid) { $mediaTables = tx_dam::register_getEntries('mediaTable'); $values = array('pid' => $pid); if ($forceAll) { foreach ($mediaTables as $table) { $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid NOT IN (' . tx_dam_sysfolder::getPidList() . ')', $values); } } else { foreach ($mediaTables as $table) { $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid=0', $values); } } } }
/** * Returns a single pid of a DAM folder. * This pid have to be used for storage of DAM records. * * For fetching data getPidList() have to be used. * * @return integer Current/default DAM folder pid for storage. */ function getPid() { global $TYPO3_CONF_VARS; static $pid = 0; if (!$pid and is_object($GLOBALS['TSFE'])) { // get pid from TS // // plugin.tx_dam.defaults { // // The pid of the media folder. Needs to be set when multiple media folders exist // pid = $pid = intval(tx_dam::config_getValue('plugin.defaults.pid')); # $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_dam.']['defaults.']['pid']); } if (!$pid) { require_once PATH_txdam . 'lib/class.tx_dam_sysfolder.php'; $pid = tx_dam_sysfolder::init(); } return $pid; }