Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,34 @@
|
||||
namespace IPS\convert\Software\Core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Content\Search\Index;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Photopost Core Converter
|
||||
*/
|
||||
class _Photopost extends \IPS\convert\Software
|
||||
class Photopost extends Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
@@ -94,15 +112,15 @@ class _Photopost extends \IPS\convert\Software
|
||||
|
||||
$options = array();
|
||||
$options['none'] = 'None';
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
|
||||
{
|
||||
$options[$group->g_id] = $group->name;
|
||||
}
|
||||
|
||||
foreach( $this->db->select( '*', 'usergroups' ) AS $group )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['groupid']}"] = $group['groupname'];
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['groupid']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
Member::loggedIn()->language()->words["map_group_{$group['groupid']}"] = $group['groupname'];
|
||||
Member::loggedIn()->language()->words["map_group_{$group['groupid']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
|
||||
$return['convertGroups']["map_group_{$group['groupid']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -117,29 +135,29 @@ class _Photopost extends \IPS\convert\Software
|
||||
case 'convertMembers':
|
||||
$return['convertMembers'] = array();
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
|
||||
Member::loggedIn()->language()->words['photo_location_desc'] = Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
|
||||
$return['convertMembers']['photo_location'] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => "The path to the folder where avatars are saved (no trailing slash - usually /path_to_photopost/data/avatars):",
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
/* And decide what to do about these... */
|
||||
foreach( array( 'homepage', 'icq', 'aim', 'yahoo', 'location', 'interests', 'occupation', 'bio' ) AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => ucwords( $field ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
Member::loggedIn()->language()->words["field_{$field}"] = Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => ucwords( $field ) ) );
|
||||
Member::loggedIn()->language()->words["field_{$field}_desc"] = Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
$return['convertMembers']["field_{$field}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'no_convert',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'no_convert' => \IPS\Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => \IPS\Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
'no_convert' => Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
),
|
||||
'userSuppliedInput' => 'create_field'
|
||||
),
|
||||
@@ -160,18 +178,18 @@ class _Photopost extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Search Index Rebuild */
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
Index::i()->rebuild();
|
||||
|
||||
/* Clear Cache and Store */
|
||||
\IPS\Data\Store::i()->clearAll();
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
Store::i()->clearAll();
|
||||
Cache::i()->clearAll();
|
||||
|
||||
/* Non-Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
|
||||
/* Content Counts */
|
||||
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
|
||||
return array( "f_search_index_rebuild", "f_clear_caches", "f_signatures_rebuild" );
|
||||
}
|
||||
@@ -201,7 +219,7 @@ class _Photopost extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -263,7 +281,7 @@ class _Photopost extends \IPS\convert\Software
|
||||
/* We don't actually need this, but we need to make sure the field was created */
|
||||
$this->app->getLink( $pseudo, 'core_pfields_data' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$libraryClass->convertProfileField( array(
|
||||
'pf_id' => $pseudo,
|
||||
@@ -289,26 +307,26 @@ class _Photopost extends \IPS\convert\Software
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
* @return NULL|Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
/* If we can't access profiles, don't bother trying to redirect */
|
||||
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
|
||||
if( !Member::loggedIn()->canAccessModule( Module::get( 'core', 'members' ) ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$url = \IPS\Request::i()->url();
|
||||
$url = Request::i()->url();
|
||||
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'member.php' ) !== FALSE )
|
||||
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'member.php' ) !== FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( \IPS\Request::i()->cat, array( 'members', 'core_members' ) );
|
||||
return \IPS\Member::load( $data )->url();
|
||||
$data = (string) $this->app->getLink( Request::i()->cat, array( 'members', 'core_members' ) );
|
||||
return Member::load( $data )->url();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user