diff options
| -rw-r--r-- | includes/classes/LibertyMime.php | 29 | ||||
| -rw-r--r-- | includes/edit_storage_inc.php | 2 |
2 files changed, 7 insertions, 24 deletions
diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php index c5feb74..0ccb8a6 100644 --- a/includes/classes/LibertyMime.php +++ b/includes/classes/LibertyMime.php @@ -623,7 +623,7 @@ class LibertyMime extends LibertyContent { * @access public * @return attachment details */ - public function getAttachment( $pAttachmentId, $pParams = NULL ) { + public static function getAttachment( $pAttachmentId, $pParams = NULL ) { global $gLibertySystem, $gBitSystem; $ret = NULL; @@ -632,13 +632,7 @@ class LibertyMime extends LibertyContent { if( $result = $gBitSystem->mDb->query( $query, array( (int)$pAttachmentId ))) { if( $row = $result->fetchRow() ) { if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function', 'mime' )) { - $prefs = array(); - // if the object is available, we'll copy the preferences by reference to allow the plugin to update them as needed - if( !empty( $this ) && !empty( $this->mStoragePrefs[$pAttachmentId] )) { - $prefs = &$this->mStoragePrefs[$pAttachmentId]; - } else { - $prefs = static::getAttachmentPreferences( $pAttachmentId ); - } + $prefs = static::getAttachmentPreferences( $pAttachmentId ); $ret = $func( $row, $prefs, $pParams ); } } @@ -758,25 +752,14 @@ class LibertyMime extends LibertyContent { * @param string Default value to return if the preference is empty * @param int Optional content_id for arbitrary content preference */ - function getAttachmentPreferences( $pAttachmentId ) { + protected static function getAttachmentPreferences( $pAttachmentId ) { global $gBitSystem; $ret = array(); if( BitBase::verifyId( $pAttachmentId ) ) { - if( !empty( $this ) && is_subclass_of( $this, "LibertyMime" ) ) { - // we're loading from within object - if( is_null( $this->mStoragePrefs )) { - $this->loadAttachmentPreferences(); - } - - if( @BitBase::verifyId( $pAttachmentId ) && isset( $this->mStoragePrefs[$pAttachmentId] )) { - $ret = $this->mStoragePrefs[$pAttachmentId]; - } - } else { - // if the object isn't loaded, we need to get the prefs from the database - $sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?"; - $ret = $gBitSystem->mDb->getAssoc( $sql, array( (int)$pAttachmentId )); - } + // if the object isn't loaded, we need to get the prefs from the database + $sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?"; + $ret = $gBitSystem->mDb->getAssoc( $sql, array( (int)$pAttachmentId )); } return $ret; diff --git a/includes/edit_storage_inc.php b/includes/edit_storage_inc.php index 3d40b0f..bba99ad 100644 --- a/includes/edit_storage_inc.php +++ b/includes/edit_storage_inc.php @@ -35,7 +35,7 @@ if( !empty( $_REQUEST['deleteAttachment'] )) { } $attachmentId = $_REQUEST['deleteAttachment']; - $attachmentInfo = $gContent->getAttachment( $attachmentId ); + $attachmentInfo = LibertyMime::getAttachment( $attachmentId ); // the second part of this check seems odd (never used?) to me, but I'll leave it in for now - spiderr 10/17/2007 if( $gContent->hasAdminPermission() || ( $gContent->isOwner( $attachmentInfo ) && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) { |
