Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Content Router extension: Records
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Board
* @since 17 Apr 2014
* @version SVN_VERSION_NUMBER
@@ -39,11 +39,14 @@ class _Records
{
try
{
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases', 'database_page_id>0' ) as $id )
foreach ( \IPS\cms\Databases::databases() as $id => $database )
{
if ( !$member or call_user_func( array( 'IPS\cms\Databases', 'load' ), $id )->can( 'view', $member ) )
if( $database->page_id )
{
$this->classes[] = 'IPS\cms\Records' . $id;
if ( !$member or $database->can( 'view', $member ) )
{
$this->classes[] = 'IPS\cms\Records' . $id;
}
}
}
}
@@ -2,10 +2,10 @@
/**
* @brief Create Menu Extension : Records
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @package IPS Community Suite
* @subpackage Content
* @since 18 Dec 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Designers Mode Extension
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Content
* @since 28 Nov 2014
* @version SVN_VERSION_NUMBER
*/
@@ -44,6 +44,8 @@ class _Cms
{
\IPS\cms\Theme\Advanced\Theme::export();
\IPS\cms\Media::exportDesignersModeMedia();
\IPS\cms\Pages\Page::exportDesignersMode();
return TRUE;
}
@@ -56,6 +58,7 @@ class _Cms
{
\IPS\cms\Theme\Advanced\Theme::import();
\IPS\cms\Media::importDesignersModeMedia();
\IPS\cms\Pages\Page::importDesignersMode();
return TRUE;
}
@@ -2,9 +2,10 @@
/**
* @brief Editor Extension: Block Form
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 20 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -44,7 +45,7 @@ class _BlockContent
{
return NULL;
}
/**
* Permission check for attachments
*
@@ -52,9 +53,10 @@ class _BlockContent
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment )
{
try
{
@@ -2,9 +2,10 @@
/**
* @brief Editor Extension: Contact Form
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 12 Nov 2013
* @version SVN_VERSION_NUMBER
*/
@@ -44,7 +45,7 @@ class _PageContent
{
return NULL;
}
/**
* Permission check for attachments
*
@@ -52,9 +53,10 @@ class _PageContent
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment )
{
try
{
@@ -2,9 +2,10 @@
/**
* @brief Editor Extension: Record Form
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 20 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -44,7 +45,7 @@ class _Records
{
return NULL;
}
/**
* Permission check for attachments
*
@@ -52,9 +53,10 @@ class _Records
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment )
{
if ( ! $id3 )
{
@@ -2,9 +2,10 @@
/**
* @brief Editor Extension: Record Form
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 20 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -44,7 +45,7 @@ class _Widgets
{
return TRUE;
}
/**
* Permission check for attachments
*
@@ -52,23 +53,34 @@ class _Widgets
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment )
{
if ( ! $id3 )
{
throw new \OutOfRangeException;
}
/* See if it's on a page in Pages */
$pageId = $this->getPageIdFromWidgetUniqueId( $id3 );
if ( $pageId === NULL )
if ( $pageId !== NULL )
{
throw new \OutOfRangeException;
return \IPS\cms\Pages\Page::load( $pageId )->can( 'view', $member );
}
return \IPS\cms\Pages\Page::load( $pageId )->can( 'view', $member );
/* Still here? Look elsewhere */
$area = $this->getAreaFromWidgetUniqueId( $id3 );
if ( $area !== NULL )
{
return \IPS\Application\Module::get( $area[0], $area[1], 'front' )->can( 'view', $member );
}
/* Still here? */
throw new \OutOfRangeException;
}
/**
@@ -84,12 +96,19 @@ class _Widgets
{
$pageId = $this->getPageIdFromWidgetUniqueId( $id3 );
if ( $pageId === NULL )
if ( $pageId !== NULL )
{
return FALSE;
return \IPS\cms\Pages\Page::load( $pageId );
}
return \IPS\cms\Pages\Page::load( $pageId );
$area = $this->getAreaFromWidgetUniqueId( $id3 );
if ( $area !== NULL )
{
return \IPS\Application\Module::get( $area[0], $area[1] );
}
return FALSE;
}
/**
@@ -116,4 +135,29 @@ class _Widgets
return $pageId;
}
/**
* Returns area information if the widget is not on a cms page
*
* @param string $uniqueId The widget's unique ID
* @return array|null Index 0 = Application, Index 1 = Module, Index 2 = Controller
*/
protected function getAreaFromWidgetUniqueId( $uniqueId )
{
$return = NULL;
foreach( \IPS\Db::i()->select( '*', 'core_widget_areas' ) AS $row )
{
$widgets = json_decode( $row['widgets'], TRUE );
foreach( $widgets AS $widget )
{
if ( $widget['unique'] == $uniqueId )
{
$return = array( $row['app'], $row['module'], $row['controller'] );
}
}
}
return $return;
}
}
@@ -2,10 +2,10 @@
/**
* @brief File Storage Extension: Media
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Content
* @since 07 July 2015
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief File Storage Extension: Pages
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Content
* @since 20 October 2014
* @version SVN_VERSION_NUMBER
*/
@@ -79,9 +79,17 @@ class _Pages
try
{
$count = \IPS\Db::i()->select( 'COUNT(*)', 'cms_pages', array( "page_js_css_objects LIKE '%" . \IPS\Db::i()->escape_string( $name ) . "%'") )->first();
foreach( \IPS\Db::i()->select( '*', 'cms_templates', array( "template_file_object LIKE '%" . \IPS\Db::i()->escape_string( $name ) . "%'") ) as $template )
{
$fileObject = \IPS\File::get( 'core_Theme', $template['template_file_object'] );
if( $fileObject->url == (string) $file )
{
return TRUE;
}
}
return $count ? TRUE : FALSE;
return FALSE;
}
catch( \IPS\Db\Exception $e )
{
@@ -2,10 +2,10 @@
/**
* @brief File Storage Extension: Records
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Content
* @since 11 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -41,17 +41,17 @@ class _Records
foreach( \IPS\cms\Databases::databases() as $id => $db )
{
$where = array( array( 'record_image IS NOT NULL' ) );
$where = array( 'record_image IS NOT NULL' );
if ( isset( $fields[ $id ] ) )
{
foreach( $fields[ $id ] as $field_id )
{
$where[] = array( 'field_' . $field_id . ' IS NOT NULL' );
$where[] = 'field_' . $field_id . ' IS NOT NULL';
}
}
$count += \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $id, $where )->first();
$count += \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $id, implode( ' OR ', $where ) )->first();
}
return $count;
@@ -2,10 +2,10 @@
/**
* @brief Front Navigation Extension: Pages
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @package IPS Community Suite
* @subpackage Content
* @since 01 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -61,7 +61,7 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
return array(
new \IPS\Helpers\Form\Select( 'menu_content_page', isset( $existingConfiguration['menu_content_page'] ) ? $existingConfiguration['menu_content_page'] : NULL, NULL, array( 'options' => $pages ), NULL, NULL, NULL, 'menu_content_page' ),
new \IPS\Helpers\Form\Radio( 'menu_title_page_type', isset( $existingConfiguration['menu_title_page'] ) ? $existingConfiguration['menu_title_page'] : 0, NULL, array( 'options' => array( 0 => 'menu_title_page_inherit', 1 => 'menu_title_page_custom' ), 'toggles' => array( 1 => array( 'menu_title_page' ) ) ), NULL, NULL, NULL, 'menu_title_page_type' ),
new \IPS\Helpers\Form\Radio( 'menu_title_page_type', isset( $existingConfiguration['menu_title_page_type'] ) ? $existingConfiguration['menu_title_page_type'] : 0, NULL, array( 'options' => array( 0 => 'menu_title_page_inherit', 1 => 'menu_title_page_custom' ), 'toggles' => array( 1 => array( 'menu_title_page' ) ) ), NULL, NULL, NULL, 'menu_title_page_type' ),
new \IPS\Helpers\Form\Translatable( 'menu_title_page', NULL, NULL, array( 'app' => 'cms', 'key' => $id ? "cms_menu_title_{$id}" : NULL ), NULL, NULL, NULL, 'menu_title_page' ),
);
}
@@ -163,15 +163,16 @@ class _Pages extends \IPS\core\FrontNavigation\FrontNavigationAbstract
*/
public function active()
{
return ( \IPS\cms\Pages\Page::$currentPage and \IPS\cms\Pages\Page::$currentPage->id == $this->configuration['menu_content_page'] ) or parent::active();
return ( \IPS\cms\Pages\Page::$currentPage and \IPS\cms\Pages\Page::$currentPage->id == $this->configuration['menu_content_page'] );
}
/**
* Children
*
* @param bool $noStore If true, will skip datastore and get from DB (used for ACP preview)
* @return array
*/
public function children()
public function children( $noStore=FALSE )
{
return array();
}
@@ -2,10 +2,10 @@
/**
* @brief Member Sync
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @package IPS Community Suite
* @subpackage Content
* @since 20 Aug 2015
* @version SVN_VERSION_NUMBER
*/
@@ -39,8 +39,8 @@ class _Databases
{
foreach ( \IPS\Db::i()->select( 'database_id', 'cms_databases' ) as $id )
{
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_comment_by' => $member->member_id, 'record_last_comment_name' => $member->name, 'record_last_comment_seo' => $member->members_seo_name ), array( 'record_last_comment_by=?', $member2->member_id ) );
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_review_by' => $member->member_id, 'record_last_review_name' => $member->name, 'record_last_review_seo' => $member->members_seo_name ), array( 'record_last_review_by=?', $member2->member_id ) );
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_comment_by' => $member->member_id, 'record_last_comment_name' => $member->name ), array( 'record_last_comment_by=?', $member2->member_id ) );
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_last_review_by' => $member->member_id, 'record_last_review_name' => $member->name ), array( 'record_last_review_by=?', $member2->member_id ) );
\IPS\Db::i()->update( 'cms_custom_database_' . $id, array( 'record_edit_member_id' => $member->member_id, 'record_edit_member_name' => $member->name ), array( 'record_edit_member_id=?', $member2->member_id ) );
}
}
@@ -92,26 +92,30 @@ class _Databases
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
/* Update member fields in the db */
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'Member' ) ) as $field )
try
{
$where = array(
\IPS\Db::i()->findInSet( 'field_' . $field['field_id'], array( $member->member_id ) )
);
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'Member' ) ) as $field )
{
$members = explode( ',', $record['field_' . $field['field_id'] ] );
foreach( $members as $k => $_member )
$where = array(
\IPS\Db::i()->findInSet( 'field_' . $field['field_id'], array( $member->member_id ) )
);
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $field['field_database_id'], $where ) as $record )
{
if( $_member == $member2->member_id )
$members = explode( ',', $record['field_' . $field['field_id'] ] );
foreach( $members as $k => $_member )
{
unset( $members[ $k ] );
if( $_member == $member->member_id )
{
unset( $members[ $k ] );
}
}
\IPS\Db::i()->update( 'cms_custom_database_' . $field['field_database_id'], array( 'field_' . $field['field_id'] => implode( ',', $members ) ), array( 'primary_id_field=?', $record['primary_id_field'] ) );
}
\IPS\Db::i()->update( 'cms_custom_database_' . $field['field_database_id'], array( 'field_' . $field['field_id'] => implode( ',', $members ) ), array( 'primary_id_field=?', $record['primary_id_field'] ) );
}
}
catch ( \Exception $e ) {} // If you have not upgraded pages but it is installed, this throws an error
}
}
@@ -2,9 +2,10 @@
/**
* @brief Moderator Permissions: Databases
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 30 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -48,7 +49,8 @@ class _Databases
return array(
'can_content_revisions_content' => 'YesNo',
'can_content_edit_record_slugs' => "YesNo",
'can_content_edit_meta_tags' => "YesNo"
'can_content_edit_meta_tags' => "YesNo",
'can_content_view_others_records' => "YesNo"
);
}
@@ -2,9 +2,10 @@
/**
* @brief Template Plugin - Content: Block
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 12 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,9 +2,10 @@
/**
* @brief Template Plugin - Content: Database
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 12 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,9 +2,10 @@
/**
* @brief Template Plugin - Pages: Media
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 07 July 2015
* @version SVN_VERSION_NUMBER
*/
@@ -2,9 +2,10 @@
/**
* @brief Template Plugin - Pages: Page Url
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 27 May 2015
* @version SVN_VERSION_NUMBER
*/
@@ -0,0 +1,62 @@
<?php
/**
* @brief Background Task: Convert bbcode pages to html pages post-3.4 upgrade
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Content
* @since 22 Jul 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\extensions\core\Queue;
/* 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;
}
/**
* Background Task: Convert bbcode pages to html pages post-3.4 upgrade
*/
class _ConvertPages
{
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
foreach( \IPS\Db::i()->select( '*', 'cms_pages', array( 'page_type=?', 'bbcode' ) ) as $page )
{
$update = array(
'page_content' => \IPS\Text\LegacyParser::parseStatic( $page['page_content'] ),
'page_type' => 'html'
);
\IPS\Db::i()->update( 'cms_pages', $update, array( 'page_id=?', $page['page_id'] ) );
}
throw new \IPS\Task\Queue\OutOfRangeException;
}
/**
* Get Progress
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'converting_pages_34x' ), 'complete' => 100 );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Background Task: Rebuild database categories
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 13 Jun 2014
* @version SVN_VERSION_NUMBER
*/
@@ -39,7 +40,7 @@ class _RebuildCategories
$classname = $data['class'];
$databaseId = mb_substr( $classname, 18 );
\IPS\Log::i( LOG_DEBUG )->write( "Getting preQueueData for " . $classname, 'rebuildCategories' );
\IPS\Log::debug( "Getting preQueueData for " . $classname, 'rebuildCategories' );
try
{
@@ -61,10 +62,10 @@ class _RebuildCategories
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
@@ -84,12 +85,15 @@ class _RebuildCategories
$parsed++;
}
catch( \Exception $e )
{
}
catch( \Exception $e ){}
}
if( $parsed !== $this->rebuild )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return ( $parsed == $this->rebuild ) ? ( $offset + $this->rebuild ) : null;
return ( $offset + $this->rebuild );
}
/**
@@ -97,14 +101,15 @@ class _RebuildCategories
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaning task and percentage complete
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
$classname = $data['class'];
$databaseId = mb_substr( $classname, 18 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'rebuilding_cms_database_categories', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $databaseId )->_title : 'Database #' . $databaseId;
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'rebuilding_cms_database_categories', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
}
}
@@ -0,0 +1,106 @@
<?php
/**
* @brief Background Task: Rebuild comment likes
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Content
* @since 16 Feb 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\extensions\core\Queue;
/* 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;
}
/**
* Background Task: Rebuild comment likes
*/
class _RebuildCommentLikes
{
/**
* @brief Number of content items to rebuild per cycle
*/
public $rebuild = 500;
/**
* Parse data before queuing
*
* @param array $data
* @return array
*/
public function preQueueData( $data )
{
try
{
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'core_reputation_index', array( 'app=? AND type=?', 'cms', 'id' ) )->first();
}
catch( \Exception $ex )
{
throw new \OutOfRangeException;
}
if( $data['count'] == 0 )
{
return null;
}
return $data;
}
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( &$data, $offset )
{
$count = 0;
foreach( \IPS\Db::i()->select( '*', 'core_reputation_index', array( '`app`=? AND `type`=?', 'cms', 'id' ), 'type_id ASC', array( 0, $this->rebuild ) ) as $item )
{
$count++;
try
{
$databaseId = \IPS\Db::i()->select( 'comment_database_id', 'cms_database_comments', array( 'comment_id=?', intval( $item['id'] ) ) )->first();
\IPS\Db::i()->update( 'core_reputation_index', array( 'type' => 'comment_id_' . $databaseId ), array( 'id=?', $item['id'] ) );
}
catch( \UnderflowException $e )
{
/* Comment no longer exists */
\IPS\Db::i()->delete( 'core_reputation_index', array( '`app`=? and `type`=? and `id`=?', 'cms', 'id', $item['id'] ) );
}
}
if( !$count )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return ( $offset + $count );
}
/**
* Get Progress
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_comment_likes'), 'complete' => round( 100 / $data['count'] * $offset, 2 ) );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Background Task: Rebuild database editor fields
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 27 March 2015
* @version SVN_VERSION_NUMBER
*/
@@ -60,10 +61,10 @@ class _RebuildEditorFields
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
@@ -75,7 +76,7 @@ class _RebuildEditorFields
$class = '\IPS\cms\Records' . $databaseId;
$last = NULL;
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) AND \IPS\Db::i()->checkForColumn( 'cms_custom_database_' . $databaseId, 'field_' . $fieldId ) )
{
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'primary_id_field > ?', $offset ), 'primary_id_field asc', array( 0, $this->rebuild ) ) as $row )
{
@@ -135,6 +136,11 @@ class _RebuildEditorFields
$last = $item->$idColumn;
}
}
if( $last === NULL )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return $last;
}
@@ -144,7 +150,7 @@ class _RebuildEditorFields
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaning task and percentage complete
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
@@ -0,0 +1,123 @@
<?php
/**
* @brief Background Task: Rebuild database reciprocal maps
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Content
* @since 31 May 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\extensions\core\Queue;
/* 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;
}
/**
* Background Task: Rebuild database reciprocal maps
*/
class _RebuildReciprocalMaps
{
/**
* @brief Number of content items to rebuild per cycle
*/
public $rebuild = 500;
/**
* Parse data before queuing
*
* @param array $data
* @return array
*/
public function preQueueData( $data )
{
$databaseId = $data['database'];
$fieldId = $data['field'];
try
{
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL' ) )->first();
}
catch( \Exception $ex )
{
throw new \OutOfRangeException;
}
if( $data['count'] == 0 )
{
return null;
}
return $data;
}
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @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 )
{
$databaseId = $data['database'];
$fieldId = $data['field'];
$parsed = 0;
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $databaseId ) )
{
$fieldsClass = 'IPS\cms\Fields' . $databaseId;
$field = $fieldsClass::load( $fieldId );
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, array( 'field_' . $fieldId . ' != \'\' or field_' . $fieldId . ' IS NOT NULL' ), 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
{
$extra = $field->extra;
if ( $row[ 'field_' . $fieldId ] and ! empty( $extra['database'] ) )
{
foreach( explode( ',', $row[ 'field_' . $fieldId ] ) as $foreignId )
{
if ( $foreignId )
{
\IPS\Db::i()->insert( 'cms_database_fields_reciprocal_map', array(
'map_origin_database_id' => $databaseId,
'map_foreign_database_id' => $extra['database'],
'map_origin_item_id' => $row['primary_id_field'],
'map_foreign_item_id' => $foreignId,
'map_field_id' => $fieldId
) );
}
}
}
$parsed++;
}
}
if ( ! $parsed )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return $offset + $this->rebuild;
}
/**
* Get Progress
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
$databaseId = $data['database'];
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_reciprocal_map', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title, $data['field'] ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Background Task: Rebuild database records
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 13 Jun 2014
* @version SVN_VERSION_NUMBER
*/
@@ -39,7 +40,7 @@ class _RebuildRecords
$classname = $data['class'];
$databaseId = mb_substr( $classname, 15 );
\IPS\Log::i( LOG_DEBUG )->write( "Getting preQueueData for " . $classname, 'rebuildRecords' );
\IPS\Log::debug( "Getting preQueueData for " . $classname, 'rebuildRecords' );
try
{
@@ -61,22 +62,25 @@ class _RebuildRecords
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int|null New offset or NULL if complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
$classname = $data['class'];
$databaseId = mb_substr( $classname, 15 );
/* Make sure there's even content to parse */
if( !isset( $classname::$databaseColumnMap['content'] ) )
{
throw new \OutOfRangeException;
}
/* Make sure there's even content to parse */
if( !class_exists( $classname ) or !isset( $classname::$databaseColumnMap['content'] ) )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
$fixImage = isset( $data['fixImage'] ) ? (boolean) $data['fixImage'] : TRUE;
$fixHtml = isset( $data['fixHtml'] ) ? (boolean) $data['fixHtml'] : FALSE;
$fixFurls = isset( $data['fixFurls']) ? (boolean) $data['fixFurls'] : FALSE;
$parsed = 0;
$class = '\IPS\cms\Records' . $databaseId;
@@ -86,24 +90,94 @@ class _RebuildRecords
{
$record = $class::constructFromData( $row );
$record->resetLastComment();
$save = FALSE;
if ( $record->record_image and file_exists( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) )
{
$record->record_image = (string) \IPS\File::create( 'content_Records', $record->record_image, file_get_contents( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) );
$record->save();
if ( $fixImage )
{
if ( $record->record_image and file_exists( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) )
{
try
{
$record->record_image = (string) \IPS\File::create( 'cms_Records', $record->record_image, file_get_contents( \IPS\ROOT_PATH . '/uploads/' . $record->record_image ) );
}
catch ( \Exception $e )
{
$record->record_image = NULL;
}
$save = TRUE;
}
}
if ( ! $record->record_publish_date )
{
$record->record_publish_date = $record->record_saved;
$save = TRUE;
}
if ( $fixFurls and preg_match( '#%([\d\w]{2})#', $record->record_static_furl ) )
{
$record->record_static_furl = urldecode( $record->record_static_furl );
$save = TRUE;
}
if ( $save )
{
$record->save();
}
if ( $fixHtml )
{
$fields = iterator_to_array( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND field_type=? AND field_html=1', $databaseId, 'Editor' ) ) );
if ( count( $fields ) )
{
foreach( $fields as $field )
{
$column = 'field_' . $field['field_id'];
if ( $record->member_id and $record->$column )
{
try
{
$author = \IPS\Member::load( $record->member_id );
/* In 3.x this would have been shown as HTML */
if ( $author->group['g_dohtml'] )
{
/* This code is copied from IPB3 to ensure it is compatible with data saved */
$record->$column = str_replace( "&#39;" , "'", $record->$column );
$record->$column = str_replace( "&#33;" , "!", $record->$column );
$record->$column = str_replace( "&#036;", "$", $record->$column );
$record->$column = str_replace( "&#124;", "|", $record->$column );
$record->$column = str_replace( "&amp;" , "&", $record->$column );
$record->$column = str_replace( "&gt;" , ">", $record->$column );
$record->$column = str_replace( "&lt;" , "<", $record->$column );
$record->$column = str_replace( "&#60;" , "<", $record->$column );
$record->$column = str_replace( "&#62;" , ">", $record->$column );
$record->$column = str_replace( "&quot;", '"', $record->$column );
$record->$column = str_replace( '&quot;', '"', $record->$column );
$record->$column = str_replace( '&lt;', '<', $record->$column );
$record->$column = str_replace( '&gt;', '>', $record->$column );
$record->save();
}
}
catch( \OutOfRangeException $e ) { }
}
}
}
}
$parsed++;
}
}
return ( $parsed == $this->rebuild ) ? ( $offset + $this->rebuild ) : null;
if( $parsed != $this->rebuild )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return ( $offset + $this->rebuild );
}
/**
@@ -111,14 +185,15 @@ class _RebuildRecords
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaning task and percentage complete
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
$classname = $data['class'];
$databaseId = mb_substr( $classname, 18 );
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( $databaseId )->_title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
$databaseId = mb_substr( $classname, 15 );
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $databaseId )->_title : 'Database #' . $databaseId;
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_records', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
}
}
@@ -0,0 +1,131 @@
<?php
/**
* @brief Background Task: Resychronise the first post of a topic generated by Pages
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Content
* @since 7 Oct 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\extensions\core\Queue;
/* 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;
}
/**
* Background Task: Rebuild database records
*/
class _ResyncTopicContent
{
/**
* @brief Number of content items to rebuild per cycle
*/
public $rebuild = 100;
/**
* Parse data before queuing
*
* @param array $data
* @return array
*/
public function preQueueData( $data )
{
try
{
$database = \IPS\cms\Databases::load( $data['databaseId'] );
if ( $database->forum_record )
{
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $data['databaseId'] )->first();
}
else
{
$cats = iterator_to_array( \IPS\Db::i()->select( 'category_id', 'cms_database_categories', array( 'category_forum_record=1 AND category_database_id=?', $data['databaseId'] ) ) );
if ( count( $cats ) )
{
$data['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $data['databaseId'], array( \IPS\Db::i()->in( 'category_id', $cats ) ) )->first();
}
else
{
return null;
}
}
}
catch( \Exception $ex )
{
throw new \OutOfRangeException;
}
if( $data['count'] == 0 )
{
return null;
}
return $data;
}
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
$class = '\IPS\cms\Records' . $data['databaseId'];
$where = NULL;
$parsed = 0;
$database = \IPS\cms\Databases::load( $data['databaseId'] );
if ( ! $database->forum_record )
{
$cats = iterator_to_array( \IPS\Db::i()->select( 'category_id', 'cms_database_categories', array( 'category_forum_record=1 AND category_database_id=?', $data['databaseId'] ) ) );
$where = array( \IPS\Db::i()->in( 'category_id', $cats ) );
}
if ( \IPS\Db::i()->checkForTable( 'cms_custom_database_' . $data['databaseId'] ) )
{
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $data['databaseId'], $where, 'primary_id_field asc', array( $offset, $this->rebuild ) ) as $row )
{
try
{
$record = $class::constructFromData( $row );
$record->syncTopic();
}
catch( \Exception $ex ) { }
$parsed++;
}
}
if( $parsed != $this->rebuild )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return ( $offset + $this->rebuild );
}
/**
* Get Progress
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
$title = ( \IPS\Application::appIsEnabled('cms') ) ? \IPS\cms\Databases::load( $data['databaseId'] )->_title : 'Database #' . $data['databaseId'];
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('rebuilding_cms_database_sync_topics', FALSE, array( 'sprintf' => array( $title ) ) ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $offset, 2 ) ) : 100 );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Support Pages Databases in sitemaps
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 1 April 2015
* @version SVN_VERSION_NUMBER
*/
@@ -28,7 +29,7 @@ class _Databases
*/
public $recommendedSettings = array(
'sitemap_databases_count' => -1,
'sitemap_databases_priority' => -1
'sitemap_databases_priority' => 1
);
/**
@@ -81,7 +82,7 @@ class _Databases
}
/* 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 ), \IPS\Settings::i()->sitemap_databases_count ) / \IPS\Sitemap::MAX_PER_FILE );
$count = ceil( max( (int) $class::getItemsWithPermission( $class::sitemapWhere(), NULL, 10, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, new \IPS\Member )->count( TRUE ), \IPS\Settings::i()->sitemap_databases_count ) / \IPS\Sitemap::MAX_PER_FILE );
for( $i=1; $i <= $count; $i++ )
{
$files[] = $database->id . '_sitemap_database_records_' . $i;
@@ -134,9 +135,8 @@ class _Databases
if ( $priority !== -1 )
{
$data['priority'] = $priority;
$entries[] = $data;
}
$entries[] = $data;
}
}
}
@@ -154,16 +154,15 @@ class _Databases
$limit = $totalLimit - $offset;
}
foreach ( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, array( $offset, $limit ), 'read', FALSE, 0, new \IPS\Member, TRUE ) as $item )
foreach ( $class::getItemsWithPermission( $class::sitemapWhere(), NULL, array( $offset, $limit ), 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, new \IPS\Member, TRUE ) as $item )
{
$data = array( 'url' => $item->url() );
$priority = ( $item->sitemapPriority() ?: ( intval( \IPS\Settings::i()->sitemap_databases_priority ) ) );
if ( $priority !== -1 )
{
$data['priority'] = $priority;
$entries[] = $data;
}
$entries[] = $data;
}
}
@@ -2,9 +2,10 @@
/**
* @brief Support Pages in sitemaps
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 1 April 2015
* @version SVN_VERSION_NUMBER
*/
@@ -28,7 +29,7 @@ class _Pages
*/
public $recommendedSettings = array(
'sitemap_pages_count' => -1,
'sitemap_pages_priority' => -1
'sitemap_pages_priority' => 1
);
/**
@@ -86,6 +87,7 @@ class _Pages
$count = 0;
$member = new \IPS\Member;
$permissionCheck = 'view';
$entries = array();
$exploded = explode( '_', $filename );
$block = (int) array_pop( $exploded );
@@ -101,7 +103,7 @@ class _Pages
$where = array( array( '(' . \IPS\Db::i()->findInSet( 'perm_' . $class::$permissionMap[ $permissionCheck ], $member->groups ) . ' OR ' . 'perm_' . $class::$permissionMap[ $permissionCheck ] . '=? )', '*' ) );
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, NULL, 'page_id ASC', array( $offset, $limit ) )
$select = \IPS\Db::i()->select( '*', $class::$databaseTable, $where, 'page_id ASC', array( $offset, $limit ) )
->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . $class::$databaseTable . "." . $class::$databasePrefix . $class::$databaseColumnId, $class::$permApp, $class::$permType ) );
foreach( $select as $row )
@@ -113,9 +115,8 @@ class _Pages
if ( $priority !== -1 )
{
$data['priority'] = $priority;
$entries[] = $data;
}
$entries[] = $data;
}
$sitemap->buildSitemapFile( $filename, $entries );
@@ -2,10 +2,10 @@
/**
* @brief File Storage Extension: Records
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Content
* @since 11 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -0,0 +1,100 @@
<?php
/**
* @brief Uninstall callback
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @subpackage Content
* @since 10 Feb 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\extensions\core\Uninstall;
/* 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;
}
/**
* Uninstall callback
*/
class _Widgets
{
/**
* Code to execute before the application has been uninstalled
*
* @param string $application Application directory
* @return array
*/
public function preUninstall( $application )
{
}
/**
* Code to execute after the application has been uninstalled
*
* @param string $application Application directory
* @return array
*/
public function postUninstall( $application )
{
}
/**
* Code to execute when other applications are uninstalled
*
* @param string $application Application directory
* @return void
* @deprecated This is here for backwards-compatibility - all new code should go in onOtherUninstall
*/
public function onOtherAppUninstall( $application )
{
return $this->onOtherUninstall( $application );
}
/**
* Code to execute when other applications or plugins are uninstalled
*
* @param string $application Application directory
* @param int $plugin Plugin ID
* @return void
*/
public function onOtherUninstall( $application=NULL, $plugin=NULL )
{
/* clean up widget areas table */
foreach ( \IPS\Db::i()->select( '*', 'cms_page_widget_areas' ) as $row )
{
$data = json_decode( $row['area_widgets'], true );
$deleted = false;
foreach ( $data as $key => $widget )
{
if( $application !== NULL )
{
if ( isset( $widget['app'] ) and $widget['app'] == $application )
{
$deleted = true;
unset( $data[$key] );
}
}
if( $plugin !== NULL )
{
if ( isset( $widget['plugin'] ) and $widget['plugin'] == $plugin )
{
$deleted = true;
unset( $data[$key] );
}
}
}
if ( $deleted === true )
{
\IPS\Db::i()->update( 'cms_page_widget_areas', array( 'area_widgets' => json_encode( $data ) ), array( 'area_page_id=? AND area_area=?', $row['area_page_id'], $row['area_area'] ) );
}
}
}
}