Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Profile Sync Abstract Class
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 13 Jun 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -40,13 +40,15 @@ abstract class _ProfileSyncAbstract
|
||||
{
|
||||
if ( !$file->isDot() and mb_substr( $file, -4 ) === '.php' and mb_substr( $file, 0, 2 ) != '._' )
|
||||
{
|
||||
require_once $file->getPathname();
|
||||
$class = 'IPS\core\ProfileSync\\' . mb_substr( $file, 0, -4 );
|
||||
|
||||
if ( $class::enabled() )
|
||||
if ( class_exists( 'IPS\core\ProfileSync\\' . mb_substr( $file, 0, -4 ) ) )
|
||||
{
|
||||
$services[ mb_substr( $file, 0, -4 ) ] = $class;
|
||||
}
|
||||
$class = 'IPS\core\ProfileSync\\' . mb_substr( $file, 0, -4 );
|
||||
|
||||
if ( $class::enabled() )
|
||||
{
|
||||
$services[ mb_substr( $file, 0, -4 ) ] = $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $services;
|
||||
@@ -97,19 +99,22 @@ abstract class _ProfileSyncAbstract
|
||||
*/
|
||||
abstract public function connected();
|
||||
|
||||
/**
|
||||
* Get photo
|
||||
*
|
||||
* @return \IPS\Http\Url|\IPS\File|NULL
|
||||
*/
|
||||
abstract public function photo();
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function name();
|
||||
|
||||
/**
|
||||
* Member can import statuses?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function canImportStatus( \IPS\Member $member )
|
||||
{
|
||||
return \IPS\Settings::i()->profile_comments and method_exists( $this, 'status' ) and $member->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) and $member->pp_setting_count_comments and !$member->members_bitoptions['bw_no_status_update'] and !$member->group['gbw_no_status_import'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
@@ -156,7 +161,7 @@ abstract class _ProfileSyncAbstract
|
||||
$return[] = $_return[0];
|
||||
}
|
||||
}
|
||||
if ( $settings['status'] )
|
||||
if ( $settings['status'] and \IPS\Settings::i()->profile_comments )
|
||||
{
|
||||
$langKey = 'sync_settings_status_' . $settings['status'];
|
||||
$return[] = \IPS\Member::loggedIn()->language()->addToStack( $langKey );
|
||||
@@ -186,7 +191,7 @@ abstract class _ProfileSyncAbstract
|
||||
$settings[ static::$loginKey ] = array(
|
||||
'photo' => isset( $values['profilesync_photo'] ) ? $values['profilesync_photo'] : ( isset( $settings[ static::$loginKey ]['photo'] ) ? $settings[ static::$loginKey ]['photo'] : FALSE ),
|
||||
'cover' => isset( $values['profilesync_cover'] ) ? $values['profilesync_cover'] : ( isset( $settings[ static::$loginKey ]['cover'] ) ? $settings[ static::$loginKey ]['cover'] : FALSE ),
|
||||
'status' => isset( $values['profilesync_status'] ) ? ( $values['profilesync_status'] == 'none' ) ? FALSE : $values['profilesync_status'] : ( isset( $settings[ static::$loginKey ]['status'] ) ? $settings[ static::$loginKey ]['status'] : FALSE ),
|
||||
'status' => isset( $values['profilesync_status'] ) ? ( $values['profilesync_status'] ? 'import' : '' ) : ( isset( $settings[ static::$loginKey ]['status'] ) ? $settings[ static::$loginKey ]['status'] : FALSE ),
|
||||
);
|
||||
|
||||
/* We cannot have more than one service syncing photos/cover photos - otherwise they conflict */
|
||||
@@ -224,6 +229,12 @@ abstract class _ProfileSyncAbstract
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
/* Don't sync for banned users */
|
||||
if( $this->member->isBanned() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = $this->settings();
|
||||
if ( $settings['photo'] )
|
||||
{
|
||||
@@ -250,22 +261,32 @@ abstract class _ProfileSyncAbstract
|
||||
}
|
||||
if ( $settings['cover'] and $this->member->group['gbw_allow_upload_bgimage'] )
|
||||
{
|
||||
if ( $this->member->pp_cover_photo )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_Profile', $this->member->pp_cover_photo )->delete();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
/* Download and import the synced cover photo */
|
||||
try
|
||||
{
|
||||
$this->member->pp_cover_photo = (string) $this->cover();
|
||||
$coverPhoto = (string) $this->cover();
|
||||
}
|
||||
catch ( \RuntimeException $e ) {}
|
||||
|
||||
/* Did we get a cover photo returned? */
|
||||
if ( !empty( $coverPhoto ) )
|
||||
{
|
||||
/* Delete any existing */
|
||||
if ( $this->member->pp_cover_photo )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_Profile', $this->member->pp_cover_photo )->delete();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
/* Save */
|
||||
$this->member->pp_cover_photo = $coverPhoto;
|
||||
}
|
||||
}
|
||||
if ( $settings['status'] and $settings['status'] == 'import' and !$this->member->group['gbw_no_status_import'] )
|
||||
/* We check against canImportStatus() to ensure we check all appropriate restrictions, including group and member restrictions */
|
||||
if ( $settings['status'] and $settings['status'] == 'import' and $this->canImportStatus( $this->member ) )
|
||||
{
|
||||
if ( $status = $this->status() )
|
||||
{
|
||||
@@ -276,6 +297,8 @@ abstract class _ProfileSyncAbstract
|
||||
$status->member_id = $this->member->member_id;
|
||||
$status->imported = TRUE;
|
||||
$status->save();
|
||||
|
||||
\IPS\Content\Search\Index::i()->index( $status );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
@@ -304,4 +327,22 @@ abstract class _ProfileSyncAbstract
|
||||
|
||||
$this->_disassociate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse status text - ensures valid and safe HTML, filters profanity, etc.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
protected function _parseStatusText( $value )
|
||||
{
|
||||
/* Make sure utf8mb4 characters won't cause us issues */
|
||||
$value = \IPS\Text\Parser::utf8mb4SafeDecode( $value );
|
||||
|
||||
/* Parse */
|
||||
$value = \IPS\Text\Parser::parseStatic( $value, FALSE, NULL, $this->member, 'core_Members' );
|
||||
|
||||
/* Return */
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user