Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Advertisement Images
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 14 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Advertisement Images
|
||||
*/
|
||||
class _Ads
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
$images[ $key ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Ads', $location )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
unset( \IPS\Data\Cache::i()->advertisements );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
$images[ $key ] = \IPS\File::repairUrl( $location );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
unset( \IPS\Data\Cache::i()->advertisements );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
if ( in_array( (string) $file, json_decode( $ad['ad_images'], TRUE ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
foreach ( json_decode( $ad['ad_images'], TRUE ) as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $location )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Customer Fields
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 29 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Customer Fields
|
||||
*/
|
||||
class _Customer
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$update[ 'field_' . $id ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Customer', $update[ 'field_' . $id ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
foreach( $update as $k => $v )
|
||||
{
|
||||
if ( $update[ $k ] == $customer[ $k ] )
|
||||
{
|
||||
unset( $update[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $customer[ 'field_' . $id ] ) )
|
||||
{
|
||||
$update[ 'field_' . $id ] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
if ( count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$_where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$_where[] = "field_{$field->id}=?";
|
||||
}
|
||||
if ( !count( $_where ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$where = array_fill( 0, count( $_where ), (string) $file );
|
||||
array_unshift( $where, implode( ' OR ', $_where ) );
|
||||
|
||||
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', $where )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) ) as $customer )
|
||||
{
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Customer', $customer[ 'field_' . $id ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Package Groups
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Groups
|
||||
*/
|
||||
class _PackageGroups
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_groups', array( 'pg_image<>?', '' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_PackageGroups', $record['pg_image'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['pg_image'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => (string) $file ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['pg_image'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => $new ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ) ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PackageGroups', $product['pg_image'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Product Images
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Images
|
||||
*/
|
||||
class _Products
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_images' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_Products', $record['image_location'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['image_location'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => (string) $file ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['image_location'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => $new ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_images', array( 'image_location=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_images', "image_location IS NOT NULL" ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $product['image_location'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Purchase Custom Fields
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 23 Feb 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Purchase Custom Fields
|
||||
*/
|
||||
class _PurchaseFields
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_fields', array( 'cf_type=?', 'upload' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_PurchaseFields', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_custom_fields LIKE ?", "%{$file}%" ) ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $fieldValues[ $field->id ] == (string) $file )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$where = array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
);
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_purchases', $where ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PurchaseFields', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Referral Banners
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 18 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Referral Banners
|
||||
*/
|
||||
class _ReferralBanners
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referral_banners', 'rb_upload=1' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_ReferralBanners', $record['rb_url'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['rb_url'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => (string) $file ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['rb_url'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => $new ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_referral_banners', array( 'rb_url=? and rb_upload=1', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1' ) as $banner )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_ReferralBanners', $banner['rb_url'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Support Custom Fields / Severity Icons
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Support Custom Fields / Severity Icons
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_fields', array( 'sf_type=?', 'upload' ) )->first() + \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_severities', 'sev_icon IS NOT NULL' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
if ( $offset === 0 )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $severity['sev_icon'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_severities', array( 'sev_icon' => \IPS\File::get( $oldConfiguration ?: 'nexus_Support', $severity['sev_icon'] )->move( $storageConfiguration ) ), array( 'sev_id=?', $severity['sev_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_Support', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
if ( $offset === 0 )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $severity['sev_icon'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_severities', array( 'sev_icon' => $new ), array( 'sev_id=?', $severity['sev_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_support_severities', array( 'sev_icon=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_requests', array( "r_cfields LIKE ?", "%{$file}%" ) ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $fieldValues[ $field->id ] == (string) $file )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $severity['sev_icon'] )
|
||||
{
|
||||
\IPS\File::get( 'nexus_Support', $severity['sev_icon'] )->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_support_requests', $where ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Support', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Reference in new issue
Block a user