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 Abstract Login Handler
|
||||
* @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 15 Mar 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -83,11 +83,12 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
$obj->_new = FALSE;
|
||||
|
||||
/* Import data */
|
||||
$databasePrefixLength = \strlen( static::$databasePrefix );
|
||||
foreach ( $data as $k => $v )
|
||||
{
|
||||
if( static::$databasePrefix )
|
||||
{
|
||||
$k = \substr( $k, \strlen( static::$databasePrefix ) );
|
||||
$k = \substr( $k, $databasePrefixLength );
|
||||
}
|
||||
|
||||
$obj->$k = $v;
|
||||
@@ -110,6 +111,16 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get the title to store in the log
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function titleForLog()
|
||||
{
|
||||
return $this->_logKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get the log key
|
||||
*
|
||||
@@ -117,7 +128,7 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
*/
|
||||
protected function get__logKey()
|
||||
{
|
||||
return "login_handler_" . ucfirst($this->key);
|
||||
return \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'login_handler_' . ucfirst( $this->key ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +198,16 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'login_acp', $this->acp ) );
|
||||
}
|
||||
|
||||
if ( isset( static::$shareService ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$shareService = \IPS\core\ShareLinks\Service::load( static::$shareService, 'share_key' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'share_autoshare_' . $this->key, $shareService->autoshare ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,6 +237,11 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $values[ 'share_autoshare_' . $this->key ] ) )
|
||||
{
|
||||
$save['autoshare'] = $values[ 'share_autoshare_' . $this->key ];
|
||||
}
|
||||
|
||||
$values['settings'] = json_encode( $save );
|
||||
$this->settings = $values['settings'];
|
||||
|
||||
@@ -229,6 +255,29 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Save Add/Edit Form
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return void
|
||||
*/
|
||||
public function saveForm( $values )
|
||||
{
|
||||
if ( isset( $values[ 'share_autoshare_' . $this->key ] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$shareService = \IPS\core\ShareLinks\Service::load( static::$shareService, 'share_key' );
|
||||
$shareService->autoshare = $values[ 'share_autoshare_' . $this->key ];
|
||||
$shareService->save();
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
unset( $values[ 'share_autoshare_' . $this->key ] );
|
||||
}
|
||||
|
||||
parent::saveForm( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save Changed Columns
|
||||
*
|
||||
@@ -240,17 +289,6 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
unset( \IPS\Data\Store::i()->loginHandlers );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
unset( \IPS\Data\Store::i()->loginHandlers );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an account from login - checks registration is enabled, the name/email doesn't already exists and calls the spam service
|
||||
*
|
||||
@@ -269,7 +307,7 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
/* Create an account */
|
||||
if ( !$member or !$member->member_id )
|
||||
{
|
||||
/* Is registraion enabled? */
|
||||
/* Is registration enabled? */
|
||||
if( !\IPS\Settings::i()->allow_reg )
|
||||
{
|
||||
$exception = new \IPS\Login\Exception( 'reg_disabled', \IPS\Login\Exception::REGISTRATION_DISABLED );
|
||||
@@ -281,13 +319,8 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
/* Init */
|
||||
$member = new \IPS\Member;
|
||||
$member->member_group_id = \IPS\Settings::i()->member_group;
|
||||
|
||||
/* If we admin validation is enabled, set that flag */
|
||||
if ( \IPS\Settings::i()->reg_auth_type == 'admin' or \IPS\Settings::i()->reg_auth_type == 'admin_user' )
|
||||
{
|
||||
$member->members_bitoptions['validating'] = TRUE;
|
||||
}
|
||||
|
||||
$member->members_bitoptions['view_sigs'] = TRUE;
|
||||
|
||||
/* Set name - if it already exists, we'll leave it blank and they'll be prompted to fill it in */
|
||||
if ( $name !== NULL and ( !\IPS\Settings::i()->username_characters or preg_match( '/^[' . str_replace( '\-', '-', preg_quote( \IPS\Settings::i()->username_characters, '/' ) ) . ']*$/i', $name ) ) )
|
||||
{
|
||||
@@ -343,14 +376,7 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
$member->$k = $v;
|
||||
}
|
||||
$member->save();
|
||||
|
||||
/* Users created by log in don't need to validate their email if the service provided it,
|
||||
so if we admin and user validation is required, set that the user validated */
|
||||
if ( \IPS\Settings::i()->reg_auth_type == 'admin_user' )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_validating', array( 'user_verified' => 1 ), array( 'member_id=?', $member->member_id ) );
|
||||
}
|
||||
|
||||
|
||||
/* Sync photo, etc now */
|
||||
if ( $profileSync !== NULL )
|
||||
{
|
||||
@@ -359,15 +385,10 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
$sync->sync();
|
||||
}
|
||||
|
||||
if( \IPS\Settings::i()->reg_auth_type != 'none' AND \IPS\Settings::i()->reg_auth_type != 'admin' AND !$member->members_bitoptions['bw_is_spammer'] )
|
||||
/* If registration is complete, do post-registration stuff */
|
||||
if ( $member->name and $member->email and !$member->members_bitoptions['bw_is_spammer'] )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_validate', array( $member, \IPS\Db::i()->select( 'vid', 'core_validating', array( 'member_id=?', $member->member_id ) )->first() ) )->send( $member );
|
||||
}
|
||||
|
||||
/* Notify the incoming mail address except if they're a spammer */
|
||||
if( \IPS\Settings::i()->new_reg_notify && !$member->members_bitoptions['bw_is_spammer'] )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'registration_notify', array( $member, array() ) )->send( \IPS\Settings::i()->email_in );
|
||||
$member->postRegistration( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +398,11 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
foreach ( $memberProperties as $k => $v )
|
||||
{
|
||||
$member->$k = $v;
|
||||
|
||||
if( $k == 'members_pass_hash' )
|
||||
{
|
||||
$member->member_login_key = '';
|
||||
}
|
||||
}
|
||||
$member->save();
|
||||
}
|
||||
@@ -416,6 +442,16 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an action when the login handler is disabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onDisable()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the type as a textual string
|
||||
*
|
||||
@@ -608,7 +644,7 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
{
|
||||
try
|
||||
{
|
||||
$return[ $key ] = self::load( $key );
|
||||
$return[ $key ] = static::load( $key );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
@@ -616,4 +652,23 @@ abstract class _LoginAbstract extends \IPS\Node\Model
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a member sign in with this login handler?
|
||||
* Used to ensure when a user disassociates a social login that they have some other way of logging in
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
abstract function canProcess( \IPS\Member $member );
|
||||
|
||||
/**
|
||||
* [Node] Does the currently logged in user have permission to delete this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user