liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file storage.existing.php

Documentation is available at storage.existing.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_storage
  6.  */
  7. global $gLibertySystem$gBitSystem$gBitSmarty$gBitThemes;
  8.  
  9. /**
  10.  * definitions
  11.  */
  12. define'PLUGIN_GUID_EXISTING_FILES''existing' );
  13.  
  14. $pluginParams array (
  15.     'store_function' => 'existing_files_store',
  16.     'verify_function' => 'existing_files_verify',
  17.     'description' => 'Always load for handling ajax attachments',
  18.     'edit_label' => 'Ajax Upload Files',
  19.     'plugin_type' => STORAGE_PLUGIN,
  20.     'auto_activate' => FALSE,
  21. );
  22.  
  23. ifisset$gBitSystem ) ) {
  24.     $gLibertySystem->registerPluginPLUGIN_GUID_EXISTING_FILES$pluginParams );
  25. }
  26.  
  27. function existing_files_verify&$pStoreRow {
  28.     global $gBitUser$gContent;
  29.  
  30.     if@BitBase::verifyId$gContent->mContentId ) ) {
  31.  
  32.         // Pull all the data on the attachment in question
  33.         $query "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` a ".
  34.             "WHERE a.`attachment_id`=?";
  35.  
  36.         if$result $gContent->mDb->query$queryarray$pStoreRow ))) {
  37.             $pStoreRow $result->fetchRow();
  38.             // Tell LA not to do the insert.
  39.             $pStoreRow['skip_insert'TRUE;
  40.             $pStoreRow['plugin_guid'PLUGIN_GUID_EXISTING_FILES;
  41.  
  42.             // Verify the user owns this attachment
  43.             if$gBitUser->isAdmin(|| $pStoreRow['user_id'== $gBitUser->mUserId {
  44.  
  45.                 // Verify that it isn't attached already
  46.                 ifempty$pStoreRow['content_id')) {
  47.                     returnTRUE );
  48.                 }
  49.             }
  50.         }
  51.     }
  52.  
  53.     returnFALSE );
  54. }
  55.  
  56. function existing_files_store&$pStoreRow {
  57.     global $gBitSystem$gContent;
  58.  
  59.     if @BitBase::verifyId$gContent->mContentId ) ) {
  60.         // Update the attachments content_id
  61.         $query "UPDATE `".BIT_DB_PREFIX."liberty_attachments` SET ".
  62.             "content_id = ? WHERE attachment_id = ?";
  63.  
  64.         $result $gContent->mDb->query$queryarray$gContent->mContentId$pStoreRow['attachment_id') );
  65.     }
  66.  
  67.     returnTRUE );
  68. }
  69.  
  70. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:29 +0000 by phpDocumentor 1.5.0-lsces