Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -50,7 +50,7 @@ class _Ckeditor
/* This can take a while.... */
set_time_limit(0);
$command = "rm -R {$path}/applications/core/interface/ckeditor/ckeditor 2>&1";
$command = "rm -R \"{$path}/applications/core/interface/ckeditor/ckeditor\" 2>&1";
$output = array();
\exec( $command, $output );
@@ -59,7 +59,7 @@ class _Ckeditor
throw new \UnexpectedValueException( \IPS\Member::loggedIn()->language()->addToStack('dev_build_ckeditor_exists_err', FALSE, array( 'sprintf' => array( "{$path}/applications/core/interface/ckeditor/ckeditor" ) ) ) );
}
$command = "{$_javaPath}java -jar {$path}/applications/core/dev/ckbuilder.jar --build {$path}/applications/core/dev/ckeditor {$path}/applications/core/interface/ckeditor --build-config {$path}/applications/core/dev/ckeditor/build-config.js --no-zip --no-tar --overwrite 2>&1";
$command = "{$_javaPath}java -jar \"{$path}/applications/core/dev/ckbuilder.jar\" --build \"{$path}/applications/core/dev/ckeditor\" \"{$path}/applications/core/interface/ckeditor\" --build-config \"{$path}/applications/core/dev/ckeditor/build-config.js\" --no-zip --no-tar --overwrite 2>&1";
$output = array();
\exec( $command, $output );
@@ -7,7 +7,6 @@
* @package IPS Social Suite
* @since 20 June 2013
* @version SVN_VERSION_NUMBER
* @modified 13.09.2015 by IAF
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
@@ -185,17 +184,18 @@ class _Mandrill
throw new \DomainException( 'mandrill_bad_credentials' );
}
/* Do not Tell IPS */
$response = array(
"mail_method" => "smtp",
"smtp_host" => "smtp.mandrillapp.com",
"smtp_port"=> 587,
"mail_wrap_brackets" => 0,
"smtp_user" => $values['mandrill_username'],
"smtp_pass" => $values['mandrill_api_key'],
"smtp_helo" => "HELO"
);
/* Tell IPS */
$response = NULL;
try
{
$response = \IPS\Http\Url::ips( 'mandrill' )->request()->post( array(
'key' => $values['mandrill_api_key'],
'username' => $values['mandrill_username'],
'lkey' => \IPS\Settings::i()->ipb_reg_number,
'version' => \IPS\Application::load('core')->long_version
) )->decodeJson();
}
catch ( \IPS\Http\Request\Exception $e ) { }
/* If we want to use Mandrill for "everything", we need to update our local SMTP settings with the values returned from the API call */
if( $values['mandrill_use_for'] == 2 )
@@ -213,6 +213,4 @@ class _Mandrill
unset( \IPS\Data\Store::i()->settings );
}
}
}
/* Nulled by IandroidFan (IAF) */
}
@@ -7,7 +7,6 @@
* @package IPS Social Suite
* @since 17 Apr 2013
* @version SVN_VERSION_NUMBER
* @modified 13.09.2015 by IAF
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
@@ -52,7 +51,7 @@ class _SpamMonitoring
public function __construct()
{
$licenseData = \IPS\IPS::licenseKey();
if( !$licenseData or !$licenseData['products']['spam'] or strtotime( $licenseData['expires'] ) < time() )
if( !$licenseData or !isset( $licenseData['products']['spam'] ) or !$licenseData['products']['spam'] or strtotime( $licenseData['expires'] ) < time() )
{
$this->enabled = false;
}
@@ -79,7 +78,7 @@ class _SpamMonitoring
}
catch ( \LogicException $e )
{
//Do not show error message. We will see error message in Settings
\IPS\Output::i()->error( $e->getMessage(), '2C116/2', 403, '' );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&tab=service' ) );
@@ -126,6 +125,4 @@ class _SpamMonitoring
throw new \DomainException('spam_service_noservice');
}
}
}
/* Nulled by IandroidFan (IAF) */
}
@@ -27,7 +27,21 @@ class _Status
/**
* @brief Content Item Classes
*/
public $classes = array( 'IPS\core\Statuses\Status' );
public $classes = array();
/**
* Constructor
*
* @param \IPS\Member|NULL $member If checking access, the member to check for, or NULL to not check access
* @return void
*/
public function __construct( \IPS\Member $member = NULL )
{
if ( \IPS\Settings::i()->profile_comments and ( $member === NULL or $member->canAccessModule( \IPS\Application\Module::get( 'core', 'status', 'front' ) ) ) )
{
$this->classes[] = 'IPS\core\Statuses\Status';
}
}
/**
* Use a custom table helper when building content item tables
@@ -47,8 +47,8 @@ class _AwaitingValidation
"*",
'core_validating',
array( 'user_verified=?', TRUE ),
NULL,
NULL
'entry_date desc',
array( 0, 10 )
)->join(
'core_members',
'core_validating.member_id=core_members.member_id'
@@ -57,7 +57,7 @@ class _Registrations
}
/* Add Rows */
foreach ( \IPS\Db::i()->select( "COUNT(*) AS count, DATE_FORMAT( FROM_UNIXTIME( joined ), '%e %c %Y' ) as joined_date", 'core_members', array( 'joined>? AND name<>? AND email<>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P7D' ) )->getTimestamp(), '', '' ), 'joined DESC', NULL, 'joined_date' ) as $row )
foreach ( \IPS\Db::i()->select( "COUNT(*) AS count, DATE_FORMAT( FROM_UNIXTIME( joined ), '%e %c %Y' ) as joined_date", 'core_members', array( 'joined>? AND name<>? AND email<>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P7D' ) )->getTimestamp(), '', '' ), 'joined_date DESC', NULL, 'joined_date' ) as $row )
{
$data[$row['joined_date']] = $row['count'];
}
@@ -164,4 +164,13 @@ class _Modcp
return $did;
}
/**
* Total content count to be used in progress indicator
*
* @return int Total Count
*/
public function contentCount()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_members_warn_logs' )->first();
}
}
@@ -148,4 +148,14 @@ class _Reports
return $did;
}
/**
* Total content count to be used in progress indicator
*
* @return int Total Count
*/
public function contentCount()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_rc_reports' )->first();
}
}
@@ -49,10 +49,16 @@ class _Emoticons
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'core_Emoticons', $emoticon['image'] )->move( $storageConfiguration );
if ( (string) $file != $emoticon['image'] )
$image_2x = NULL;
if ( $emoticon['image_2x'] )
{
\IPS\Db::i()->update( 'core_emoticons', array( 'image' => (string) $file ), array( 'id=?', $emoticon['id'] ) );
$image_2x = \IPS\File::get( $oldConfiguration ?: 'core_Emoticons', $emoticon['image_2x'] )->move( $storageConfiguration );
}
if ( (string) $file != $emoticon['image'] or (string) $image_2x != $emoticon['image_2x'] )
{
\IPS\Db::i()->update( 'core_emoticons', array( 'image' => (string) $file, 'image_2x' => (string) $image_2x ), array( 'id=?', $emoticon['id'] ) );
}
unset( \IPS\Data\Store::i()->emoticons );
@@ -72,13 +78,26 @@ class _Emoticons
public function fixUrls( $offset )
{
$emoticon = \IPS\Db::i()->select( '*', 'core_emoticons', array(), 'id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $emoticon['image'] ) )
try
{
\IPS\Db::i()->update( 'core_emoticons', array( 'image' => $new ), array( 'id=?', $emoticon['id'] ) );
unset( \IPS\Data\Store::i()->emoticons );
$fixed = array();
foreach( array( 'image', 'image_2x' ) as $location )
{
if ( $new = \IPS\File::repairUrl( $emoticon[ $location ] ) )
{
$fixed[ $location ] = $new;
}
}
if ( count( $fixed ) )
{
\IPS\Db::i()->update( 'core_emoticons', $fixed, array( 'id=?', $emoticon['id'] ) );
unset( \IPS\Data\Store::i()->emoticons );
}
}
catch( \Exception $e ) { }
}
/**
@@ -91,7 +110,7 @@ class _Emoticons
{
try
{
$emoticon = \IPS\Db::i()->select( '*', 'core_emoticons', array( 'image=?', (string) $file ) )->first();
$emoticon = \IPS\Db::i()->select( '*', 'core_emoticons', array( 'image=? or image_2x=?', (string) $file, (string) $file ) )->first();
return TRUE;
}
@@ -113,6 +132,7 @@ class _Emoticons
try
{
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
}
catch( \Exception $e ){}
}
@@ -75,11 +75,11 @@ class _Profile
if ( count( $update ) )
{
\IPS\Db::i()->update( 'core_members', $update, array( 'member_id=?', $member['member_id'] ) );
\IPS\Db::i()->update( 'core_members', $update, array( 'member_id=?', $memberData['member_id'] ) );
}
}
return $member['member_id'];
return $memberData['member_id'];
}
/**
@@ -23,6 +23,22 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Theme
{
/**
* Some file storage engines need to store a gzip version of some files that can be served to a browser gzipped
*/
public static $storeGzipExtensions = array( 'css', 'js' );
/**
* The configuration settings have been updated
*
* @return void
*/
public static function settingsUpdated()
{
/* Clear out CSS as custom URL may have changed */
\IPS\Theme::deleteCompiledCss();
}
/**
* Count stored files
*
@@ -31,7 +47,6 @@ class _Theme
public function count()
{
return 4; // While this isn't the number of files, it's the number of steps this will take to move them, which is all it's used for
}
/**
@@ -0,0 +1,85 @@
<?php
/**
* @brief Front Navigation Extension: All Activity
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: All Activity
*/
class _AllActivity extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Default Location
*
* @return mixed
*/
public static function defaultLocation()
{
return static::DEFAULT_LOCATION_ACTIVITY;
}
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('all_activity');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'discover' ) );
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('all_activity');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return \IPS\Http\Url::internal( "app=core&module=discover&controller=streams", 'front', 'discover_all' );
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'discover' and !isset( \IPS\Request::i()->id ) and ( !isset( \IPS\Request::i()->do ) or \IPS\Request::i()->do != 'create' );
}
}
@@ -0,0 +1,172 @@
<?php
/**
* @brief Front Navigation Extension: Custom Item
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 21 Jan 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Custom Item
*/
class _CustomItem extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('menu_custom_item');
}
/**
* Allow multiple instances?
*
* @return string
*/
public static function allowMultiple()
{
return TRUE;
}
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
{
$currentUrl = NULL;
if ( isset( $existingConfiguration['menu_custom_item_url'] ) )
{
if ( isset( $existingConfiguration['internal'] ) )
{
$currentUrl = (string) \IPS\Http\Url::internal( $existingConfiguration['menu_custom_item_url'], 'front', $existingConfiguration['internal'] );
}
else
{
$currentUrl = $existingConfiguration['menu_custom_item_url'];
}
}
return array(
new \IPS\Helpers\Form\Translatable( 'menu_custom_item_link', NULL, NULL, array( 'app' => 'core', 'key' => $id ? "menu_item_{$id}" : NULL ) ),
new \IPS\Helpers\Form\Url( 'menu_custom_item_url', $currentUrl, NULL, array(), function( $val )
{
if ( isset( \IPS\Request::i()->menu_manager_extension ) and \IPS\Request::i()->menu_manager_extension === 'core_CustomItem' and empty( $val ) )
{
throw new \InvalidArgumentException('form_required');
}
} )
);
}
/**
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @return array
*/
public static function parseConfiguration( $configuration, $id )
{
$baseUrl = \IPS\Http\Url::internal('', 'front');
try
{
if ( ( $baseUrl->data['host'] === $configuration['menu_custom_item_url']->data['host'] ) and $queryString = $configuration['menu_custom_item_url']->getFriendlyUrlData() )
{
$furlDefinition = \IPS\Http\Url::furlDefinition();
$usedTemplate = NULL;
$query = $configuration['menu_custom_item_url']->getFurlQuery();
$set = array();
$configuration['menu_custom_item_url']->examineFurl( $furlDefinition, $query, $set, $usedTemplate );
if ( $usedTemplate and isset( $usedTemplate['_template'] ) )
{
$configuration['menu_custom_item_url'] = http_build_query( $queryString );
$configuration['internal'] = $usedTemplate['_template'];
}
else
{
$configuration['menu_custom_item_url'] = (string) $configuration['menu_custom_item_url'];
}
}
else
{
$configuration['menu_custom_item_url'] = (string) $configuration['menu_custom_item_url'];
}
}
/*getFriendlyUrlData() can throw an OutOfRangeException, especially if we are linking to a URL not within the community suite but on the same domain */
catch( \OutOfRangeException $e )
{
$configuration['menu_custom_item_url'] = (string) $configuration['menu_custom_item_url'];
}
\IPS\Lang::saveCustom( 'core', "menu_item_{$id}", $configuration['menu_custom_item_link'] );
unset( $configuration['menu_custom_item_link'] );
return $configuration;
}
/**
* Permissions can be inherited?
*
* @return bool
*/
public static function permissionsCanInherit()
{
return FALSE;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( "menu_item_{$this->id}" );
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
if ( isset( $this->configuration['menu_custom_item_url'] ) and ( $this->configuration['menu_custom_item_url'] or isset( $this->configuration['internal'] ) ) )
{
if ( isset( $this->configuration['internal'] ) )
{
return \IPS\Http\Url::internal( $this->configuration['menu_custom_item_url'], 'front', $this->configuration['internal'] );
}
else
{
return \IPS\Http\Url::external( $this->configuration['menu_custom_item_url'] );
}
}
else
{
return '#';
}
}
}
@@ -0,0 +1,82 @@
<?php
/**
* @brief Front Navigation Extension: Guidelines
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Guidelines
*/
class _Guidelines extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('guidelines');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and \IPS\Settings::i()->gl_type != "none";
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('guidelines');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
if ( \IPS\Settings::i()->gl_type == "internal" )
{
return \IPS\Http\Url::internal( "app=core&module=system&controller=guidelines", 'front', 'guidelines' );
}
else
{
return \IPS\Http\Url::external( \IPS\Settings::i()->gl_link );
}
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'system' and \IPS\Dispatcher::i()->controller === 'guidelines';
}
}
@@ -0,0 +1,129 @@
<?php
/**
* @brief Front Navigation Extension: Dropdown Menu
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Dropdown Menu
*/
class _Menu extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('menu_custom_menu');
}
/**
* Allow multiple instances?
*
* @return string
*/
public static function allowMultiple()
{
return TRUE;
}
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
{
return array(
new \IPS\Helpers\Form\Translatable( 'menu_custom_menu_title', NULL, NULL, array( 'app' => 'core', 'key' => $id ? "menu_item_{$id}" : NULL ) ),
);
}
/**
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @return array
*/
public static function parseConfiguration( $configuration, $id )
{
\IPS\Lang::saveCustom( 'core', "menu_item_{$id}", $configuration['menu_custom_menu_title'] );
unset( $configuration['menu_custom_menu_title'] );
return $configuration;
}
/**
* Permissions can be inherited?
*
* @return bool
*/
public static function permissionsCanInherit()
{
return FALSE;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( "menu_item_{$this->id}" );
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return NULL;
}
/**
* Children
*
* @return array
*/
public function children()
{
$items = array();
$frontNavigation = \IPS\core\FrontNavigation::frontNavigation();
if ( isset( $frontNavigation[ $this->id ] ) )
{
foreach ( $frontNavigation[ $this->id ] as $item )
{
if ( \IPS\Application::appIsEnabled( $item['app'] ) )
{
$class = 'IPS\\' . $item['app'] . '\extensions\core\FrontNavigation\\' . $item['extension'];
$items[ $item['id'] ] = new $class( json_decode( $item['config'], TRUE ), $item['id'], $item['permissions'] );
}
}
}
return $items;
}
}
@@ -0,0 +1,89 @@
<?php
/**
* @brief Front Navigation Extension: Menu Button
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 22 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Menu Button
*/
class _MenuButton
{
/**
* @brief The language string for the title
*/
protected $title;
/**
* @brief The target URL
*/
protected $link;
/**
* Constructor
*
* @param string $title The language string for the title
* @param \IPS\Http\Url $link The target URL
* @return void
*/
public function __construct( $title, \IPS\Http\Url $link )
{
$this->title = $title;
$this->link = $link;
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return TRUE;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( $this->title );
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return $this->link;
}
/**
* Children
*
* @return array
*/
public function children()
{
return NULL;
}
}
@@ -1,12 +1,12 @@
<?php
/**
* @brief Front Navigation Extension: Core
* @brief Front Navigation Extension: Menu Header
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 21 Jan 2015
* @since 22 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -20,10 +20,26 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
}
/**
* Front Navigation Extension: Core
* Front Navigation Extension: Menu Header
*/
class _Core
class _MenuHeader
{
/**
* @brief The language string for the title
*/
protected $title;
/**
* Constructor
*
* @param string $title The language string for the title
* @return void
*/
public function __construct( $title )
{
$this->title = $title;
}
/**
* Can access?
*
@@ -31,7 +47,7 @@ class _Core
*/
public function canView()
{
return (bool) \IPS\Settings::i()->show_home_link;
return TRUE;
}
/**
@@ -41,29 +57,9 @@ class _Core
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('home_name_value');
return \IPS\Member::loggedIn()->language()->addToStack( $this->title );
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return \IPS\Http\Url::external( \IPS\Settings::i()->home_url );
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return FALSE;
}
/**
* Children
*
@@ -71,6 +67,6 @@ class _Core
*/
public function children()
{
return array();
return NULL;
}
}
@@ -0,0 +1,46 @@
<?php
/**
* @brief Front Navigation Extension: Menu Separator
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 22 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Menu Separator
*/
class _MenuSeparator
{
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return TRUE;
}
/**
* Children
*
* @return array
*/
public function children()
{
return NULL;
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @brief Front Navigation Extension: Online Users
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Online Users
*/
class _OnlineUsers extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('online_users');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) );
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('online_users');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return \IPS\Http\Url::internal( "app=core&module=online&controller=online", 'front', 'online' );
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'online';
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @brief Front Navigation Extension: Search
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Search
*/
class _Search extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('search');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'search' ) );
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('search');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return \IPS\Http\Url::internal( "app=core&module=search&controller=search", 'front', 'search' );
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'search';
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @brief Front Navigation Extension: Staff Directory
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Staff Directory
*/
class _StaffDirectory extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('staff');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and !\IPS\Settings::i()->staff_directory_empty;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('staff');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return \IPS\Http\Url::internal( "app=core&module=members&controller=directory", 'front', 'staffdirectory' );
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'staffdirectory' and \IPS\Dispatcher::i()->controller === 'directory';
}
}
@@ -0,0 +1,150 @@
<?php
/**
* @brief Front Navigation Extension: Your Activity Streams
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 30 Jun 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Your Activity Streams
*/
class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('your_activity_streams_acp');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
return parent::canView() and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'discover' ) ) and count( $this->children() );
}
/**
* Get Title
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack('your_activity_streams');
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
return NULL;
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return ( \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'discover' and ( isset( \IPS\Request::i()->id ) or ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'create' ) ) ) or parent::active();
}
/**
* Cached Children
*
* @return array
*/
protected static $children = array();
/**
* Items
*
* @return array
*/
public static function items( \IPS\Member $member = NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if ( !isset( static::$children[ $member->member_id ] ) )
{
static::$children[ $member->member_id ] = array();
if ( !isset( \IPS\Data\Store::i()->globalStreamIds ) )
{
$globalStreamIds = array();
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', 'member IS NULL' ), 'IPS\core\Stream' ) as $stream )
{
$globalStreamIds[ $stream->id ] = ( $stream->ownership == 'all' and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' );
}
\IPS\Data\Store::i()->globalStreamIds = $globalStreamIds;
}
$globalStreamIdsToShow = array_keys( !$member->member_id ? array_filter( \IPS\Data\Store::i()->globalStreamIds ) : \IPS\Data\Store::i()->globalStreamIds );
if ( count( $globalStreamIdsToShow ) )
{
if ( $member->member_id )
{
static::$children[ $member->member_id ][] = new MenuHeader('default_streams');
}
foreach ( $globalStreamIdsToShow as $id )
{
static::$children[ $member->member_id ][] = new YourActivityStreamsItem( array(), $id, '*' );
}
}
if ( $member->member_id )
{
if ( $member->member_streams and $streams = json_decode( $member->member_streams, TRUE ) and count( $streams ) )
{
static::$children[ $member->member_id ][] = new MenuHeader('custom_streams');
foreach ( $streams['streams'] as $id => $title )
{
static::$children[ $member->member_id ][] = new YourActivityStreamsItem( array( 'title' => $title ), $id, '*' );
}
}
static::$children[ $member->member_id ][] = new MenuSeparator;
static::$children[ $member->member_id ][] = new MenuButton( 'create_new_stream', \IPS\Http\Url::internal( "app=core&module=discover&controller=streams&do=create", 'front', 'discover_all' ) );
}
}
return static::$children[ $member->member_id ];
}
/**
* Children
*
* @return array
*/
public function children()
{
return static::items();
}
}
@@ -0,0 +1,218 @@
<?php
/**
* @brief Front Navigation Extension: Custom Item
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Core
* @since 21 Jan 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Front Navigation Extension: Custom Item
*/
class _YourActivityStreamsItem extends \IPS\core\FrontNavigation\FrontNavigationAbstract
{
/**
* @brief The ID number
*/
public $id;
/**
* @brief The stream ID
*/
protected $streamId;
/**
* Constructor
*
* @param array $configuration The configuration
* @param int $id The ID number
* @param string $permissions The permissions (* or comma-delimited list of groups)
* @return void
*/
public function __construct( $configuration, $id, $permissions )
{
parent::__construct( $configuration, $id, $permissions );
if ( count( $configuration ) and isset( $configuration['menu_stream_id'] ) )
{
$this->streamId = $configuration['menu_stream_id'];
}
else
{
$this->streamId = $id;
}
}
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
{
return \IPS\Member::loggedIn()->language()->addToStack('activity_stream_single');
}
/**
* Can access?
*
* @return bool
*/
public function canView()
{
if ( ! \IPS\Member::loggedIn()->member_id and $this->streamId and $this->streamId <= 5 )
{
return FALSE;
}
return TRUE;
}
/**
* Allow multiple instances?
*
* @return string
*/
public static function allowMultiple()
{
return TRUE;
}
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
{
$globalStreams = array();
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', 'member IS NULL' ), 'IPS\core\Stream' ) as $stream )
{
$globalStreams[ $stream->id ] = $stream->_title;
}
return array(
new \IPS\Helpers\Form\Select( 'menu_stream_id', isset( $existingConfiguration['menu_stream_id'] ) ? $existingConfiguration['menu_stream_id'] : NULL, NULL, array( 'options' => $globalStreams ), NULL, NULL, NULL, 'menu_stream_id' ),
new \IPS\Helpers\Form\Radio( 'menu_title_type', isset( $existingConfiguration['menu_title_type'] ) ? $existingConfiguration['menu_title_type'] : 0, NULL, array( 'options' => array( 0 => 'menu_title_type_stream', 1 => 'menu_title_type_custom' ), 'toggles' => array( 1 => array( 'menu_stream_title' ) ) ), NULL, NULL, NULL, 'menu_title_type' ),
new \IPS\Helpers\Form\Translatable( 'menu_stream_title', NULL, NULL, array( 'app' => 'core', 'key' => $id ? "menu_stream_title_{$id}" : NULL ), NULL, NULL, NULL, 'menu_stream_title' ),
);
}
/**
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @return array
*/
public static function parseConfiguration( $configuration, $id )
{
if ( $configuration['menu_title_type'] )
{
\IPS\Lang::saveCustom( 'core', "menu_stream_title_{$id}", $configuration['menu_stream_title'] );
}
else
{
\IPS\Lang::deleteCustom( 'core', "menu_stream_title_{$id}" );
}
unset( $configuration['menu_stream_title'] );
return $configuration;
}
/**
* Get Title
*
* @return string
*/
public function title()
{
if ( ! empty( $this->configuration['title'] ) )
{
return $this->configuration['title'];
}
else if ( isset( $this->configuration['menu_title_type'] ) and $this->configuration['menu_title_type'] )
{
return \IPS\Member::loggedIn()->language()->addToStack( "menu_stream_title_{$this->id}" );
}
return \IPS\Member::loggedIn()->language()->addToStack( "stream_title_{$this->streamId}" );
}
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
{
switch ( $this->streamId )
{
case 1:
$furlKey = 'discover_unread';
break;
case 2:
$furlKey = 'discover_istarted';
break;
case 3:
$furlKey = 'discover_followed';
break;
case 4:
$furlKey = 'discover_following';
break;
case 5:
$furlKey = 'discover_posted';
break;
default:
$furlKey = 'discover_stream';
break;
}
return \IPS\Http\Url::internal( "app=core&module=discover&controller=streams&id={$this->streamId}", 'front', $furlKey );
}
/**
* Get Attributes
*
* @return string
*/
public function attributes()
{
return "data-streamid='{$this->id}'";
}
/**
* Is Active?
*
* @return bool
*/
public function active()
{
return \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'discover' and \IPS\Request::i()->id == $this->streamId;
}
/**
* Children
*
* @return array
*/
public function children()
{
return NULL;
}
}
@@ -26,7 +26,7 @@ class _Content
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member\Group $group Existing Group
* @return void
*/
@@ -46,9 +46,12 @@ class _Content
}
/* Polls */
$form->addHeader( 'polls' );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_post_polls', $group->g_post_polls ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_vote_polls', $group->g_vote_polls ) );
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$form->addHeader( 'polls' );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_post_polls', $group->g_post_polls ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_vote_polls', $group->g_vote_polls ) );
}
/* Tags */
$form->addHeader( 'tags' );
@@ -68,18 +71,24 @@ class _Content
$form->add( new \IPS\Helpers\Form\YesNo( 'g_topic_rate_change', $group->g_topic_rate_setting == 2, FALSE, array(), NULL, NULL, NULL, 'g_topic_rate_change' ) );
/* Editing */
$form->addHeader( 'group_editing' );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_edit_posts', $group->g_edit_posts, FALSE, array( 'togglesOn' => array( 'g_edit_cutoff', 'g_append_edit' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'g_edit_cutoff', $group->g_edit_cutoff, FALSE, array( 'unlimited' => 0 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('g_edit_cutoff_prefix'), \IPS\Member::loggedIn()->language()->addToStack('g_edit_cutoff_suffix'), 'g_edit_cutoff' ) );
if ( \IPS\Settings::i()->edit_log )
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'g_append_edit', $group->g_append_edit, FALSE, array(), NULL, NULL, NULL, 'g_append_edit' ) );
$form->addHeader( 'group_editing' );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_edit_posts', $group->g_edit_posts, FALSE, array( 'togglesOn' => array( 'g_edit_cutoff', 'g_append_edit' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'g_edit_cutoff', $group->g_edit_cutoff, FALSE, array( 'unlimited' => 0 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('g_edit_cutoff_prefix'), \IPS\Member::loggedIn()->language()->addToStack('g_edit_cutoff_suffix'), 'g_edit_cutoff' ) );
if ( \IPS\Settings::i()->edit_log )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'g_append_edit', $group->g_append_edit, FALSE, array(), NULL, NULL, NULL, 'g_append_edit' ) );
}
}
/* Deleting */
$form->addHeader( 'group_deleting' );
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_soft_delete_own', $group->g_id ? ( $group->g_bitoptions['gbw_soft_delete_own'] ) : FALSE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_delete_own_posts', $group->g_delete_own_posts ) );
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$form->addHeader( 'group_deleting' );
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_soft_delete_own', $group->g_id ? ( $group->g_bitoptions['gbw_soft_delete_own'] ) : FALSE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'g_delete_own_posts', $group->g_delete_own_posts ) );
}
/* Content Limits */
if( $group->g_id != \IPS\Settings::i()->guest_group )
@@ -123,8 +132,11 @@ class _Content
}
/* Polls */
$group->g_post_polls = $values['g_post_polls'];
$group->g_vote_polls = $values['g_vote_polls'];
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$group->g_post_polls = $values['g_post_polls'];
$group->g_vote_polls = $values['g_vote_polls'];
}
/* Ratings */
$group->g_topic_rate_setting = 0;
@@ -151,7 +163,10 @@ class _Content
$bwKeys = array( 'gbw_disable_tagging', 'gbw_disable_prefixes', 'gbw_soft_delete_own', 'gbw_no_report', 'gbw_delete_attachments' );
foreach ( $bwKeys as $k )
{
$group->g_bitoptions[ $k ] = $values[ $k ];
if ( isset( $values[ $k ] ) )
{
$group->g_bitoptions[ $k ] = $values[ $k ];
}
}
/* Other */
@@ -166,7 +181,10 @@ class _Content
$keys = array( 'g_attach_max', 'g_attach_per_post', 'g_edit_posts', 'g_edit_cutoff', 'g_append_edit', 'g_delete_own_posts', 'g_avoid_flood', 'g_avoid_q', 'g_mod_preview', 'g_bypass_badwords' );
foreach ( $keys as $k )
{
$group->$k = $values[ $k ];
if ( isset( $values[ $k ] ) )
{
$group->$k = $values[ $k ];
}
}
}
}
@@ -26,7 +26,7 @@ class _GroupSettings
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member\Group $group Existing Group
* @return void
*/
@@ -26,7 +26,7 @@ class _Social
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member\Group $group Existing Group
* @return void
*/
@@ -84,10 +84,7 @@ class _Social
}
}
if ( !$group->g_id or !in_array( $group->g_id, explode( ',', \IPS\Settings::i()->reputation_protected_groups ) ) )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_view_reps', $group->g_id ? ( $group->g_bitoptions['gbw_view_reps'] ) : TRUE ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_view_reps', $group->g_id ? ( $group->g_bitoptions['gbw_view_reps'] ) : TRUE ) );
}
if( $group->g_id != \IPS\Settings::i()->guest_group )
@@ -68,7 +68,7 @@ class _Content extends \IPS\Content\ExtensionGenerator
try
{
$comment = $class::load( $data[ $class::$databasePrefix . $class::$databaseColumnId ] );
return "<a href='" . $comment->url() . "' target='_blank'>" . htmlentities( $comment->item()->mapped('title'), \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
return "<a href='" . $comment->url() . "' target='_blank'>" . htmlspecialchars( $comment->item()->mapped('title'), \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
}
catch ( \OutOfRangeException $e )
{
@@ -109,7 +109,7 @@ class _Content extends \IPS\Content\ExtensionGenerator
}
}
return "<a href='" . $class::load( $data[ $class::$databasePrefix . $class::$databaseColumnId ] )->url() . "' target='_blank'>" . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
return "<a href='" . $class::load( $data[ $class::$databasePrefix . $class::$databaseColumnId ] )->url() . "' target='_blank'>" . htmlspecialchars( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
},
);
if( isset( $class::$databaseColumnMap['container'] ) )
@@ -118,7 +118,7 @@ class _Content extends \IPS\Content\ExtensionGenerator
{
$nodeClass = $class::$containerNodeClass;
$node = $nodeClass::load( $val );
return "<a href='" . $node->url() . "' target='_blank'>" . htmlentities( $node->_title, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
return "<a href='" . $node->url() . "' target='_blank'>" . htmlspecialchars( $node->_title, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
};
}
@@ -98,7 +98,7 @@ class _BasicInformation
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member $member Existing Member
* @return void
*/
@@ -26,7 +26,7 @@ class _Notifications
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member $member Existing Member
* @return void
*/
@@ -26,7 +26,7 @@ class _Preferences
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member $member Existing Member
* @return void
*/
@@ -97,16 +97,15 @@ class _Preferences
$member->timezone = $values['timezone'];
}
/* language */
/* Language and Theme */
$member->language = $values['language'];
$member->skin = $values['skin'];
if( $member->isAdmin() )
{
$member->language = $values['language'];
$member->acp_language = $values['acp_language'];
$member->acp_skin = $values['acp_skin'];
}
/* Skin */
$member->skin = $values['skin'];
/* Other */
$member->members_bitoptions['view_sigs'] = $values['view_sigs'];
}
@@ -26,7 +26,7 @@ class _Profile
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member $member Existing Member
* @return void
*/
@@ -146,5 +146,7 @@ class _Profile
}
}
\IPS\Db::i()->replace( 'core_pfields_content', $profileFields );
$member->changedCustomFields = $profileFields;
}
}
@@ -26,7 +26,7 @@ class _Restrictions
/**
* Process Form
*
* @param \IPS\Form\Tabbed $form The form
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member $member Existing Member
* @return void
*/
@@ -133,6 +133,7 @@ class _System
'core_pfields_content' => 'member_id',
'core_ratings' => 'member',
'core_reputation_index' => 'member_id',
'core_reputation_index' => 'member_received',
'core_sessions' => 'member_id',
'core_sys_cp_sessions' => 'session_member_id',
'core_sys_social_groups' => 'owner_id',
@@ -32,7 +32,7 @@ class _ipsconnect
*/
public function onLogin( $member, $returnUrl )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -60,7 +60,7 @@ class _ipsconnect
*/
public function onLogout( $member, $returnUrl )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -86,7 +86,7 @@ class _ipsconnect
*/
public function onValidate( $member )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -107,7 +107,7 @@ class _ipsconnect
*/
public function onMerge( $member, $member2 )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -128,7 +128,7 @@ class _ipsconnect
*/
public function onDelete( $member )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -148,7 +148,7 @@ class _ipsconnect
*/
public function onCreateAccount( $member )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -174,7 +174,7 @@ class _ipsconnect
*/
public function onProfileUpdate( $member, $changes )
{
if( !$this->_checkStatus() )
if( !$this->_checkStatus( $member ) )
{
return;
}
@@ -238,9 +238,10 @@ class _ipsconnect
* We only need to push the requests to our slaves if we are the master and if the request
* was not triggered by a connect call.
*
* @param $member \IPS\Member|NULL Optional member account to check
* @return bool
*/
protected function _checkStatus()
protected function _checkStatus( $member = NULL )
{
if( !\IPS\Settings::i()->connect_slaves )
{
@@ -254,6 +255,23 @@ class _ipsconnect
return FALSE;
}
/* Are we also testing a member account? */
if( $member !== NULL )
{
foreach( \IPS\Login::handlers() as $key => $handler )
{
if( $key == 'Internal' )
{
if( !$handler->canProcess( $member ) )
{
return FALSE;
}
break;
}
}
}
return TRUE;
}
}
@@ -40,6 +40,9 @@ class _Content
*/
public function manage()
{
/* CSS */
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
/* What types are there? */
$types = array();
$exclude = array();
@@ -56,7 +59,7 @@ class _Content
if ( isset( $containerClass::$modPerm ) )
{
$allowedContainers = \IPS\Member::loggedIn()->modPermission( $containerClass::$modPerm );
if ( $allowedContainers !== 0 and $allowedContainers !== true )
if ( $allowedContainers !== -1 and $allowedContainers !== true )
{
$exclude[ $class ] = $allowedContainers;
}
@@ -107,7 +110,6 @@ class _Content
/* Can we only view some kinds of hidden content? */
if ( count( $exclude ) )
{
$query->filterByExcludeContent( $exclude, TRUE );
}
/* What page are we on? */
@@ -53,7 +53,7 @@ class _IPTools extends \IPS\core\modules\admin\members\ip
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'modcp_ip_tools' );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=modcp&controller=modcp&tab=ip_tools", 'front', 'modcp_ip_tools' ), \IPS\Member::loggedIn()->language()->addToStack( 'modcp_ip_tools' ) );
if ( isset( \IPS\Request::i()->ip ) )
if ( isset( \IPS\Request::i()->ip ) and filter_var( \IPS\Request::i()->ip, FILTER_VALIDATE_IP ) )
{
$ip = \IPS\Request::i()->ip;
\IPS\Output::i()->title = $ip;
@@ -77,7 +77,7 @@ class _IPTools extends \IPS\core\modules\admin\members\ip
try
{
$geolocation = \IPS\GeoLocation::getByIp( $ip );
$map = $geolocation->map()->render( 400, 350, 6 );
$map = $geolocation->map()->render( 400, 350, 0.6 );
}
catch ( \Exception $e ) {}
@@ -128,10 +128,10 @@ class _Unapproved
}
foreach ( $class::getItemsWithPermission( $where, NULL, 1 ) as $item )
{
{
$idColumn = $item::$databaseColumnId;
$container = NULL;
if ( $item instanceof \IPS\Content\Comment )
if ( $item instanceof \IPS\Content\Comment AND !( $item instanceof \IPS\core\Statuses\Reply ) )
{
$approveUrl = $item->url()->setQueryString( array( 'do' => 'unhideComment', 'comment' => $item->$idColumn ) )->csrf();
$deleteUrl = $item->url()->setQueryString( array( 'do' => 'deleteComment', 'comment' => $item->$idColumn ) )->csrf();
@@ -143,7 +143,19 @@ class _Unapproved
{
$approveUrl = $item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'unhide' ) )->csrf();
$deleteUrl = $item->url()->setQueryString( array( 'do' => 'moderate', 'action' => 'delete' ) )->csrf();
$ref = base64_encode( json_encode( array( 'app' => $item::$application, 'module' => $item::$module, 'id_1' => $item->id ) ) );
if( $item instanceof \IPS\core\Statuses\Reply )
{
$itemClass = $item::$itemClass;
$ref = base64_encode( json_encode( array( 'app' => $itemClass::$application, 'module' => $itemClass::$module, 'id_1' => $item->mapped('item'), 'id_2' => $item->id ) ) );
$approveUrl = $approveUrl->setQueryString( 'type', 'reply' );
$deleteUrl = $deleteUrl->setQueryString( 'type', 'reply' );
}
else
{
$ref = base64_encode( json_encode( array( 'app' => $item::$application, 'module' => $item::$module, 'id_1' => $item->id ) ) );
}
try
{
@@ -154,7 +166,16 @@ class _Unapproved
$title = $item->mapped('title');
}
$skipUrl = \IPS\Http\Url::internal( 'app=core&module=modcp&controller=modcp&tab=approval', 'front', 'modcp_approval' )->setQueryString( array( 'skip' => '1', 'class' => md5( $class ), 'id' => $item->$idColumn ) );
if ( !$item->canUnhide() )
{
$approveUrl = NULL;
}
if ( !$item->canDelete() )
{
$deleteUrl = NULL;
}
$return = \IPS\Theme::i()->getTemplate('modcp')->approvalQueueHeader( $item, $approveUrl, $skipUrl, $deleteUrl );
$return .= $item->approvalQueueHtml( $ref, $container, $title );
@@ -576,6 +576,7 @@ class _Content
*/
public function parse_new_likes( $notification )
{
$comment = $notification->item;
if ( !$comment )
@@ -594,8 +595,8 @@ class _Content
}
catch( \UnderflowException $e ) {}
$likers = \IPS\Db::i()->select( 'DISTINCT member_id', 'core_reputation_index', array( 'app=? AND type=? AND rep_date>=? AND rep_date<? AND type_id=?', $comment::$application, $comment::$reputationType, $notification->sent_time->getTimestamp(), $between, $comment->$idColumn ), 'rep_date desc' );
$likers = \IPS\Db::i()->select( 'DISTINCT member_id, rep_date', 'core_reputation_index', array( 'app=? AND type=? AND rep_date>=? AND rep_date<? AND type_id=?', $comment::$application, $comment::$reputationType, $notification->sent_time->getTimestamp(), $between, $comment->$idColumn ), 'rep_date desc' );
$names = array();
foreach( $likers AS $member )
{
@@ -604,16 +605,17 @@ class _Content
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'x_others', FALSE, array( 'pluralize' => array( count( $likers ) - 3 ) ) );
break;
}
$names[] = \IPS\Member::load( $member )->name;
$names[] = \IPS\Member::load( $member['member_id'] )->name;
}
try
{
$first = $likers->first();
return array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'notification__new_likes', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ), mb_strtolower( $comment->indefiniteArticle() ) ) ) ) . ' ' . $item->mapped('title'),
'title' => \IPS\Member::loggedIn()->language()->addToStack( \IPS\Settings::i()->reputation_point_types === 'like' ? 'notification__new_likes' : 'notification__new_rep', FALSE, array( 'sprintf' => array( ( \IPS\Member::loggedIn()->group['gbw_view_reps'] ) ? \IPS\Member::loggedIn()->language()->formatList( $names ) : \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get( 'notifications_user_count' ), array( count( $likers ) ) ), mb_strtolower( $comment->indefiniteArticle() ) ) ) ) . ' ' . $item->mapped('title'),
'url' => ( $comment instanceof \IPS\Content\Comment ) ? $comment->url('find') : $comment->url(),
'content' => $comment->truncated(),
'author' => \IPS\Member::load( $likers->first() )
'author' => ( \IPS\Member::loggedIn()->group['gbw_view_reps'] ) ? \IPS\Member::load( $first['member_id'] ) : new \IPS\Member
);
}
catch( \UnderflowException $ex )
@@ -76,11 +76,22 @@ class _MemberContent
throw new \OutOfRangeException;
}
$select = \IPS\Db::i()->select( '*', $classname::$databaseTable, static::_getWhere( $data ), $classname::$databasePrefix.$classname::$databaseColumnId, array( $offset, 100 ) );
$select = \IPS\Db::i()->select( '*', $classname::$databaseTable, static::_getWhere( $data ), $classname::$databasePrefix.$classname::$databaseColumnId, array( 0, 100 ) );
if ( count( $select ) )
{
foreach ( new \IPS\Patterns\ActiveRecordIterator( $select, $classname ) as $item )
{
/* If this is the first comment on an item where a first comment is required (e.g. posts) do nothing, as when we get to the item, that will handle it */
if ( $item instanceof \IPS\Content\Comment )
{
$itemClass = $item::$itemClass;
if ( $itemClass::$firstCommentRequired and $item->isFirst() )
{
continue;
}
}
/* Do the action... */
switch ( $data['action'] )
{
case 'hide':
@@ -79,102 +79,10 @@ class _RebuildContainerCounts
$select = \IPS\Db::i()->select( '*', $classname::$databaseTable, array( $classname::$databasePrefix . $classname::$databaseColumnId . ' > ?', $offset ), $classname::$databasePrefix . $classname::$databaseColumnId . ' ASC', array( 0, $this->index ) );
$idColumn = $classname::$databaseColumnId;
$iterator = new \IPS\Patterns\ActiveRecordIterator( $select, $classname );
$idColumn = $classname::$databaseColumnId;
$itemClass = $classname::$contentItemClass;
$itemIdColumn = $itemClass::$databaseColumnId;
$commentClass = $itemClass::$commentClass;
$commentIdColumn = $commentClass::$databaseColumnId;
foreach( $iterator as $item )
{
/* Update container */
$containerWhere = array( array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['container'] . '=?', $item->_id ) );
$anyContainerWhere = $containerWhere;
if ( in_array( 'IPS\Content\Hideable', class_implements( $itemClass ) ) )
{
if ( isset( $itemClass::$databaseColumnMap['approved'] ) )
{
$containerWhere[] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['approved'] . '=?', 1 );
}
elseif ( isset( $itemClass::$databaseColumnMap['hidden'] ) )
{
$containerWhere[] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['hidden'] . '=?', 0 );
}
}
if ( $item->_items !== NULL )
{
$item->_items = \IPS\Db::i()->select( 'COUNT(*)', $itemClass::$databaseTable, $containerWhere )->first();
}
if ( $item->_comments !== NULL )
{
$commentWhere = array(
array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . ' = ' . $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemIdColumn ),
array( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['container'] . '=?', $item->_id )
);
if ( isset( $commentClass::$databaseColumnMap['approved'] ) )
{
$commentWhere[] = array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['approved'] . '=?', 1 );
}
elseif ( isset( $commentClass::$databaseColumnMap['hidden'] ) )
{
$commentWhere[] = array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['hidden'] . '=?', 0 );
}
$item->_comments = \IPS\Db::i()->select( 'COUNT(*)', array(
array( $commentClass::$databaseTable, $commentClass::$databaseTable ),
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
), $commentWhere )->first();
}
if ( in_array( 'IPS\Content\Hideable', class_implements( $itemClass ) ) )
{
if ( $item->_unapprovedItems !== NULL )
{
$hiddenContainerWhere = array( array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['container'] . '=?', $item->_id ) );
if ( isset( $itemClass::$databaseColumnMap['approved'] ) )
{
$hiddenContainerWhere[] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['approved'] . '=?', 0 );
}
elseif ( isset( $itemClass::$databaseColumnMap['hidden'] ) )
{
$hiddenContainerWhere[] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['hidden'] . '=?', 1 );
}
$item->_unapprovedItems = \IPS\Db::i()->select( 'COUNT(*)', $itemClass::$databaseTable, $hiddenContainerWhere )->first();
}
$commentWhere = array( array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . ' = ' . $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemIdColumn ) );
if ( $item->_unapprovedComments !== NULL )
{
if ( $itemClass::$firstCommentRequired )
{
/* Only look in non-hidden items otherwise this count will be added to */
$commentWhere = array_merge( $commentWhere, $containerWhere );
}
else
{
$commentWhere = array_merge( $commentWhere, $anyContainerWhere );
}
if ( isset( $commentClass::$databaseColumnMap['approved'] ) )
{
$commentWhere[] = array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['approved'] . '=?', 0 );
}
elseif ( isset( $commentClass::$databaseColumnMap['hidden'] ) )
{
$commentWhere[] = array( $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['hidden'] . '=?', 1 );
}
$item->_unapprovedComments = \IPS\Db::i()->select( 'COUNT(*)', array(
array( $commentClass::$databaseTable, $commentClass::$databaseTable ),
array( $itemClass::$databaseTable, $itemClass::$databaseTable )
), $commentWhere )->first();
}
}
$item->resetCommentCounts();
$item->setLastComment();
$item->save();
@@ -42,7 +42,8 @@ class _RebuildContentImages
try
{
$data['count'] = $classname::db()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable )->first();
$data['count'] = $classname::db()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable )->first();
$data['realCount'] = $classname::db()->select( 'COUNT(*)', $classname::$databaseTable )->first();
}
catch( \Exception $ex )
{
@@ -53,6 +54,8 @@ class _RebuildContentImages
{
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -65,7 +68,7 @@ class _RebuildContentImages
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -83,10 +86,9 @@ class _RebuildContentImages
\IPS\Log::i( LOG_DEBUG )->write( "Running " . $classname . ", with an offset of " . $offset, 'rebuildContentImages' );
$contentColumn = $classname::$databaseColumnMap['content'];
$dateColumn = $classname::$databaseColumnMap['date'];
$idColumn = $classname::$databaseColumnId;
$iterator = new \IPS\Patterns\ActiveRecordIterator( $classname::db()->select( '*', $classname::$databaseTable, array( array( $classname::$databasePrefix . $classname::$databaseColumnId . ' > ?', $offset ) ) , $classname::$databasePrefix . $dateColumn . ' ASC', array( 0, $this->rebuild ) ), $classname );
$iterator = new \IPS\Patterns\ActiveRecordIterator( $classname::db()->select( '*', $classname::$databaseTable, array( array( $classname::$databasePrefix . $classname::$databaseColumnId . ' > ?', $offset ) ) , $classname::$databasePrefix . $classname::$databaseColumnId . ' ASC', array( 0, $this->rebuild ) ), $classname );
$last = NULL;
foreach( $iterator as $item )
@@ -100,6 +102,7 @@ class _RebuildContentImages
}
$last = $item->$idColumn;
$data['indexed']++;
}
return $last;
@@ -122,6 +125,6 @@ class _RebuildContentImages
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_content_images', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_content_images', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
}
@@ -45,7 +45,8 @@ class _RebuildItemCounts
try
{
$data['count'] = \IPS\Db::i()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable )->first();
$data['count'] = \IPS\Db::i()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable )->first();
$data['realCount'] = $classname::db()->select( 'COUNT(*)', $classname::$databaseTable )->first();
}
catch( \Exception $ex )
{
@@ -56,6 +57,8 @@ class _RebuildItemCounts
{
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -68,7 +71,7 @@ class _RebuildItemCounts
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -88,7 +91,11 @@ class _RebuildItemCounts
foreach( $iterator as $item )
{
$item->resyncCommentCounts();
$item->save();
$last = $item->$idColumn;
$data['indexed']++;
}
return $last;
@@ -111,6 +118,6 @@ class _RebuildItemCounts
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_item_counts', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_item_counts', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
}
@@ -86,7 +86,8 @@ class _RebuildItems
$iterator = new \IPS\Patterns\ActiveRecordIterator( $select, $classname );
foreach( $iterator as $item )
{
$item->$titleColumn = html_entity_decode( $item->$titleColumn, ENT_QUOTES, 'UTF-8' );
$item->$titleColumn = \IPS\Text\Parser::utf8mb4SafeDecode( $item->$titleColumn );
$item->save();
$indexed++;
}
@@ -48,7 +48,15 @@ class _RebuildNonContentImages
if( method_exists( $extension, 'contentCount' ) )
{
$data['count'] = (int) $extension->contentCount();
$count = $extension->contentCount();
/* If there is nothing to rebuild, return NULL so the task won't be stored in the first place */
if( !$count )
{
return NULL;
}
$data['count'] = (int) $count;
}
break;
@@ -48,7 +48,15 @@ class _RebuildNonContentPosts
if( method_exists( $extension, 'contentCount' ) )
{
$data['count'] = (int) $extension->contentCount();
$count = $extension->contentCount();
/* If there is nothing to rebuild, return NULL so the task won't be stored in the first place */
if( !$count )
{
return NULL;
}
$data['count'] = (int) $count;
}
break;
@@ -46,7 +46,8 @@ class _RebuildPosts
try
{
$data['count'] = $classname::db()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable, ( is_subclass_of( $classname, 'IPS\Content\Comment' ) ) ? $classname::commentWhere() : array() )->first();
$data['count'] = $classname::db()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable, ( is_subclass_of( $classname, 'IPS\Content\Comment' ) ) ? $classname::commentWhere() : array() )->first();
$data['realCount'] = $classname::db()->select( 'COUNT(*)', $classname::$databaseTable, ( is_subclass_of( $classname, 'IPS\Content\Comment' ) ) ? $classname::commentWhere() : array() )->first();
}
catch( \Exception $ex )
{
@@ -63,6 +64,8 @@ class _RebuildPosts
{
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -75,7 +78,7 @@ class _RebuildPosts
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -107,7 +110,7 @@ class _RebuildPosts
/* If the ID is greater than the max we started with, don't rebuild - we're done because this post and any newer
will have been posted under 4.0 already */
if( $item->$idColumn >= $data['count'] )
if( $item->$idColumn > $data['count'] )
{
return NULL;
}
@@ -190,6 +193,8 @@ class _RebuildPosts
$item->save();
$last = $item->$idColumn;
$data['indexed']++;
}
return $last;
@@ -212,6 +217,6 @@ class _RebuildPosts
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
}
@@ -47,7 +47,8 @@ class _RebuildReputationIndex
{
try
{
$data['count'] = \IPS\Db::i()->select( 'MAX( id )', 'core_reputation_index', array( 'app=? and type=?', $classname::$application, $classname::$reputationType ) )->first();
$data['count'] = \IPS\Db::i()->select( 'MAX( id )', 'core_reputation_index', array( 'app=? and type=?', $classname::$application, $classname::$reputationType ) )->first();
$data['realCount'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_reputation_index', array( 'app=? and type=?', $classname::$application, $classname::$reputationType ) )->first();
}
catch( \Exception $ex )
{
@@ -60,6 +61,8 @@ class _RebuildReputationIndex
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -71,7 +74,7 @@ class _RebuildReputationIndex
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -101,6 +104,8 @@ class _RebuildReputationIndex
catch( \OutOfRangeException $ex ) { }
$last = $row['id'];
$data['indexed']++;
}
return $last;
@@ -123,6 +128,6 @@ class _RebuildReputationIndex
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_reputation', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_reputation', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title, FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
}
@@ -54,6 +54,11 @@ class _RebuildSearchIndex
$where[] = array( $classname::$databasePrefix . $classname::$databaseColumnMap['container'] . '=' . $data['container'] );
}
}
if ( is_subclass_of( $classname, 'IPS\Content\Comment' ) AND $classname::commentWhere() !== NULL )
{
$where[] = $classname::commentWhere();
}
if( \IPS\Settings::i()->search_index_timeframe )
{
@@ -77,13 +82,20 @@ class _RebuildSearchIndex
$queryData = $this->_buildQuery( $data );
try
{
$select = \IPS\Db::i()->select( 'count(*)', $classname::$databaseTable, $queryData['where'] );
{
$select = \IPS\Db::i()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable, $queryData['where'] );
foreach ( $queryData['joins'] as $table => $on )
{
$select->join( $table, $on );
}
$data['count'] = $select->first();
$select = \IPS\Db::i()->select( 'COUNT(*)', $classname::$databaseTable, $queryData['where'] );
foreach ( $queryData['joins'] as $table => $on )
{
$select->join( $table, $on );
}
$data['realCount'] = $select->first();
}
catch( \Exception $ex )
{
@@ -94,6 +106,8 @@ class _RebuildSearchIndex
{
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -106,7 +120,7 @@ class _RebuildSearchIndex
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -115,13 +129,13 @@ class _RebuildSearchIndex
throw new \OutOfRangeException;
}
$indexed = 0;
$indexed = NULL;
\IPS\Log::i( LOG_DEBUG )->write( "Running " . $classname . ", with an offset of " . $offset, 'rebuildSearchIndex' );
$queryData = $this->_buildQuery( $data );
$dateColumn = $classname::$databaseColumnMap['date'];
$select = \IPS\Db::i()->select( '*', $classname::$databaseTable, $queryData['where'], $classname::$databasePrefix . $dateColumn . ' DESC', array( $offset, $this->index ) );
$select = \IPS\Db::i()->select( '*', $classname::$databaseTable, array_merge( $queryData['where'], array( array( $classname::$databasePrefix . $classname::$databaseColumnId . ' > ?', $offset ) ) ), $classname::$databasePrefix . $classname::$databaseColumnId . ' ASC', array( 0, $this->index ) );
foreach ( $queryData['joins'] as $table => $on )
{
$select->join( $table, $on );
@@ -130,6 +144,14 @@ class _RebuildSearchIndex
foreach( $iterator as $item )
{
$idColumn = $classname::$databaseColumnId;
/* If the ID is greater than the max we started with, don't reindex because it should already be indexed through normal function */
if( $item->$idColumn > $data['count'] )
{
return NULL;
}
try
{
if ( !$item->isFutureDate() )
@@ -142,10 +164,11 @@ class _RebuildSearchIndex
\IPS\Log::i( LOG_ERR )->write( "Error encountered indexing item: " . $e->getMessage(), 'rebuildSearchIndex' );
}
$indexed++;
$indexed = $item->$idColumn;
$data['indexed']++;
}
return ( $indexed == $this->index ) ? ( $offset + $this->index ) : null;
return $indexed;
}
/**
@@ -158,13 +181,13 @@ class _RebuildSearchIndex
*/
public function getProgress( $data, $offset )
{
$class = $data['class'];
$exploded = explode( '\\', $class );
if ( !class_exists( $class ) or !\IPS\Application::appIsEnabled( $exploded[1] ) )
$class = $data['class'];
$exploded = explode( '\\', $class );
if ( !class_exists( $class ) or !\IPS\Application::appIsEnabled( $exploded[1] ) )
{
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('reindexing_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('reindexing_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
}
@@ -53,7 +53,10 @@ class _RestoreBrokenAttachments
try
{
$data['count'] = \IPS\Db::i()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable,
$data['count'] = \IPS\Db::i()->select( 'MAX(' . $classname::$databasePrefix . $classname::$databaseColumnId . ')', $classname::$databaseTable,
array( $classname::$databasePrefix . $classname::$databaseColumnMap['content'] . " LIKE '%attachment%' OR " . $classname::$databasePrefix . $classname::$databaseColumnMap['content'] . " LIKE '%ipsAttach%'" ) )->first();
$data['realCount'] = \IPS\Db::i()->select( 'COUNT(*)', $classname::$databaseTable,
array( $classname::$databasePrefix . $classname::$databaseColumnMap['content'] . " LIKE '%attachment%' OR " . $classname::$databasePrefix . $classname::$databaseColumnMap['content'] . " LIKE '%ipsAttach%'" ) )->first();
}
catch( \Exception $ex )
@@ -71,6 +74,8 @@ class _RestoreBrokenAttachments
{
return null;
}
$data['indexed'] = 0;
return $data;
}
@@ -83,7 +88,7 @@ class _RestoreBrokenAttachments
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$classname = $data['class'];
$exploded = explode( '\\', $classname );
@@ -160,6 +165,7 @@ class _RestoreBrokenAttachments
$item->save();
$last = $item->$idColumn;
$data['indexed']++;
}
return $last;
@@ -197,7 +203,7 @@ class _RestoreBrokenAttachments
throw new \OutOfRangeException;
}
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl', FALSE, array( 'strtolower' => TRUE ) ) ) ) ), 'complete' => $data['realCount'] ? ( round( 100 / $data['realCount'] * $data['indexed'], 2 ) ) : 100 );
}
/**
@@ -160,12 +160,12 @@ class _Content extends \IPS\Content\ExtensionGenerator
}
/* And however many for the content items */
$count = ceil( max( (int) $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', 10, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, new \IPS\Member )->count( TRUE ), isset( $settings["sitemap_{$class::$title}_count"] ) ? $settings["sitemap_{$class::$title}_count"] : 0 ) / \IPS\Sitemap::MAX_PER_FILE );
$count = ceil( max( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', 10, 0, new \IPS\Member, NULL, NULL, NULL, TRUE ), isset( $settings["sitemap_{$class::$title}_count"] ) ? $settings["sitemap_{$class::$title}_count"] : 0 ) / \IPS\Sitemap::MAX_PER_FILE );
for( $i=1; $i <= $count; $i++ )
{
$files[] = 'sitemap_content_' . str_replace( '\\', '_', mb_substr( $class, 4 ) ) . '_' . $i;
}
return $files;
}
@@ -194,7 +194,7 @@ class _Content extends \IPS\Content\ExtensionGenerator
{
$select = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', $nodeClass::$databaseTable, array( '(' . \IPS\Db::i()->findInSet( 'perm_view', array( \IPS\Settings::i()->guest_group ) ) . ' OR ' . 'perm_view=? )', '*' ) )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id={$nodeClass::$databaseTable}.{$nodeClass::$databasePrefix}{$nodeClass::$databaseColumnId}", $nodeClass::$permApp, $nodeClass::$permType ) ), $nodeClass );
}
else if ( $nodeClass::$ownerTypes !== NULL and is_subclass_of( $nodeClass, 'IPS\Node\Model', true ) )
else if ( $nodeClass::$ownerTypes !== NULL and is_subclass_of( $nodeClass, 'IPS\Node\Model' ) )
{
$select = $nodeClass::roots( 'view', new \IPS\Member );
}