Version 4.1.19.4
This commit is contained in:
1 parent
2bd5025018
commit
0dc2aee5ed
312 files changed
+53730
-32118
No files matched your search
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter Coppermine Gallery Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Converter
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
class _Coppermine extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "Coppermine";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "coppermine";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryCategories' => array(
|
||||
'table' => 'categories',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertGalleryAlbums' => array(
|
||||
'table' => 'albums',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryImages' => array(
|
||||
'table' => 'pictures',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryComments' => array(
|
||||
'table' => 'comments',
|
||||
'where' => NULL,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return NULL|array
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'phpbb' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* List of conversion methods that require additional information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryAlbums',
|
||||
'convertGalleryImages'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get More Information
|
||||
*
|
||||
* @param string $method Method name
|
||||
* @return array
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
{
|
||||
$return = array();
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertGalleryAlbums':
|
||||
$options = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'gallery_categories' ), 'IPS\gallery\Category' ) AS $category )
|
||||
{
|
||||
$options[$category->_id] = $category->_title;
|
||||
}
|
||||
|
||||
$return['convertGalleryAlbums']['members_gallery_category'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
'field_default' => NULL,
|
||||
'field_required' => FALSE,
|
||||
'field_extra' => array(
|
||||
'options' => $options
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
);
|
||||
break;
|
||||
case 'convertGalleryImages':
|
||||
$return['convertGalleryImages']['file_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'convert_coppermine_filehint' ),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return array Messages to display
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount", "f_image_tags_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryCategories()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'cid' );
|
||||
|
||||
foreach( $this->fetch( 'categories', 'cid' ) AS $row )
|
||||
{
|
||||
$libraryClass->convertGalleryCategory( array(
|
||||
'category_id' => $row['cid'],
|
||||
'category_name' => $row['name'],
|
||||
'category_desc' => $row['description'],
|
||||
'category_parent_id' => $row['parent'],
|
||||
'category_position' => $row['pos']
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['cid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert albums
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryAlbums()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'aid' );
|
||||
|
||||
foreach( $this->fetch( 'albums', 'aid' ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'album_id' => $row['aid'],
|
||||
'album_owner_id' => isset( $row['owner'] ) ? $row['owner'] : NULL,
|
||||
'album_category_id' => $row['category'],
|
||||
'album_description' => $row['description'],
|
||||
'album_position' => $row['pos'],
|
||||
'album_name' => $row['title'],
|
||||
'album_allow_comments' => ( $row['comments'] == 'YES' ),
|
||||
'album_allow_reviews' => ( $row['comments'] == 'YES' ),
|
||||
'album_allow_rating' => ( $row['votes'] == 'YES' )
|
||||
);
|
||||
|
||||
$category = NULL;
|
||||
try
|
||||
{
|
||||
$this->app->getLink( $row['category'], 'gallery_categories' );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$category = $this->app->_session['more_info']['convertGalleryAlbums']['members_gallery_category'];
|
||||
if ( $category == 0 )
|
||||
{
|
||||
$category = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->convertGalleryAlbum( $info, NULL, $category );
|
||||
$libraryClass->setLastKeyValue( $row['aid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryImages()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'pid' );
|
||||
|
||||
foreach( $this->fetch( 'pictures', 'pid' ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'image_id' => $row['pid'],
|
||||
'image_album_id' => $row['aid'],
|
||||
'image_member_id' => $row['owner_id'],
|
||||
/* Some images in the test data don't have titles, use filename if title is missing */
|
||||
'image_caption' => $row['title'] ?: $row['filename'],
|
||||
'image_description' => $row['caption'],
|
||||
'image_views' => $row['hits'],
|
||||
'image_date' => $row['ctime'],
|
||||
'image_updated' => \strtotime( $row['mtime'] ),
|
||||
'image_ipaddress' => $row['pic_raw_ip'],
|
||||
'image_file_name' => $row['filename']
|
||||
);
|
||||
|
||||
/* Filepath */
|
||||
$path = rtrim( $this->app->_session['more_info']['convertGalleryImages']['file_location'], '/' ) . '/' . $row['filepath'] . '/' . $row['filename'];
|
||||
|
||||
$libraryClass->convertGalleryImage( $info, $path );
|
||||
|
||||
/* Tags */
|
||||
if( !empty( $row['keywords'] ) )
|
||||
{
|
||||
$keywords = explode( ' ', $row['keywords'] );
|
||||
foreach( $keywords as $key )
|
||||
{
|
||||
$word = explode( ',', $key );
|
||||
|
||||
foreach( $word as $w )
|
||||
{
|
||||
$libraryClass->convertTag( array(
|
||||
'tag_meta_app' => 'gallery',
|
||||
'tag_meta_area' => 'gallery',
|
||||
'tag_meta_parent_id' => $row['aid'],
|
||||
'tag_meta_id' => $row['pid'],
|
||||
'tag_text' => $w,
|
||||
'tag_prefix' => 0,
|
||||
'tag_member_id' => $row['owner_id']
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['pid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryComments()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'msg_id' );
|
||||
|
||||
foreach( $this->fetch( 'comments', 'msg_id' ) AS $row )
|
||||
{
|
||||
$libraryClass->convertGalleryComment( array(
|
||||
'comment_id' => $row['msg_id'],
|
||||
'comment_text' => $row['msg_body'],
|
||||
'comment_img_id' => $row['pid'],
|
||||
'comment_author_id' => $row['author_id'],
|
||||
'comment_author_name' => $row['msg_author'],
|
||||
'comment_ip_address' => $row['msg_raw_ip'],
|
||||
'comment_post_date' => \strtotime( $row['msg_date'] ),
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['msg_id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter PhotoPlog Gallery Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Converter
|
||||
* @since 02 October 2016
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
class _Photoplog extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "PhotoPlog (vBulletin 3.x/4.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "photoplog";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryCategories' => array(
|
||||
'table' => 'categories',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertGalleryAlbums'=> array(
|
||||
'table' => 'useralbums',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryImages' => array(
|
||||
'table' => 'fileuploads',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertGalleryComments' => array(
|
||||
'table' => 'ratecomment',
|
||||
'where' => array( "rating=?", 0 )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function requiresParent()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return NULL|array
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'vbulletin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* List of conversion methods that require additional information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryAlbums',
|
||||
'convertGalleryImages'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return string Message to display
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
|
||||
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get More Information
|
||||
*
|
||||
* @param string $method Method name
|
||||
* @return array
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
{
|
||||
$return = array();
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertGalleryAlbums':
|
||||
$options = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'gallery_categories' ), 'IPS\gallery\Category' ) AS $category )
|
||||
{
|
||||
$options[ $category->_id ] = $category->_title;
|
||||
}
|
||||
|
||||
$return['convertGalleryAlbums']['members_gallery_category'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
'field_default' => NULL,
|
||||
'field_required' => FALSE,
|
||||
'field_extra' => array(
|
||||
'options' => $options
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
);
|
||||
break;
|
||||
case 'convertGalleryImages':
|
||||
$return['convertGalleryImages']['file_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_photoplog_hint'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Photoplog Albums
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryAlbums()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'albumid' );
|
||||
|
||||
foreach( $this->fetch( 'useralbums', 'albumid' ) AS $row )
|
||||
{
|
||||
$info = array(
|
||||
'album_id' => $row['albumid'],
|
||||
'album_owner_id' => $row['userid'],
|
||||
'album_description' => $row['description'],
|
||||
'album_name' => $row['title'],
|
||||
'album_type' => $row['visible'] ?: 0
|
||||
);
|
||||
|
||||
$category = $this->app->_session['more_info']['convertGalleryAlbums']['members_gallery_category'];
|
||||
if ( $category == 0 )
|
||||
{
|
||||
$category = NULL;
|
||||
}
|
||||
|
||||
$libraryClass->convertGalleryAlbum( $info, NULL, $category );
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['albumid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Photoplog Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryCategories()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'catid' );
|
||||
|
||||
foreach( $this->fetch( 'categories', 'catid' ) AS $row )
|
||||
{
|
||||
$libraryClass->convertGalleryCategory( array(
|
||||
'category_id' => $row['catid'],
|
||||
'category_name' => $row['title'],
|
||||
'category_desc' => $row['description'],
|
||||
'category_parent_id' => $row['parentid'] > 0 ? $row['parentid'] : 0,
|
||||
'category_position' => $row['displayorder']
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['catid'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Photoplog Images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryImages()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'fileid' );
|
||||
|
||||
foreach( $this->fetch( 'fileuploads', 'fileid' ) AS $row )
|
||||
{
|
||||
$album = \unserialize( $row['albumids'] );
|
||||
$albumId = NULL;
|
||||
|
||||
if( is_array( $album ) )
|
||||
{
|
||||
$albumId = $album[0];
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'image_id' => $row['fileid'],
|
||||
'image_album_id' => $albumId,
|
||||
'image_category_id' => $row['catid'],
|
||||
'image_member_id' => $row['userid'],
|
||||
'image_caption' => $row['title'],
|
||||
'image_views' => $row['views'],
|
||||
'image_comments' => $row['num_comments0'] + $row['num_comments1'],
|
||||
'image_ratings_total' => $row['sum_ratings1'],
|
||||
'image_ratings_count' => $row['num_ratings1'],
|
||||
'image_rating' => $row['num_ratings1'] > 0 ? intval( $row['sum_ratings1'] / $row['num_ratings1'] ) : 0,
|
||||
'image_date' => $row['dateline'],
|
||||
'image_metadata' => json_encode( \unserialize( $row['exifinfo'] ) ),
|
||||
'image_file_name' => $row['filename'],
|
||||
'image_description' => $row['description'],
|
||||
'image_approved' => $row['moderate'] == 1 ? 0 : 1,
|
||||
);
|
||||
|
||||
$libraryClass->convertGalleryImage( $info, rtrim( $this->app->_session['more_info']['convertGalleryImages']['file_location'], '/' ) . '/' . $row['userid'] . '/' . $row['filename'] );
|
||||
|
||||
/* Ratings! */
|
||||
foreach( $this->db->select( '*', 'ratecomment', array( "fileid=? AND rating>0", $row['fileid'] ) ) AS $rating )
|
||||
{
|
||||
$libraryClass->convertRating( array(
|
||||
'id' => $rating['commentid'],
|
||||
'class' => 'IPS\gallery\Image',
|
||||
'item_link' => 'gallery_images',
|
||||
'item_id' => $row['fileid'],
|
||||
'rating' => $rating['rating'],
|
||||
'member' => $rating['userid'],
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['fileid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Photoplog Comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryComments()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'commentid' );
|
||||
|
||||
foreach( $this->fetch( 'ratecomment', 'commentid', array( "rating=?", 0 ) ) AS $row )
|
||||
{
|
||||
$libraryClass->convertGalleryComment( array(
|
||||
'comment_id' => $row['commentid'],
|
||||
'comment_text' => $row['comment'],
|
||||
'comment_img_id' => $row['fileid'],
|
||||
'comment_author_id' => $row['userid'],
|
||||
'comment_author_name' => $row['username'],
|
||||
'comment_post_date' => $row['dateline'],
|
||||
'comment_approved' => ( $row['moderate'] == 1 ) ? 0 : 1,
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['commentid'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter Photopost Gallery Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Converter
|
||||
* @since 6 December 2016
|
||||
* @note Only redirect scripts are supported right now
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
class _Photopost extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "Photopost";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "photopost";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showgallery.php' ) !== FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( \IPS\Request::i()->cat, 'gallery_categories' );
|
||||
$item = \IPS\gallery\Category::load( $data );
|
||||
|
||||
if( $item->can('view') )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showphoto.php' ) !== FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( \IPS\Request::i()->photo, 'gallery_images' );
|
||||
$item = \IPS\gallery\Image::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter vBulletin 4.x Gallery Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Converter
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* @brief vBulletin 4 Stores all attachments under one table - this will store the content type for the forums app.
|
||||
*/
|
||||
protected static $imageContentType = NULL;
|
||||
|
||||
/**
|
||||
* @brief The schematic for vB3 and vB4 is similar enough that we can make specific concessions in a sinle converter for either version.
|
||||
*/
|
||||
protected static $isLegacy = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App The application to reference for database and other information.
|
||||
* @param bool Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
|
||||
{
|
||||
$return = parent::__construct( $app, $needDB );
|
||||
|
||||
/* Is this vB3 or vB4? */
|
||||
if ( $needDB )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( static::$isLegacy === NULL )
|
||||
{
|
||||
$version = $this->db->select( 'value', 'setting', array( "varname=?", 'templateversion' ) )->first();
|
||||
|
||||
if ( mb_substr( $version, 0, 1 ) == '3' )
|
||||
{
|
||||
static::$isLegacy = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$isLegacy = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If this is vB4, what is the content type ID for posts? */
|
||||
if ( static::$imageContentType === NULL AND ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) )
|
||||
{
|
||||
static::$imageContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'Album' ) )->first();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "vBulletin Gallery (3.x/4.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "vbulletin";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
$imageWhere = NULL;
|
||||
$imageTable = 'picture';
|
||||
|
||||
if ( static::$isLegacy == FALSE )
|
||||
{
|
||||
$imageWhere = array( "contenttypeid=?", static::$imageContentType );
|
||||
$imageTable = 'attachment';
|
||||
}
|
||||
|
||||
return array(
|
||||
'convertGalleryAlbums'=> array(
|
||||
'table' => 'album',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryImages' => array(
|
||||
'table' => $imageTable,
|
||||
'where' => $imageWhere
|
||||
),
|
||||
'convertGalleryComments' => array(
|
||||
'table' => 'picturecomment',
|
||||
'where' => NULL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function requiresParent()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'vbulletin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return array Messages to display
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount", "f_image_tags_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix Post Data
|
||||
*
|
||||
* @param string Post
|
||||
* @return string Fixed Posts
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
return \IPS\convert\Software\Core\Vbulletin::fixPostData( $post );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get More Information
|
||||
*
|
||||
* @param string $method Conversion method
|
||||
* @return array
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
{
|
||||
$return = array();
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertGalleryImages':
|
||||
$return['convertGalleryImages'] = array(
|
||||
'file_location' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'database',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'file_system' ),
|
||||
),
|
||||
'userSuppliedInput' => 'file_system',
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List of conversion methods that require additional information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array( 'convertGalleryImages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery albums
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryAlbums()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'albumid' );
|
||||
|
||||
foreach( $this->fetch( 'album', 'albumid' ) AS $album )
|
||||
{
|
||||
$socialgroup = NULL;
|
||||
if ( $album['state'] == 'private' )
|
||||
{
|
||||
/* Fetch users friends */
|
||||
$friends = array();
|
||||
foreach( $this->db->select( 'relationid', 'userlist', array( "userid=?", $album['userid'] ) ) AS $friend )
|
||||
{
|
||||
$friends[$friend] = $friend;
|
||||
}
|
||||
|
||||
$socialgroup = array( 'members' => $friends );
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'album_id' => $album['albumid'],
|
||||
'album_owner_id' => $album['userid'],
|
||||
'album_name' => $album['title'],
|
||||
'album_description' => $album['description'],
|
||||
'album_type' => ( $album['state'] == 'private' ) ? 3 : 1,
|
||||
'album_count_imgs' => $album['visible'],
|
||||
'album_count_imgs_hidden' => $album['moderation'],
|
||||
'album_last_img_date' => $album['lastpicturedate']
|
||||
);
|
||||
|
||||
$libraryClass->convertGalleryAlbum( $info, $socialgroup );
|
||||
|
||||
$libraryClass->setLastKeyValue( $album['albumid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryImages()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
/* Don't even bother trying to swap things out - just do different things based on version */
|
||||
if ( static::$isLegacy === TRUE )
|
||||
{
|
||||
$libraryClass::setKey( 'pictureid' );
|
||||
|
||||
foreach( $this->fetch( 'picture', 'pictureid' ) AS $image )
|
||||
{
|
||||
$filedata = NULL;
|
||||
$filepath = NULL;
|
||||
|
||||
if ( $this->app->_session['more_info']['convertGalleryImages']['file_location'] == 'database' )
|
||||
{
|
||||
/* Simples! */
|
||||
$filedata = $image['filedata'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$filepath = floor( $image['pictureid'] / 1000 );
|
||||
$filepath = rtrim( $this->app->_session['more_info']['convertGalleryImages']['file_location'], '/' ) . '/' . $filepath . '/' . $image['pictureid'] . '.picture';
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'image_id' => $image['pictureid'],
|
||||
'image_album_id' => $this->db->select( 'albumid', 'albumpicture', array( "pictureid=?", $image['pictureid'] ) )->first(),
|
||||
'image_member_id' => $image['userid'],
|
||||
'image_caption' => $image['caption'],
|
||||
'image_file_name' => $image['caption'] . '.' . $image['extension'],
|
||||
'image_date' => $this->db->select( 'dateline', 'albumpicture', array( "pictureid=?", $image['pictureid'] ) )->first(),
|
||||
);
|
||||
|
||||
$libraryClass->convertGalleryImage( $info, $filepath, $filedata );
|
||||
|
||||
$libraryClass->setLastKeyValue( $image['pictureid'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$libraryClass::setKey( 'attachmentid' );
|
||||
|
||||
foreach( $this->fetch( 'attachment', 'attachmentid', array( "contenttypeid=?", static::$imageContentType ) ) AS $image )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->db->select( '*', 'filedata', array( "filedataid=?", $image['filedataid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $image['attachmentid'] );
|
||||
continue;
|
||||
}
|
||||
|
||||
$filedata = NULL;
|
||||
$filepath = NULL;
|
||||
|
||||
if ( $this->app->_session['more_info']['convertGalleryImages']['file_location'] == 'database' )
|
||||
{
|
||||
$filedata = $data['filedata'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$filepath = implode( '/', preg_split( '//', $data['userid'], -1, PREG_SPLIT_NO_EMPTY ) );
|
||||
$filepath = rtrim( $this->app->_session['more_info']['convertGalleryImages']['file_location'], '/' ) . '/' . $filepath . '/' . $data['filedataid'] . '.attach';
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'image_id' => $image['attachmentid'],
|
||||
'image_album_id' => $image['contentid'],
|
||||
'image_member_id' => $image['userid'],
|
||||
'image_caption' => $image['caption'],
|
||||
'image_file_name' => $image['filename'],
|
||||
'image_date' => $image['dateline']
|
||||
);
|
||||
|
||||
$libraryClass->convertGalleryImage( $info, $filepath, $filedata );
|
||||
|
||||
$libraryClass->setLastKeyValue( $image['attachmentid'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryComments()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'commentid' );
|
||||
|
||||
foreach( $this->fetch( 'picturecomment', 'commentid' ) AS $comment )
|
||||
{
|
||||
switch( $comment['state'] )
|
||||
{
|
||||
case 'visible':
|
||||
$approved = 1;
|
||||
break;
|
||||
|
||||
case 'moderation':
|
||||
$approved = 0;
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
$approved = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* For 3.x this is just the value stored for pictureid */
|
||||
$image_id = $comment['pictureid'];
|
||||
|
||||
/* For 4.x though, we have to get the attachmentid based on the filedataid */
|
||||
if ( static::$isLegacy === FALSE )
|
||||
{
|
||||
/* If VB tracked the attachmentid, just use it so we don't have to query */
|
||||
if( $comment['sourceattachmentid'] )
|
||||
{
|
||||
$image_id = $comment['sourceattachmentid'];
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$image_id = $this->db->select( 'attachmentid', 'attachment', array( array( 'filedataid=?', $comment['filedataid'] ) ) )->first();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
$image_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->convertGalleryComment( array(
|
||||
'comment_id' => $comment['commentid'],
|
||||
'comment_text' => $comment['pagetext'],
|
||||
'comment_img_id' => $image_id,
|
||||
'comment_author_id' => $comment['postuserid'],
|
||||
'comment_author_name' => $comment['postusername'],
|
||||
'comment_post_date' => $comment['dateline'],
|
||||
'comment_approved' => $approved,
|
||||
) );
|
||||
|
||||
$libraryClass->setLastKeyValue( $comment['commentid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
|
||||
try
|
||||
{
|
||||
if( isset( \IPS\Request::i()->albumid ) )
|
||||
{
|
||||
$data = $this->app->getLink( \IPS\Request::i()->albumid, 'gallery_albums' );
|
||||
$item = \IPS\gallery\Album::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'album.php' ) !== FALSE AND isset( \IPS\Request::i()->pictureid ) )
|
||||
{
|
||||
$data = $this->app->getLink( \IPS\Request::i()->pictureid, 'gallery_images' );
|
||||
$item = \IPS\gallery\Image::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
elseif( isset( \IPS\Request::i()->userid ) )
|
||||
{
|
||||
$data = $this->app->getLink( \IPS\Request::i()->userid, array( 'members', 'core_members' ) );
|
||||
return \IPS\Member::load( $data )->url();
|
||||
}
|
||||
elseif( ( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'picture.php' ) !== FALSE AND isset( \IPS\Request::i()->pictureid ) ) OR
|
||||
( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'attachment.php' ) !== FALSE AND isset( \IPS\Request::i()->attachmentid ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->app->getLink( \IPS\Request::i()->pictureid ?: \IPS\Request::i()->attachmentid, 'gallery_images' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$data = \IPS\Request::i()->pictureid ?: \IPS\Request::i()->attachmentid;
|
||||
}
|
||||
|
||||
return \IPS\File::get( 'gallery_Images', \IPS\gallery\Image::load( $data )->masked_file_name )->url;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,637 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Converter XenForo Media Gallery Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Converter
|
||||
* @since 21 Jan 2015
|
||||
*/
|
||||
|
||||
namespace IPS\convert\Software\Gallery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "XenForo Media Gallery";
|
||||
}
|
||||
|
||||
/**
|
||||
* Software Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function softwareKey()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "xenforo";
|
||||
}
|
||||
|
||||
/**
|
||||
* Content we can convert from this software.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function canConvert()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryCategories' => array(
|
||||
'table' => 'xengallery_category',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertGalleryAlbums' => array(
|
||||
'table' => 'xengallery_album',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryImages' => array(
|
||||
'table' => 'xengallery_media',
|
||||
'where' => NULL,
|
||||
),
|
||||
'convertGalleryComments' => array(
|
||||
'table' => 'xengallery_comment',
|
||||
'where' => NULL,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Prefix
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function usesPrefix()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires Parent
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function requiresParent()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible Parent Conversions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parents()
|
||||
{
|
||||
return array( 'core' => array( 'xenforo' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* List of conversion methods that require additional information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkConf()
|
||||
{
|
||||
return array(
|
||||
'convertGalleryAlbums',
|
||||
'convertGalleryImages'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get More Information
|
||||
*
|
||||
* @param string $method Conversion method
|
||||
* @return array
|
||||
*/
|
||||
public function getMoreInfo( $method )
|
||||
{
|
||||
$return = array();
|
||||
switch( $method )
|
||||
{
|
||||
case 'convertGalleryAlbums':
|
||||
$options = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'gallery_categories' ), 'IPS\gallery\Category' ) AS $category )
|
||||
{
|
||||
$options[$category->_id] = $category->_title;
|
||||
}
|
||||
|
||||
$return['convertGalleryAlbums']['members_gallery_category'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
'field_default' => NULL,
|
||||
'field_required' => FALSE,
|
||||
'field_extra' => array(
|
||||
'options' => $options
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
);
|
||||
break;
|
||||
case 'convertGalleryImages':
|
||||
$return['convertGalleryImages']['file_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_xf_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
$return['convertGalleryImages']['media_thumb_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_xf_gal_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish - Adds everything it needs to the queues and clears data store
|
||||
*
|
||||
* @return array Messages to display
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount", "f_image_tags_recount" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to fetch a xenforo phrase
|
||||
*
|
||||
* @param string $title Phrase
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getPhrase( $title )
|
||||
{
|
||||
try
|
||||
{
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryCategories()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'category_id' );
|
||||
|
||||
foreach( $this->fetch( 'xengallery_category', 'category_id' ) AS $row )
|
||||
{
|
||||
$libraryClass->convertGalleryCategory( array(
|
||||
'category_id' => $row['category_id'],
|
||||
'category_name' => $row['category_title'],
|
||||
'category_desc' => $row['category_description'],
|
||||
'category_parent_id' => $row['parent_category_id'],
|
||||
'category_count_imgs' => $row['category_media_count'],
|
||||
'category_position' => $row['display_order']
|
||||
) );
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( '*', 'xengallery_category_watch', array( "notify_on=? AND category_id=?", 'media', $row['category_id'] ) ) AS $follow )
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'gallery',
|
||||
'follow_area' => 'category',
|
||||
'follow_rel_id' => $row['category_id'],
|
||||
'follow_rel_id_type' => 'gallery_categories',
|
||||
'follow_member_id' => $follow['user_id'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => ( $follow['send_alert'] OR $follow['send_email'] ) ? 'immediate' : 'none',
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
'follow_index_id' => NULL
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery albums
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryAlbums()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'album_id' );
|
||||
|
||||
foreach( $this->fetch( 'xengallery_album', 'album_id' ) AS $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
$perm = $this->db->select( '*', 'xengallery_album_permission', array( "album_id=? AND permission=?", $row['album_id'], 'view' ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* If the permission row is missing for some reason, err on the side of caution and set this album private */
|
||||
$perm = array(
|
||||
'album_id' => $row['album_id'],
|
||||
'permission' => 'view',
|
||||
'access_type' => 'private',
|
||||
'share_users' => \serialize( array() ),
|
||||
);
|
||||
}
|
||||
|
||||
$socialgroup = NULL;
|
||||
if ( $perm['access_type'] == 'shared' OR $perm['access_type'] == 'followed' )
|
||||
{
|
||||
switch( $perm['access_type'] )
|
||||
{
|
||||
/* Specific members */
|
||||
case 'shared':
|
||||
$users = \unserialize( $perm['share_users'] );
|
||||
$socialgroup['members'] = array();
|
||||
|
||||
if ( count( $users ) )
|
||||
{
|
||||
foreach( $users AS $key => $user )
|
||||
{
|
||||
$socialgroup['members'][] = $user['shared_user_id'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Followers */
|
||||
case 'followed':
|
||||
$socialgroup['members'] = array();
|
||||
foreach( $this->db->select( 'follow_user_id', 'xf_user_follow', array( "user_id=?", $row['album_user_id'] ) ) AS $user )
|
||||
{
|
||||
$socialgroup['members'][] = $user;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch( $perm['access_type'] )
|
||||
{
|
||||
case 'private':
|
||||
case 'members': # we don't have an equivalent of "members only" but we don't want to just open everything up either, so set these private.
|
||||
$type = 2;
|
||||
break;
|
||||
|
||||
case 'public':
|
||||
$type = 1;
|
||||
break;
|
||||
|
||||
case 'followed':
|
||||
case 'shared':
|
||||
$type = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'album_id' => $row['album_id'],
|
||||
'album_owner_id' => $row['album_user_id'],
|
||||
'album_description' => $row['album_description'],
|
||||
'album_name' => $row['album_title'],
|
||||
'album_type' => $type,
|
||||
'album_count_imgs' => $row['album_media_count'],
|
||||
'album_count_comments' => $row['album_comment_count'],
|
||||
'album_rating_aggregate' => $row['album_rating_avg'],
|
||||
'album_rating_count' => $row['album_rating_count'],
|
||||
'album_rating_total' => $row['album_rating_sum'],
|
||||
);
|
||||
|
||||
$category = $this->app->_session['more_info']['convertGalleryAlbums']['members_gallery_category'];
|
||||
if ( $category == 0 )
|
||||
{
|
||||
$category = NULL;
|
||||
}
|
||||
|
||||
$libraryClass->convertGalleryAlbum( $info, $socialgroup, $category );
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( '*', 'xengallery_album_watch', array( "notify_on=? AND album_id=?", 'media', $row['album_id'] ) ) AS $follow )
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'gallery',
|
||||
'follow_area' => 'album',
|
||||
'follow_rel_id' => $row['album_id'],
|
||||
'follow_rel_id_type' => 'gallery_albums',
|
||||
'follow_member_id' => $follow['user_id'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => ( $follow['send_alert'] OR $follow['send_email'] ) ? 'immediate' : 'none',
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
'follow_index_id' => NULL
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['album_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryImages()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'media_id' );
|
||||
|
||||
foreach( $this->fetch( 'xengallery_media', 'media_id' ) AS $row )
|
||||
{
|
||||
/* Exif */
|
||||
$exif = array();
|
||||
foreach( $this->db->select( 'exif_name, exif_value', 'xengallery_exif', array( "media_id=?", $row['media_id'] ) )->setKeyField( 'exif_name' )->setValueField( 'exif_value' ) AS $key => $value )
|
||||
{
|
||||
$exif[$key] = $value;
|
||||
}
|
||||
|
||||
/* IP Address */
|
||||
try
|
||||
{
|
||||
$ip = $this->db->select( '*', 'xf_ip', array( "ip_id=?", $row['ip_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
|
||||
/* Now the fun part... we need to do different things depending on the type of item this is. */
|
||||
switch( $row['media_type'] )
|
||||
{
|
||||
/* Normal image upload */
|
||||
case 'image_upload':
|
||||
try
|
||||
{
|
||||
$file_data = $this->db->select( '*', 'xf_attachment', array( "xf_attachment.content_type=? AND xf_attachment.content_id=?", 'xengallery_media', $row['media_id'] ) )
|
||||
->join( 'xf_attachment_data', 'xf_attachment.data_id = xf_attachment_data.data_id' )
|
||||
->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
/* If the file data is missing, we can't do anything. */
|
||||
$libraryClass->setLastKeyValue( $row['media_id'] );
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$group = floor( $file_data['data_id'] / 1000 );
|
||||
$path = rtrim( $this->app->_session['more_info']['convertGalleryImages']['file_location'], '/' ) . '/' . $group . '/' . $file_data['data_id'] . '-' . $file_data['file_hash'] . '.data';
|
||||
$file_name = $file_data['filename'];
|
||||
$description = $row['media_description'];
|
||||
|
||||
break;
|
||||
|
||||
/* Video Embed */
|
||||
case 'video_embed':
|
||||
$path = $this->app->_session['more_info']['convertGalleryImages']['media_thumb_location'];
|
||||
|
||||
/* We need to figure out what service we came from, and the video ID */
|
||||
preg_match( '/\[media=(.*?)\](.*?)\[\/media\]/i', $row['media_tag'], $matches );
|
||||
$service = $matches[1];
|
||||
$video_id = $matches[2];
|
||||
|
||||
$file_name = $service . '_' . $video_id . '.jpg';
|
||||
$path = rtrim( $path, '/' ) . '/' . $service . '/' . $file_name;
|
||||
|
||||
try
|
||||
{
|
||||
$em = \IPS\Text\Parser::embeddableMedia( $row['media_embed_url'] );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* If anything went wrong, back out */
|
||||
$libraryClass->setlastKeyValue( $row['media_id'] );
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$description = $em . "<br>" . $row['media_description'];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'image_id' => $row['media_id'],
|
||||
'image_album_id' => $row['album_id'],
|
||||
'image_category_id' => $row['category_id'],
|
||||
'image_member_id' => $row['user_id'],
|
||||
'image_caption' => $row['media_title'],
|
||||
'image_views' => $row['media_view_count'],
|
||||
'image_comments' => $row['comment_count'],
|
||||
'image_ratings_total' => $row['rating_sum'],
|
||||
'image_ratings_count' => $row['rating_count'],
|
||||
'image_rating' => $row['rating_avg'],
|
||||
'image_date' => $row['media_date'],
|
||||
'image_updated' => $row['last_edit_date'],
|
||||
'image_last_comment' => $row['last_comment_date'],
|
||||
'image_metadata' => json_encode( $exif ),
|
||||
'image_ipaddress' => $ip,
|
||||
'image_file_name' => $file_name,
|
||||
'image_description' => $description
|
||||
);
|
||||
|
||||
$libraryClass->convertGalleryImage( $info, $path );
|
||||
|
||||
/* Warnings */
|
||||
foreach( $this->db->select( '*', 'xf_warning', array( "content_type=? AND content_id=?", 'xengallery_media', $row['media_id'] ) ) AS $warn )
|
||||
{
|
||||
$libraryClass->convertWarnLog( array(
|
||||
'wl_id' => $warn['warning_id'],
|
||||
'wl_member' => $warn['user_id'],
|
||||
'wl_moderator' => $warn['warning_user_id'],
|
||||
'wl_date' => $warn['warning_date'],
|
||||
'wl_points' => $warn['points'],
|
||||
'wl_note_member' => $warn['title'],
|
||||
'wl_note_mods' => $warn['notes'],
|
||||
) );
|
||||
}
|
||||
|
||||
/* Reputation */
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
if ( is_array( $likes ) AND count( $likes ) )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
{
|
||||
$libraryClass->convertReputation( array(
|
||||
'app' => 'gallery',
|
||||
'type' => 'image_id',
|
||||
'type_id' => $row['media_id'],
|
||||
'member_id' => $like['user_id'],
|
||||
'member_received' => $row['user_id'],
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Follows */
|
||||
foreach( $this->db->select( '*', 'xengallery_media_watch', array( "media_id=?", $row['media_id'] ) ) AS $follow )
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'gallery',
|
||||
'follow_area' => 'image',
|
||||
'follow_rel_id' => $row['media_id'],
|
||||
'follow_rel_id_type' => 'gallery_images',
|
||||
'follow_member_id' => $follow['user_id'],
|
||||
'follow_is_anon' => 0,
|
||||
'follow_added' => time(),
|
||||
'follow_notify_do' => 1,
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => ( $follow['send_alert'] OR $follow['send_email'] ) ? 'immediate' : 'none',
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1,
|
||||
'follow_index_id' => NULL
|
||||
) );
|
||||
}
|
||||
|
||||
$tags = NULL;
|
||||
/* Tags 1.0.x */
|
||||
if( isset( $row['media_content_tag_cache'] ) )
|
||||
{
|
||||
$tags = \unserialize( $row['media_content_tag_cache'] );
|
||||
}
|
||||
/* Tags 1.1.x */
|
||||
elseif( isset( $row['tags'] ) )
|
||||
{
|
||||
$tags = \unserialize( $row['tags'] );
|
||||
}
|
||||
|
||||
if ( is_array( $tags ) and count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $k => $tag )
|
||||
{
|
||||
$libraryClass->convertTag( array(
|
||||
'tag_meta_app' => 'gallery',
|
||||
'tag_meta_area' => 'gallery',
|
||||
'tag_meta_parent_id' => ( $row['album_id'] ) ? $row['album_id'] : $row['category_id'],
|
||||
'tag_meta_id' => $row['media_id'],
|
||||
'tag_text' => isset( $tag['tag_clean'] ) ? $tag['tag_clean'] : $tag['tag'], // Select 1.0 or 1.1 version
|
||||
'tag_prefix' => 0,
|
||||
'tag_member_id' => $row['user_id']
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['media_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gallery comments
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertGalleryComments()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'comment_id' );
|
||||
|
||||
foreach( $this->fetch( 'xengallery_comment', 'comment_id', array( "content_type=?", 'media' ) ) AS $row )
|
||||
{
|
||||
/* IP Address */
|
||||
try
|
||||
{
|
||||
$ip = $this->db->select( 'ip', 'xf_ip', array( "ip_id=?", $row['ip_id'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$ip = '127.0.0.1';
|
||||
}
|
||||
|
||||
/* Approved */
|
||||
switch( $row['comment_state'] )
|
||||
{
|
||||
case 'visible':
|
||||
$approved = 1;
|
||||
break;
|
||||
|
||||
case 'moderated':
|
||||
$approved = 0;
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
$approved = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
$libraryClass->convertGalleryComment( array(
|
||||
'comment_id' => $row['comment_id'],
|
||||
'comment_text' => $row['message'],
|
||||
'comment_img_id' => $row['content_id'],
|
||||
'comment_author_id' => $row['user_id'],
|
||||
'comment_author_name' => $row['username'],
|
||||
'comment_ip_address' => $ip,
|
||||
'comment_post_date' => $row['comment_date'],
|
||||
'comment_approved' => $approved,
|
||||
) );
|
||||
|
||||
/* Reputation */
|
||||
$likes = \unserialize( $row['like_users'] );
|
||||
if ( is_array( $likes ) AND count( $likes ) )
|
||||
{
|
||||
foreach( $likes AS $like )
|
||||
{
|
||||
$libraryClass->convertReputation( array(
|
||||
'app' => 'gallery',
|
||||
'type' => 'comment_id',
|
||||
'type_id' => $row['comment_id'],
|
||||
'member_id' => $like['user_id'],
|
||||
'member_received' => $row['user_id'],
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Warnings */
|
||||
foreach( $this->db->select( '*', 'xf_warning', array( "content_type=? AND content_id=?", 'xengallery_comment', $row['comment_id'] ) ) AS $warn )
|
||||
{
|
||||
$libraryClass->convertWarnLog( array(
|
||||
'wl_id' => $warn['warning_id'],
|
||||
'wl_member' => $warn['user_id'],
|
||||
'wl_moderator' => $warn['warning_user_id'],
|
||||
'wl_date' => $warn['warning_date'],
|
||||
'wl_points' => $warn['points'],
|
||||
'wl_note_member' => $warn['title'],
|
||||
'wl_note_mods' => $warn['notes'],
|
||||
) );
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['comment_id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user