Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Member;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -66,38 +66,6 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'profile_step_title_';
|
||||
|
||||
/**
|
||||
* Load Record
|
||||
*
|
||||
* @see \IPS\Db::build
|
||||
* @param int|string $id ID
|
||||
* @param string $idField The database column that the $id parameter pertains to (NULL will use static::$databaseColumnId)
|
||||
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details) - if used will cause multiton store to be skipped and a query always ran
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
|
||||
{
|
||||
if ( $idField === NULL AND $extraWhereClause === NULL )
|
||||
{
|
||||
$steps = static::getStore();
|
||||
|
||||
if ( isset( $steps[ $id ] ) )
|
||||
{
|
||||
return static::constructFromData( $steps[ $id ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::load( $id, $idField, $extraWhereClause );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Return the custom badge for each row
|
||||
@@ -136,11 +104,12 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
* @param string|NULL $permissionCheck The permission key to check for or NULl to not check permissions
|
||||
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
|
||||
* @param mixed $where Additional WHERE clause
|
||||
* @param array|NULL $limit Limit/offset to use, or NULL for no limit (default)
|
||||
* @return array
|
||||
*/
|
||||
public static function roots( $permissionCheck='view', $member=NULL, $where=array() )
|
||||
public static function roots( $permissionCheck='view', $member=NULL, $where=array(), $limit=NULL )
|
||||
{
|
||||
if ( !count( $where ) )
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
$return = array();
|
||||
foreach( static::getStore() AS $node )
|
||||
@@ -152,22 +121,22 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::roots( $permissionCheck, $member, $where );
|
||||
return parent::roots( $permissionCheck, $member, $where, $limit );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Changed Columns
|
||||
*
|
||||
* @return void
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
|
||||
unset( \IPS\Data\Store::i()->profileSteps );
|
||||
}
|
||||
|
||||
protected $caches = array( 'profileSteps' );
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Attempt to load from cache
|
||||
* @note If this is set to TRUE you MUST define a getStore() method to return the objects from cache
|
||||
*/
|
||||
protected static $loadFromCache = TRUE;
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
@@ -184,8 +153,8 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
\IPS\Lang::deleteCustom( 'core', 'profile_step_text_' . $this->id );
|
||||
|
||||
parent::delete();
|
||||
|
||||
unset( \IPS\Data\Store::i()->profileSteps );
|
||||
|
||||
\IPS\Db::i()->delete( 'core_profile_completion', array( 'step_id=?', $this->id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +165,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
public function get_subcompletion_act()
|
||||
{
|
||||
$return = ! empty( $this->_data['subcompletion_act'] ) ? json_decode( $this->_data['subcompletion_act'], TRUE ) : array();
|
||||
if ( ! is_array( $return ) and ! empty( $this->_data['subcompletion_act'] ) )
|
||||
if ( ! \is_array( $return ) and ! empty( $this->_data['subcompletion_act'] ) )
|
||||
{
|
||||
$return = array( $this->_data['subcompletion_act'] );
|
||||
}
|
||||
@@ -207,12 +176,12 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
/**
|
||||
* Set the "subcompletion_act" field
|
||||
*
|
||||
* @param string|array $value
|
||||
* @return void
|
||||
* @param string|array $value Value of field
|
||||
* @return void
|
||||
*/
|
||||
public function set_subcompletion_act( $value )
|
||||
{
|
||||
$this->_data['subcompletion_act'] = ( is_array( $value ) ? json_encode( $value ) : $value );
|
||||
$this->_data['subcompletion_act'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +195,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
|
||||
foreach( static::loadAll() as $id => $object )
|
||||
{
|
||||
if ( $object->id !== $this->id and count( $object->subcompletion_act ) )
|
||||
if ( $object->id !== $this->id and \count( $object->subcompletion_act ) )
|
||||
{
|
||||
foreach( $object->subcompletion_act as $item )
|
||||
{
|
||||
@@ -241,7 +210,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
/**
|
||||
* Return the next step
|
||||
*
|
||||
* @return int
|
||||
* @return int|string
|
||||
*/
|
||||
public function getNextStep()
|
||||
{
|
||||
@@ -249,13 +218,13 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
$steps = array();
|
||||
foreach( \IPS\Application::allExtensions( 'core', 'ProfileSteps' ) AS $extension )
|
||||
{
|
||||
if ( method_exists( $extension, 'wizard') AND count( $extension::wizard() ) )
|
||||
if ( method_exists( $extension, 'wizard') AND \is_array( $extension::wizard() ) AND \count( $extension::wizard() ) )
|
||||
{
|
||||
$steps = array_merge( $steps, $extension::wizard() );
|
||||
}
|
||||
}
|
||||
|
||||
$steps = static::setOrder( $steps );
|
||||
|
||||
$steps = static::setOrder( $steps, FALSE );
|
||||
|
||||
foreach( $steps as $key => $object )
|
||||
{
|
||||
@@ -356,7 +325,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
* Can the actions have multiple choices?
|
||||
*
|
||||
* @param string $action Action key (basic_profile, etc)
|
||||
* @return boolean
|
||||
* @return boolean|null
|
||||
*/
|
||||
public static function actionMultipleChoice( $action )
|
||||
{
|
||||
@@ -432,7 +401,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $lang ) )
|
||||
if ( \count( $lang ) )
|
||||
{
|
||||
$result = \IPS\Member::loggedIn()->language()->get( 'complete_profile_' . $this->completion_act ) . ' (' . \IPS\Member::loggedIn()->language()->formatList( $lang ) . ')';
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $result );
|
||||
@@ -460,7 +429,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
/**
|
||||
* Has a specific step been completed?
|
||||
*
|
||||
* @param \IPS\Member|NULL The member to check, or NULL for currently logged in
|
||||
* @param \IPS\Member|NULL $member The member to check, or NULL for currently logged in
|
||||
* @return bool
|
||||
*/
|
||||
public function completed( \IPS\Member $member = NULL )
|
||||
@@ -470,17 +439,23 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Can add cache
|
||||
* @brief Can add cache
|
||||
*/
|
||||
protected static $canAdd = NULL;
|
||||
|
||||
/**
|
||||
* Can add new steps
|
||||
*
|
||||
* @return param
|
||||
* @return bool|int
|
||||
*/
|
||||
public function canAdd()
|
||||
{
|
||||
/* We can't add children, so just return now */
|
||||
if( $this->id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( static::$canAdd === NULL )
|
||||
{
|
||||
$actions = static::actions();
|
||||
@@ -512,7 +487,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form Form
|
||||
* @param \IPS\Helpers\Form $form Form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
@@ -544,8 +519,18 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
$disabled = $usedSubActions[ $key ];
|
||||
}
|
||||
|
||||
$formClass = static::actionMultipleChoice( $key ) ? '\IPS\Helpers\Form\CheckboxSet' : '\IPS\Helpers\Form\Select';
|
||||
$subActionFormElements[] = new $formClass( 'profile_step_subaction_' . $key, $this->subcompletion_act, TRUE, array( 'options' => $subActions[ $key ], 'disabled' => $disabled ), NULL, NULL, NULL, 'profile_step_subaction_' . $key );
|
||||
$choiceType = static::actionMultipleChoice( $key );
|
||||
|
||||
if( $choiceType === NULL )
|
||||
{
|
||||
$subActionFormElements[] = new \IPS\Helpers\Form\Translatable( 'profile_step_subaction_' . $key, $this->subcompletion_act, TRUE, array( 'app' => 'core', 'editor' => array( 'app' => 'core', 'key' => 'ProfileSteps', 'autoSaveKey' => 'core-step-' . $key . ( $this->id ?: 0 ) ) ), NULL, NULL, NULL, 'profile_step_subaction_' . $key );
|
||||
}
|
||||
else
|
||||
{
|
||||
$formClass = $choiceType ? '\IPS\Helpers\Form\CheckboxSet' : '\IPS\Helpers\Form\Select';
|
||||
$subActionFormElements[] = new $formClass( 'profile_step_subaction_' . $key, $this->subcompletion_act, TRUE, array( 'options' => $subActions[ $key ], 'disabled' => $disabled ), NULL, NULL, NULL, 'profile_step_subaction_' . $key );
|
||||
}
|
||||
|
||||
$toggles[ $key ][] = 'profile_step_subaction_' . $key;
|
||||
}
|
||||
}
|
||||
@@ -567,7 +552,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
|
||||
/**
|
||||
* Format Form Values
|
||||
* @param array Values
|
||||
* @param array $values Values
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
@@ -631,7 +616,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
|
||||
if ( array_key_exists( 'step_title', $return ) )
|
||||
{
|
||||
if ( is_array( $return['step_title'] ) )
|
||||
if ( \is_array( $return['step_title'] ) )
|
||||
{
|
||||
foreach( $return['step_title'] AS $lang => $text )
|
||||
{
|
||||
@@ -666,7 +651,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
/**
|
||||
* Find extension key from action key
|
||||
*
|
||||
* @param string The action key
|
||||
* @param string $key The action key
|
||||
* @return string The extension key
|
||||
* @throws \OutOfBoundsException
|
||||
*/
|
||||
@@ -690,7 +675,7 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
* Resync
|
||||
* Triggered when something happens externally that may affect these fields (such as a field being deleted, etc)
|
||||
*
|
||||
* return @void
|
||||
* @return void
|
||||
*/
|
||||
public static function resync()
|
||||
{
|
||||
@@ -733,18 +718,30 @@ class _ProfileStep extends \IPS\Node\Model
|
||||
* Given an array of wizard steps, reorder them based on AdminCP order
|
||||
*
|
||||
* @param array $steps Wizard steps
|
||||
* @param bool $countExtra Include extra steps
|
||||
* @return array
|
||||
*/
|
||||
public static function setOrder( $steps )
|
||||
public static function setOrder( $steps, $countExtra = TRUE )
|
||||
{
|
||||
$finalSteps = array();
|
||||
|
||||
foreach( array_keys( static::loadAll() ) as $id )
|
||||
$profileSteps = static::loadAll();
|
||||
|
||||
foreach( $profileSteps as $id => $profileStep )
|
||||
{
|
||||
if( isset( $steps['profile_step_title_' . $id ] ) )
|
||||
{
|
||||
$finalSteps['profile_step_title_' . $id ] = $steps['profile_step_title_' . $id ];
|
||||
}
|
||||
if ( $countExtra and method_exists( $profileStep->extension, 'extraStep') )
|
||||
{
|
||||
$extension = $profileStep->extension;
|
||||
if( \count( $extension::extraStep() ) and isset( $steps[ $extension::extraStepTitle() ] ) )
|
||||
{
|
||||
$finalSteps[ $extension::extraStepTitle() ] = $steps[ $extension::extraStepTitle() ];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $finalSteps;
|
||||
|
||||
Reference in new issue
Block a user