diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2007-06-16 16:45:57 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2007-06-16 16:45:57 +0000 |
| commit | 6679a4cb389e621ac0fd907345ee2a01897ea045 (patch) | |
| tree | ca384f12e60805bde20d1394d1e823edf1147d88 /plugins | |
| parent | cbf8a70a8af7169cbdf8e0bc7eef77cca64622a0 (diff) | |
| download | liberty-6679a4cb389e621ac0fd907345ee2a01897ea045.tar.gz liberty-6679a4cb389e621ac0fd907345ee2a01897ea045.tar.bz2 liberty-6679a4cb389e621ac0fd907345ee2a01897ea045.zip | |
finally fix the friggin image replacement bug
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/storage.bitfile.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/storage.bitfile.php b/plugins/storage.bitfile.php index ac2df07..ee4ac91 100644 --- a/plugins/storage.bitfile.php +++ b/plugins/storage.bitfile.php @@ -1,6 +1,6 @@ <?php /** - * @version $Revision: 1.31 $ + * @version $Revision: 1.32 $ * @package liberty * @subpackage plugins_storage */ @@ -74,9 +74,14 @@ function bit_files_verify( &$pStoreRow ) { function bit_files_store( &$pStoreRow ) { global $gBitSystem, $gBitUser; $ret = NULL; - if( !empty( $pStoreRow['foreign_id'] ) ) { - $sql = "UPDATE `".BIT_DB_PREFIX."liberty_files SET `storage_path`=?, `mime_type`=?, `file_size`=? WHERE `file_id` = ?"; - $gBitSystem->mDb->query( $sql, array( $pStoreRow['dest_file_path'], $pStoreRow['type'], $pStoreRow['size'], $pStoreRow['foreign_id'] ) ); + // we have been given an attachment_id but no foreign_id. we will make a last attempt to see if this is an update or an insert + if( @BitBase::verifyId( $pStoreRow['attachment_id'] ) && !@BitBase::verifyId( $pStoreRow['foreign_id'] )) { + $pStoreRow['foreign_id'] = $gBitSystem->mDb->getOne( "SELECT `foreign_id` FROM `".BIT_DB_PREFIX."liberty_attachments` WHERE `attachment_id` = ?", array( $pStoreRow['attachment_id'] )); + } + + if( @BitBase::verifyId( $pStoreRow['foreign_id'] ) ) { + $sql = "UPDATE `".BIT_DB_PREFIX."liberty_files` SET `storage_path`=?, `mime_type`=?, `file_size`=? WHERE `file_id` = ?"; + $gBitSystem->mDb->query( $sql, array( $pStoreRow['upload']['dest_path'].$pStoreRow['upload']['name'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $pStoreRow['foreign_id'] ) ); } else { $pStoreRow['foreign_id'] = $gBitSystem->mDb->GenID( 'liberty_files_id_seq' ); $sql = "INSERT INTO `".BIT_DB_PREFIX."liberty_files` ( `storage_path`, `file_id`, `mime_type`, `file_size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )"; |
