Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\core\ShareLinks;
/* 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;
@@ -86,25 +86,43 @@ class _Service extends \IPS\Node\Model
static::$rootsResult = NULL;
}
/**
* @brief Cached sharelinks
*/
protected static $cachedShareLinks = NULL;
/**
* Fetch All Nodes
*
* @return array
*/
public static function shareLinks()
{
if( static::$cachedShareLinks === NULL )
{
static::$cachedShareLinks = array();
foreach ( static::getStore() as $service )
{
static::$cachedShareLinks[] = static::constructFromData( $service );
}
}
return static::$cachedShareLinks;
}
/**
* Get data store
*
* @return array
*/
public static function getStore()
{
if ( !isset( \IPS\Data\Store::i()->shareLinks ) )
{
\IPS\Data\Store::i()->shareLinks = iterator_to_array( \IPS\Db::i()->select( '*', static::$databaseTable, NULL, static::$databasePrefix . static::$databaseColumnOrder ) );
}
$return = array();
foreach ( \IPS\Data\Store::i()->shareLinks as $service )
{
$return[] = static::constructFromData( $service );
}
return $return;
return \IPS\Data\Store::i()->shareLinks;
}
/**
@@ -113,11 +131,18 @@ class _Service extends \IPS\Node\Model
* @param \IPS\Http\Url $url URL to the content [optional - if omitted, some services will figure out on their own]
* @param string $title Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
* @param \IPS\Member|NULL $member Member the links will display to or NULL for currently logged in member
* @param \IPS\Content|NULL $item Content item (or comment) to share
* @return array
*/
public static function getAllServices( \IPS\Http\Url $url, $title, \IPS\Member $member = NULL, \IPS\Content $item = NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if( \IPS\Settings::i()->ref_on )
{
$url = $url->setQueryString( array( '_rid' => $member->member_id ) );
}
$services = array();
foreach( static::shareLinks() as $node )
{
@@ -142,12 +167,16 @@ class _Service extends \IPS\Node\Model
*/
public function getService( \IPS\Http\Url $url, $title, $item )
{
if( file_exists( \IPS\ROOT_PATH . '/system/Content/ShareServices/' . ucwords( $this->key ) . '.php' ) )
try
{
$className = "IPS\\Content\\ShareServices\\" . ucwords( $this->key );
$className = \IPS\Content\ShareServices::getClassByKey( $this->key );
return new $className( $url, $title, $item );
}
throw new \LogicException;
catch ( \InvalidArgumentException $e )
{
throw new \LogicException;
}
}
/**
@@ -204,7 +233,8 @@ class _Service extends \IPS\Node\Model
$form->add( new \IPS\Helpers\Form\Select( 'share_groups', ( $this->groups != '*' ) ? explode( ",", $this->groups ) : $this->groups, FALSE, array( 'options' => \IPS\Member\Group::groups(), 'parse' => 'normal', 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'everyone' ) ) );
/* Find the service and see if it has any additional settings... */
$className = "\\IPS\\Content\\ShareServices\\" . ucwords( $this->key );
$services = \IPS\Content\ShareServices::services();
$className = $services[ ucwords( $this->key ) ];
$className::modifyForm( $form, $this );
}
@@ -217,7 +247,7 @@ class _Service extends \IPS\Node\Model
*/
public function formatFormValues( $values )
{
if( count( $values ) )
if( \count( $values ) )
{
if ( isset( $values[ 'share_autoshare_' . ucwords( $this->key ) ] ) )
{
@@ -237,13 +267,13 @@ class _Service extends \IPS\Node\Model
$settingsToUpdate = array();
foreach ( $values as $k => $v )
{
if( !in_array( $k, array( 'share_title', 'share_groups', 'share_autoshare' ) ) )
if( !\in_array( $k, array( 'share_title', 'share_groups', 'share_autoshare' ) ) )
{
if ( $v instanceof \IPS\GeoLocation )
{
$v = json_encode( $v );
}
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
$v = implode( ',', $v );
}
@@ -372,26 +402,10 @@ class _Service extends \IPS\Node\Model
}
return parent::search( $column, $query, $order, $where );
}
/**
* 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()->shareLinks );
}
/**
* [ActiveRecord] Delete Record
*
* @return void
*/
public function delete()
{
parent::delete();
unset( \IPS\Data\Store::i()->shareLinks );
}
protected $caches = array( 'shareLinks' );
}