/**
  * 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);
             }
         }
     }
 }