Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -44,7 +44,7 @@ class _applications extends \IPS\Node\Controller
|
||||
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . "/applications/" ) as $file )
|
||||
{
|
||||
if ( $file->isDir() AND !in_array( $file->getFilename(), $installed ) )
|
||||
if ( $file->isDir() AND !in_array( $file->getFilename(), $installed ) AND !$file->isDot() )
|
||||
{
|
||||
if( file_exists( $file->getPathname() . '/data/application.json' ) )
|
||||
{
|
||||
@@ -420,19 +420,12 @@ class _applications extends \IPS\Node\Controller
|
||||
'unlimitedLang' => 'all'
|
||||
), NULL, NULL, NULL, 'app_disabled_groups' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'app_disabled_message', $node->disabled_message, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => $node->_key . 'app_disabled_message', 'attachIds' => array( $node->id, NULL, 'appdisabled' ) ), NULL, NULL, NULL, 'app_disabled_message_editor' ) );
|
||||
|
||||
if ( count( $node->extensions( 'core', 'FrontNavigation' ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'app_hide_tab', !$node->hide_tab ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* And then save the values, if appropriate */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$node->disabled_message = $values['app_disabled_message'];
|
||||
$node->disabled_groups = $values['app_enabled'] ? NULL : ( $values['app_disabled_groups'] == '*' ? '*' : implode( ',', $values['app_disabled_groups'] ) );
|
||||
$node->hide_tab = ( isset( $values['app_hide_tab'] ) and !$values['app_hide_tab'] );
|
||||
$node->save();
|
||||
|
||||
if ( !\IPS\NO_WRITES )
|
||||
@@ -558,7 +551,7 @@ class _applications extends \IPS\Node\Controller
|
||||
unset($download);
|
||||
\Phar::unlinkArchive($pharPath);
|
||||
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'application/tar', array( 'Content-Disposition' => \IPS\Output::getContentDisposition( 'attachment', $application->directory . '.tar' ) ) );
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'application/tar', array( 'Content-Disposition' => \IPS\Output::getContentDisposition( 'attachment', $application->directory . '.tar' ) ), FALSE, FALSE, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -629,11 +622,21 @@ class _applications extends \IPS\Node\Controller
|
||||
/* Determine our current version and the last version we ran */
|
||||
$currentVersion = \IPS\Application::load( $data['key'] )->long_version;
|
||||
$allVersions = \IPS\Application::load( $data['key'] )->getAllVersions();
|
||||
$longVersions = array_keys( $allVersions );
|
||||
$humanVersions = array_values( $allVersions );
|
||||
$lastRan = ( isset( $data['extra']['_last'] ) ) ? intval( $data['extra']['_last'] ) : $currentVersion;
|
||||
|
||||
if( count($allVersions) )
|
||||
{
|
||||
$latestLVersion = array_pop( $longVersions );
|
||||
$latestHVersion = array_pop( $humanVersions );
|
||||
|
||||
\IPS\Db::i()->insert( 'core_upgrade_history', array( 'upgrade_version_human' => $latestHVersion, 'upgrade_version_id' => $latestLVersion, 'upgrade_date' => time(), 'upgrade_mid' => (int) \IPS\Member::loggedIn()->member_id, 'upgrade_app' => $data['key'] ) );
|
||||
}
|
||||
|
||||
/* Now find any upgrade paths since the last one we ran that need to be executed */
|
||||
$upgradeSteps = \IPS\Application::load( $data['key'] )->getUpgradeSteps( $lastRan );
|
||||
|
||||
|
||||
/* Did we find any? */
|
||||
if( count( $upgradeSteps ) )
|
||||
{
|
||||
@@ -683,6 +686,14 @@ class _applications extends \IPS\Node\Controller
|
||||
/* If the next step exists, run it */
|
||||
if( method_exists( $upgrader, $_methodName ) )
|
||||
{
|
||||
/* Get custom title first as the step may unset session variables that are being referenced */
|
||||
$customTitleMethod = 'step' . $upgradeStep . 'CustomTitle';
|
||||
|
||||
if ( method_exists( $upgrader, $customTitleMethod ) )
|
||||
{
|
||||
$language = $upgrader->$customTitleMethod();
|
||||
}
|
||||
|
||||
$result = $upgrader->$_methodName();
|
||||
|
||||
/* If the result is 'true' we move on to the next step, otherwise we need to run the same step again and store the data returned */
|
||||
@@ -708,7 +719,7 @@ class _applications extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
$laststep = 'start';
|
||||
$language = \IPS\Member::loggedIn()->language()->addToStack('appupdate_databasechanges', FALSE, array( 'sprintf' => $allVersions[ $_next ] ) );
|
||||
$language = $language ?: \IPS\Member::loggedIn()->language()->addToStack('appupdate_databasechanges', FALSE, array( 'sprintf' => $allVersions[ $_next ] ) );
|
||||
$progress = round( ( 30 * ( $data['extra']['_totalSteps'] - count($upgradeSteps) ) ) / ( $data['extra']['_totalSteps'] ?: 1 ) );
|
||||
}
|
||||
else
|
||||
@@ -1016,6 +1027,9 @@ class _applications extends \IPS\Node\Controller
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
/* Clear \Data\Store */
|
||||
\IPS\Data\Store::i()->clearAll();
|
||||
}
|
||||
/* Legacy */
|
||||
catch ( \UnexpectedValueException $e )
|
||||
@@ -1142,7 +1156,7 @@ class _applications extends \IPS\Node\Controller
|
||||
\IPS\Output::i()->error( 'app_dir_not_write', '4C133/8', 500, '' );
|
||||
}
|
||||
|
||||
if( !is_writable( \IPS\ROOT_PATH . "/plugins/" ) ) // necessary as we write the hooks.txt file here
|
||||
if( !is_writable( \IPS\ROOT_PATH . "/plugins/" ) ) // necessary as we write the hooks.php file here
|
||||
{
|
||||
\IPS\Output::i()->error( 'plugin_dir_not_write', '4C133/L', 403, '' );
|
||||
}
|
||||
|
||||
@@ -1148,6 +1148,7 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
$table = new \IPS\Helpers\Table\Custom( $json, \IPS\Http\Url::internal( "app=core&module=applications&controller=developer&appKey={$this->application->directory}&tab=schema" ) );
|
||||
$table->langPrefix = 'database_table_';
|
||||
$table->mainColumn = 'name';
|
||||
$table->limit = 150;
|
||||
$table->include = array( 'name' );
|
||||
|
||||
/* Set default sort */
|
||||
@@ -1672,7 +1673,7 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
$output = new \IPS\Helpers\Table\Custom( $definition['columns'], \IPS\Http\Url::internal( "app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=editSchema&_name={$definition['name']}&existing=1&tab=columns" ) );
|
||||
$output->langPrefix = 'database_column_';
|
||||
$output->include = array( 'name', 'type', 'length', 'unsigned', 'zerofill', 'binary', 'allow_null', 'default', 'auto_increment', 'comment' );
|
||||
|
||||
$output->limit = 150;
|
||||
$output->rootButtons = array(
|
||||
'add' => array(
|
||||
'icon' => 'plus',
|
||||
@@ -1738,7 +1739,7 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
$output = new \IPS\Helpers\Table\Custom( $definition['indexes'], \IPS\Http\Url::internal( "app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=editSchema&_name={$definition['name']}&existing=1&tab=indexes" ) );
|
||||
$output->langPrefix = 'database_index_';
|
||||
$output->exclude = array( 'length' );
|
||||
|
||||
$output->limit = 150;
|
||||
$output->rootButtons = array(
|
||||
'add' => array(
|
||||
'icon' => 'plus',
|
||||
@@ -1795,6 +1796,7 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$output = new \IPS\Helpers\Table\Custom( isset( $definition['inserts'] ) ? $definition['inserts'] : array(), \IPS\Http\Url::internal( "app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=editSchema&_name={$definition['name']}&existing=1&tab=inserts" ) );
|
||||
$output->langPrefix = "‌";
|
||||
$output->limit = 150;
|
||||
|
||||
$output->rootButtons = array(
|
||||
'add' => array(
|
||||
@@ -2826,7 +2828,6 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
NULL,
|
||||
FALSE,
|
||||
TRUE,
|
||||
TRUE
|
||||
);
|
||||
|
||||
@@ -3131,7 +3132,7 @@ class _developer extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Check our Regex will be okay with it */
|
||||
preg_match( '/^\\\IPS\\\Db::i\(\)->(.+?)\(\s*[\'"](.+?)[\'"]\s*,\s*(.+?)\)\s*;$/', $val, $matches );
|
||||
preg_match( '/^\\\IPS\\\Db::i\(\)->(.+?)\(\s*[\'"](.+?)[\'"]\s*(,\s*(.+?))?\)\s*;$/', $val, $matches );
|
||||
if ( empty( $matches ) )
|
||||
{
|
||||
throw new \DomainException( 'versions_query_format' );
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Menu Manager
|
||||
* @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 29 Jun 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\applications;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu
|
||||
*/
|
||||
class _menu extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'menu_manage' );
|
||||
\IPS\Output::i()->responsive = FALSE;
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/menumanager.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_system.js', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'jquery/jquery.nestedSortable.js', 'core', 'interface' ) );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Buttons */
|
||||
\IPS\Output::i()->sidebar['actions']['publish'] = array(
|
||||
'icon' => 'cloud-upload',
|
||||
'link' => \IPS\Http\Url::internal('app=core&module=applications&controller=menu&do=publish'),
|
||||
'title' => 'menu_manager_publish',
|
||||
'class' => ( isset( \IPS\Data\Store::i()->frontNavigation ) && \IPS\Data\Store::i()->frontNavigation == \IPS\core\FrontNavigation::frontNavigation( TRUE ) ) ? 'ipsButton_disabled' : '',
|
||||
'data' => array(
|
||||
'action' => 'publishMenu'
|
||||
)
|
||||
);
|
||||
\IPS\Output::i()->sidebar['actions']['restore'] = array(
|
||||
'icon' => 'refresh',
|
||||
'link' => \IPS\Http\Url::internal('app=core&module=applications&controller=menu&do=restore'),
|
||||
'title' => 'menu_manager_revert',
|
||||
'data' => array(
|
||||
'action' => 'restoreMenu'
|
||||
)
|
||||
);
|
||||
|
||||
/* Get items from the database */
|
||||
$items = array( 0 => array(), 1 => array() );
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_menu', NULL, 'position' ) as $item )
|
||||
{
|
||||
if ( \IPS\Application::appIsEnabled( $item['app'] ) )
|
||||
{
|
||||
$class = 'IPS\\' . $item['app'] . '\extensions\core\FrontNavigation\\' . $item['extension'];
|
||||
$items[ intval( $item['parent'] ) ][ $item['id'] ] = new $class( json_decode( $item['config'], TRUE ), $item['id'], $item['permissions'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_applications_menu');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'applications' )->menuManager( $items );
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish Menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function publish()
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->frontNavigation );
|
||||
\IPS\Session::i()->log( 'acplog__menu_published' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=applications&controller=menu'), 'menu_manager_published' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Menu Item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
/* What menu items have we already configured? */
|
||||
$current = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_menu', NULL, 'position' ) as $item )
|
||||
{
|
||||
if ( !isset( $current[ $item['app'] ][ $item['extension'] ] ) )
|
||||
{
|
||||
$current[ $item['app'] ][ $item['extension'] ] = 0;
|
||||
}
|
||||
$current[ $item['app'] ][ $item['extension'] ]++;
|
||||
}
|
||||
|
||||
/* Are we editing an existing item? */
|
||||
$existing = NULL;
|
||||
if ( \IPS\Request::i()->id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$existing = \IPS\Db::i()->select( '*', 'core_menu', array( 'id=?', \IPS\Request::i()->id ) )->first();
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* What options are available? */
|
||||
$options = array();
|
||||
$toggles = array();
|
||||
$fieldNames = array();
|
||||
$extraFields = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'FrontNavigation', FALSE, 'core', NULL, FALSE ) as $key => $class )
|
||||
{
|
||||
if ( method_exists( $class, 'typeTitle' ) )
|
||||
{
|
||||
$exploded = explode( '_', $key );
|
||||
if ( $class::allowMultiple() or !isset( $current[ $exploded[0] ][ $exploded[1] ] ) or ( $existing and $existing['app'] == $exploded[0] and $existing['extension'] == $exploded[1] ) )
|
||||
{
|
||||
$options[ $key ] = $class::typeTitle();
|
||||
|
||||
foreach ( $class::configuration( $existing ? json_decode( $existing['config'], TRUE ) : array(), $existing ? $existing['id'] : NULL ) as $field )
|
||||
{
|
||||
if ( !$field->htmlId )
|
||||
{
|
||||
$field->htmlId = md5( uniqid() );
|
||||
}
|
||||
|
||||
$toggles[ $key ][ $field->name ] = $field->htmlId;
|
||||
|
||||
$fieldNames[ $key ][] = $field->name;
|
||||
$extraFields[] = $field;
|
||||
}
|
||||
|
||||
if ( $class::permissionsCanInherit() )
|
||||
{
|
||||
$toggles[ $key ][] = 'menu_manager_access_type';
|
||||
}
|
||||
else
|
||||
{
|
||||
$toggles[ $key ][] = 'menu_manager_access';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the form */
|
||||
$form = new \IPS\Helpers\Form( 'menu_item', 'save_menu_item' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'menu_manager_extension', $existing ? "{$existing['app']}_{$existing['extension']}" : NULL, TRUE, array( 'options' => $options, 'toggles' => $toggles ) ) );
|
||||
foreach ( $extraFields as $field )
|
||||
{
|
||||
$form->add( $field );
|
||||
}
|
||||
$groups = array();
|
||||
foreach ( \IPS\Member\Group::groups() as $group )
|
||||
{
|
||||
$groups[ $group->g_id ] = $group->name;
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'menu_manager_access_type', ( $existing and $existing['permissions'] ) ? 1 : 0, TRUE, array(
|
||||
'options' => array( 0 => 'menu_manager_access_type_inherit', 1 => 'menu_manager_access_type_override' ),
|
||||
'toggles' => array( 1 => array( 'menu_manager_access' ) )
|
||||
), NULL, NULL, NULL, 'menu_manager_access_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'menu_manager_access', $existing ? ( $existing['permissions'] == '*' ? '*' : explode( ',', $existing['permissions'] ) ) : '*', NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone' ), NULL, NULL, NULL, 'menu_manager_access' ) );
|
||||
|
||||
if( !$existing ){
|
||||
$form->hiddenValues['newItem'] = TRUE;
|
||||
}
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$exploded = explode( '_', $values['menu_manager_extension'] );
|
||||
$class = 'IPS\\' . $exploded[0] . '\extensions\core\FrontNavigation\\' . $exploded[1];
|
||||
|
||||
$config = array();
|
||||
if ( isset( $fieldNames[ $values['menu_manager_extension'] ] ) )
|
||||
{
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( in_array( $k, $fieldNames[ $values['menu_manager_extension'] ] ) )
|
||||
{
|
||||
$config[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$save = array(
|
||||
'app' => $exploded[0],
|
||||
'extension' => $exploded[1],
|
||||
'config' => json_encode( $config ),
|
||||
'parent' => $existing ? $existing['parent'] : ( \IPS\Request::i()->parent ?: NULL ),
|
||||
);
|
||||
|
||||
if ( $class::permissionsCanInherit() )
|
||||
{
|
||||
if ( $values['menu_manager_access_type'] )
|
||||
{
|
||||
$save['permissions'] = $values['menu_manager_access'] == '*' ? '*' : implode( ',', $values['menu_manager_access'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$save['permissions'] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$save['permissions'] = $values['menu_manager_access'] == '*' ? '*' : implode( ',', $values['menu_manager_access'] );
|
||||
}
|
||||
if ( $existing )
|
||||
{
|
||||
$id = $existing['id'];
|
||||
|
||||
$_config = $class::parseConfiguration( $config, $id );
|
||||
|
||||
if ( $_config != $config )
|
||||
{
|
||||
$save['config'] = json_encode( $_config );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_menu', $save, array( 'id=?', $id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$save['position'] = \IPS\Db::i()->select( 'MAX(position)', 'core_menu', array( 'parent=?', \IPS\Request::i()->parent ) )->first() + 1;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$save['position'] = 1;
|
||||
}
|
||||
|
||||
$id = \IPS\Db::i()->insert( 'core_menu', $save );
|
||||
|
||||
$_config = $class::parseConfiguration( $config, $id );
|
||||
|
||||
if ( $_config != $config )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_menu', array( 'config' => json_encode( $_config ) ), array( 'id=?', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$item = new $class( $_config, $id, $save['permissions'] );
|
||||
$output = array(
|
||||
'menu_item' => \IPS\Theme::i()->getTemplate( 'applications' )->menuItem( $item, $id )
|
||||
);
|
||||
|
||||
/* If the item has a parent and it's a dropdown menu, then the menu_item
|
||||
we need to return needs to be the one used for dropdown menus */
|
||||
if ( $save['parent'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$parent = \IPS\Db::i()->select( '*', 'core_menu', array( 'id=?', $save['parent'] ) )->first();
|
||||
$parentClass = 'IPS\\' . $parent['app'] . '\extensions\core\FrontNavigation\\' . $parent['extension'];
|
||||
$parentItem = new $parentClass( json_decode( $parent['config'], TRUE ), $parent['id'], $parent['permissions'] );
|
||||
|
||||
if ( $parent['app'] === 'core' and $parent['extension'] === 'Menu' )
|
||||
{
|
||||
$output['menu_item'] = \IPS\Theme::i()->getTemplate( 'applications' )->menuManagerDropdownItem( $item, $id );
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
}
|
||||
|
||||
/* If this is a dropdown item, we also need to return the HTML for the dropdown edit screen */
|
||||
if ( $exploded[1] == 'Menu' )
|
||||
{
|
||||
$output['dropdown_menu'] = \IPS\Theme::i()->getTemplate( 'applications' )->menuManagerDropdown( $item, $id, ( isset( $parentItem ) ? $parentItem : 0 ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( $output );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=applications&controller=menu') );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'applications', 'core' ) ), 'menuManagerForm' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function remove()
|
||||
{
|
||||
static::_remove( intval( \IPS\Request::i()->id ) );
|
||||
\IPS\Output::i()->json('OK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a menu item
|
||||
*
|
||||
* @param int $id ID of item to remove
|
||||
* @return void
|
||||
*/
|
||||
protected static function _remove( $id )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( 'id', 'core_menu', array( 'parent=?', $id ) ) as $child )
|
||||
{
|
||||
static::_remove( $child );
|
||||
}
|
||||
\IPS\Db::i()->delete( 'core_menu', array( 'id=?', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder Items
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reorder()
|
||||
{
|
||||
$positions = array();
|
||||
foreach ( \IPS\Request::i()->menu_order as $id => $parent )
|
||||
{
|
||||
if ( !isset( $positions[ $parent ] ) )
|
||||
{
|
||||
$positions[ $parent ] = 1;
|
||||
}
|
||||
\IPS\Db::i()->update( 'core_menu', array( 'position' => $positions[ $parent ]++, 'parent' => $parent == 'null' ? NULL : $parent ), array( 'id=?', $id ) );
|
||||
}
|
||||
\IPS\Output::i()->json('OK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore Default Menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function restore()
|
||||
{
|
||||
\IPS\core\FrontNavigation::buildDefaultFrontNavigation();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=applications&controller=menu'), 'menu_manager_reverted' );
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,86 @@ class _plugins extends \IPS\Node\Controller
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'plugins_view' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
if ( \IPS\Settings::i()->disable_all_plugins )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'undo',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins&do=reenableAll' ),
|
||||
'title' => 'plugins_reenable_all',
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'times',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins&do=disableAll' ),
|
||||
'title' => 'plugins_disable_all',
|
||||
);
|
||||
}
|
||||
|
||||
parent::manage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable All
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function disableAll()
|
||||
{
|
||||
$disabledPlugins = array();
|
||||
|
||||
foreach ( \IPS\Plugin::plugins() as $plugin )
|
||||
{
|
||||
if ( $plugin->enabled )
|
||||
{
|
||||
$plugin->enabled = FALSE;
|
||||
$plugin->save();
|
||||
|
||||
$disabledPlugins[] = $plugin->id;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->disable_all_plugins = implode( ',', $disabledPlugins );
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Settings::i()->disable_all_plugins ), array( 'conf_key=?', 'disable_all_plugins' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Re-enable All
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reenableAll()
|
||||
{
|
||||
foreach ( explode( ',', \IPS\Settings::i()->disable_all_plugins ) as $plugin )
|
||||
{
|
||||
try
|
||||
{
|
||||
$plugin = \IPS\Plugin::load( $plugin );
|
||||
$plugin->enabled = TRUE;
|
||||
$plugin->save();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->disable_all_plugins = '';
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=?', 'disable_all_plugins' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=applications&controller=plugins' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Enabled/Disable
|
||||
@@ -50,7 +130,10 @@ class _plugins extends \IPS\Node\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_writes', '1C145/G', 403, '' );
|
||||
}
|
||||
|
||||
|
||||
/* Remove plugin.js so it can be rebuilt with only active plugins */
|
||||
\IPS\Output\Javascript::deleteCompiled( 'core', 'plugins', 'plugins.js' );
|
||||
|
||||
return parent::enableToggle();
|
||||
}
|
||||
|
||||
@@ -200,7 +283,8 @@ class _plugins extends \IPS\Node\Controller
|
||||
|
||||
if ( !$plugin->location )
|
||||
{
|
||||
$plugin->location = 'p' . mb_substr( md5( uniqid() ), 0, 10 );
|
||||
$directory = \mb_strtolower( preg_replace( '#[^a-zA-Z0-9_]#', '', $plugin->name ) );
|
||||
$plugin->location = file_exists( \IPS\ROOT_PATH . "/plugins/" . $directory ) ? 'p' . mb_substr( md5( uniqid() ), 0, 10 ) : $directory;
|
||||
}
|
||||
|
||||
$plugin->version_long = $xml->getAttribute('version_long');
|
||||
@@ -382,6 +466,7 @@ class _plugins extends \IPS\Node\Controller
|
||||
case 'cssFiles':
|
||||
case 'jsFiles':
|
||||
case 'resourcesFiles':
|
||||
$class = ( \IPS\Theme::designersModeEnabled() ) ? '\IPS\Theme\Advanced\Theme' : '\IPS\Theme';
|
||||
|
||||
while ( $xml->read() and in_array( $xml->name, array( 'html', 'css', 'js', 'resources' ) ) )
|
||||
{
|
||||
@@ -394,7 +479,7 @@ class _plugins extends \IPS\Node\Controller
|
||||
preg_match('/^<ips:template parameters="(.+?)?"([^>]+?)>(\r\n?|\n)/', $content, $matches );
|
||||
$output = preg_replace( '/^<ips:template parameters="(.+?)?"([^>]+?)>(\r\n?|\n)/', '', $content );
|
||||
|
||||
\IPS\Theme::addTemplate( array(
|
||||
$class::addTemplate( array(
|
||||
'app' => 'core',
|
||||
'location' => 'global',
|
||||
'group' => 'plugins',
|
||||
@@ -408,7 +493,7 @@ class _plugins extends \IPS\Node\Controller
|
||||
break;
|
||||
|
||||
case 'css':
|
||||
\IPS\Theme::addCss( array(
|
||||
$class::addCss( array(
|
||||
'app' => 'core',
|
||||
'location' => 'front',
|
||||
'path' => 'custom',
|
||||
@@ -438,7 +523,7 @@ class _plugins extends \IPS\Node\Controller
|
||||
break;
|
||||
|
||||
case 'resources':
|
||||
\IPS\Theme::addResource( array(
|
||||
$class::addResource( array(
|
||||
'app' => 'core',
|
||||
'location' => 'global',
|
||||
'path' => '/plugins/',
|
||||
@@ -1210,6 +1295,10 @@ class _plugins extends \IPS\Node\Controller
|
||||
{
|
||||
throw new \DomainException( 'form_number_bad' );
|
||||
}
|
||||
if( $val < 10000 )
|
||||
{
|
||||
throw new \DomainException( 'versions_long_too_low' );
|
||||
}
|
||||
if( isset( $json[ $val ] ) )
|
||||
{
|
||||
throw new \DomainException( 'versions_long_exists' );
|
||||
@@ -1428,7 +1517,7 @@ class _plugins extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
/* Build */
|
||||
\IPS\Output::i()->sendOutput( $xml->asXML(), 200, 'application/xml', array( "Content-Disposition" => \IPS\Output::getContentDisposition( 'attachment', $plugin->name . '.xml' ) ) );
|
||||
\IPS\Output::i()->sendOutput( $xml->asXML(), 200, 'application/xml', array( "Content-Disposition" => \IPS\Output::getContentDisposition( 'attachment', $plugin->name . '.xml' ) ), FALSE, FALSE, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -443,7 +443,7 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
/* Start the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->addtab( 'bulkmail__main' );
|
||||
$form->addTab( 'bulkmail__main' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'mail_subject', $mail->subject, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'mail_body', $mail->content ?: "<p>{member_name},</p><p> </p>", TRUE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'bulkmail' . ( $mail->id ? '-' . $mail->id : '' ), 'tags' => $tags, 'attachIds' => array( $mail->id, NULL, 'bulkmail' ) ) ) );
|
||||
|
||||
@@ -453,7 +453,7 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Add the filters tab and the "generic filters" header */
|
||||
$form->addtab( 'bulkmail__filters' );
|
||||
$form->addTab( 'bulkmail__filters' );
|
||||
$form->addHeader( 'generic_bm_filters' );
|
||||
|
||||
$lastApp = 'core';
|
||||
|
||||
@@ -201,7 +201,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( !in_array( 'unmodified', explode( ',', \IPS\Request::i()->filters ) ) )
|
||||
{
|
||||
$where[] = array( 'template_user_edited>0' );
|
||||
$where[] = array( 'template_user_edited>0 or template_added_to > 0' );
|
||||
}
|
||||
$where[] = array( 'template_set_id IN (' . implode( ',' , $parents ) . ')' );
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class _emails extends \IPS\Dispatcher\Controller
|
||||
public function manage()
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_email_templates', \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails' ), array( "template_parent=?", 0 ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_email_templates', \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails' ), array( array( "template_parent=?", 0 ) ) );
|
||||
$table->langPrefix = 'emailtpl_';
|
||||
$table->mainColumn = 'template_name';
|
||||
$table->include = array( 'template_name', 'template_app' );
|
||||
@@ -94,14 +94,20 @@ class _emails extends \IPS\Dispatcher\Controller
|
||||
return $return;
|
||||
};
|
||||
|
||||
/* Import button */
|
||||
/* Buttons */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'upload' => array(
|
||||
'title' => 'upload_email_template',
|
||||
'icon' => 'upload',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails&do=import' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('upload_email_template') )
|
||||
),
|
||||
),
|
||||
'preview' => array(
|
||||
'title' => 'preview_email_wrapper',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails&do=preview' ),
|
||||
'data' => array( 'ipsDialog' => \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails&do=preview' ), 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('preview_email_wrapper') )
|
||||
),
|
||||
);
|
||||
|
||||
/* Display */
|
||||
@@ -312,4 +318,38 @@ class _emails extends \IPS\Dispatcher\Controller
|
||||
$key = $template['template_key'] . '_email_plaintext';
|
||||
\IPS\Data\Store::i()->$key = $ptFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple wrapper for the email out, so that we can show it in an iframe
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function preview()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('emailtpl_edit');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'customization', 'core', 'admin' )->emailFrame( \IPS\Http\Url::internal( 'app=core&module=customization&controller=emails&do=emailPreview' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the raw email preview HTML (to be called inside an iframe)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function emailPreview()
|
||||
{
|
||||
/* Add some dummy content */
|
||||
$body = \IPS\Theme::i()->getTemplate( 'customization', 'core', 'admin' )->emailPreview();
|
||||
|
||||
$templateData = \IPS\Db::i()->select( '*', 'core_email_templates', array( "template_app=? AND template_name=?", 'core', 'emailWrapper' ) )->first();
|
||||
$template = "namespace IPS\Theme;\n" . \IPS\Theme::compileTemplate( $templateData['template_content_html'], "email_html_core_emailWrapper", $templateData['template_data'] );
|
||||
|
||||
if( !function_exists( 'IPS\\Theme\\email_html_core_emailWrapper' ) )
|
||||
{
|
||||
eval( $template );
|
||||
}
|
||||
|
||||
$output = call_user_func_array( 'IPS\\Theme\\email_html_core_emailWrapper', array( NULL, new \IPS\Member, $body, NULL, FALSE, '', NULL ) );
|
||||
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/html' );
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ class _themes extends \IPS\Node\Controller
|
||||
else if ( $data['toImport'] )
|
||||
{
|
||||
$toImport = $_SESSION['theme_dev_import'];
|
||||
|
||||
|
||||
reset( $toImport );
|
||||
$themeId = key( $toImport );
|
||||
$theme = \IPS\Theme::load( $themeId );
|
||||
@@ -295,10 +295,18 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
$languageIds = array_keys( \IPS\Lang::languages() );
|
||||
$languageInserts = array();
|
||||
$seen = array();
|
||||
require \IPS\ROOT_PATH . "/themes/{$themeId}/lang.php";
|
||||
|
||||
foreach ( $lang as $k => $v )
|
||||
{
|
||||
if ( isset( $seen[ $k ] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[ $k ] = true;
|
||||
|
||||
if ( mb_substr( $k, 0, 17 ) === 'theme_custom_tab_' )
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', $k );
|
||||
@@ -306,7 +314,7 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
foreach ( $languageIds as $langId )
|
||||
{
|
||||
$languageInserts[] = array(
|
||||
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
|
||||
'lang_id' => $langId,
|
||||
'word_app' => NULL,
|
||||
'word_plugin' => NULL,
|
||||
@@ -318,14 +326,9 @@ class _themes extends \IPS\Node\Controller
|
||||
'word_custom_version' => NULL,
|
||||
'word_js' => FALSE,
|
||||
'word_export' => TRUE
|
||||
);
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $languageInserts ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_sys_lang_words', $languageInserts );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'html':
|
||||
@@ -605,8 +608,13 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customization' )->resourceDisplay( $row );
|
||||
},
|
||||
'resource_name' => function( $val, $row )
|
||||
'resource_name' => function( $val, $row ) use ($set)
|
||||
{
|
||||
if ( in_array( mb_substr( $row['resource_name'], mb_strrpos( $row['resource_name'], '.' ) + 1 ), \IPS\Image::$imageExtensions ) )
|
||||
{
|
||||
$row['resource_filename'] = $set->resource( ltrim( $row['resource_path'], '/' ) . $row['resource_name'], $row['resource_app'], $row['resource_location'] );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customization' )->resourceName( $row );
|
||||
},
|
||||
'resource_filename' => function( $val, $row )
|
||||
@@ -1029,9 +1037,9 @@ class _themes extends \IPS\Node\Controller
|
||||
'set_author_name' => $xml->getAttribute('author_name'),
|
||||
'set_author_url' => $xml->getAttribute('author_url'),
|
||||
'set_version' => $xml->getAttribute('version'),
|
||||
'set_long_version' => $xml->getAttribute('long_version'),
|
||||
'set_long_version' => ( $xml->getAttribute('long_version') ) ? $xml->getAttribute('long_version') : \IPS\Application::load('core')->long_version,
|
||||
'set_is_default' => $set->is_default,
|
||||
'set_permissions' => implode( ',', $groups )
|
||||
'set_permissions' => $set->id ? $set->permissions : implode( ',', $groups )
|
||||
) );
|
||||
|
||||
if ( $xml->getAttribute('editor_skin') )
|
||||
@@ -1064,6 +1072,7 @@ class _themes extends \IPS\Node\Controller
|
||||
/* Move to correct app */
|
||||
$appKey = NULL;
|
||||
$version = \IPS\Theme::load( \IPS\Request::i()->id )->long_version;
|
||||
|
||||
$xml->read();
|
||||
while ( $xml->read() )
|
||||
{
|
||||
@@ -1278,19 +1287,32 @@ class _themes extends \IPS\Node\Controller
|
||||
$languageIds = isset( $languageIds ) ? $languageIds : array_keys( \IPS\Lang::languages() );
|
||||
foreach ( $languageIds as $langId )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
|
||||
'lang_id' => $langId,
|
||||
'word_app' => NULL,
|
||||
'word_plugin' => NULL,
|
||||
'word_theme' => \IPS\Request::i()->id,
|
||||
'word_key' => $xml->getAttribute('key'),
|
||||
'word_default' => $xml->readString(),
|
||||
'word_custom' => NULL,
|
||||
'word_default_version' => $version,
|
||||
'word_custom_version' => NULL,
|
||||
'word_js' => FALSE,
|
||||
'word_export' => TRUE
|
||||
) );
|
||||
$default = $xml->readString();
|
||||
$exists = \IPS\Db::i()->select( 'COUNT(*)', 'core_sys_lang_words', array( array( 'lang_id=? and word_key=? and word_theme=?', $langId, $xml->getAttribute('key'), \IPS\Request::i()->id ) ) )->first();
|
||||
|
||||
if ( $exists )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_lang_words', array(
|
||||
'word_default' => $default,
|
||||
'word_default_version' => $version,
|
||||
), array( array( 'lang_id=? and word_key=? and word_theme=?', $langId, $xml->getAttribute('key'), \IPS\Request::i()->id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_sys_lang_words', array(
|
||||
'lang_id' => $langId,
|
||||
'word_app' => NULL,
|
||||
'word_plugin' => NULL,
|
||||
'word_theme' => \IPS\Request::i()->id,
|
||||
'word_key' => $xml->getAttribute('key'),
|
||||
'word_default' => $default,
|
||||
'word_custom' => NULL,
|
||||
'word_default_version' => $version,
|
||||
'word_custom_version' => NULL,
|
||||
'word_js' => FALSE,
|
||||
'word_export' => TRUE
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
$xml->next();
|
||||
@@ -1332,6 +1354,8 @@ class _themes extends \IPS\Node\Controller
|
||||
{
|
||||
$set = \IPS\Theme::load( \IPS\Request::i()->id );
|
||||
\IPS\Theme::deleteCompiledResources( null, null, null, null, $set->id );
|
||||
\IPS\Theme::deleteCompiledTemplate( null, null, null, $set->id );
|
||||
\IPS\Theme::deleteCompiledCss( null, null, null, null, $set->id );
|
||||
|
||||
\IPS\Data\Store::i()->delete( 'core_theme_import_' . md5_file( \IPS\Request::i()->file ) );
|
||||
|
||||
@@ -1377,9 +1401,9 @@ class _themes extends \IPS\Node\Controller
|
||||
if ( isset( $conflicts['template'] ) AND count( $conflicts['template'] ) )
|
||||
{
|
||||
$templates = iterator_to_array( \IPS\Db::i()->select(
|
||||
'*, MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) ) as bit_key',
|
||||
'*, MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) ) as bit_key',
|
||||
'core_theme_templates',
|
||||
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) )', array_keys( $conflicts['template'] ) )
|
||||
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) )', array_keys( $conflicts['template'] ) )
|
||||
)->setKeyField( 'bit_key' ) );
|
||||
}
|
||||
else
|
||||
@@ -1390,9 +1414,9 @@ class _themes extends \IPS\Node\Controller
|
||||
if ( isset( $conflicts['css'] ) AND count( $conflicts['css'] ) )
|
||||
{
|
||||
$css = iterator_to_array( \IPS\Db::i()->select(
|
||||
'*, MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) ) as bit_key',
|
||||
'*, MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) ) as bit_key',
|
||||
'core_theme_css',
|
||||
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) )', array_keys( $conflicts['css'] ) )
|
||||
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) )', array_keys( $conflicts['css'] ) )
|
||||
)->setKeyField( 'bit_key' ) );
|
||||
}
|
||||
else
|
||||
@@ -1458,18 +1482,18 @@ class _themes extends \IPS\Node\Controller
|
||||
if ( isset( $conflicts['template'] ) AND count( $conflicts['template'] ) )
|
||||
{
|
||||
$templates = iterator_to_array( \IPS\Db::i()->select(
|
||||
'*, MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) ) as bit_key',
|
||||
'*, MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) ) as bit_key',
|
||||
'core_theme_templates',
|
||||
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, ".", template_location, ".", template_group, ".", template_name ) )', array_keys( $conflicts['template'] ) )
|
||||
'template_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( template_app, \'.\', template_location, \'.\', template_group, \'.\', template_name ) )', array_keys( $conflicts['template'] ) )
|
||||
)->setKeyField( 'bit_key' ) );
|
||||
}
|
||||
|
||||
if ( isset( $conflicts['css'] ) AND count( $conflicts['css'] ) )
|
||||
{
|
||||
$css = iterator_to_array( \IPS\Db::i()->select(
|
||||
'*, MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) ) as bit_key',
|
||||
'*, MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) ) as bit_key',
|
||||
'core_theme_css',
|
||||
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, ".", css_location, ".", css_path, ".", css_name ) )', array_keys( $conflicts['css'] ) )
|
||||
'css_set_id=' . $id . ' AND ' . \IPS\Db::i()->in('MD5( CONCAT( css_app, \'.\', css_location, \'.\', css_path, \'.\', css_name ) )', array_keys( $conflicts['css'] ) )
|
||||
)->setKeyField( 'bit_key' ) );
|
||||
}
|
||||
|
||||
@@ -2034,7 +2058,30 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
/* Language strings */
|
||||
$xml->startElement('language');
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_theme=?', $themeSet->id ) ) as $row )
|
||||
|
||||
$parents = array( $themeSet->id );
|
||||
try
|
||||
{
|
||||
foreach( $themeSet->parents() as $parent )
|
||||
{
|
||||
$parents[] = $parent->_id;
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
|
||||
$words = array();
|
||||
|
||||
foreach ( \IPS\Db::i()->select(
|
||||
'*, INSTR(\',' . implode( ',' , $parents ) . ',\', CONCAT(\',\',word_theme,\',\') ) as theorder',
|
||||
'core_sys_lang_words',
|
||||
array( 'word_theme IN(' . implode( ',' , $parents ) . ')' ),
|
||||
'theorder desc'
|
||||
) as $data )
|
||||
{
|
||||
$words[ $data['word_key'] ] = $data;
|
||||
}
|
||||
|
||||
foreach ( $words as $row )
|
||||
{
|
||||
$xml->startElement( 'word' );
|
||||
$xml->startAttribute('key');
|
||||
@@ -2108,10 +2155,10 @@ class _themes extends \IPS\Node\Controller
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->hiddenValues['id'] = $id;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'theme_template_name', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_\\-]+?)$/i' ),
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'theme_template_name', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_]+?)$/i' ),
|
||||
function( $val )
|
||||
{
|
||||
if ( ! preg_match( '/^([A-Z0-9_\-]+?)$/i', $val ) )
|
||||
if ( ! preg_match( '/^([A-Z0-9_]+?)$/i', $val ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_bad_value' );
|
||||
}
|
||||
@@ -2265,8 +2312,11 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
if ( isset( $template['template_content'] ) )
|
||||
{
|
||||
$template['type'] = 'templates';
|
||||
$template['name'] = $template['template_name'];
|
||||
$template['type'] = 'templates';
|
||||
$template['name'] = $template['template_name'];
|
||||
$template['app'] = $template['template_app'];
|
||||
$template['location'] = $template['template_location'];
|
||||
$template['group'] = $template['template_group'];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2275,8 +2325,11 @@ class _themes extends \IPS\Node\Controller
|
||||
|
||||
if ( isset( $template['css_content'] ) )
|
||||
{
|
||||
$template['type'] = 'css';
|
||||
$template['name'] = $template['css_name'];
|
||||
$template['type'] = 'css';
|
||||
$template['name'] = $template['css_name'];
|
||||
$template['app'] = $template['css_app'];
|
||||
$template['location'] = $template['css_location'];
|
||||
$template['group'] = $template['css_path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2285,8 +2338,11 @@ class _themes extends \IPS\Node\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '3S121/1', 500, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__themetemplate_deleted', array( $template['name'] => FALSE ) );
|
||||
|
||||
if ( isset( $template['app'] ) )
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplogs__themetemplate_deleted', array( $template['app'] => FALSE, $template['location'] => FALSE, $template['group'] => FALSE, $template['name'] => FALSE ) );
|
||||
}
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
@@ -2363,7 +2419,7 @@ class _themes extends \IPS\Node\Controller
|
||||
if ( in_array( $k, array( 'app', 'location', 'group', 'name' ) ) )
|
||||
{
|
||||
$url[] = 't_' . $k . '=' . $v;
|
||||
$log[ $k ] = $v;
|
||||
$log[ $v ] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Search settings
|
||||
* @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 14 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\discovery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search settings
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'search_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Rebuild button */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'rebuildIndex' => array(
|
||||
'title' => 'search_rebuild_index',
|
||||
'icon' => 'undo',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=discovery&controller=search&do=queueIndexRebuild' ),
|
||||
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->get('search_rebuild_index_confirm') ),
|
||||
),
|
||||
);
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_index_timeframe', \IPS\Settings::i()->search_index_timeframe, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'all' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('search_index_timeframe_prefix'), \IPS\Member::loggedIn()->language()->addToStack('search_index_timeframe_suffix'), 'search_index_timeframe' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$indexPrune = \IPS\Settings::i()->search_index_timeframe;
|
||||
|
||||
/* Go ahead and save... */
|
||||
$form->saveAsSettings();
|
||||
\IPS\Session::i()->log( 'acplogs__search_settings' );
|
||||
|
||||
/* And re-index if setting updated */
|
||||
if( $indexPrune != $values['search_index_timeframe'] )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_discovery_search');
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'menu__core_discovery_search', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue an index rebuild
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function queueIndexRebuild()
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__queued_search_index' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=discovery&controller=search' ), 'search_index_rebuilding' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief 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 01 Jul 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\discovery;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* streams
|
||||
*/
|
||||
class _streams extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\core\Stream';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'streams_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'rebuildIndex' => array(
|
||||
'title' => 'all_activity_stream_settings',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams&do=allActivitySettings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('all_activity_stream_settings') )
|
||||
),
|
||||
'rebuildDefault' => array(
|
||||
'title' => 'restore_default_streams',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams&do=restoreDefaultStreams' )
|
||||
),
|
||||
);
|
||||
|
||||
return parent::manage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores default streams
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function restoreDefaultStreams()
|
||||
{
|
||||
$schema = json_decode( file_get_contents( \IPS\ROOT_PATH . "/applications/core/data/schema.json" ), TRUE );
|
||||
|
||||
foreach ( $schema['core_streams']['inserts'] as $insertData )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->replace( 'core_streams', $insertData );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
{}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams' ), 'restore_default_streams_restored' );
|
||||
}
|
||||
|
||||
/**
|
||||
* All Activity Stream Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function allActivitySettings()
|
||||
{
|
||||
$types = array( 'register', 'follow_member', 'follow_content', 'photo' );
|
||||
if ( \IPS\Settings::i()->reputation_enabled )
|
||||
{
|
||||
if ( \IPS\Settings::i()->reputation_point_types == 'like' )
|
||||
{
|
||||
$types[] = 'like';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->reputation_point_types == 'both' )
|
||||
{
|
||||
$types[] = 'like';
|
||||
$types[] = 'rep_neg';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->reputation_point_types == 'positive' )
|
||||
{
|
||||
$types[] = 'like';
|
||||
}
|
||||
elseif ( \IPS\Settings::i()->reputation_point_types == 'negative' )
|
||||
{
|
||||
$types[] = 'rep_neg';
|
||||
}
|
||||
}
|
||||
|
||||
$options = array();
|
||||
$currentValuesStream = array();
|
||||
foreach ( $types as $k )
|
||||
{
|
||||
$key = "all_activity_{$k}";
|
||||
if ( \IPS\Settings::i()->$key )
|
||||
{
|
||||
$currentValuesStream[] = $k;
|
||||
}
|
||||
$options[ $k ] = ( $k == 'like' and \IPS\Settings::i()->reputation_point_types != 'like' ) ? 'all_activity_rep_pos' : $key;
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'all_activity_extra_stream', $currentValuesStream, FALSE, array( 'options' => $options ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$toSave = array();
|
||||
foreach ( $types as $k )
|
||||
{
|
||||
$toSave[ "all_activity_{$k}" ] = intval( in_array( $k, $values['all_activity_extra_stream'] ) );
|
||||
}
|
||||
$form->saveAsSettings( $toSave );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -80,28 +80,32 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
'toggles' => array( 'create' => array( 'emoticons_add_newgroup' ), 'existing' => array( 'emoticons_add_choosegroup' ) ),
|
||||
'disabled' => empty($groups)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'emoticons_add_newgroup', NULL, FALSE, array(), NULL, NULL, NULL, 'emoticons_add_newgroup' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'emoticons_add_newgroup', NULL, FALSE, array(), function( $value )
|
||||
{
|
||||
if ( $values['emoticons_add_group'] === 'create' )
|
||||
if ( \IPS\Request::i()->emoticons_add_group === 'create' )
|
||||
{
|
||||
foreach ( \IPS\Lang::languages() as $lang )
|
||||
{
|
||||
if ( $lang->default )
|
||||
{
|
||||
if( !$values['emoticons_add_newgroup'][ $lang->id ] )
|
||||
if( ! $value[ $lang->id ] )
|
||||
{
|
||||
$form->elements['']['emoticons_add_newgroup']->error = \IPS\Member::loggedIn()->language()->addToStack( 'emoticon_group_name_error' );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'emoticons_add', $form, FALSE );
|
||||
return;
|
||||
throw new \InvalidArgumentException('form_required');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, NULL, NULL, 'emoticons_add_newgroup' ) );
|
||||
|
||||
if ( !empty( $groups ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( $values['emoticons_add_group'] === 'create' )
|
||||
{
|
||||
$position = 0;
|
||||
$setId = md5( uniqid() );
|
||||
\IPS\Lang::saveCustom( 'core', "core_emoticon_group_{$setId}", $values['emoticons_add_newgroup'] );
|
||||
@@ -120,8 +124,18 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$inserts = array();
|
||||
$images2x = array();
|
||||
foreach ( $values['emoticons_upload'] as $file )
|
||||
{
|
||||
/* Is it "retina" */
|
||||
if( \mb_stristr( $file->filename, '@2x' ) )
|
||||
{
|
||||
$filename_2x = preg_replace( "/^(.+?)\.[0-9a-f]{32}(?:\..+?)$/i", "$1", str_replace( '@2x', '', $file->filename ) );
|
||||
|
||||
$images2x[ $filename_2x ] = (string) $file;
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = preg_replace( "/^(.+?)\.[0-9a-f]{32}(?:\..+?)$/i", "$1", $file->filename );
|
||||
|
||||
$inserts[] = array(
|
||||
@@ -132,8 +146,42 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
'emo_position' => ++$position,
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
|
||||
|
||||
if( count( $inserts ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
|
||||
}
|
||||
|
||||
/* Add 2x */
|
||||
if( count( $images2x ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $setId ) ) as $emo )
|
||||
{
|
||||
$file = \IPS\File::get( 'core_Emoticons', $emo['image'] );
|
||||
$imageDimensions = $file->getImageDimensions();
|
||||
|
||||
/* There isn't an original for the 2x emo */
|
||||
if( !isset( $images2x[ $file->filename ] ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_emoticons', array(
|
||||
'image_2x' => $images2x[ $file->filename ],
|
||||
'width' => $imageDimensions[0],
|
||||
'height' => $imageDimensions[1]
|
||||
), 'id=' . $emo['id']);
|
||||
|
||||
unset( $images2x[ $file->filename ] );
|
||||
}
|
||||
|
||||
/* Delete any unused 2x files */
|
||||
foreach( $images2x as $img )
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $img )->delete();
|
||||
}
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->emoticons );
|
||||
|
||||
/* Clear guest page caches */
|
||||
@@ -205,6 +253,11 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( $emoticons[ $id ] ) )
|
||||
{
|
||||
if ( !$data['name'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !isset( $data['order'] ) )
|
||||
{
|
||||
if ( !isset( $orders[ $set ] ) )
|
||||
@@ -256,6 +309,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
if ( $emoticon['id'] )
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_emoticons', array( 'id=?', (int) \IPS\Request::i()->id ) );
|
||||
@@ -296,6 +350,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief settings
|
||||
* @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 13 Aug 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\editor;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/* Restrictions check */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
|
||||
/* Choose active tab */
|
||||
$this->tabs = array( 'general' => 'editor_settings_general', 'advanced' => 'editor_settings_advanced' );
|
||||
if ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $this->tabs ) )
|
||||
{
|
||||
$this->activeTab = \IPS\Request::i()->tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
$keys = array_keys( $this->tabs );
|
||||
$this->activeTab = array_shift( $keys );
|
||||
}
|
||||
|
||||
/* Run */
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Work out output */
|
||||
$activeTabContents = call_user_func( array( $this, '_manage'.ucfirst( $this->activeTab ) ) );
|
||||
|
||||
/* If this is an AJAX request, just return it */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('editor_settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $this->tabs, $this->activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=editor&controller=settings" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* General Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _manageGeneral()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'editor_paste_behaviour', \IPS\Settings::i()->editor_paste_behaviour, FALSE, array( 'options' => array(
|
||||
'rich' => 'editor_paste_behaviour_rich',
|
||||
'force' => 'editor_paste_behaviour_force',
|
||||
) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'editor_paragraph_padding', \IPS\Settings::i()->editor_paragraph_padding, FALSE, array( 'options' => array(
|
||||
1 => 'editor_paragraph_padding_on',
|
||||
0 => 'editor_paragraph_padding_off'
|
||||
) ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$clearCss = ( $values['editor_paragraph_padding'] !== \IPS\Settings::i()->editor_paragraph_padding );
|
||||
|
||||
$form->saveAsSettings();
|
||||
|
||||
if ( $clearCss )
|
||||
{
|
||||
\IPS\Theme::deleteCompiledCss();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=settings&tab=general" ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _manageAdvanced()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form' );
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('editor_allowed_formmsg') );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_classes', \IPS\Settings::i()->editor_allowed_classes ? explode( ',', \IPS\Settings::i()->editor_allowed_classes ) : array(), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_datacontrollers', \IPS\Settings::i()->editor_allowed_datacontrollers ? explode( ',', \IPS\Settings::i()->editor_allowed_datacontrollers ) : array(), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_iframe_bases', \IPS\Settings::i()->editor_allowed_iframe_bases ? explode( ',', \IPS\Settings::i()->editor_allowed_iframe_bases ) : array(), FALSE, array( 'placeholder' => 'example.com/embed/' ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=settings&tab=advanced" ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
@@ -77,39 +77,10 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
'title' => 'editor_revert',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar&do=revert" ),
|
||||
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack('editor_revert_confirm' ) )
|
||||
),
|
||||
'edit' => array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'editor_advanced_config',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar&do=advanced" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('editor_advanced_config') )
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Advanced ckeditor configuration options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function advanced()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form' );
|
||||
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('editor_allowed_formmsg') );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_classes', \IPS\Settings::i()->editor_allowed_classes ? explode( ',', \IPS\Settings::i()->editor_allowed_classes ) : array(), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_datacontrollers', \IPS\Settings::i()->editor_allowed_datacontrollers ? explode( ',', \IPS\Settings::i()->editor_allowed_datacontrollers ) : array(), FALSE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar" ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save
|
||||
*
|
||||
@@ -309,6 +280,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'editor_plugin_nowrite', '4C120/2', 403, '' );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'editor_plugin_zip', NULL, TRUE, array( 'allowedFileTypes' => array( 'zip' ), 'temporary' => TRUE ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['editor_plugin_zip_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'editor_plugin_zip_desc' ), \IPS\Helpers\Form\Editor::ckeditorVersion() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -321,6 +293,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'editor_plugin_folder', NULL, TRUE, array( 'options' => $plugins ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['editor_plugin_folder_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'editor_plugin_folder_desc' ), \IPS\Helpers\Form\Editor::ckeditorVersion() );
|
||||
}
|
||||
|
||||
/* Handle Submissions */
|
||||
@@ -344,7 +317,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
$name = mb_substr( zip_entry_name( $resource ), 0, -1 );
|
||||
$name = explode( '/', $name );
|
||||
$name = array_shift( $name );
|
||||
if ( strstr( $fileName, $name ) !== FALSE )
|
||||
if ( strstr( mb_strtolower( $fileName ), mb_strtolower( $name ) ) !== FALSE )
|
||||
{
|
||||
$inRoot = FALSE;
|
||||
break;
|
||||
|
||||
@@ -139,7 +139,7 @@ class _languages extends \IPS\Node\Controller
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
/* Log */
|
||||
\IPS\Session::i()->log( 'lang_created', array( $values['lang_title'] => FALSE ) );
|
||||
\IPS\Session::i()->log( 'acplogs__lang_created', array( $values['lang_title'] => FALSE ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=languages&controller=languages' ), 'saved' );
|
||||
@@ -330,7 +330,7 @@ class _languages extends \IPS\Node\Controller
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->cookie['vle_editor'] ) and \IPS\Request::i()->cookie['vle_editor'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_translate_with_vle', '', 403 ); //@todo errorcode
|
||||
\IPS\Output::i()->error( 'no_translate_with_vle', '1C126/8', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -476,6 +476,11 @@ class _languages extends \IPS\Node\Controller
|
||||
\IPS\Output::clearJsFiles( 'global', 'root', 'js_lang_' . $word['lang_id'] . '.js' );
|
||||
}
|
||||
|
||||
if ( $word['word_key'] === '_list_format_' )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->listFormats );
|
||||
}
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
@@ -709,6 +714,29 @@ class _languages extends \IPS\Node\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add "UTF8" if we can */
|
||||
$currentLocale = setlocale( LC_ALL, '0' );
|
||||
|
||||
foreach ( array( \IPS\Request::i()->locale . ".UTF-8", \IPS\Request::i()->locale . ".UTF8" ) as $l )
|
||||
{
|
||||
$test = setlocale( LC_ALL, $l );
|
||||
if ( $test !== FALSE )
|
||||
{
|
||||
\IPS\Request::i()->locale = $l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( explode( ";", $currentLocale ) as $locale )
|
||||
{
|
||||
$parts = explode( "=", $locale );
|
||||
if( in_array( $parts[0], array( 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME' ) ) )
|
||||
{
|
||||
setlocale( constant( $parts[0] ), $parts[1] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert the language pack record */
|
||||
$max = \IPS\Db::i()->select( 'MAX(lang_order)', 'core_sys_lang' )->first();
|
||||
$insertId = \IPS\Db::i()->insert( 'core_sys_lang', array(
|
||||
'lang_short' => \IPS\Request::i()->locale,
|
||||
|
||||
@@ -165,7 +165,7 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
$form = new \IPS\Helpers\Form( ( !$group->g_id ? 'groups_add' : $group->g_id ) );
|
||||
foreach ( $extensions as $k => $class )
|
||||
{
|
||||
$form->addtab( 'group__' . $k );
|
||||
$form->addTab( 'group__' . $k );
|
||||
$class->process( $form, $group );
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class _ip extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
$geolocation = \IPS\GeoLocation::getByIp( $ip );
|
||||
$map = $geolocation->map()->render( 400, 350, 6 );
|
||||
$map = $geolocation->map()->render( 400, 350, 0.6 );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
|
||||
@@ -124,13 +124,13 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
'from' => array( 'core_pfields_content', 'p' ),
|
||||
'where' => 'p.member_id=core_members.member_id' ),
|
||||
array(
|
||||
'select' => 'row_id',
|
||||
'from' => array( 'core_admin_permission_rows', 'a' ),
|
||||
'where' => "a.row_id=core_members.member_id AND a.row_id_type='member'" ),
|
||||
'select' => 'm.row_id',
|
||||
'from' => array( 'core_admin_permission_rows', 'm' ),
|
||||
'where' => "m.row_id=core_members.member_id AND m.row_id_type='member'" ),
|
||||
array(
|
||||
'select' => 'g_access_cp',
|
||||
'from' => array( 'core_groups', 'g' ),
|
||||
'where' => "g.g_id=core_members.member_group_id" ),
|
||||
'select' => 'g.row_id',
|
||||
'from' => array( 'core_admin_permission_rows', 'g' ),
|
||||
'where' => "( g.row_id=core_members.member_group_id OR FIND_IN_SET( g.row_id, core_members.mgroup_others ) ) AND g.row_id_type='group'" ),
|
||||
);
|
||||
|
||||
/* Makes query less efficient */
|
||||
@@ -183,7 +183,7 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
'members_filter_locked' => 'failed_login_count>=' . (int) \IPS\Settings::i()->ipb_bruteforce_attempts,
|
||||
'members_filter_spam' => \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ),
|
||||
'members_filter_validating' => '( v.lost_pass=0 AND v.vid IS NOT NULL )',
|
||||
'members_filter_administrators' => '( a.row_id IS NOT NULL OR g.g_access_cp=1 )'
|
||||
'members_filter_administrators' => '( m.row_id IS NOT NULL OR g.row_id IS NOT NULL )'
|
||||
);
|
||||
|
||||
/* Custom parsers */
|
||||
@@ -372,6 +372,7 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
'members_last_post' => \IPS\Request::i()->members_last_post,
|
||||
'members_last_visit' => \IPS\Request::i()->members_last_visit,
|
||||
'members_posts' => \IPS\Request::i()->members_posts,
|
||||
'filter' => \IPS\Request::i()->filter,
|
||||
) );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_delete' ) )
|
||||
@@ -519,6 +520,28 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
$where[] = array( 'posts'.$operator.'?', (int) \IPS\Request::i()->members_posts[1] );
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->filter ) )
|
||||
{
|
||||
switch ( \IPS\Request::i()->filter )
|
||||
{
|
||||
case 'members_filter_banned':
|
||||
$where[] = array( 'temp_ban<>0' );
|
||||
break;
|
||||
case 'members_filter_locked':
|
||||
$where[] = array( 'failed_login_count>=' . (int) \IPS\Settings::i()->ipb_bruteforce_attempts );
|
||||
break;
|
||||
case 'members_filter_spam':
|
||||
$where[] = array( \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) );
|
||||
break;
|
||||
case 'members_filter_validating':
|
||||
$where[] = array( '( v.lost_pass=0 AND v.vid IS NOT NULL )' );
|
||||
break;
|
||||
case 'members_filter_administrators':
|
||||
$where[] = array( '( m.row_id IS NOT NULL OR g.row_id IS NOT NULL )' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->action === 'prune' )
|
||||
@@ -812,7 +835,7 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
$form = new \IPS\Helpers\Form;
|
||||
foreach ( $extensions as $k => $class )
|
||||
{
|
||||
$form->addtab( 'member__' . $k );
|
||||
$form->addTab( 'member__' . $k );
|
||||
$class->process( $form, $member );
|
||||
|
||||
if ( method_exists( $class, 'actionButtons' ) )
|
||||
@@ -999,6 +1022,7 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
$member->pp_main_photo = NULL;
|
||||
$member->pp_main_photo = (string) $values['member_photo_upload'];
|
||||
$member->pp_thumb_photo = (string) $values['member_photo_upload']->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE );
|
||||
$member->photo_last_update = time();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1006,11 +1030,13 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
$member->pp_photo_type = 'custom';
|
||||
$member->pp_main_photo = NULL;
|
||||
$member->pp_main_photo = (string) $values['member_photo_url'];
|
||||
$member->photo_last_update = time();
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
$member->pp_main_photo = NULL;
|
||||
$member->members_bitoptions['bw_disable_gravatar'] = 1;
|
||||
$member->photo_last_update = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1057,10 +1083,13 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Init Table */
|
||||
$table = new \IPS\Helpers\Table\Custom( $member->ipAddresses(), \IPS\Http\Url::internal( "app=core&module=members&controller=members&id={$member->member_id}&do=ip" ) );
|
||||
$table->langPrefix = 'members_iptable_';
|
||||
$table->mainColumn = 'ip';
|
||||
$table->sortBy = $table->sortBy ?: 'last';
|
||||
$ips = $member->ipAddresses();
|
||||
|
||||
$table = new \IPS\Helpers\Table\Custom( $ips, \IPS\Http\Url::internal( "app=core&module=members&controller=members&id={$member->member_id}&do=ip" ) );
|
||||
$table->langPrefix = 'members_iptable_';
|
||||
$table->mainColumn = 'ip';
|
||||
$table->sortBy = $table->sortBy ?: 'last';
|
||||
$table->quickSearch = 'ip';
|
||||
|
||||
/* Parsers */
|
||||
$table->parsers = array(
|
||||
@@ -1404,7 +1433,14 @@ class _members extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
$accountToKeep->merge( $accountToDelete );
|
||||
try
|
||||
{
|
||||
$accountToKeep->merge( $accountToDelete );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '3C114/J', 403, '' );
|
||||
}
|
||||
|
||||
/* Delete the account */
|
||||
$accountToDelete->delete( FALSE );
|
||||
|
||||
@@ -154,19 +154,10 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'subs_autoprune', \IPS\Settings::i()->subs_autoprune, FALSE, array(), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'autoforum_sub_groups', \IPS\Settings::i()->autoforum_sub_groups ? explode( ",", \IPS\Settings::i()->autoforum_sub_groups ) : array(), FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'auto_track_method', \IPS\Settings::i()->auto_track_method, FALSE, array( 'options' => array(
|
||||
0 => 'select_disabled',
|
||||
'immediate' => 'follow_type_immediate',
|
||||
'daily' => 'follow_type_daily',
|
||||
'weekly' => 'follow_type_weekly',
|
||||
) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'prune_notifications', \IPS\Settings::i()->prune_notifications, FALSE, array(), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('months') ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['autoforum_sub_groups'] = implode( ",", $values['autoforum_sub_groups'] );
|
||||
|
||||
$form->saveAsSettings();
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__notification_settings' );
|
||||
|
||||
@@ -170,7 +170,7 @@ class _ranks extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$pip = \IPS\File::get( 'core_Theme', $current['icon'] );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'member_ranks_num_pips' , $current ? $current['pips'] : 0, FALSE, array( 'min' => 0 ), NULL, NULL, NULL, 'member_ranks_pips' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'member_ranks_num_pips' , $current ? $current['pips'] : 0, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, NULL, 'member_ranks_pips' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'member_ranks_icon', $pip, FALSE, array( 'image' => array( 'maxWidth' => 140, 'maxHeight' => 140 ), 'storageExtension' => 'core_Theme' ), NULL, NULL, NULL, 'member_ranks_icon' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
|
||||
@@ -76,13 +76,26 @@ class _reputation extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
|
||||
/* Fake names for the "like" preview */
|
||||
/* Random for the "like" preview */
|
||||
$maxMemberId = \IPS\Db::i()->select( 'MAX(member_id)', 'core_members' )->first();
|
||||
$names = array();
|
||||
foreach ( range( 1, 3 ) as $i )
|
||||
foreach ( range( 1, ( $maxMemberId > 3 ) ? 3 : $maxMemberId ) as $i )
|
||||
{
|
||||
do
|
||||
{
|
||||
$randomMemberId = rand( 1, $maxMemberId );
|
||||
}
|
||||
while ( array_key_exists( $randomMemberId, $names ) );
|
||||
|
||||
try
|
||||
{
|
||||
$member = \IPS\Member::constructFromData( \IPS\Db::i()->select( '*', 'core_members', empty( $names ) ? array() : 'member_id NOT IN(' . implode( ',', array_keys( $names ) ) . ')', 'RAND()', 1 )->first() );
|
||||
$where = array( array( 'member_id>=?', $randomMemberId ) );
|
||||
if ( !empty( $names ) )
|
||||
{
|
||||
$where[] = \IPS\Db::i()->in( 'member_id', array_keys( $names ), TRUE );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::constructFromData( \IPS\Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
|
||||
$names[ $member->member_id ] = '<a>' . htmlentities( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
@@ -142,7 +155,7 @@ class _reputation extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_reputation_levels', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation' ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_reputation_levels', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
$table->langPrefix = 'rep_';
|
||||
|
||||
/* Columns */
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* @package IPS Social Suite
|
||||
* @since 18 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @modified 13.09.2015 by IAF
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
@@ -67,7 +66,7 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Add a button for logs */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'spam_service_log' ) )
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'spam_service_log' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['errorLog'] = array(
|
||||
'title' => 'spamlogs',
|
||||
@@ -174,11 +173,11 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
$disabled = TRUE;
|
||||
if( !\IPS\Settings::i()->ipb_reg_number )
|
||||
{
|
||||
$form->addMessage( '__iaf__nulling_null_alert', 'ipsMessage ipsMessage_error' ); //Changing error message to custom
|
||||
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'spam_service_nokey', FALSE, array( 'sprintf' => array( \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey', null ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addMessage( '__iaf__nulling_null_alert', 'ipsMessage ipsMessage_error' ); //Changing error message to custom
|
||||
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'spam_service_noservice' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,6 +416,4 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spamlogssettings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'spamlogssettings', $form, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
}
|
||||
@@ -206,7 +206,7 @@ class _warnings extends \IPS\Node\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'wa_' . $k, ( $current ? array( $current[ 'wa_' . $k ], $current[ 'wa_' . $k . '_unit' ] ) : 0 ), FALSE, array(
|
||||
'getHtml' => function( $element )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'members' )->warningTime( $element->name, $element->value, TRUE );
|
||||
return \IPS\Theme::i()->getTemplate( 'members' )->warningTime( $element->name, $element->value, 'for', 'indefinitely' );
|
||||
},
|
||||
'formatValue'=> function( $element )
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* @package IPS Social Suite
|
||||
* @since 2 July 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @modified 13.09.2015 by IAF
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\overview;
|
||||
@@ -141,30 +140,7 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Get new core update available data */
|
||||
$system = \IPS\Application::load( 'core' );
|
||||
$update = array();
|
||||
if( $system->update_version )
|
||||
{
|
||||
$versions = json_decode( $system->update_version, TRUE );
|
||||
if ( is_array( $versions ) and !isset( $versions[0] ) and isset( $versions['longversion'] ) )
|
||||
{
|
||||
$versions = array( $versions );
|
||||
}
|
||||
|
||||
$update = array();
|
||||
foreach ( $versions as $data )
|
||||
{
|
||||
if( !empty($data['longversion']) AND $data['longversion'] > $system->long_version )
|
||||
{
|
||||
if( $data['released'] AND intval($data['released']) == $data['released'] AND \strlen($data['released']) == 10 )
|
||||
{
|
||||
$data['released'] = (string) \IPS\DateTime::ts( $data['released'] )->localeDate();
|
||||
}
|
||||
|
||||
$update[] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
$update = \IPS\Application::load( 'core' )->availableUpgrade( TRUE );
|
||||
|
||||
/* Don't show the ACP header bar */
|
||||
\IPS\Output::i()->hiddenElements[] = 'acpHeader';
|
||||
@@ -281,22 +257,5 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=overview&controller=dashboard" ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Download latest version
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function upgrade()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('ips_suite_upgrade');
|
||||
|
||||
$form = new \IPS\Helpers\Form( NULL, NULL );
|
||||
$form->addMessage( "__iaf__nulling_null_alert", 'ipsMessage ipsMessage_error' ); //No requests to IPS. Only error message about Null.
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
}
|
||||
}
|
||||
@@ -86,15 +86,17 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'attach_file' => function( $val, $row ) use ( $table )
|
||||
{
|
||||
$url = \IPS\Http\Url::external( \IPS\File::get( 'core_Attachment', $row['attach_location'] )->url )->makeSafeForAcp( $row['attach_is_image'] );
|
||||
if ( $row['attach_is_image'] and $table->filter === 'images' )
|
||||
{
|
||||
$url = \IPS\Http\Url::external( \IPS\File::get( 'core_Attachment', $row['attach_location'] )->url )->makeSafeForAcp( TRUE );
|
||||
return "<a href='{$url}' target='_blank'><img src='{$url}' style='max-height:200px'></a>";
|
||||
}
|
||||
|
||||
$val = htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
|
||||
return "<a href='{$url}' target='_blank'>{$val}</a>";
|
||||
else
|
||||
{
|
||||
$url = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . "applications/core/interface/file/attachment.php" )->setQueryString( 'id', $row['attach_id'] )->makeSafeForAcp( FALSE );
|
||||
$val = htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
return "<a href='{$url}' target='_blank'>{$val}</a>";
|
||||
}
|
||||
},
|
||||
'attach_filesize' => function( $val )
|
||||
{
|
||||
@@ -253,8 +255,8 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
'disabled'=> class_exists( 'Imagick', FALSE ) ? array() : array( 'imagemagick' )
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'image_jpg_quality', \IPS\Settings::i()->image_jpg_quality, FALSE, array( 'min' => 0, 'max' => 100, 'range' => TRUE ), NULL, NULL, NULL, 'image_jpg_quality' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'image_png_quality_gd', \IPS\Settings::i()->image_png_quality_gd, FALSE, array( 'min' => 0, 'max' => 9, 'range' => TRUE ), NULL, NULL, NULL, 'image_png_quality_gd' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'image_jpg_quality', \IPS\Settings::i()->image_jpg_quality, FALSE, array( 'min' => 0, 'max' => 100, 'range' => TRUE, 'step' => 1 ), NULL, NULL, NULL, 'image_jpg_quality' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'image_png_quality_gd', \IPS\Settings::i()->image_png_quality_gd, FALSE, array( 'min' => 0, 'max' => 9, 'range' => TRUE, 'step' => 1 ), NULL, NULL, NULL, 'image_png_quality_gd' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -632,10 +634,12 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
\IPS\Db::i()->update( 'core_file_storage', array( 'configuration' => json_encode( $currentHandlerSettings ) ), array( 'id=?', $current['id'] ) );
|
||||
unset( \IPS\Data\Store::i()->storageConfigurations );
|
||||
}
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
|
||||
if ( $current !== NULL and ! $createNewAndMove )
|
||||
{
|
||||
$classname::getClass( $current['id'] )->settingsUpdated();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=files&do=settings&tab=configurations' ), 'saved' );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
@@ -666,7 +670,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'files_invalid_id', '3C158/5', 404, '' );
|
||||
\IPS\Output::i()->json( array( 'needsMoving' => FALSE ) );
|
||||
}
|
||||
|
||||
$currentConf = json_decode( $current['configuration'], TRUE );
|
||||
|
||||
@@ -103,7 +103,7 @@ class _advertisements extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'ad_active' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'promotion' )->activeBadge( $row['ad_id'], ( $val == -1 ) ? 'ad_filters_pending' : ( ( $val == 0 ) ? 'ad_filters_inactive' : 'ad_filters_active' ), $val );
|
||||
return \IPS\Theme::i()->getTemplate( 'promotion' )->activeBadge( $row['ad_id'], ( $val == -1 ) ? 'ad_filters_pending' : ( ( $val == 0 ) ? 'ad_filters_inactive' : 'ad_filters_active' ), $val, $row );
|
||||
},
|
||||
'ad_clicks' => function( $val, $row )
|
||||
{
|
||||
@@ -622,4 +622,15 @@ class _advertisements extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->blankTemplate( $preview ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adsense Help
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function adsense()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('google_adsense_header');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('promotion')->adsenseHelp();
|
||||
}
|
||||
}
|
||||
@@ -100,8 +100,15 @@ class _seo extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( ( !isset( \IPS\Request::i()->htaccess_mod_rewrite ) and \IPS\Settings::i()->htaccess_mod_rewrite ) or \IPS\Request::i()->htaccess_mod_rewrite or \IPS\Request::i()->htaccess_mod_rewrite_checkbox )
|
||||
{
|
||||
$response = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . 'login' )->request( 5, '1.1', FALSE )->get();
|
||||
if ( !in_array( mb_substr( $response->httpResponseCode, 0, 1 ), array( '2', '3' ) ) and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . 'login' )->request( 5, '1.1', FALSE )->get();
|
||||
if ( !in_array( mb_substr( $response->httpResponseCode, 0, 1 ), array( '2', '3' ) ) and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['htaccess_mod_rewrite_warning'] = \IPS\Member::loggedIn()->language()->get( $isApache ? 'htaccess_mod_rewrite_err' : 'htaccess_mod_rewrite_err_na' );
|
||||
}
|
||||
}
|
||||
catch( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['htaccess_mod_rewrite_warning'] = \IPS\Member::loggedIn()->language()->get( $isApache ? 'htaccess_mod_rewrite_err' : 'htaccess_mod_rewrite_err_na' );
|
||||
}
|
||||
@@ -477,7 +484,7 @@ Options -MultiViews
|
||||
RewriteEngine On
|
||||
RewriteBase {$dir}
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule \\.(js|css|jpeg|jpg|gif|png|ico)(\\?|$) - [L,NC,R=404]
|
||||
RewriteRule \\.(js|css|jpeg|jpg|gif|png|ico)(\\?|$) {$dir}404error.php [L,NC]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
@@ -167,7 +167,6 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$options = array(
|
||||
'None' => 'datastore_method_None',
|
||||
'Apc' => 'datastore_method_Apc',
|
||||
'Eaccelerator' => 'datastore_method_Eaccelerator',
|
||||
'Memcache' => 'datastore_method_Memcache',
|
||||
'Redis' => 'datastore_method_Redis',
|
||||
'Wincache' => 'datastore_method_Wincache',
|
||||
@@ -329,6 +328,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}, NULL, NULL, 'task_use_cron' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_cache_ttl', ( isset( \IPS\Settings::i()->widget_cache_ttl ) ) ? \IPS\Settings::i()->widget_cache_ttl : 60, FALSE, array( 'min' => 60 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), \IPS\Member::loggedIn()->language()->addToStack('seconds') ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_polling_enabled', \IPS\Settings::i()->auto_polling_enabled, FALSE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -630,6 +630,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$definition = \IPS\Http\Url::furlDefinition();
|
||||
$table = new \IPS\Helpers\Table\Custom( $definition, \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=furl' ) );
|
||||
$table->include = array( 'friendly', 'real' );
|
||||
$table->limit = 100;
|
||||
$table->langPrefix = 'furl_';
|
||||
$table->mainColumn = 'real';
|
||||
$table->parsers = array(
|
||||
@@ -735,12 +736,13 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$furl = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
|
||||
|
||||
$save = array(
|
||||
'friendly' => $values['furl_friendly'],
|
||||
'real' => $values['furl_real'],
|
||||
'custom' => true
|
||||
);
|
||||
$currentDefinition = \IPS\Http\Url::furlDefinition();
|
||||
$save = \IPS\Request::i()->key ? $currentDefinition[ \IPS\Request::i()->key ] : array();
|
||||
|
||||
$save['friendly'] = $values['furl_friendly'];
|
||||
$save['real'] = $values['furl_real'];
|
||||
$save['custom'] = true;
|
||||
|
||||
if ( \IPS\Request::i()->key )
|
||||
{
|
||||
$furl[ \IPS\Request::i()->key ] = $save;
|
||||
|
||||
@@ -56,10 +56,12 @@ class _email extends \IPS\Dispatcher\Controller
|
||||
'options' => array( 'mail' => 'mail_method_php', 'smtp' => 'mail_method_smtp' ),
|
||||
'toggles' => array(
|
||||
'mail' => array( 'php_mail_extra' ),
|
||||
'smtp' => array( 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_helo' )
|
||||
'smtp' => array( 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_helo', 'smtp_protocol' )
|
||||
)
|
||||
) ) );
|
||||
$options = array( 'plain' => 'smtp_plaintext', 'ssl' => 'smtp_ssl', 'tls' => 'smtp_tls' );
|
||||
$settingsForm->add( new \IPS\Helpers\Form\Text( 'smtp_host', \IPS\Settings::i()->smtp_host, FALSE, array(), NULL, NULL, NULL, 'smtp_host' ) );
|
||||
$settingsForm->add( new \IPS\Helpers\Form\Select( 'smtp_protocol', \IPS\Settings::i()->smtp_protocol, FALSE, array( 'options' => $options ), NULL, NULL, NULL, 'smtp_protocol' ) );
|
||||
$settingsForm->add( new \IPS\Helpers\Form\Number( 'smtp_port', \IPS\Settings::i()->smtp_port, FALSE, array(), NULL, NULL, NULL, 'smtp_port' ) );
|
||||
$settingsForm->add( new \IPS\Helpers\Form\Text( 'smtp_user', \IPS\Settings::i()->smtp_user, FALSE, array(), NULL, NULL, NULL, 'smtp_user' ) );
|
||||
$settingsForm->add( new \IPS\Helpers\Form\Password( 'smtp_pass', \IPS\Settings::i()->smtp_pass, FALSE, array(), NULL, NULL, NULL, 'smtp_pass' ) );
|
||||
@@ -68,7 +70,7 @@ class _email extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$sendTestEmail = FALSE;
|
||||
|
||||
foreach( array( 'mail_method', 'smtp_host', 'smtp_port', 'smtp_pass', 'smtp_user', 'php_mail_extra' ) as $setting )
|
||||
foreach( array( 'mail_method', 'smtp_host', 'smtp_port', 'smtp_pass', 'smtp_user', 'php_mail_extra', 'smtp_protocol' ) as $setting )
|
||||
{
|
||||
if( $values[ $setting ] != \IPS\Settings::i()->$setting )
|
||||
{
|
||||
|
||||
@@ -49,19 +49,12 @@ class _general extends \IPS\Dispatcher\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'site_offline_message', \IPS\Settings::i()->site_offline_message, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'onlineoffline', 'attachIds' => array( NULL, NULL, 'site_offline_message' ) ), NULL, NULL, NULL, 'site_offline_message_id' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'site_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address ), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'copyright_line', NULL, FALSE, array( 'app' => 'core', 'key' => 'copyright_line_value', 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack('copyright_line_placeholder') ) ) );
|
||||
|
||||
$form->addHeader( 'home_link' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'show_home_link', \IPS\Settings::i()->show_home_link, FALSE, array(
|
||||
'togglesOn' => array( 'home_name', 'home_url' ),
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'home_name', NULL, FALSE, array( 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack('home_name_placeholder'), 'app' => 'core', 'key' => 'home_name_value' ), NULL, NULL, NULL, 'home_name' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'home_url', \IPS\Settings::i()->home_url, FALSE, array( 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack('home_url_placeholder') ), NULL, NULL, NULL, 'home_url' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'upgrade_email', explode( ',', \IPS\Settings::i()->upgrade_email ), FALSE, array( 'stackFieldType' => 'Email' ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'core', "copyright_line_value", $values['copyright_line'] );
|
||||
\IPS\Lang::saveCustom( 'core', "home_name_value", $values['home_name'] );
|
||||
unset( $values['copyright_line'], $values['home_name'] );
|
||||
unset( $values['copyright_line'] );
|
||||
|
||||
$form->saveAsSettings();
|
||||
|
||||
|
||||
@@ -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\modules\admin\settings;
|
||||
@@ -96,29 +95,9 @@ class _licensekey extends \IPS\Dispatcher\Controller
|
||||
protected function settings()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addHeader('ipb_license_edit_main');
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', \IPS\Settings::i()->ipb_reg_number, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_active', \IPS\Settings::i()->ipb_license_active ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_expires', \IPS\Settings::i()->ipb_license_expires ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_cloud', \IPS\Settings::i()->ipb_license_cloud ) );
|
||||
|
||||
$form->addHeader('ipb_license_urls');
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_url', \IPS\Settings::i()->ipb_license_url ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_test_url', \IPS\Settings::i()->ipb_license_test_url ) );
|
||||
|
||||
$form->addHeader('ipb_license_components');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_forums', \IPS\Settings::i()->ipb_license_product_forums ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_calendar', \IPS\Settings::i()->ipb_license_product_calendar ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_blog', \IPS\Settings::i()->ipb_license_product_blog ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_gallery', \IPS\Settings::i()->ipb_license_product_gallery ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_downloads', \IPS\Settings::i()->ipb_license_product_downloads ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_cms', \IPS\Settings::i()->ipb_license_product_cms ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_nexus', \IPS\Settings::i()->ipb_license_product_nexus ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_copyright', \IPS\Settings::i()->ipb_license_product_copyright ) );
|
||||
|
||||
$form->addHeader('ipb_license_services');
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_chat_limit', \IPS\Settings::i()->ipb_license_chat_limit ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_support', \IPS\Settings::i()->ipb_license_support ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
\IPS\IPS::checkLicenseKey( $val, \IPS\Settings::i()->base_url );
|
||||
} ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -141,6 +120,4 @@ class _licensekey extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license_settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'menu__core_settings_licensekey', $form );
|
||||
}
|
||||
}
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class _posting extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$this->tabs['urlFilters'] = 'url_settings';
|
||||
}
|
||||
|
||||
|
||||
/* Choose active tab */
|
||||
if ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $this->tabs ) )
|
||||
{
|
||||
@@ -112,12 +112,14 @@ class _posting extends \IPS\Dispatcher\Controller
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'attach_allowed_extensions', \IPS\Settings::i()->attach_allowed_extensions ? explode( ',', \IPS\Settings::i()->attach_allowed_extensions ) : NULL, FALSE, array( 'nullLang' => 'no_restriction', 'autocomplete' => array( 'freeChoice' => TRUE, 'source' => array( 'doc', 'docx', 'log', 'msg', 'odt', 'pages', 'rtf', 'tex', 'txt', 'wpd', 'wps', 'csv', 'dat', 'gbr', 'ged', 'key', 'keychain', 'pps', 'ppt', 'pptx', 'sdf', 'tar', 'tax2012', 'tax2014', 'vcf', 'xml', 'aif', 'iff', 'm3u', 'm4a', 'mid', 'mp3', 'mpa', 'ra', 'wav', 'wma', '3g2', '3gp', 'asf', 'asx', 'avi', 'flv', 'm4v', 'mov', 'mp4', 'mpg', 'rm', 'srt', 'swf', 'vob', 'wmv', '3dm', '3ds', 'max', 'obj', 'bmp', 'dds', 'gif', 'jpg', 'png', 'psd', 'pspimage', 'tga', 'thm', 'tif', 'tiff', 'yuv', 'ai', 'eps', 'ps', 'svg', 'indd', 'pct', 'pdf', 'xlr', 'xls', 'xlsx', 'accdb', 'db', 'dbf', 'mdb', 'pdb', 'sql', 'apk', 'app', 'bat', 'cgi', 'com', 'exe', 'gadget', 'jar', 'pif', 'vb', 'wsf', 'dem', 'gam', 'nes', 'rom', 'sav', 'dwg', 'dxf', 'gpx', 'kml', 'kmz', 'asp', 'aspx', 'cer', 'cfm', 'csr', 'css', 'htm', 'html', 'js', 'jsp', 'php', 'rss', 'xhtml', 'crx', 'plugin', 'fnt', 'fon', 'otf', 'ttf', 'cab', 'cpl', 'cur', 'deskthemepack', 'dll', 'dmp', 'drv', 'icns', 'ico', 'lnk', 'sys', 'cfg', 'ini', 'prf', 'hqx', 'mim', 'uue', '7z', 'cbr', 'deb', 'gz', 'pkg', 'rar', 'rpm', 'sitx', 'tar.gz', 'zip', 'zipx', 'bin', 'cue', 'dmg', 'iso', 'mdf', 'toast', 'vcd', 'c', 'class', 'cpp', 'cs', 'dtd', 'fla', 'h', 'java', 'lua', 'm', 'pl', 'py', 'sh', 'sln', 'swift', 'vcxproj', 'xcodeproj', 'bak', 'tmp', 'crdownload', 'ics', 'msi', 'part', 'torrent' ) ) ), NULL, NULL, NULL, 'attach_allowed_extensions' ) );
|
||||
$form->addHeader('posting_images');
|
||||
$form->add( new \IPS\Helpers\Form\WidthHeight( 'attachment_resample_size', \IPS\Settings::i()->attachment_resample_size ? explode( 'x', \IPS\Settings::i()->attachment_resample_size ) : array( 0, 0 ), FALSE, array( 'resizableDiv' => FALSE, 'unlimited' => array( 0, 0 ) ), NULL, NULL, NULL, 'attachment_resample_size' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_remote_images', \IPS\Settings::i()->allow_remote_images, FALSE, array( 'togglesOn' => array( 'remote_image_proxy' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'remote_image_proxy', \IPS\Settings::i()->remote_image_proxy, FALSE, array(), NULL, NULL, NULL, 'remote_image_proxy' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\WidthHeight( 'attachment_resample_size', \IPS\Settings::i()->attachment_resample_size ? explode( 'x', \IPS\Settings::i()->attachment_resample_size ) : array( 0, 0 ), FALSE, array( 'resizableDiv' => FALSE, 'unlimited' => array( 0, 0 ) ), NULL, NULL, NULL, 'attachment_resample_size' ) );
|
||||
$current = ( isset( \IPS\Settings::i()->attachment_image_size ) ) ? explode( 'x', \IPS\Settings::i()->attachment_image_size ) : array( 1000, 750 );
|
||||
$form->add( new \IPS\Helpers\Form\WidthHeight( 'attachment_image_size', $current, FALSE, array( 'resizableDiv' => FALSE ), NULL, NULL, NULL, 'attachment_image_size' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'max_video_width', \IPS\Settings::i()->max_video_width, FALSE, array( 'unlimited' => 0 ), NULL, NULL, 'px' ) );
|
||||
$form->addHeader('posting_content');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'strip_quotes', !\IPS\Settings::i()->strip_quotes, FALSE, array(), NULL, NULL, NULL, 'strip_quotes' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'max_title_length', \IPS\Settings::i()->max_title_length, FALSE, array( 'max' => 255 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('max_title_length_suffix') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'merge_concurrent_posts', \IPS\Settings::i()->merge_concurrent_posts, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('minutes') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'flood_control', \IPS\Settings::i()->flood_control, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'none' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('seconds') ) );
|
||||
@@ -169,7 +171,6 @@ class _posting extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$clearCss = ( $values['max_video_width'] !== \IPS\Settings::i()->max_video_width );
|
||||
|
||||
$values['strip_quotes'] = $values['strip_quotes'] ? FALSE : TRUE;
|
||||
$values['attachment_resample_size'] = implode( 'x', $values['attachment_resample_size'] );
|
||||
$values['attachment_image_size'] = implode( 'x', $values['attachment_image_size'] );
|
||||
$values['attach_allowed_extensions'] = is_array( $values['attach_allowed_extensions'] ) ? implode( ',', array_unique( array_map( function( $val )
|
||||
@@ -328,33 +329,13 @@ class _posting extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$values['ipb_url_whitelist'] = implode( ",", $values['ipb_url_whitelist'] );
|
||||
$values['ipb_url_blacklist'] = implode( ",", $values['ipb_url_blacklist'] );
|
||||
|
||||
/* We need to clean these up */
|
||||
$nofollowExclude = array();
|
||||
|
||||
foreach( $values['posts_add_nofollow_exclude'] as $domain )
|
||||
{
|
||||
/* We only want to compare against the domain, not the full URL */
|
||||
$domain = str_replace( array( 'http://', 'https://' ), '', $domain );
|
||||
|
||||
/* And we are comparing against the non-www. version during parsing */
|
||||
$domain = preg_replace( '/^www\./', '', $domain );
|
||||
|
||||
/* Use the domain as the key as well to prevent duplicates for efficiency purposes */
|
||||
$nofollowExclude[ $domain ] = $domain;
|
||||
}
|
||||
|
||||
$values['posts_add_nofollow_exclude'] = json_encode( array_values( $nofollowExclude ) );
|
||||
|
||||
$values['posts_add_nofollow_exclude'] = json_encode( $values['posts_add_nofollow_exclude'] );
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__url_filter_settings' );
|
||||
|
||||
/* Redirect otherwise our changes to posts_add_nofollow_exclude won't reflect initially */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=urlFilters' ), 'saved' );
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
||||
@@ -1,242 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Search settings
|
||||
* @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 14 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\settings;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search settings
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'search_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
* @return void
|
||||
* @note There is a hardcoded check for Sphinx here
|
||||
* @todo The lang string replacements need to be checked <- checked for what?
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Rebuild button */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'rebuildIndex' => array(
|
||||
'title' => 'search_rebuild_index',
|
||||
'icon' => 'undo',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=search&do=queueIndexRebuild' ),
|
||||
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->get('search_rebuild_index_confirm') ),
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['search_engine__sphinx_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get('search_engine__sphinx_desc'), \IPS\Settings::i()->sphinx_base_path . '/sphinx.conf' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'search_engine', isset( \IPS\Request::i()->search_sphinx_server ) ? 'sphinx' : \IPS\Settings::i()->search_engine, TRUE, array( 'options' => $this->_getEngines(), 'toggles' => array( 'mysql' => array( 'search_index_timeframe' ), 'sphinx' => array( 'form_header_sphinx_header', 'form_header_sphinx_instructions', 'search_sphinx_server', 'search_sphinx_port', 'sphinx_base_path', 'sphinx_prefix' ) ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_index_timeframe', \IPS\Settings::i()->search_index_timeframe, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'all' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('search_index_timeframe_prefix'), \IPS\Member::loggedIn()->language()->addToStack('search_index_timeframe_suffix'), 'search_index_timeframe' ) );
|
||||
|
||||
$form->addHeader( 'sphinx_header' );
|
||||
if ( \IPS\Settings::i()->search_engine == 'sphinx' )
|
||||
{
|
||||
$form->addMessage( 'sphinx_instructions', '', TRUE, 'form_header_sphinx_instructions' );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'search_sphinx_server', \IPS\Settings::i()->search_sphinx_server, FALSE, array(), function( $val )
|
||||
{
|
||||
if ( $val === 'localhost' )
|
||||
{
|
||||
throw new \DomainException('search_sphinx_server_err');
|
||||
}
|
||||
}, NULL, NULL, 'search_sphinx_server' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_sphinx_port', \IPS\Settings::i()->search_sphinx_port, FALSE, array( 'placeholder' => "3312" ), NULL, NULL, NULL, 'search_sphinx_port' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sphinx_base_path', \IPS\Settings::i()->sphinx_base_path, FALSE, array( 'placeholder' => "/var/sphinx" ), NULL, NULL, NULL, 'sphinx_base_path' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sphinx_prefix', \IPS\Settings::i()->sphinx_prefix, FALSE, array(), NULL, NULL, NULL, 'sphinx_prefix' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$existing = \IPS\Settings::i()->search_engine;
|
||||
$indexPrune = \IPS\Settings::i()->search_index_timeframe;
|
||||
|
||||
/* Did we just enable Sphinx? If so, we need some more instructions... */
|
||||
if( $existing != $values['search_engine'] and $values['search_engine'] === 'sphinx' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=search&do=sphinxInstructions' )->setQueryString( $values ) );
|
||||
}
|
||||
|
||||
/* Otherwise go ahead and save... */
|
||||
$form->saveAsSettings();
|
||||
\IPS\Session::i()->log( 'acplogs__search_settings' );
|
||||
|
||||
/* And re-index if setting updated */
|
||||
if( $existing != $values['search_engine'] or $indexPrune != $values['search_index_timeframe'] )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_search');
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'menu__core_settings_search', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Sphinx instructions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sphinxInstructions()
|
||||
{
|
||||
$configuration = array();
|
||||
foreach ( array( 'search_sphinx_server', 'search_sphinx_port', 'sphinx_prefix', 'sphinx_base_path' ) as $k )
|
||||
{
|
||||
$configuration[ $k ] = isset( \IPS\Request::i()->$k ) ? \IPS\Request::i()->$k : '';
|
||||
}
|
||||
|
||||
$error = NULL;
|
||||
if ( isset( \IPS\Request::i()->check ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$database = \IPS\Db::i( 'SPHINXQL', array(
|
||||
'sql_host' => \IPS\Request::i()->search_sphinx_server,
|
||||
'sql_user' => NULL,
|
||||
'sql_pass' => NULL,
|
||||
'sql_database' => NULL,
|
||||
'sql_port' => (int) \IPS\Request::i()->search_sphinx_port,
|
||||
'sql_socket' => NULL,
|
||||
'sql_utf8mb4' => NULL,
|
||||
) );
|
||||
|
||||
$result = $database->query("SHOW STATUS");
|
||||
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 'sphinx' ), array( 'conf_key=?', 'search_engine' ) );
|
||||
foreach ( $configuration as $k => $v )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $v ), array( 'conf_key=?', $k ) );
|
||||
\IPS\Settings::i()->$k = $v;
|
||||
}
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
\IPS\Session::i()->log( 'acplogs__search_settings' );
|
||||
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=search' ), 'sphinx_setup_successful' );
|
||||
}
|
||||
catch( \Exception $exception )
|
||||
{
|
||||
\IPS\Log::i( \LOG_INFO )->write( get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
|
||||
$error = 'sphinx_appear_invalid';
|
||||
}
|
||||
}
|
||||
|
||||
$configurationUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=search&do=sphinxConfiguration' )->setQueryString( $configuration );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('sphinx_header');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'settings' )->sphinxInstructions( $configurationUrl, $error );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Sphinx conifguration file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sphinxConfiguration()
|
||||
{
|
||||
$server = isset( \IPS\Request::i()->search_sphinx_server ) ? \IPS\Request::i()->search_sphinx_server : \IPS\Settings::i()->search_sphinx_server;
|
||||
$port = isset( \IPS\Request::i()->search_sphinx_port ) ? \IPS\Request::i()->search_sphinx_port : \IPS\Settings::i()->search_sphinx_port;
|
||||
$prefix = isset( \IPS\Request::i()->sphinx_prefix ) ? \IPS\Request::i()->sphinx_prefix : \IPS\Settings::i()->sphinx_prefix;
|
||||
$path = isset( \IPS\Request::i()->sphinx_base_path ) ? \IPS\Request::i()->sphinx_base_path : \IPS\Settings::i()->sphinx_base_path;
|
||||
$collation = 'utf8_general_ci';
|
||||
|
||||
$sphinxConfiguration = <<<SPHINX
|
||||
searchd
|
||||
{
|
||||
listen = {$server}:{$port}:mysql41
|
||||
max_children = 30
|
||||
pid_file = {$path}/buildsearchd.pid
|
||||
preopen_indexes = 0
|
||||
collation_server = {$collation}
|
||||
workers = threads
|
||||
}
|
||||
|
||||
index {$prefix}ips
|
||||
{
|
||||
type = rt
|
||||
path = {$path}/index
|
||||
|
||||
rt_field = index_title
|
||||
rt_field = index_content
|
||||
rt_field = index_tags
|
||||
rt_attr_bigint = index_object_id
|
||||
rt_attr_bigint = index_item_id
|
||||
rt_attr_bigint = index_container_id
|
||||
rt_attr_bigint = index_author
|
||||
rt_attr_bigint = index_views
|
||||
rt_attr_bigint = index_num_comments
|
||||
rt_attr_bigint = index_num_reviews
|
||||
rt_attr_json = index_permissions
|
||||
rt_attr_timestamp = index_date_created
|
||||
rt_attr_timestamp = index_date_updated
|
||||
rt_attr_string = index_class
|
||||
rt_attr_uint = index_class_id
|
||||
rt_attr_uint = index_hidden
|
||||
}
|
||||
SPHINX;
|
||||
|
||||
\IPS\Output::i()->sendOutput( $sphinxConfiguration, 200, 'application/octet-stream', array( 'Content-Disposition' => 'attachment; filename=sphinx.conf' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of engine options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getEngines()
|
||||
{
|
||||
$engines = array();
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . "/system/Content/Search/" ) as $file )
|
||||
{
|
||||
if ( $file->isDir() and !$file->isDot() and $file != 'index.html' )
|
||||
{
|
||||
$name = mb_strtolower( $file );
|
||||
$engines[ $name ] = 'search_engine__' . $name;
|
||||
}
|
||||
}
|
||||
return $engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue an index rebuild
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function queueIndexRebuild()
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__queued_search_index' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=search' ), 'search_index_rebuilding' );
|
||||
}
|
||||
}
|
||||
@@ -78,21 +78,76 @@ class _terms extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* What were our previous values? */
|
||||
$existingPrivacyPolicy = iterator_to_array( \IPS\Db::i()->select( 'word_custom', 'core_sys_lang_words', array( 'word_key=?', 'privacy_text_value' ) ) );
|
||||
$existingRegistrationTerms = iterator_to_array( \IPS\Db::i()->select( 'word_custom', 'core_sys_lang_words', array( 'word_key=?', 'reg_rules_value' ) ) );
|
||||
|
||||
/* Save */
|
||||
foreach ( array( 'gl_guidelines' => 'guidelines_value', 'privacy_text' => 'privacy_text_value', 'reg_rules' => 'reg_rules_value' ) as $k => $v )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'core', $v, $values[ $k ] );
|
||||
unset( $values[ $k ] );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
|
||||
/* Log */
|
||||
\IPS\Session::i()->log( 'acplogs__terms_edited' );
|
||||
|
||||
/* Do we need to ask the admin if they want to ask members to reconfirm? */
|
||||
$changedPrivacyPolicy = $existingPrivacyPolicy != iterator_to_array( \IPS\Db::i()->select( 'word_custom', 'core_sys_lang_words', array( 'word_key=?', 'privacy_text_value' ) ) );
|
||||
$changedRegistrationTerms = $existingRegistrationTerms != iterator_to_array( \IPS\Db::i()->select( 'word_custom', 'core_sys_lang_words', array( 'word_key=?', 'reg_rules_value' ) ) );
|
||||
if ( $changedPrivacyPolicy or $changedRegistrationTerms )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=settings&controller=terms&do=reconfirm')->setQueryString( array(
|
||||
'privacy' => intval( $changedPrivacyPolicy ),
|
||||
'reg' => intval( $changedRegistrationTerms )
|
||||
) ) );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_terms');
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'menu__core_settings_terms', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the admin if they want users to re-confirm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reconfirm()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
$form->addMessage( 'admin_reconfirm_blurb' );
|
||||
|
||||
if ( \IPS\Request::i()->reg )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'admin_reconfirm_reg_terms', FALSE ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->privacy )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'admin_reconfirm_privacy', FALSE ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( isset( $values['admin_reconfirm_reg_terms'] ) and $values['admin_reconfirm_reg_terms'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_members', "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_terms'] );
|
||||
}
|
||||
if ( isset( $values['admin_reconfirm_privacy'] ) and $values['admin_reconfirm_privacy'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_members', "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_privacy'] );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=settings&controller=terms') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_terms');
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -457,11 +457,6 @@ class _admin extends \IPS\Dispatcher\Controller
|
||||
'ctime' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'module' => function( $val, $key )
|
||||
{
|
||||
$key = "module__{$key['appcomponent']}_{$val}";
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $key );
|
||||
}
|
||||
);
|
||||
$table->sortBy = $table->sortBy ?: 'ctime';
|
||||
@@ -472,7 +467,6 @@ class _admin extends \IPS\Dispatcher\Controller
|
||||
'member_id' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'ctime' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'module' => array( \IPS\Helpers\Table\SEARCH_NODE, array( 'class' => 'IPS\Application', 'subnodeWhere' => array( 'sys_module_area=?', 'admin' ), 'searchProp' => 'key' ) ),
|
||||
'note' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
);
|
||||
$table->quickSearch = 'note';
|
||||
|
||||
@@ -279,6 +279,9 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to remember which keys are 'nodes' so we can adjust values upon submit */
|
||||
$nodeFields = array();
|
||||
|
||||
/* Build */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
@@ -304,6 +307,12 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
/* Class */
|
||||
$type = is_array( $data ) ? $data[0] : $data;
|
||||
$class = '\IPS\Helpers\Form\\' . ( $type );
|
||||
|
||||
/* Remember 'nodes' */
|
||||
if( $type == 'Node' )
|
||||
{
|
||||
$nodeFields[ $name ] = $name;
|
||||
}
|
||||
|
||||
/* Current Value */
|
||||
if ( $currentPermissions === '*' )
|
||||
@@ -326,6 +335,12 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
$currentValue = ( isset( $currentPermissions[ $name ] ) ? $currentPermissions[ $name ] : NULL );
|
||||
|
||||
/* We translate nodes to -1 so the moderator permissions merging works as expected allowing "all" to override individual node selections */
|
||||
if( $type == 'Node' AND $currentValue == -1 )
|
||||
{
|
||||
$currentValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Options */
|
||||
@@ -360,6 +375,16 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
/* For node fields, if the value is 0 translate it to -1 so mod permissions can merge properly */
|
||||
if( in_array( $k, $nodeFields ) )
|
||||
{
|
||||
if( $v == 0 )
|
||||
{
|
||||
$v = -1;
|
||||
$values[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $v ) )
|
||||
{
|
||||
foreach ( $v as $l => $w )
|
||||
@@ -422,6 +447,7 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = $_name;
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'members' )->moderatorPermissions( $_name, $form );
|
||||
}
|
||||
|
||||
@@ -541,11 +567,6 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
'ctime' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'module' => function( $val, $key )
|
||||
{
|
||||
$key = "module__{$key['appcomponent']}_{$val}";
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $key );
|
||||
}
|
||||
);
|
||||
$table->sortBy = $table->sortBy ?: 'ctime';
|
||||
@@ -556,7 +577,6 @@ class _moderators extends \IPS\Dispatcher\Controller
|
||||
'member_id' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'ctime' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'module' => array( \IPS\Helpers\Table\SEARCH_NODE, array( 'class' => 'IPS\Application', 'subnodeWhere' => array( 'sys_module_area=?', 'front' ), 'searchProp' => 'key' ) )
|
||||
);
|
||||
|
||||
/* Add a button for settings */
|
||||
|
||||
@@ -66,6 +66,7 @@ class _sql extends \IPS\Dispatcher\Controller
|
||||
$table->sortBy = $table->sortBy ?: 'name';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->quickSearch = 'name';
|
||||
$table->limit = 200;
|
||||
|
||||
/* Buttons */
|
||||
$table->rowButtons = function( $row )
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* @package IPS Social Suite
|
||||
* @since 21 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @modified 13.09.2015 by IAF
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\support;
|
||||
@@ -159,12 +158,7 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
$baseUrl = $baseUrl->setQueryString( 'next', $overrideThingToTry );
|
||||
}
|
||||
|
||||
$possibleSolutions = array( '_requirementsChecker', '_databaseChecker', '_clearCaches', '_connectionChecker', '_md5sumChecker', '_upgradeCheck', '_defaultTheme' );
|
||||
if ( !\IPS\NO_WRITES )
|
||||
{
|
||||
$possibleSolutions[] = '_disableThirdParty';
|
||||
}
|
||||
$possibleSolutions[] = '_knowledgebase';
|
||||
$possibleSolutions = array( '_requirementsChecker', '_databaseChecker', '_clearCaches', '_connectionChecker', '_md5sumChecker', '_upgradeCheck', '_disableAdvertisements', '_disableThirdParty', '_knowledgebase' );
|
||||
$self = $this;
|
||||
|
||||
return new \IPS\Helpers\MultipleRedirect(
|
||||
@@ -298,42 +292,17 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _md5sumChecker( $id )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: md5sum Checker Iterator
|
||||
*
|
||||
* @param string $directory Directory to look through
|
||||
* @return array
|
||||
*/
|
||||
public function _md5sumCheckerIterator( $directory, $correctMd5s )
|
||||
{
|
||||
$return = array();
|
||||
foreach( new \DirectoryIterator( $directory ) as $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mb_substr( $file, 0, 1 ) === '.' or mb_substr( $file, 0, 1 ) === '_' or $file == 'index.html' )
|
||||
$files = \IPS\Application::md5Check();
|
||||
if ( count( $files ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $file->isDir() )
|
||||
{
|
||||
$return = array_merge( $return, $this->_md5sumCheckerIterator( $file->getPathname(), $correctMd5s ) );
|
||||
}
|
||||
elseif ( mb_substr( $file, -4 ) === '.php' )
|
||||
{
|
||||
$fullPath = $file->getPathname();
|
||||
$shortPath = mb_substr( $fullPath, mb_strlen( \IPS\ROOT_PATH ) );
|
||||
|
||||
if ( $shortPath != '/init.php' and isset( $correctMd5s[ $shortPath ] ) and md5( preg_replace( '#\s#', '', file_get_contents( $fullPath ) ) ) != $correctMd5s[ $shortPath ] ) // We strip whitespace since FTP in ASCII mode will change the whitespace characters
|
||||
{
|
||||
$return[] = $fullPath;
|
||||
}
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->md5sum( $files, $id );
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
catch ( \Exception $e ) {}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,47 +369,49 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Instruct user to try using default theme
|
||||
* Step 2: Self Service - Disable advertisements
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _defaultTheme( $id )
|
||||
public function _disableAdvertisements( $id )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->deleteTheme ) )
|
||||
if ( isset( \IPS\Request::i()->enableAds ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Theme::load( \IPS\Request::i()->deleteTheme )->delete();
|
||||
foreach ( explode( ',', \IPS\Request::i()->enableAds ) as $ad )
|
||||
{
|
||||
try
|
||||
{
|
||||
$ad = \IPS\core\Advertisement::load( $ad );
|
||||
$ad->active = 1;
|
||||
$ad->save();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_templates', 'template_set_id>0' )->first() or \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_css', 'css_set_id>0' )->first() )
|
||||
{
|
||||
$newTheme = new \IPS\Theme;
|
||||
$newTheme->permissions = \IPS\Member::loggedIn()->member_group_id;
|
||||
$newTheme->save();
|
||||
$newTheme->installThemeSettings();
|
||||
$newTheme->copyResourcesFromSet();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_theme_set_title_" . $newTheme->id, "IPS Support" );
|
||||
|
||||
\IPS\Member::loggedIn()->skin = $newTheme->id;
|
||||
|
||||
if( \IPS\Member::loggedIn()->acp_skin !== NULL )
|
||||
{
|
||||
\IPS\Member::loggedIn()->acp_skin = $newTheme->id;
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( $id, 'try_default_theme', '&deleteTheme=' . $newTheme->id );
|
||||
}
|
||||
$disabledAds = array();
|
||||
|
||||
return NULL;
|
||||
/* Loop ads */
|
||||
foreach( \IPS\Db::i()->select( '*' ,'core_advertisements', array( 'ad_active=?', 1 ) ) as $ad )
|
||||
{
|
||||
$ad = \IPS\core\Advertisement::constructFromData( $ad );
|
||||
|
||||
$ad->active = 0;
|
||||
$disabledAds[] = $ad->id;
|
||||
}
|
||||
|
||||
/* Do any? */
|
||||
if ( count( $disabledAds ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->disabledAdvertisements( $id, '&enableAds=' . implode( ',', $disabledAds ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -451,8 +422,28 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function _disableThirdParty( $id )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->enableApps ) or isset( \IPS\Request::i()->enablePlugins ) )
|
||||
/* Button to put stuff back */
|
||||
if ( isset( \IPS\Request::i()->deleteTheme ) or isset( \IPS\Request::i()->enableApps ) or isset( \IPS\Request::i()->enablePlugins ) )
|
||||
{
|
||||
/* Theme */
|
||||
if ( isset( \IPS\Request::i()->deleteTheme ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Theme::load( \IPS\Request::i()->deleteTheme )->delete();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
if( isset( $_SESSION['old_acp_theme'] ) )
|
||||
{
|
||||
\IPS\Member::loggedIn()->acp_skin = $_SESSION['old_acp_theme'];
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
unset( $_SESSION['old_acp_theme'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Apps */
|
||||
foreach ( explode( ',', \IPS\Request::i()->enableApps ) as $app )
|
||||
{
|
||||
try
|
||||
@@ -464,6 +455,7 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
/* Plugins */
|
||||
foreach ( explode( ',', \IPS\Request::i()->enablePlugins ) as $plugin )
|
||||
{
|
||||
try
|
||||
@@ -478,41 +470,71 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$restoredDefaultTheme = FALSE;
|
||||
$disabledApps = array();
|
||||
$disabledPlugins = array();
|
||||
$disabledAppNames = array();
|
||||
$disabledPluginNames = array();
|
||||
|
||||
/* Loop Apps */
|
||||
foreach ( \IPS\Application::applications() as $app )
|
||||
/* Do we need to restore the default theme? */
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_templates', 'template_set_id>0' )->first() or \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_css', 'css_set_id>0' )->first() )
|
||||
{
|
||||
if ( $app->enabled and !in_array( $app->directory, \IPS\Application::$ipsApps ) )
|
||||
$newTheme = new \IPS\Theme;
|
||||
$newTheme->permissions = \IPS\Member::loggedIn()->member_group_id;
|
||||
$newTheme->save();
|
||||
$newTheme->installThemeSettings();
|
||||
$newTheme->copyResourcesFromSet();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_theme_set_title_" . $newTheme->id, "IPS Support" );
|
||||
|
||||
\IPS\Member::loggedIn()->skin = $newTheme->id;
|
||||
|
||||
if( \IPS\Member::loggedIn()->acp_skin !== NULL )
|
||||
{
|
||||
$app->enabled = FALSE;
|
||||
$app->save();
|
||||
|
||||
$disabledApps[] = $app->directory;
|
||||
$disabledAppNames[] = $app->_title;
|
||||
$_SESSION['old_acp_theme'] = \IPS\Member::loggedIn()->acp_skin;
|
||||
\IPS\Member::loggedIn()->acp_skin = $newTheme->id;
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
$restoredDefaultTheme = TRUE;
|
||||
}
|
||||
|
||||
/* Do we need to disable any third party apps/plugins? */
|
||||
if ( !\IPS\NO_WRITES )
|
||||
{
|
||||
/* Loop Apps */
|
||||
foreach ( \IPS\Application::applications() as $app )
|
||||
{
|
||||
if ( $app->enabled and !in_array( $app->directory, \IPS\Application::$ipsApps ) )
|
||||
{
|
||||
$app->enabled = FALSE;
|
||||
$app->save();
|
||||
|
||||
$disabledApps[] = $app->directory;
|
||||
$disabledAppNames[] = $app->_title;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look Plugins */
|
||||
foreach ( \IPS\Plugin::plugins() as $plugin )
|
||||
{
|
||||
if ( $plugin->enabled )
|
||||
{
|
||||
$plugin->enabled = FALSE;
|
||||
$plugin->save();
|
||||
|
||||
$disabledPlugins[] = $plugin->id;
|
||||
$disabledPluginNames[] = $plugin->_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Look Plugins */
|
||||
foreach ( \IPS\Plugin::plugins() as $plugin )
|
||||
/* Did we do anything? */
|
||||
if ( $restoredDefaultTheme or count( $disabledApps ) or count( $disabledPlugins ) )
|
||||
{
|
||||
if ( $plugin->enabled )
|
||||
{
|
||||
$plugin->enabled = FALSE;
|
||||
$plugin->save();
|
||||
|
||||
$disabledPlugins[] = $plugin->id;
|
||||
$disabledPluginNames[] = $plugin->_title;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do any? */
|
||||
if ( count( $disabledApps ) or count( $disabledPlugins ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->thirdParty( $id, $disabledAppNames, $disabledPluginNames, '&enableApps=' . implode( ',', $disabledApps ) . '&enablePlugins=' . implode( ',', $disabledPlugins ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->thirdParty( $id, $disabledAppNames, $disabledPluginNames, $restoredDefaultTheme, '&enableApps=' . implode( ',', $disabledApps ) . '&enablePlugins=' . implode( ',', $disabledPlugins ) . ( $restoredDefaultTheme ? '&deleteTheme=' . $newTheme->id : '' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -550,7 +572,123 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function _contactSupport( $data )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( '__iaf__nulling_null_alert', 'error' );
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
if ( !$licenseData or strtotime( $licenseData['expires'] ) < time() )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_no_license', 'warning' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$supportedVerions = \IPS\Http\Url::ips('support/versions')->request()->get()->decodeJson();
|
||||
|
||||
if ( \IPS\Application::load('core')->long_version > $supportedVerions['max'] )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_unsupported_prerelease', 'warning' );
|
||||
}
|
||||
if ( \IPS\Application::load('core')->long_version < $supportedVerions['min'] )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_unsupported_obsolete', 'warning' );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'contact_support', 'contact_support_submit' );
|
||||
$form->class = 'ipsForm_vertical ipsPad';
|
||||
|
||||
$extraOptions = array( 'admin' => 'support_request_admin' );
|
||||
if ( $this->_supportLog( TRUE ) )
|
||||
{
|
||||
$form->hiddenValues['_log'] = '1';
|
||||
$extraOptions['log'] = 'support_request_log';
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'support_request_title', NULL, TRUE, array( 'maxLength' => 128 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'support_request_body', NULL, TRUE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'acp-support-request' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'support_request_extra', array( 'admin', 'log' ), FALSE, array( 'options' => $extraOptions ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$admin = NULL;
|
||||
if ( in_array( 'admin', $values['support_request_extra'] ) )
|
||||
{
|
||||
$password = '';
|
||||
$length = rand( 8, 15 );
|
||||
for ( $i = 0; $i < $length; $i++ )
|
||||
{
|
||||
do {
|
||||
$key = rand( 33, 126 );
|
||||
} while ( in_array( $key, array( 34, 39, 60, 62, 92 ) ) );
|
||||
$password .= chr( $key );
|
||||
}
|
||||
|
||||
$supportAccount = \IPS\Member::load( 'nobody@invisionpower.com', 'email' );
|
||||
if ( !$supportAccount->member_id )
|
||||
{
|
||||
$name = 'IPS Support';
|
||||
$_supportAccount = \IPS\Member::load( $name, 'name' );
|
||||
if ( $_supportAccount->member_id )
|
||||
{
|
||||
$number = 2;
|
||||
while ( $_supportAccount->member_id )
|
||||
{
|
||||
$name = "IPS Support {$number}";
|
||||
$_supportAccount = \IPS\Member::load( $name, 'name' );
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
|
||||
$supportAccount = new \IPS\Member;
|
||||
$supportAccount->name = $name;
|
||||
$supportAccount->email = 'nobody@invisionpower.com';
|
||||
$supportAccount->member_group_id = \IPS\Settings::i()->admin_group;
|
||||
}
|
||||
|
||||
$supportAccount->members_pass_salt = $supportAccount->generateSalt();
|
||||
$supportAccount->members_pass_hash = $supportAccount->encryptedPassword( $password );
|
||||
$supportAccount->save();
|
||||
|
||||
$admin = json_encode( array( 'name' => $supportAccount->name, 'email' => $supportAccount->email, 'password' => $password, 'dir' => \IPS\CP_DIRECTORY ) );
|
||||
}
|
||||
|
||||
$log = NULL;
|
||||
if ( in_array( 'log', $values['support_request_extra'] ) )
|
||||
{
|
||||
$log = $this->_supportLog( FALSE );
|
||||
}
|
||||
|
||||
$key = md5( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
|
||||
unset( $_SESSION["wizard-{$key}-step"] );
|
||||
unset( $_SESSION["wizard-{$key}-data"] );
|
||||
|
||||
\IPS\Output::i()->parseFileObjectUrls( $values['support_request_body'] );
|
||||
|
||||
$response = \IPS\Http\Url::ips('support')->request()->login( \IPS\Settings::i()->ipb_reg_number, '' )->post( array(
|
||||
'title' => $values['support_request_title'],
|
||||
'message' => $values['support_request_body'],
|
||||
'admin' => $admin,
|
||||
'log' => $log,
|
||||
'_log' => intval( isset( $values['_log'] ) )
|
||||
) );
|
||||
|
||||
switch ( $response->httpResponseCode )
|
||||
{
|
||||
case 200:
|
||||
case 201:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'get_support_done', FALSE, array( 'pluralize' => array( intval( (string) $response ) ) ) ), 'success' );
|
||||
|
||||
case 401:
|
||||
case 403:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_no_license', 'warning' );
|
||||
|
||||
case 429:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_duplicate', 'error' );
|
||||
|
||||
case 502:
|
||||
default:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_error', 'error' );
|
||||
}
|
||||
}
|
||||
return (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -597,6 +735,4 @@ class _support extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('support')->logToSend( $this->_supportLog( FALSE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class _systemLogs extends \IPS\Dispatcher\Controller
|
||||
krsort( $dataSource );
|
||||
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Custom( array_slice( $dataSource, 0, 50 ), \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs' ) );
|
||||
$table = new \IPS\Helpers\Table\Custom( $dataSource, \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs' ) );
|
||||
$table->langPrefix = 'systemlogs_';
|
||||
$table->mainColumn = 'title';
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class _ajax extends \IPS\core\modules\front\system\ajax
|
||||
$keywords[ $word['url'] ]['keywords'][] = $word['keyword'];
|
||||
}
|
||||
|
||||
\file_put_contents( \IPS\ROOT_PATH . "/applications/{$qs['app']}/data/acpsearch.json", json_encode( $keywords ) );
|
||||
\file_put_contents( \IPS\ROOT_PATH . "/applications/{$qs['app']}/data/acpsearch.json", json_encode( $keywords, version_compare( PHP_VERSION, '5.4.0' ) >= 0 ? JSON_PRETTY_PRINT : 0 ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( 'ok' );
|
||||
|
||||
@@ -34,7 +34,7 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
$url = \IPS\Http\Url::internal( "app=core&module=system&controller=login", 'admin', NULL, array(), \IPS\Settings::i()->logins_over_https );
|
||||
if ( isset( \IPS\Request::i()->ref ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'ref', base64_encode( \IPS\Request::i()->ref ) );
|
||||
$url = $url->setQueryString( 'ref', \IPS\Request::i()->ref );
|
||||
}
|
||||
$login = new \IPS\Login( $url );
|
||||
$login->flagOptions = FALSE;
|
||||
@@ -62,14 +62,21 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
$this->log( 'ok' );
|
||||
|
||||
/* Clean out any existing session ID in the URL */
|
||||
$queryString = '';
|
||||
|
||||
$queryString = array();
|
||||
if( isset( \IPS\Request::i()->ref ) )
|
||||
{
|
||||
$queryString = preg_replace( "/adsess=([a-zA-Z0-9]+)(?:&|$)/", '', base64_decode( \IPS\Request::i()->ref ) );
|
||||
$_queryString = array();
|
||||
parse_str( preg_replace( "/adsess=([a-zA-Z0-9]+)(?:&|$)/", '', base64_decode( \IPS\Request::i()->ref ) ), $_queryString );
|
||||
foreach ( $_queryString as $k => $v )
|
||||
{
|
||||
if ( in_array( $k, array( 'app', 'module', 'controller' ) ) )
|
||||
{
|
||||
$queryString[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Boink */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( $queryString ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( http_build_query( $queryString ) ) );
|
||||
}
|
||||
/* Error */
|
||||
else
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief upgrade
|
||||
* @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 28 Jul 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\system;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* upgrade
|
||||
*/
|
||||
class _upgrade extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'upgrade_manage' );
|
||||
|
||||
if ( \IPS\NO_WRITES )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_writes', '1C287/1', 403, '' );
|
||||
}
|
||||
|
||||
$wizard = new \IPS\Helpers\Wizard( array(
|
||||
'upgrade_confirm_update' => array( $this, '_selectVersion' ),
|
||||
'upgrade_login' => array( $this, '_login' ),
|
||||
'upgrade_extract_update' => array( $this, '_extractUpdate' ),
|
||||
'upgrade_upgrade' => array( $this, '_upgrade' ),
|
||||
), \IPS\Http\Url::internal( 'app=core&module=system&controller=upgrade' ) );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('ips_suite_upgrade');
|
||||
\IPS\Output::i()->output = $wizard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select Version
|
||||
*
|
||||
* @param array $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _selectVersion( $data )
|
||||
{
|
||||
/* Check latest version */
|
||||
$versions = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_applications', \IPS\Db::i()->in( 'app_directory', \IPS\Application::$ipsApps ) ) as $app )
|
||||
{
|
||||
if ( $app['app_enabled'] )
|
||||
{
|
||||
$versions[] = $app['app_long_version'];
|
||||
}
|
||||
}
|
||||
$version = min( $versions );
|
||||
$url = \IPS\Http\Url::ips('updateCheck');
|
||||
if ( \IPS\USE_DEVELOPMENT_BUILDS )
|
||||
{
|
||||
$url = $url->setQueryString( 'development', 1 );
|
||||
}
|
||||
try
|
||||
{
|
||||
$response = $url->setQueryString( 'version', $version )->request()->get()->decodeJson();
|
||||
$coreApp = \IPS\Application::load('core');
|
||||
$coreApp->update_version = json_encode( $response );
|
||||
$coreApp->update_last_check = time();
|
||||
$coreApp->save();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form( 'select_version' );
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
$latestVersion = 0;
|
||||
foreach( \IPS\Application::load( 'core' )->availableUpgrade() as $possibleVersion )
|
||||
{
|
||||
$options[ $possibleVersion['longversion'] ] = $possibleVersion['version'];
|
||||
$descriptions[ $possibleVersion['longversion'] ] = $possibleVersion;
|
||||
if ( $latestVersion < $possibleVersion['longversion'] )
|
||||
{
|
||||
$latestVersion = $possibleVersion['longversion'];
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'version', $latestVersion, TRUE, array( 'options' => $options, '_details' => $descriptions ) ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
return array( 'version' => $values['version'] );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'system' ) ), 'upgradeSelectVersion' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Login
|
||||
*
|
||||
* @param array $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _login( $data )
|
||||
{
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form( 'login', 'continue' );
|
||||
$form->hiddenValues['version'] = $data['version'];
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'ips_email_address', NULL ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'ips_password', NULL ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$key = \IPS\IPS::licenseKey();
|
||||
|
||||
$url = \IPS\Http\Url::ips( 'build/' . $key['key'] )->setQueryString( 'ip', \IPS\Request::i()->ipAddress() );
|
||||
if ( \IPS\USE_DEVELOPMENT_BUILDS )
|
||||
{
|
||||
$url = $url->setQueryString( 'development', 1 );
|
||||
}
|
||||
elseif ( isset( $values['version'] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'versionToDownload', $values['version'] );
|
||||
}
|
||||
if ( \IPS\CP_DIRECTORY !== 'admin' )
|
||||
{
|
||||
$url = $url->setQueryString( 'cp_directory', \IPS\CP_DIRECTORY );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$response = $url->request( 30 )->login( $values['ips_email_address'], $values['ips_password'] )->get();
|
||||
switch ( $response->httpResponseCode )
|
||||
{
|
||||
case 200:
|
||||
if ( !preg_match( '/^ips_[a-z0-9]{5}$/', (string) $response ) )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( (string) $response );
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('download_upgrade_error');
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['key'] = (string) $response;
|
||||
return $data;
|
||||
}
|
||||
|
||||
case 304:
|
||||
if ( \IPS\Db::i()->select( 'MIN(app_long_version)', 'core_applications', \IPS\Db::i()->in( 'app_directory', \IPS\Application::$ipsApps ) )->first() < \IPS\Application::getAvailableVersion('core') )
|
||||
{
|
||||
$data['key'] = NULL;
|
||||
return $data;
|
||||
}
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('download_upgrade_nothing');
|
||||
break;
|
||||
|
||||
default:
|
||||
$form->error = (string) $response;
|
||||
}
|
||||
|
||||
}
|
||||
catch ( \Exception $exception )
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->write( get_class( $exception ) . "\n" . $exception->getCode() . ": " . $exception->getMessage() . "\n" . $exception->getTraceAsString() );
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('download_upgrade_error');
|
||||
}
|
||||
}
|
||||
|
||||
return (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Update
|
||||
*
|
||||
* @param array $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _extractUpdate( $data )
|
||||
{
|
||||
/* Download & Extract */
|
||||
if ( $data['key'] and !isset( \IPS\Request::i()->check ) )
|
||||
{
|
||||
/* Muliple Redirector */
|
||||
return (string) new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal('app=core&module=system&controller=upgrade'), function( $mrData ) use ( $data )
|
||||
{
|
||||
/* Init */
|
||||
if ( !is_array( $mrData ) )
|
||||
{
|
||||
return array( array( 'status' => 'download' ), \IPS\Member::loggedIn()->language()->addToStack('delta_upgrade_downloading'), 0 );
|
||||
}
|
||||
/* Download */
|
||||
elseif ( $mrData['status'] == 'download' )
|
||||
{
|
||||
if ( !isset( $mrData['tmpFileName'] ) )
|
||||
{
|
||||
$mrData['tmpFileName'] = tempnam( \IPS\TEMP_DIRECTORY, 'IPS' ) . '.zip';
|
||||
|
||||
return array( $mrData, \IPS\Member::loggedIn()->language()->addToStack('delta_upgrade_downloading'), 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !isset( $mrData['range'] ) )
|
||||
{
|
||||
$mrData['range'] = 0;
|
||||
}
|
||||
$startRange = $mrData['range'];
|
||||
$endRange = $startRange + 1000000 - 1;
|
||||
|
||||
$response = \IPS\Http\Url::ips("download/{$data['key']}")->request( 30 )->setHeaders( array( 'Range' => "bytes={$startRange}-{$endRange}" ) )->get();
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Fetching download [range={$startRange}-{$endRange}] with a response code: " . $response->httpResponseCode, 'auto_upgrade' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
if ( $response->httpResponseCode == 404 )
|
||||
{
|
||||
if ( isset( $mrData['tmpFileName'] ) )
|
||||
{
|
||||
@unlink( $mrData['tmpFileName'] );
|
||||
}
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate('system')->upgradeDeltaFailed( TRUE, isset( $data['key'] ) ? \IPS\Http\Url::ips("download/{$data['key']}") : NULL ) );
|
||||
}
|
||||
elseif ( $response->httpResponseCode == 206 )
|
||||
{
|
||||
$totalFileSize = intval( mb_substr( $response->httpHeaders['Content-Range'], mb_strpos( $response->httpHeaders['Content-Range'], '/' ) + 1 ) );
|
||||
$fh = \fopen( $mrData['tmpFileName'], 'a' );
|
||||
\fwrite( $fh, (string) $response );
|
||||
\fclose( $fh );
|
||||
|
||||
$mrData['range'] = $endRange + 1;
|
||||
return array( $mrData, \IPS\Member::loggedIn()->language()->addToStack('delta_upgrade_downloading'), 100 / $totalFileSize * $mrData['range'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$mrData['status'] = 'extract';
|
||||
return array( $mrData, \IPS\Member::loggedIn()->language()->addToStack('delta_upgrade_extracting'), 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Extract */
|
||||
elseif ( $mrData['status'] == 'extract' )
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Attempting to extract", 'auto_upgrade' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
/* Open the zip */
|
||||
$zip = \IPS\Archive\Zip::fromLocalFile( $mrData['tmpFileName'], $data['key'] . '/' );
|
||||
|
||||
/* Extract some files */
|
||||
$numberToDo = 20;
|
||||
if ( !isset( $mrData['extractNumber'] ) )
|
||||
{
|
||||
$mrData['extractNumber'] = 0;
|
||||
}
|
||||
$offset = $mrData['extractNumber'];
|
||||
|
||||
if ( $zip->extract( \IPS\ROOT_PATH, $numberToDo, $offset ) === TRUE )
|
||||
{
|
||||
if ( isset( $mrData['tmpFileName'] ) )
|
||||
{
|
||||
@unlink( $mrData['tmpFileName'] );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mrData['extractNumber'] += $numberToDo;
|
||||
$numberOfFiles = $zip->numberOfFiles();
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Extracting files {$mrData['extractNumber']} / {$numberOfFiles}", 'auto_upgrade' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
return array( $mrData, \IPS\Member::loggedIn()->language()->addToStack('delta_upgrade_extracting'), 100 / $numberOfFiles * $mrData['extractNumber'] );
|
||||
}
|
||||
}
|
||||
catch ( \RuntimeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Log::i( LOG_ERR )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( "Extract Failed", 'auto_upgrade' );
|
||||
\IPS\Log::i( LOG_ERR )->setIpAddress( $_SERVER['REMOTE_ADDR'] )->write( $e, 'auto_upgrade' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
\IPS\Session\Admin::i()->log( ( $e->getCode() === \IPS\Archive\Exception::COULD_NOT_OPEN ) ? 'delta_upgrade_zip_fail' : ( $e->getCode() === \IPS\Archive\Exception::COULD_NOT_WRITE ? 'delta_upgrade_write_fail' : '' ) );
|
||||
|
||||
if ( isset( $mrData['tmpFileName'] ) )
|
||||
{
|
||||
@unlink( $mrData['tmpFileName'] );
|
||||
}
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate('system')->upgradeDeltaFailed( $e->getCode(), isset( $data['key'] ) ? \IPS\Http\Url::ips("download/{$data['key']}") : NULL ) );
|
||||
}
|
||||
}
|
||||
},
|
||||
function()
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=system&controller=upgrade&check=1') );
|
||||
} );
|
||||
}
|
||||
|
||||
/* Run md5 check */
|
||||
try
|
||||
{
|
||||
$files = \IPS\Application::md5Check();
|
||||
if ( count( $files ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('system')->upgradeDeltaFailed( $files, isset( $data['key'] ) ? \IPS\Http\Url::ips("download/{$data['key']}") : NULL );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
/* Nope, we're good! */
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade
|
||||
*
|
||||
* @param array $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _upgrade( $data )
|
||||
{
|
||||
\IPS\Output::i()->redirect( 'upgrade/?adsess=' . \IPS\Request::i()->adsess );
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Activity Stream
|
||||
* @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 2 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\activity;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activity Stream
|
||||
*/
|
||||
class _activity extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* New Content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
/* Flood control */
|
||||
\IPS\Request::floodCheck();
|
||||
|
||||
/* Get the different types */
|
||||
$types = array();
|
||||
$hasCallback = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'ContentRouter', TRUE, NULL, NULL, TRUE ) as $router )
|
||||
{
|
||||
foreach( $router->classes as $class )
|
||||
{
|
||||
if( !is_subclass_of( $class, 'IPS\Content\Searchable' ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ) ] = $class;
|
||||
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$commentClass, 4 ) ) ) ] = $class::$commentClass;
|
||||
}
|
||||
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$reviewClass, 4 ) ) ) ] = $class::$reviewClass;
|
||||
}
|
||||
|
||||
if( method_exists( $class, 'customTableHelper' ) )
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ) ] = $router;
|
||||
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$commentClass, 4 ) ) ) ] = $router;
|
||||
}
|
||||
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$reviewClass, 4 ) ) ) ] = $router;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* What type are we looking at? */
|
||||
$currentAppModule = NULL;
|
||||
$currentType = NULL;
|
||||
if ( isset( \IPS\Request::i()->type ) )
|
||||
{
|
||||
foreach ( $types as $appModule => $_types )
|
||||
{
|
||||
if ( array_key_exists( \IPS\Request::i()->type, $_types ) )
|
||||
{
|
||||
$currentAppModule = $appModule;
|
||||
$currentType = \IPS\Request::i()->type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$url = \IPS\Http\Url::internal( "app=core&module=activity&controller=activity", 'front', 'activity' );
|
||||
|
||||
/* Build Output */
|
||||
if ( !$currentType )
|
||||
{
|
||||
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$query = \IPS\Content\Search\Query::init()->excludeFirstPostContentItems()->excludeDisabledApps()->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED )->setPage( $page );
|
||||
$results = $query->search();
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $url, ceil( $results->count( TRUE ) / $query->resultsToGet ), $page, $query->resultsToGet ) );
|
||||
$output = \IPS\Theme::i()->getTemplate('system')->activityStream( $results, $pagination );
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentClass = $types[ $currentAppModule ][ $currentType ];
|
||||
$currentAppArray = explode( '_', $currentAppModule );
|
||||
$currentApp = $currentAppArray[0];
|
||||
if( isset( $hasCallback[ $currentType ] ) )
|
||||
{
|
||||
$output = $hasCallback[ $currentType ]->customTableHelper( $currentClass, $url->setQueryString( array( 'type' => $currentType ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = array();
|
||||
if ( isset( $currentClass::$databaseColumnMap['state'] ) )
|
||||
{
|
||||
$where[] = array( $currentClass::$databaseColumnMap['state'] . ' != ?', 'link' );
|
||||
}
|
||||
$output = new \IPS\Helpers\Table\Content( $currentClass, $url->setQueryString( array( 'type' => $currentType ) ), $where, NULL, NULL, 'read', FALSE );
|
||||
}
|
||||
|
||||
$output->showFilters = FALSE;
|
||||
}
|
||||
|
||||
/* If we've clicked from the tab section */
|
||||
if ( \IPS\Request::i()->isAjax() && \IPS\Request::i()->change_section )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'system' )->activitySection( $url, $types, $currentAppModule, $currentType, (string) $output ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->get('activity_stream');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->activity( $url, $types, $currentAppModule, $currentType, (string) $output );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -56,8 +56,9 @@ class _contact extends \IPS\Dispatcher\Controller
|
||||
/* Send the message */
|
||||
$fromName = ( \IPS\Member::loggedIn()->member_id ) ? \IPS\Member::loggedIn()->name : $values['contact_name'];
|
||||
$mail = \IPS\Email::buildFromTemplate( 'core', 'contact_form', array( \IPS\Member::loggedIn(), $fromName, $values['contact_text'] ) );
|
||||
$mail->from = ( \IPS\Member::loggedIn()->member_id ) ? \IPS\Member::loggedIn()->email : $values['email_address'];
|
||||
$mail->fromName = $fromName;
|
||||
|
||||
/* Set contact email as Reply-To instead of From, so that it will pass Spam/SPF checks */
|
||||
$mail->headers['Reply-To'] = '=?UTF-8?B?' . base64_encode( $fromName ) . "?= <" . ( \IPS\Member::loggedIn()->member_id ? \IPS\Member::loggedIn()->email : $values['email_address'] ) . '>';
|
||||
$mail->send( \IPS\Settings::i()->email_in );
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
|
||||
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief 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 02 Jul 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\discover;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* streams
|
||||
*/
|
||||
class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/* Initiate the breadcrumb */
|
||||
\IPS\Output::i()->breadcrumb = array( array( \IPS\Http\Url::internal( "app=core&module=discovery&controller=streams", 'front', 'discover_all' ), \IPS\Member::loggedIn()->language()->addToStack('activity') ) );
|
||||
|
||||
/* Necessary CSS/JS */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_streams.js', 'core' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
|
||||
|
||||
/* Execute */
|
||||
return parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* View Stream
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* If this request is from an auto-poll, kill it and exit */
|
||||
if ( !\IPS\Settings::i()->auto_polling_enabled && \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->after ) ){
|
||||
\IPS\Output::i()->json( array( 'error' => 'auto_polling_disabled' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Viewing a particular stream? */
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
{
|
||||
/* Get it */
|
||||
try
|
||||
{
|
||||
$stream = \IPS\core\Stream::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C280/1', 404, '' );
|
||||
}
|
||||
|
||||
/* Suitable for guests? */
|
||||
if ( ! \IPS\Member::loggedIn()->member_id and ! ( ( $stream->ownership == 'all' or $stream->ownership == 'custom' ) and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'stream_no_permission', '2C280/3', 403, '' );
|
||||
}
|
||||
|
||||
$baseUrl = $stream->url();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id and isset( \IPS\Request::i()->default ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->default )
|
||||
{
|
||||
\IPS\Member::loggedIn()->defaultStream = $stream->_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->defaultStream = NULL;
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$defaultStream = \IPS\core\Stream::defaultStream();
|
||||
|
||||
if ( ! $defaultStream )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'title' => NULL ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->json( array(
|
||||
'url' => $defaultStream->url(),
|
||||
'title' => $defaultStream->_title,
|
||||
'id' => $defaultStream->_id
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $stream->url() );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->form ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->form == 'show' )
|
||||
{
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $this->_buildForm( $stream ), 200, 'text/html' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $this->_buildForm( $stream );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to process the form */
|
||||
$this->_buildForm( $stream );
|
||||
}
|
||||
}
|
||||
|
||||
/* Set title and breadcrumb */
|
||||
\IPS\Output::i()->breadcrumb[] = array( $stream->url(), $stream->_title );
|
||||
\IPS\Output::i()->title = $stream->_title;
|
||||
}
|
||||
|
||||
/* Or just everything? */
|
||||
else
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->member_id and isset( \IPS\Request::i()->default ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->default )
|
||||
{
|
||||
\IPS\Member::loggedIn()->defaultStream = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->defaultStream = NULL;
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$defaultStream = \IPS\core\Stream::defaultStream();
|
||||
|
||||
if ( ! $defaultStream )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'title' => NULL ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->json( array(
|
||||
'url' => \IPS\Http\Url::internal( "app=core&module=discovery&controller=streams", 'front', 'discover_all' ),
|
||||
'title' => $defaultStream->_title,
|
||||
'id' => $defaultStream->_id
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=discovery&controller=streams", 'front', 'discover_all' ) );
|
||||
}
|
||||
|
||||
/* Start with a blank stream */
|
||||
$stream = \IPS\core\Stream::allActivityStream();
|
||||
$baseUrl = \IPS\Http\Url::internal( "app=core&module=discovery&controller=streams", 'front', 'discover_all' );
|
||||
|
||||
/* Set the title to "All Activity" */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('all_activity');
|
||||
}
|
||||
|
||||
/* Changes from Update Only */
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'ownership', 'read', 'follow', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort' ) as $k )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->$k ) )
|
||||
{
|
||||
$stream->$k = \IPS\Request::i()->$k;
|
||||
$baseUrl = $baseUrl->setQueryString( $k, \IPS\Request::i()->$k );
|
||||
}
|
||||
}
|
||||
|
||||
/* RSS validate? */
|
||||
$member = NULL;
|
||||
if ( isset( \IPS\Request::i()->rss ) )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
if ( \IPS\Request::i()->key != md5( ( $member->members_pass_hash ?: $member->email ) . $member->members_pass_salt ) )
|
||||
{
|
||||
$member = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Build the query */
|
||||
$query = $stream->query( $member );
|
||||
|
||||
/* Set page or the before/after date */
|
||||
$currentPage = 1;
|
||||
if ( isset( \IPS\Request::i()->page ) )
|
||||
{
|
||||
$currentPage = \IPS\Request::i()->page;
|
||||
$query->setPage( $currentPage );
|
||||
}
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->before ) )
|
||||
{
|
||||
if ( $stream->id and !$stream->include_comments )
|
||||
{
|
||||
$query->filterByLastUpdatedDate( NULL, \IPS\DateTime::ts( \IPS\Request::i()->before ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->filterByCreateDate( NULL, \IPS\DateTime::ts( \IPS\Request::i()->before ) );
|
||||
}
|
||||
}
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->after ) )
|
||||
{
|
||||
if ( $stream->id and !$stream->include_comments )
|
||||
{
|
||||
$query->filterByLastUpdatedDate( \IPS\DateTime::ts( \IPS\Request::i()->after ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->filterByCreateDate( \IPS\DateTime::ts( \IPS\Request::i()->after ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the results */
|
||||
$results = $query->search( NULL, $stream->tags ? explode( ',', $stream->tags ) : NULL );
|
||||
|
||||
/* Load data we need like the authors, etc */
|
||||
$results->init();
|
||||
|
||||
/* Add in extra stuff? */
|
||||
if ( !isset( \IPS\Request::i()->id ) )
|
||||
{
|
||||
/* Is anything turned on? */
|
||||
$extra = array();
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'rep_neg' ) as $k )
|
||||
{
|
||||
$key = "all_activity_{$k}";
|
||||
if ( \IPS\Settings::i()->$key )
|
||||
{
|
||||
$extra[] = $k;
|
||||
}
|
||||
}
|
||||
if ( !empty( $extra ) )
|
||||
{
|
||||
$results = $results->addExtraItems( $extra, NULL, ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->after ) : NULL, ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->before ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->before ) : NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/* Condensed or expanded? */
|
||||
$view = 'expanded';
|
||||
$streamID = ( \IPS\Request::i()->id ) ? \IPS\Request::i()->id : 'all';
|
||||
|
||||
if ( ( isset( \IPS\Request::i()->cookie['stream_view_' . $streamID] ) and \IPS\Request::i()->cookie['stream_view_' . $streamID] == 'condensed' ) or ( isset( \IPS\Request::i()->view ) and \IPS\Request::i()->view == 'condensed' ) )
|
||||
{
|
||||
$view = 'condensed';
|
||||
}
|
||||
|
||||
|
||||
/* If this is an AJAX request, just show the results */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->_changeView ) )
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate('streams')->stream( $stream, $results, !isset( \IPS\Request::i()->id ), true, $baseUrl, ( $stream->id and !$stream->include_comments ) ? 'last_comment' : 'date', $view );
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate('streams')->streamItems( $results, true, ( $stream->id and !$stream->include_comments ) ? 'last_comment' : 'date', $view );
|
||||
}
|
||||
|
||||
$return = array(
|
||||
'title' => $stream->_title,
|
||||
'blurb' => $stream->blurb(),
|
||||
'count' => count( $results ),
|
||||
'results' => $output,
|
||||
'id' => ( $stream->id ) ? $stream->id : ''
|
||||
);
|
||||
|
||||
\IPS\Output::i()->json( $return );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display - RSS */
|
||||
if ( isset( \IPS\Request::i()->rss ) )
|
||||
{
|
||||
$document = \IPS\Xml\Rss::newDocument( $baseUrl, $stream->_title, sprintf( \IPS\Member::loggedIn()->language()->get( 'stream_rss_title' ), \IPS\Settings::i()->board_name, $stream->_title ) );
|
||||
|
||||
foreach ( $results as $result )
|
||||
{
|
||||
$result->addToRssFeed( $document );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml' );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Display - HTML */
|
||||
else
|
||||
{
|
||||
/* What's the RSS Link? */
|
||||
$rssLink = NULL;
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
{
|
||||
$rssLink = \IPS\Http\Url::internal( "app=core&module=discovery&controller=streams&id={$stream->id}", 'front', 'discover_rss' );
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$rssLink = $rssLink->setQueryString( 'member', \IPS\Member::loggedIn()->member_id );
|
||||
if ( !\IPS\Member::loggedIn()->members_pass_salt )
|
||||
{
|
||||
\IPS\Member::loggedIn()->members_pass_salt = \IPS\Member::loggedIn()->generateSalt();
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
$rssLink = $rssLink->setQueryString( 'key', md5( ( \IPS\Member::loggedIn()->members_pass_hash ?: \IPS\Member::loggedIn()->email ) . \IPS\Member::loggedIn()->members_pass_salt ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate('streams')->stream( $stream, $results, !isset( \IPS\Request::i()->id ), true, $baseUrl, ( $stream->id and !$stream->include_comments ) ? 'last_comment' : 'date', $view );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('streams')->streamWrapper( $stream, $output, ( isset( \IPS\Request::i()->id ) and ( !$stream->member or $stream->member == \IPS\Member::loggedIn()->member_id ) ) ? TRUE : FALSE, $rssLink, isset( \IPS\Request::i()->id ) and $stream->member and $stream->member != \IPS\Member::loggedIn()->member_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new stream
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$stream = new \IPS\core\Stream;
|
||||
$stream->member = \IPS\Member::loggedIn()->member_id;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'create_new_stream' );
|
||||
\IPS\Output::i()->output = $this->_buildForm( $stream );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a stream
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
try
|
||||
{
|
||||
$stream = clone \IPS\core\Stream::load( \IPS\Request::i()->id );
|
||||
$stream->member = \IPS\Member::loggedIn()->member_id;
|
||||
$stream->save();
|
||||
$this->_rebuildStreams();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C280/3', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $stream->url() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a new stream
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
try
|
||||
{
|
||||
$stream = \IPS\core\Stream::load( \IPS\Request::i()->id );
|
||||
if ( !$stream->member or $stream->member != \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C280/2', 404, '' );
|
||||
}
|
||||
|
||||
$stream->delete();
|
||||
$this->_rebuildStreams();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=discover&controller=streams", 'front', 'discover_all' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build form
|
||||
*
|
||||
* @param \IPS\core\Stream $stream The stream
|
||||
* @return string
|
||||
*/
|
||||
protected function _buildForm( \IPS\core\Stream $stream )
|
||||
{
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form( 'select_blog', 'continue', ( $stream->id ? $stream->url() : NULL ) );
|
||||
$form->class = 'ipsForm_vertical ipsForm_noLabels';
|
||||
|
||||
$stream->form( $form, 'Text', !$stream->id );
|
||||
$redirectAfterSave = FALSE;
|
||||
|
||||
/* Note if it's custom */
|
||||
if ( $stream->member && \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->hiddenValues['__custom_stream'] = TRUE;
|
||||
}
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Update only */
|
||||
if ( !$stream->member or isset( \IPS\Request::i()->updateOnly ) )
|
||||
{
|
||||
$url = $stream->url();
|
||||
$formattedValues = $stream->formatFormValues( $values );
|
||||
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'ownership', 'read', 'follow', 'date_type', 'date_start', 'date_end', 'date_relative_days' ) as $k )
|
||||
{
|
||||
if ( $stream->$k != $formattedValues[ $k ] )
|
||||
{
|
||||
$url = $url->setQueryString( $k, $formattedValues[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
/* Update & Save */
|
||||
else
|
||||
{
|
||||
if ( !$stream->id )
|
||||
{
|
||||
$stream->position = \IPS\Db::i()->select( 'MAX(position)', 'core_streams', array( 'member=?', \IPS\Member::loggedIn()->member_id ) )->first() + 1;
|
||||
$redirectAfterSave = TRUE;
|
||||
}
|
||||
|
||||
if ( count( $values['stream_classes'] ) )
|
||||
{
|
||||
$values['stream_classes_type'] = 1;
|
||||
}
|
||||
|
||||
$stream->saveForm( $stream->formatFormValues( $values ) );
|
||||
|
||||
$this->_rebuildStreams();
|
||||
|
||||
if( $redirectAfterSave )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $stream->url() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'streams', 'core' ) ), $stream->id ? ( $stream->member ? 'filterUpdateForm' : 'filterDuplicateForm' ) : 'filterCreateForm' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild logged in member's streams
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _rebuildStreams()
|
||||
{
|
||||
$default = \IPS\Member::loggedIn()->defaultStream;
|
||||
\IPS\Member::loggedIn()->member_streams = json_encode( array( 'default' => $default, 'streams' => iterator_to_array( \IPS\Db::i()->select( 'id, title', 'core_streams', array( 'member=?', \IPS\Member::loggedIn()->member_id ) )->setKeyField('id')->setValueField('title') ) ) );
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
@@ -51,12 +51,12 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
if( !\IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_profile.js', 'core' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_statuses.js', 'core' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/profiles.css' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/statuses.css' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/statuses_responsive.css' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/profiles_responsive.css' ) );
|
||||
}
|
||||
}
|
||||
@@ -100,23 +100,14 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* Can we access this member's statuses */
|
||||
$canAccessStatuses = ( \IPS\Settings::i()->profile_comments
|
||||
and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) )
|
||||
and ( $this->member->pp_setting_count_comments or \IPS\Member::loggedIn()->member_id == $this->member->member_id ) );
|
||||
$canAccessSingleStatuses = ( \IPS\Settings::i()->profile_comments and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) );
|
||||
$canAccessStatuses = $canAccessSingleStatuses and ( $this->member->pp_setting_count_comments or \IPS\Member::loggedIn()->member_id == $this->member->member_id );
|
||||
|
||||
/* Are we loading a different page of comments? */
|
||||
if ( \IPS\Request::i()->status && \IPS\Request::i()->isAjax() && !\IPS\Request::i()->submitting && !\IPS\Request::i()->getUploader && $canAccessStatuses )
|
||||
{
|
||||
try
|
||||
{
|
||||
$status = \IPS\core\Statuses\Status::loadAndCheckPerms( \IPS\Request::i()->status );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Output::i()->error( 'node_error', '2C138/D', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile' )->statusReplies( $status );
|
||||
$status = \IPS\core\Statuses\Status::loadAndCheckPerms( \IPS\Request::i()->status );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'statuses' )->statusReplies( $status );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,24 +148,21 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Work out the main content to display */
|
||||
if ( $canAccessStatuses and \IPS\Request::i()->status and \IPS\Request::i()->type == 'status' )
|
||||
if ( $canAccessSingleStatuses and \IPS\Request::i()->status and \IPS\Request::i()->type == 'status' )
|
||||
{
|
||||
$statuses = $this->_getStatuses();
|
||||
$mainContent = \IPS\Theme::i()->getTemplate( 'profile' )->statusFeed( $this->member, $statuses['statuses'], $statuses['count'], $statuses['form'], TRUE );
|
||||
$status = \IPS\core\Statuses\Status::loadAndCheckPerms( \IPS\Request::i()->status );
|
||||
$mainContent = \IPS\Theme::i()->getTemplate( 'profile' )->singleStatus( $this->member, $status );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->get( 'viewing_single_status' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->get( 'viewing_single_status' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* What tabs are available? */
|
||||
$tabs = array( 'activity' => 'users_activity_feed' );
|
||||
if ( $canAccessStatuses )
|
||||
{
|
||||
$tabs['statuses'] = 'status_feed';
|
||||
}
|
||||
foreach( $mainFields as $group => $fields )
|
||||
{
|
||||
foreach( $fields as $field => $value )
|
||||
@@ -196,7 +184,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$tabs[ "node_{$matches[1]}_{$matches[2]}" ] = "profile_{$matches[1]}_{$matches[2]}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* What tab are we on? */
|
||||
if ( !isset( \IPS\Request::i()->tab ) or !array_key_exists( \IPS\Request::i()->tab, $tabs ) )
|
||||
{
|
||||
@@ -206,19 +194,65 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$tab = \IPS\Request::i()->tab;
|
||||
}
|
||||
|
||||
|
||||
/* Work out the content */
|
||||
$tabContents = '';
|
||||
if ( $tab == 'activity' )
|
||||
{
|
||||
$latestActivity = \IPS\Content\Search\Query::init()->filterByAuthor( $this->member )->excludeFirstPostContentItems()->excludeDisabledApps()->setLimit( 15 )->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED )->search();
|
||||
$latestActivity = \IPS\Content\Search\Query::init()->filterForProfile( $this->member )->setLimit( 15 )->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED )->search();
|
||||
$latestActivity->init( TRUE );
|
||||
$tabContents = \IPS\Theme::i()->getTemplate( 'profile' )->profileActivity( $this->member, $latestActivity );
|
||||
}
|
||||
elseif ( $tab == 'statuses' )
|
||||
{
|
||||
$statuses = $this->_getStatuses();
|
||||
$tabContents = \IPS\Theme::i()->getTemplate( 'profile' )->statusFeed( $this->member, $statuses['statuses'], $statuses['count'], $statuses['form'] );
|
||||
|
||||
$extra = array();
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'rep_neg' ) as $k )
|
||||
{
|
||||
$key = "all_activity_{$k}";
|
||||
if ( \IPS\Settings::i()->$key )
|
||||
{
|
||||
$extra[] = $k;
|
||||
}
|
||||
}
|
||||
if ( !empty( $extra ) )
|
||||
{
|
||||
$latestActivity = $latestActivity->addExtraItems( $extra, $this->member );
|
||||
}
|
||||
|
||||
$statusForm = NULL;
|
||||
if ( \IPS\core\Statuses\Status::canCreate( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->status_content_ajax ) )
|
||||
{
|
||||
\IPS\Request::i()->status_content = \IPS\Request::i()->status_content_ajax;
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'new_status', 'status_new' );
|
||||
foreach( \IPS\core\Statuses\Status::formElements() AS $k => $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$status = \IPS\core\Statuses\Status::createFromForm( $values );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'statuses', 'core', 'front' )->statusContainer( $status ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $status->url() );
|
||||
}
|
||||
}
|
||||
|
||||
$statusForm = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'statusTemplate' ) );
|
||||
|
||||
if ( \IPS\core\Statuses\Status::moderateNewItems( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
$statusForm = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . $statusForm;
|
||||
}
|
||||
}
|
||||
|
||||
$tabContents = \IPS\Theme::i()->getTemplate( 'profile' )->profileActivity( $this->member, $latestActivity, $statusForm );
|
||||
}
|
||||
elseif ( mb_substr( $tab, 0, 6 ) == 'field_' )
|
||||
{
|
||||
@@ -230,16 +264,16 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$type = mb_substr( $tab, 5 );
|
||||
$tabContents = (string) $nodes[ $type ]->render();
|
||||
}
|
||||
|
||||
|
||||
/* If this is AJAX request to change the tab, just display that */
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->tab ) )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $tabContents );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $tabContents ) );
|
||||
}
|
||||
|
||||
|
||||
/* Otherwise wrap it in the tabs */
|
||||
$mainContent = \IPS\Theme::i()->getTemplate( 'profile' )->profileTabs( $this->member, $tabs, $tab, $tabContents );
|
||||
|
||||
|
||||
\IPS\Output::i()->title = $this->member->name;
|
||||
}
|
||||
|
||||
@@ -329,22 +363,19 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $class == 'IPS\core\Statuses\Status' AND ( !\IPS\Settings::i()->profile_comments OR !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Add CSS for this app */
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'profile.css', $class::$application ) );
|
||||
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ) ] = $class;
|
||||
|
||||
if ( isset( $class::$commentClass ) )
|
||||
|
||||
$supportsComments = ( in_array( 'IPS\Content\Item', class_parents( $class ) ) and $class::supportsComments( \IPS\Member::loggedIn() ) );
|
||||
if ( $supportsComments )
|
||||
{
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$commentClass, 4 ) ) ) ] = $class::$commentClass;
|
||||
}
|
||||
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
$supportsReviews = ( in_array( 'IPS\Content\Item', class_parents( $class ) ) and $class::supportsReviews( \IPS\Member::loggedIn() ) );
|
||||
if ( $supportsReviews )
|
||||
{
|
||||
$types[ $class::$application . '_' . $class::$module ][ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$reviewClass, 4 ) ) ) ] = $class::$reviewClass;
|
||||
}
|
||||
@@ -353,12 +384,12 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ) ] = $router;
|
||||
|
||||
if ( isset( $class::$commentClass ) )
|
||||
if ( $supportsComments )
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$commentClass, 4 ) ) ) ] = $router;
|
||||
}
|
||||
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
if ( $supportsReviews )
|
||||
{
|
||||
$hasCallback[ mb_strtolower( str_replace( '\\', '_', mb_substr( $class::$reviewClass, 4 ) ) ) ] = $router;
|
||||
}
|
||||
@@ -392,7 +423,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
/* Build Output */
|
||||
if ( !$currentType )
|
||||
{
|
||||
$query = \IPS\Content\Search\Query::init()->filterByAuthor( $this->member )->excludeFirstPostContentItems()->excludeDisabledApps()->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_UPDATED )->setPage( $page );
|
||||
$query = \IPS\Content\Search\Query::init()->filterByAuthor( $this->member )->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_UPDATED )->setPage( $page );
|
||||
$results = $query->search();
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $this->member->url()->setQueryString( array( 'do' => 'content' ) ), ceil( $results->count( TRUE ) / $query->resultsToGet ), $page, $query->resultsToGet ) );
|
||||
$output = \IPS\Theme::i()->getTemplate('profile')->userContentStream( $this->member, $results, $pagination );
|
||||
@@ -423,8 +454,13 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$output = new \IPS\Helpers\Table\Content( $currentClass, $this->member->url()->setQueryString( array( 'do' => 'content', 'type' => $currentType ) ), $where, NULL, NULL, 'read', FALSE );
|
||||
}
|
||||
|
||||
$output->showFilters = FALSE;
|
||||
$output->classes[] = 'cProfileContent';
|
||||
if ( $currentType == 'core_statuses_status' )
|
||||
{
|
||||
$output->noModerate = TRUE;
|
||||
}
|
||||
|
||||
$output->showFilters = FALSE;
|
||||
$output->classes[] = 'cProfileContent';
|
||||
}
|
||||
|
||||
/* If we've clicked from the tab section */
|
||||
@@ -673,44 +709,6 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Statuses
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function statuses()
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->modPermission('can_modify_profiles') AND ( \IPS\Member::loggedIn()->member_id !== $this->member->member_id OR !$this->member->group['g_edit_profile'] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_permission_edit_profile', '2C138/4', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$statuses = array( 'statuses' => array(), 'form' => NULL );
|
||||
if ( \IPS\Request::i()->state == 0 )
|
||||
{
|
||||
$this->member->pp_setting_count_comments = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->member->pp_setting_count_comments = TRUE;
|
||||
}
|
||||
|
||||
$this->member->save();
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$statuses = $this->_getStatuses();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile', 'core' )->statuses( $statuses['statuses'], $statuses['count'], $statuses['form'], $this->member );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->member->url(), 'saved' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Status
|
||||
*
|
||||
@@ -766,7 +764,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
/* The basics */
|
||||
$form->addtab( 'profile_edit_basic_tab', 'user');
|
||||
$form->addTab( 'profile_edit_basic_tab', 'user');
|
||||
$form->addHeader( 'profile_edit_basic_header' );
|
||||
if( \IPS\Settings::i()->post_titlechange != -1 and ( isset( \IPS\Settings::i()->post_titlechange ) and $this->member->member_posts >= \IPS\Settings::i()->post_titlechange ) )
|
||||
{
|
||||
@@ -782,6 +780,10 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
'yyyy' => \IPS\Theme::i()->getTemplate( 'members', 'core', 'global' )->bdayForm_year( $element->name, $element->value, $element->error ),
|
||||
) );
|
||||
} ) ) );
|
||||
if ( \IPS\Settings::i()->profile_comments and $this->member->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'enable_status_updates', $this->member->pp_setting_count_comments ) );
|
||||
}
|
||||
|
||||
/* Profile fields */
|
||||
try
|
||||
@@ -833,6 +835,13 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$this->member->member_title = $values['member_title'];
|
||||
}
|
||||
|
||||
if( $values['bday'] and ( ( $values['bday']['day'] and !$values['bday']['month'] ) or ( $values['bday']['month'] and !$values['bday']['day'] ) ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'bday_month_and_day_required' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'profile_edit' ), $form );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $values['bday'] and $values['bday']['day'] and $values['bday']['month'] )
|
||||
{
|
||||
$this->member->bday_day = $values['bday']['day'];
|
||||
@@ -846,6 +855,20 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$this->member->bday_year = NULL;
|
||||
}
|
||||
|
||||
if ( isset( $values['enable_status_updates'] ) )
|
||||
{
|
||||
$this->member->pp_setting_count_comments = $values['enable_status_updates'];
|
||||
|
||||
if ( $values['enable_status_updates'] )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( 'IPS\core\Statuses\Status', NULL, NULL, '*', NULL, NULL, $this->member->member_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->massUpdate( 'IPS\core\Statuses\Status', NULL, NULL, '', NULL, NULL, $this->member->member_id );
|
||||
}
|
||||
}
|
||||
|
||||
/* Profile Fields */
|
||||
try
|
||||
{
|
||||
@@ -870,11 +893,13 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$profileFields[ "field_{$id}" ] = $field::stringValue( $values[ $field->name ] );
|
||||
|
||||
if ( $fields instanceof \IPS\Helpers\Form\Editor )
|
||||
if ( $field instanceof \IPS\Helpers\Form\Editor )
|
||||
{
|
||||
$field->claimAttachments( $this->id );
|
||||
\IPS\core\ProfileFields\Field::load( $id )->claimAttachments( $this->member->member_id );
|
||||
}
|
||||
}
|
||||
|
||||
$this->member->changedCustomFields = $profileFields;
|
||||
}
|
||||
|
||||
/* Moderator stuff */
|
||||
@@ -902,8 +927,8 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
}
|
||||
|
||||
/* Save */
|
||||
$this->member->save();
|
||||
\IPS\Db::i()->replace( 'core_pfields_content', $profileFields );
|
||||
$this->member->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $this->member->url() );
|
||||
}
|
||||
@@ -911,7 +936,14 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
/* Set Session Location */
|
||||
\IPS\Session::i()->setLocation( $this->member->url(), array(), 'loc_editing_profile', array( $this->member->name => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->editContentForm( \IPS\Member::loggedIn()->language()->addToStack( 'profile_edit' ), $form );
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'editing_profile', FALSE, array( 'sprintf' => array( $this->member->name ) ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'editing_profile', FALSE, array( 'sprintf' => array( $this->member->name ) ) ) );
|
||||
}
|
||||
@@ -1011,6 +1043,8 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
$thumbnail = $values['member_photo_upload']->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE );
|
||||
$this->member->pp_thumb_photo = (string) $thumbnail;
|
||||
|
||||
$this->member->photo_last_update = time();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1024,12 +1058,15 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
$thumbnail = $values['member_photo_url']->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE );
|
||||
$this->member->pp_thumb_photo = (string) $thumbnail;
|
||||
|
||||
$this->member->photo_last_update = time();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
$this->member->pp_main_photo = NULL;
|
||||
$this->member->members_bitoptions['bw_disable_gravatar'] = 1;
|
||||
$this->member->photo_last_update = NULL;
|
||||
break;
|
||||
|
||||
case 'gravatar':
|
||||
@@ -1174,7 +1211,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? \IPS\core\Statuses\Status::load( \IPS\Request::i()->status ) : \IPS\core\Statuses\Reply::load( \IPS\Request::i()->status );
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? \IPS\core\Statuses\Status::load( \IPS\Request::i()->status ) : \IPS\core\Statuses\Reply::load( \IPS\Request::i()->reply );
|
||||
|
||||
$item->modAction( \IPS\Request::i()->action, \IPS\Member::loggedIn() );
|
||||
|
||||
@@ -1186,7 +1223,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
if( \IPS\Request::i()->action == 'delete' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( ( $item instanceof \IPS\core\Statuses\Status ) ? \IPS\Member::load( $item->member_id )->url() : \IPS\core\Statuses\Status::load( $item->status_id )->url());
|
||||
\IPS\Output::i()->redirect( ( $item instanceof \IPS\core\Statuses\Status ) ? \IPS\Member::load( $item->member_id )->url()->setQueryString( array( 'do' => 'content', 'type' => 'core_statuses_status' ) ) : \IPS\core\Statuses\Status::load( $item->status_id )->url());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1218,14 +1255,14 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? \IPS\core\Statuses\Status::load( \IPS\Request::i()->status ) : \IPS\core\Statuses\Reply::load( \IPS\Request::i()->status );
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? \IPS\core\Statuses\Status::load( \IPS\Request::i()->status ) : \IPS\core\Statuses\Reply::load( \IPS\Request::i()->reply );
|
||||
|
||||
$type = intval( \IPS\Request::i()->rep ) === 1 ? 1 : -1;
|
||||
$item->giveReputation( $type );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->reputationMini( $item ) );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->reputationMini( $item->reputation(), $item->canGiveReputation( 1 ), $item->canGiveReputation( -1 ), $item->url('showRep'), $item->url('rep') ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1275,7 +1312,7 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
$itemClass = '\IPS\core\Statuses\Status';
|
||||
$commentClass = '\IPS\core\Statuses\Reply';
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? $itemClass::load( \IPS\Request::i()->status ) : $commentClass::load( \IPS\Request::i()->status );
|
||||
$item = ( \IPS\Request::i()->type == 'status' ) ? $itemClass::load( \IPS\Request::i()->status ) : $commentClass::load( \IPS\Request::i()->reply );
|
||||
$canReport = $item->canReport();
|
||||
|
||||
if ( $canReport !== TRUE )
|
||||
@@ -1288,6 +1325,10 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$idColumn = ( \IPS\Request::i()->type == 'status' ) ? $itemClass::$databaseColumnId : $commentClass::$databaseColumnId;
|
||||
$autoSaveKey = ( \IPS\Request::i()->type == 'status' ) ? "report-{$itemClass::$application}-{$itemClass::$module}-{$item->$idColumn}" : "report-{$itemClass::$application}-{$itemClass::$module}-{$item->status_id}-{$item->$idColumn}";
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'report_message', NULL, FALSE, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => $autoSaveKey, 'minimize' => 'report_message_placeholder' ) ) );
|
||||
if( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Captcha );
|
||||
}
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$report = $item->report( $values['report_message'] );
|
||||
@@ -1332,98 +1373,6 @@ class _profile extends \IPS\Helpers\CoverPhoto\Controller
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('members_followers', FALSE, array( 'sprintf' => array( $this->member->name ) ) ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile' )->allFollowers( $this->member, $followers );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns status list and form
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getStatuses()
|
||||
{
|
||||
$statuses = array();
|
||||
$count = 0;
|
||||
|
||||
if ( !\IPS\Settings::i()->profile_comments OR !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'status' ) ) )
|
||||
{
|
||||
return array( 'statuses' => $statuses, 'form' => '', 'count' => $count );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->status )
|
||||
{
|
||||
try
|
||||
{
|
||||
$statuses = array( \IPS\core\Statuses\Status::loadAndCheckPerms( \IPS\Request::i()->status ) );
|
||||
$count = 1;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
if ( !count( $statuses ) )
|
||||
{
|
||||
$_where = !\IPS\core\Statuses\Status::modPermission( 'unhide' ) ? "status_approved=1 AND " : '';
|
||||
$count = \IPS\Db::i()->select( 'count(*)', 'core_member_status_updates', array( "{$_where} (status_member_id=? or status_author_id=?)", $this->member->member_id, $this->member->member_id ) )->first();
|
||||
|
||||
$start = ( intval( \IPS\Request::i()->statusPage ?: 1 ) - 1 ) * 25;
|
||||
|
||||
if( $start > $count )
|
||||
{
|
||||
$start = 0;
|
||||
\IPS\Request::i()->statusPage = 1;
|
||||
}
|
||||
|
||||
$statuses = new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select(
|
||||
'*',
|
||||
'core_member_status_updates',
|
||||
array( "{$_where} (status_member_id=? or status_author_id=?)", $this->member->member_id, $this->member->member_id ),
|
||||
'status_date DESC',
|
||||
array( $start, 25 )
|
||||
),
|
||||
'\IPS\core\Statuses\Status'
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\core\Statuses\Status::canCreate( \IPS\Member::loggedIn() ) AND !isset( \IPS\Request::i()->status ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->status_content_ajax ) )
|
||||
{
|
||||
\IPS\Request::i()->status_content = \IPS\Request::i()->status_content_ajax;
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'new_status', 'status_new' );
|
||||
foreach( \IPS\core\Statuses\Status::formElements() AS $k => $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$status = \IPS\core\Statuses\Status::createFromForm( $values );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'profile', 'core', 'front' )->statusContainer( $status ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $status->url() );
|
||||
}
|
||||
}
|
||||
|
||||
$formTpl = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'statusTemplate' ) );
|
||||
|
||||
if ( \IPS\core\Statuses\Status::moderateNewItems( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
$formTpl = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . $formTpl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$formTpl = NULL;
|
||||
}
|
||||
|
||||
return array( 'statuses' => $statuses, 'form' => $formTpl, 'count' => $count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Cover Photo Storage Extension
|
||||
|
||||
@@ -218,6 +218,7 @@ class _messenger extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
/* If we're searching, get the results */
|
||||
$perPage = 25;
|
||||
if ( \IPS\Request::i()->q )
|
||||
{
|
||||
$where[] = array( "( MATCH(core_message_topics.mt_title) AGAINST ('" . \IPS\Db::i()->escape_string( \IPS\Request::i()->q ) . "' IN BOOLEAN MODE) OR
|
||||
@@ -248,7 +249,7 @@ class _messenger extends \IPS\Content\Controller
|
||||
'core_message_posts',
|
||||
$where,
|
||||
( in_array( \IPS\Request::i()->sortBy, array( 'mt_last_post_time', 'mt_start_time', 'mt_replies' ) ) ? \IPS\Request::i()->sortBy : 'mt_last_post_time' ) . ' DESC',
|
||||
array( ( intval( \IPS\Request::i()->listPage ?: 1 ) - 1 ) * 25, 25 ),
|
||||
array( ( intval( \IPS\Request::i()->listPage ?: 1 ) - 1 ) * $perPage, $perPage ),
|
||||
'msg_topic_id'
|
||||
)->join(
|
||||
'core_message_topics',
|
||||
@@ -269,7 +270,7 @@ class _messenger extends \IPS\Content\Controller
|
||||
'core_message_topic_user_map',
|
||||
$where,
|
||||
( in_array( \IPS\Request::i()->sortBy, array( 'mt_last_post_time', 'mt_start_time', 'mt_replies' ) ) ? \IPS\Request::i()->sortBy : 'mt_last_post_time' ) . ' DESC',
|
||||
array( ( intval( \IPS\Request::i()->listPage ?: 1 ) - 1 ) * 25, 25 )
|
||||
array( ( intval( \IPS\Request::i()->listPage ?: 1 ) - 1 ) * $perPage, $perPage )
|
||||
)->join(
|
||||
'core_message_topics',
|
||||
'core_message_topic_user_map.map_topic_id=core_message_topics.mt_id'
|
||||
@@ -278,18 +279,20 @@ class _messenger extends \IPS\Content\Controller
|
||||
|
||||
/* Build the message list */
|
||||
$conversations = array();
|
||||
|
||||
foreach ( $iterator as $row )
|
||||
{
|
||||
$row['last_message'] = \IPS\core\Messenger\Conversation::load( $row['mt_id'] )->comments( 1, 0, 'date', 'desc' );
|
||||
$row['participants'] = \IPS\core\Messenger\Conversation::load( $row['mt_id'] )->participantBlurb();
|
||||
$conversations[ $row['mt_id'] ] = $row;
|
||||
}
|
||||
|
||||
|
||||
/* Note the last time we looked at the message list */
|
||||
\IPS\Member::loggedIn()->msg_count_reset = time();
|
||||
\IPS\core\Messenger\Conversation::rebuildMessageCounts( \IPS\Member::loggedIn() );
|
||||
|
||||
/* Display */
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl->setQueryString('_list', 1), ceil( $count / 25 ), ( \IPS\Request::i()->listPage ?: 1 ), 25, TRUE, 'listPage' );
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl->setQueryString('_list', 1), ceil( $count / $perPage ), ( \IPS\Request::i()->listPage ?: 1 ), $perPage, TRUE, 'listPage' );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
if( \IPS\Request::i()->id )
|
||||
@@ -302,7 +305,7 @@ class _messenger extends \IPS\Content\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('messaging')->messageListRows( $conversations, $pagination );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate('messaging')->messageListRows( $conversations, $pagination, TRUE ), 200, 'text/html' );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -664,10 +667,23 @@ class _messenger extends \IPS\Content\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$conversation = \IPS\core\Messenger\Conversation::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$conversation->deauthorize( \IPS\Member::loggedIn() );
|
||||
\IPS\core\Messenger\Conversation::rebuildMessageCounts( \IPS\Member::loggedIn() );
|
||||
|
||||
$ids = \IPS\Request::i()->id;
|
||||
|
||||
if ( !is_array( \IPS\Request::i()->id ) )
|
||||
{
|
||||
$ids = array( $ids );
|
||||
}
|
||||
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$conversation = \IPS\core\Messenger\Conversation::loadAndCheckPerms( $id );
|
||||
$conversation->deauthorize( \IPS\Member::loggedIn() );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array_merge( array( 'result' => 'success' ), $this->_getNewTotals() ) );
|
||||
|
||||
@@ -95,7 +95,7 @@ class _modcp extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $class::$commentClass ) and in_array( 'IPS\Content\Hideable', class_implements( $class::$commentClass ) ) )
|
||||
if ( in_array( 'IPS\Content\Item', class_parents( $class ) ) and $class::supportsComments( \IPS\Member::loggedIn() ) and in_array( 'IPS\Content\Hideable', class_implements( $class::$commentClass ) ) )
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
if ( \IPS\Member::loggedIn()->modPermission( 'can_view_hidden_content' ) or \IPS\Member::loggedIn()->modPermission( 'can_view_hidden_' . $commentClass::$title ) )
|
||||
@@ -104,7 +104,7 @@ class _modcp extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $class::$reviewClass ) and in_array( 'IPS\Content\Hideable', class_implements( $class::$reviewClass ) ) )
|
||||
if ( in_array( 'IPS\Content\Item', class_parents( $class ) ) and $class::supportsReviews( \IPS\Member::loggedIn() ) and in_array( 'IPS\Content\Hideable', class_implements( $class::$reviewClass ) ) )
|
||||
{
|
||||
$reviewClass = $class::$reviewClass;
|
||||
if ( \IPS\Member::loggedIn()->modPermission( 'can_view_hidden_content' ) or \IPS\Member::loggedIn()->modPermission( 'can_view_hidden_' . $reviewClass::$title ) )
|
||||
|
||||
@@ -32,29 +32,28 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Init stuff for the output */
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams.css' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/search.css' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/search_responsive.css' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_search.js', 'core' ) );
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex'; // Tell search engines not to index search pages
|
||||
|
||||
/* Get the form */
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
$form = $this->_form();
|
||||
|
||||
/* If we have the term, show the results */
|
||||
if ( \IPS\Request::i()->isAjax() or isset( \IPS\Request::i()->q ) or isset( \IPS\Request::i()->tags ) or ( \IPS\Request::i()->type == 'core_members' ) )
|
||||
if ( \IPS\Request::i()->isAjax() or isset( \IPS\Request::i()->q ) or isset( \IPS\Request::i()->tags ) or ( \IPS\Request::i()->type == 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) ) )
|
||||
{
|
||||
if ( !\IPS\Request::i()->isAjax() and !\IPS\Request::i()->q and !\IPS\Request::i()->tags and \IPS\Request::i()->type !== 'core_members' )
|
||||
if ( !\IPS\Request::i()->isAjax() and !\IPS\Request::i()->q and !\IPS\Request::i()->tags and \IPS\Request::i()->type !== 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->csrfKey ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('no_search_term');
|
||||
$form->hiddenValues['__advanced'] = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'advanced_search' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'advancedSearchForm' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), FALSE, FALSE, FALSE, $baseUrl, FALSE, $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, NULL ), 0, TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -68,8 +67,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Otherwise, show the advanced search form */
|
||||
else
|
||||
{
|
||||
$form->hiddenValues['__advanced'] = true;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'advanced_search' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'advancedSearchForm' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), FALSE, FALSE, FALSE, $baseUrl, FALSE, $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, NULL ), 0, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +87,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'q', \IPS\Request::i()->q );
|
||||
}
|
||||
elseif ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'tags', \IPS\Request::i()->tags );
|
||||
}
|
||||
|
||||
$types = $this->_contentTypes();
|
||||
|
||||
@@ -93,7 +98,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
\IPS\Request::floodCheck();
|
||||
|
||||
/* Are we searching members? */
|
||||
if ( isset( \IPS\Request::i()->type ) and \IPS\Request::i()->type === 'core_members' )
|
||||
if ( isset( \IPS\Request::i()->type ) and \IPS\Request::i()->type === 'core_members' and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members', 'front' ) ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
if ( \IPS\Request::i()->q )
|
||||
@@ -111,7 +116,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$$l = NULL;
|
||||
$key = "start_{$l}";
|
||||
if ( isset( \IPS\Request::i()->$key ) )
|
||||
if ( isset( \IPS\Request::i()->$key ) AND \IPS\Request::i()->$key != 'any' )
|
||||
{
|
||||
switch ( \IPS\Request::i()->$key )
|
||||
{
|
||||
@@ -252,8 +257,8 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array(
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( \IPS\Request::i()->q, $title, $results, $pagination, $baseUrl, $count ),
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $count ),
|
||||
'title' => $title,
|
||||
'css' => array()
|
||||
) );
|
||||
@@ -261,63 +266,16 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( \IPS\Request::i()->q, $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ), $count );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ), $count );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$query = \IPS\Content\Search\Query::init();
|
||||
|
||||
/* Work out the title */
|
||||
if ( \IPS\Request::i()->tags and !\IPS\Request::i()->q )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'tags', \IPS\Request::i()->tags );
|
||||
$tagList = array_map( function( $val )
|
||||
{
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '\'';
|
||||
}, explode( ',', \IPS\Request::i()->tags ) );
|
||||
$term = \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') );
|
||||
|
||||
$titleKey = 'search_results_title_tag';
|
||||
}
|
||||
else
|
||||
{
|
||||
$term = urldecode( \IPS\Request::i()->q );
|
||||
$titleKey = 'search_results_title_term';
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->type ) and array_key_exists( \IPS\Request::i()->type, $types ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, \IPS\Member::loggedIn()->language()->addToStack( \IPS\Request::i()->type . '_pl' ) ) ) );
|
||||
|
||||
if ( isset( \IPS\Request::i()->item ) )
|
||||
{
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
try
|
||||
{
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->item );
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, $item->mapped('title') ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->nodes ) and mb_strstr( \IPS\Request::i()->nodes, ',' ) === FALSE )
|
||||
{
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::loadAndCheckPerms( \IPS\Request::i()->nodes );
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey . '_area', FALSE, array( 'sprintf' => array( $term, $node->_title ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $titleKey, FALSE, array( 'sprintf' => array( $term ) ) );
|
||||
}
|
||||
|
||||
$titleConditions = array();
|
||||
$titleType = 'search_blurb_all_content';
|
||||
|
||||
/* Set content type */
|
||||
if ( isset( \IPS\Request::i()->type ) and array_key_exists( \IPS\Request::i()->type, $types ) )
|
||||
{
|
||||
@@ -326,41 +284,58 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
try
|
||||
{
|
||||
$query->filterByItem( $class::load( \IPS\Request::i()->item ) );
|
||||
$item = $class::loadAndCheckPerms( \IPS\Request::i()->item );
|
||||
$query->filterByContent( array( \IPS\Content\Search\ContentFilter::init( $class )->onlyInItems( array( \IPS\Request::i()->item ) ) ) );
|
||||
$baseUrl = $baseUrl->setQueryString( 'item', intval( \IPS\Request::i()->item ) );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_in', FALSE, array( 'sprintf' => array( $item->mapped('title') ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
$nodes = NULL;
|
||||
$filter = \IPS\Content\Search\ContentFilter::init( $types[ \IPS\Request::i()->type ] );
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
|
||||
if ( isset( \IPS\Request::i()->nodes ) )
|
||||
{
|
||||
$nodes = explode( ',', \IPS\Request::i()->nodes );
|
||||
$nodeClass = $types[ \IPS\Request::i()->type ]::$containerNodeClass;
|
||||
$node = $nodeClass::loadAndCheckPerms( \IPS\Request::i()->nodes );
|
||||
$filter->onlyInContainers( explode( ',', \IPS\Request::i()->nodes ) );
|
||||
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_in', FALSE, array( 'sprintf' => array( $node->_title ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$titleType = $types[ \IPS\Request::i()->type ]::$title . '_pl_lc';
|
||||
}
|
||||
|
||||
$query->filterByContent( $types[ \IPS\Request::i()->type ], $nodes, isset( \IPS\Request::i()->comments ) ? \IPS\Request::i()->comments : ( isset( \IPS\Request::i()->replies ) ? ( \IPS\Request::i()->replies + 1 ) : NULL ), isset( \IPS\Request::i()->reviews ) ? \IPS\Request::i()->reviews : NULL, isset( \IPS\Request::i()->views ) ? \IPS\Request::i()->views : NULL );
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
if ( $nodes )
|
||||
if ( isset( \IPS\Request::i()->search_min_comments ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
|
||||
$filter->minimumComments( \IPS\Request::i()->search_min_comments );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_comments', \IPS\Request::i()->search_min_comments );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_comments', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_comments ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->comments ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_replies ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'comments', \IPS\Request::i()->comments );
|
||||
$filter->minimumComments( \IPS\Request::i()->search_min_replies + 1 );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_replies', \IPS\Request::i()->search_min_replies );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_replies', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_replies ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->replies ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_reviews ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'replies', \IPS\Request::i()->replies );
|
||||
$filter->minimumReviews( \IPS\Request::i()->search_min_reviews );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_reviews', \IPS\Request::i()->search_min_reviews );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_reviews', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_reviews ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->reviews ) )
|
||||
if ( isset( \IPS\Request::i()->search_min_views ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'reviews', \IPS\Request::i()->reviews );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->views ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'views', \IPS\Request::i()->views );
|
||||
$filter->minimumViews( \IPS\Request::i()->search_min_views );
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_min_views', \IPS\Request::i()->search_min_views );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_min_views', FALSE, array( 'sprintf' => array( \IPS\Request::i()->search_min_views ) ) );
|
||||
}
|
||||
|
||||
$query->filterByContent( array( $filter ) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,6 +347,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$query->filterByAuthor( $author );
|
||||
$baseUrl = $baseUrl->setQueryString( 'author', $author->name );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_author', FALSE, array( 'sprintf' => array( $author->name ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,28 +368,36 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
case 'day':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_day' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_week' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1M' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_month' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'six_months':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P6M' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_6months' ) ) ) );
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$$l = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_rel_{$l}", FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_date_rel_year' ) ) ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
$$l = \IPS\DateTime::ts( \IPS\Request::i()->$$key );
|
||||
$dateCondition = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_{$l}", FALSE, array( 'sprintf' => array( $$l->localeDate() ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( "search_blurb_date_{$k}", FALSE, array( 'sprintf' => array( $dateCondition ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,6 +405,51 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Work out the title */
|
||||
if ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$tagList = array_map( function( $val )
|
||||
{
|
||||
return '\'' . htmlentities( $val, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '\'';
|
||||
}, explode( ',', \IPS\Request::i()->tags ) );
|
||||
}
|
||||
$title = '';
|
||||
if ( \IPS\Request::i()->q )
|
||||
{
|
||||
if ( \IPS\Request::i()->tags )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ) ) ) );
|
||||
$titleConditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_tag_condition', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term_or_tag', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ), \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_term', FALSE, array( 'sprintf' => array( urldecode( \IPS\Request::i()->q ) ) ) );
|
||||
}
|
||||
}
|
||||
elseif ( \IPS\Request::i()->tags )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_tag', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $tagList, \IPS\Member::loggedIn()->language()->get('or_list_format') ) ) ) );
|
||||
}
|
||||
if ( count( $titleConditions ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_conditions', FALSE, array( 'sprintf' => array( $title, \IPS\Member::loggedIn()->language()->addToStack( $titleType ), \IPS\Member::loggedIn()->language()->formatList( $titleConditions ) ) ) );
|
||||
}
|
||||
elseif ( $titleType != 'search_blurb_all_content' )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_with_type', FALSE, array( 'sprintf' => array( $title, \IPS\Member::loggedIn()->language()->addToStack( $titleType ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'search_blurb_no_conditions', FALSE, array( 'sprintf' => array( $title ) ) );
|
||||
}
|
||||
|
||||
/* Set page */
|
||||
if ( isset( \IPS\Request::i()->page ) AND intval( \IPS\Request::i()->page ) > 0 )
|
||||
{
|
||||
@@ -446,15 +475,30 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_CREATED );
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', 'newest' );
|
||||
/* Default to relevancy which is a total score of relevancy + date + title weighted search */
|
||||
$query->setOrder( \IPS\Content\Search\Query::ORDER_RELEVANCY );
|
||||
$baseUrl = $baseUrl->setQueryString( 'sortby', 'relevancy' );
|
||||
}
|
||||
|
||||
$flags = ( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' ) ? \IPS\Content\Search\Query::TERM_AND_TAGS : \IPS\Content\Search\Query::TERM_OR_TAGS;
|
||||
|
||||
if ( isset( \IPS\Request::i()->search_and_or ) and \IPS\Request::i()->search_and_or === 'or' )
|
||||
{
|
||||
$flags = $flags | \IPS\Content\Search\Query::TERM_OR_MODE;
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_and_or', \IPS\Request::i()->search_and_or );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->search_in ) and \IPS\Request::i()->search_in === 'titles' )
|
||||
{
|
||||
$flags = $flags | \IPS\Content\Search\Query::TERM_TITLES_ONLY;
|
||||
$baseUrl = $baseUrl->setQueryString( 'search_in', \IPS\Request::i()->search_in );
|
||||
}
|
||||
|
||||
/* Run query */
|
||||
$results = $query->excludeDisabledApps()->search(
|
||||
$results = $query->search(
|
||||
isset( \IPS\Request::i()->q ) ? ( \IPS\Request::i()->q ) : NULL,
|
||||
isset( \IPS\Request::i()->tags ) ? explode( ',', \IPS\Request::i()->tags ) : NULL,
|
||||
( isset( \IPS\Request::i()->eitherTermsOrTags ) and \IPS\Request::i()->eitherTermsOrTags === 'and' ) ? \IPS\Content\Search\Query::TERM_AND_TAGS : \IPS\Content\Search\Query::TERM_OR_TAGS
|
||||
$flags
|
||||
);
|
||||
|
||||
/* Get pagination */
|
||||
@@ -466,13 +510,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$pagination = trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $results->count( TRUE ) / $query->resultsToGet ), $page, $query->resultsToGet ) );
|
||||
|
||||
|
||||
/* Display results */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$count = $results->count( TRUE );
|
||||
\IPS\Output::i()->json( array(
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( htmlentities( $term, \IPS\HTMLENTITIES, 'UTF-8', FALSE ), $title, $results, $pagination, $baseUrl, $results->count( TRUE ) ),
|
||||
'filters' => $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ),
|
||||
'hints' => \IPS\Theme::i()->getTemplate( 'search' )->hints( $baseUrl, $count ),
|
||||
'content' => \IPS\Theme::i()->getTemplate( 'search' )->results( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $count ),
|
||||
'title' => $title,
|
||||
'css' => array()
|
||||
) );
|
||||
@@ -483,9 +529,10 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
'Cache-Control' => "max-age=" . 30 * 60 . ", public" );
|
||||
|
||||
\IPS\Output::i()->httpHeaders += $httpHeaders;
|
||||
|
||||
\IPS\Output::i()->title = $title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( htmlentities( $term, \IPS\HTMLENTITIES, 'UTF-8', FALSE ), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ) ), $results->count( TRUE ) );
|
||||
|
||||
$count = $results->count( TRUE );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('search_results_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'search' )->search( $this->_splitTermsForDisplay(), $title, $results, $pagination, $baseUrl, $types, $this->_form()->customTemplate( array( \IPS\Theme::i()->getTemplate( 'search' ), 'filters' ), $baseUrl, $count ), $count );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,12 +555,26 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
/* Types */
|
||||
$types = array( '' => 'search_everything' );
|
||||
$contentTypes = $this->_contentTypes();
|
||||
$contentToggles = array( 'tags', 'eitherTermsOrTags', 'author', 'elAdvancedSearch_dateFilters', 'startDate', 'updatedDate' );
|
||||
$contentToggles = array();
|
||||
$typeFields = array();
|
||||
$typeFieldToggles = array( '' => $contentToggles );
|
||||
$typeFieldToggles = array( '' => array( 'search_min_views', 'search_min_reviews', 'search_min_comments' ) );
|
||||
$haveCommentClass = FALSE;
|
||||
$haveReplyClass = FALSE;
|
||||
$haveReviewClass = FALSE;
|
||||
$dateOptions = array(
|
||||
'any' => 'any',
|
||||
'day' => 'last_24hr',
|
||||
'week' => 'last_week',
|
||||
'month' => 'last_month',
|
||||
'six_months' => 'six_months',
|
||||
'year' => 'year',
|
||||
'custom' => 'custom'
|
||||
);
|
||||
|
||||
/* Form tabs */
|
||||
$form->addTab( 'search_tab_all' );
|
||||
$form->addTab( 'search_tab_content' );
|
||||
$form->addTab( 'search_tab_member' );
|
||||
|
||||
/* Figure out member fields to set toggles */
|
||||
$memberToggles = array( 'joinedDate', 'core_members_group' );
|
||||
@@ -540,10 +601,6 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Type select */
|
||||
if ( isset( \IPS\Request::i()->type ) and isset( $contentTypes[ \IPS\Request::i()->type ] ) )
|
||||
{
|
||||
$contentTypes = array( $contentTypes[ \IPS\Request::i()->type ] );
|
||||
}
|
||||
foreach ( $contentTypes as $k => $class )
|
||||
{
|
||||
$types[ $k ] = $k . '_pl';
|
||||
@@ -569,36 +626,27 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$typeFieldToggles[ $k ][] = 'search_min_reviews';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$typeFieldToggles[ $k ] = $memberToggles;
|
||||
}
|
||||
$typeFieldToggles[ $k ][] = 'elAdvancedSearch_appFilters';
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'searchType', '', FALSE, array( 'options' => $types, 'toggles' => $typeFieldToggles ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'type', '', FALSE, array( 'options' => $types, 'toggles' => $typeFieldToggles ) ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Term */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'q' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'tags', \IPS\Request::i()->tags, FALSE, array( 'autocomplete' => array() ), NULL, NULL, NULL, 'tags' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'eitherTermsOrTags', \IPS\Request::i()->eitherTermsOrTags, FALSE, array( 'options' => array( 'or' => 'termsortags_or_desc', 'and' => 'termsortags_and_desc' ) ), NULL, NULL, NULL, 'eitherTermsOrTags' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'q' ), NULL, 'search_tab_all' );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'tags', \IPS\Request::i()->tags, FALSE, array( 'autocomplete' => array() ), NULL, NULL, NULL, 'tags' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'eitherTermsOrTags', \IPS\Request::i()->eitherTermsOrTags, FALSE, array( 'options' => array( 'or' => 'termsortags_or_desc', 'and' => 'termsortags_and_desc' ) ), NULL, NULL, NULL, 'eitherTermsOrTags' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Author */
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'author', NULL, FALSE, array(), NULL, NULL, NULL, 'author' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'author', NULL, FALSE, array(), NULL, NULL, NULL, 'author' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Dates */
|
||||
$dateOptions = array(
|
||||
'any' => 'any',
|
||||
'day' => 'last_24hr',
|
||||
'week' => 'last_week',
|
||||
'month' => 'last_month',
|
||||
'six_months' => 'six_months',
|
||||
'year' => 'year',
|
||||
'custom' => 'custom'
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'startDate', ( isset( \IPS\Request::i()->start_before ) or ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_startDate' ) ) ), NULL, NULL, NULL, 'startDate' ) );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'startDateCustom', array( 'start' => ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_after ) : NULL, 'end' => isset( \IPS\Request::i()->start_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_before ) : NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'updatedDate', ( isset( \IPS\Request::i()->updated_before ) or ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ) ? 'custom' : \IPS\Request::i()->updated_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_updatedDate' ) ) ), NULL, NULL, NULL, 'updatedDate' ) );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'updatedDateCustom', array( 'start' => ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_after ) : NULL, 'end' => isset( \IPS\Request::i()->updated_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_before ) : NULL ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'startDate', ( isset( \IPS\Request::i()->start_before ) or ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_startDate' ) ) ), NULL, NULL, NULL, 'startDate' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'startDateCustom', array( 'start' => ( isset( \IPS\Request::i()->start_after ) and is_numeric( \IPS\Request::i()->start_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_after ) : NULL, 'end' => isset( \IPS\Request::i()->start_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->start_before ) : NULL ) ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'updatedDate', ( isset( \IPS\Request::i()->updated_before ) or ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ) ? 'custom' : \IPS\Request::i()->updated_after, FALSE, array( 'options' => $dateOptions, 'toggles' => array( 'custom' => array( 'elCustomDate_updatedDate' ) ) ), NULL, NULL, NULL, 'updatedDate' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'updatedDateCustom', array( 'start' => ( isset( \IPS\Request::i()->updated_after ) and is_numeric( \IPS\Request::i()->updated_after ) ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_after ) : NULL, 'end' => isset( \IPS\Request::i()->updated_before ) ? \IPS\DateTime::ts( \IPS\Request::i()->updated_before ) : NULL ) ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Other filters */
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'search_in', \IPS\Request::i()->search_in, FALSE, array( 'options' => array( 'all' => 'titles_and_body', 'titles' => 'titles_only' ) ), NULL, NULL, NULL, 'searchIn' ), NULL, 'search_tab_content' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'search_and_or', \IPS\Request::i()->search_and_or, FALSE, array( 'options' => array( 'and' => 'search_and', 'or' => 'search_or' ) ), NULL, NULL, NULL, 'andOr' ), NULL, 'search_tab_content' );
|
||||
|
||||
/* Nodes */
|
||||
foreach ( $contentTypes as $k => $class )
|
||||
@@ -608,36 +656,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
$field = new \IPS\Helpers\Form\Node( 'nodes', ( isset( \IPS\Request::i()->nodes ) ) ? \IPS\Request::i()->nodes : NULL, FALSE, array( 'class' => $nodeClass, 'multiple' => TRUE, 'permissionCheck' => 'view', ), NULL, NULL, NULL, $k . '_node' );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle );
|
||||
$form->add( $field );
|
||||
$form->add( $field, NULL, 'search_tab_content' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Member group and joined */
|
||||
if( ( isset( \IPS\Request::i()->searchType ) and \IPS\Request::i()->searchType === 'core_members' ) or !isset( \IPS\Request::i()->q ) )
|
||||
{
|
||||
$form->add(new \IPS\Helpers\Form\CheckboxSet('group', (isset(\IPS\Request::i()->group)) ? array_keys(\IPS\Request::i()->group) : array(), FALSE, array('options' => \IPS\Member\Group::groups(TRUE, FALSE), 'parse' => 'normal'), NULL, NULL, NULL, 'core_members_group'));
|
||||
$form->add(new \IPS\Helpers\Form\Select('joinedDate', (isset(\IPS\Request::i()->start_before) or (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after))) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array('options' => $dateOptions, 'toggles' => array('custom' => array('elCustomDate_joinedDate'))), NULL, NULL, NULL, 'joinedDate'));
|
||||
$form->add(new \IPS\Helpers\Form\DateRange('joinedDateCustom', array('start' => (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after)) ? \IPS\DateTime::ts(\IPS\Request::i()->start_after) : NULL, 'end' => isset(\IPS\Request::i()->start_before) ? \IPS\DateTime::ts(\IPS\Request::i()->start_before) : NULL)));
|
||||
}
|
||||
|
||||
/* Comments/Views */
|
||||
$queryClass = \IPS\Content\Search\Query::init();
|
||||
if ( $queryClass::SUPPORTS_JOIN_FILTERS )
|
||||
{
|
||||
if ( $haveCommentClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_comments', isset( \IPS\Request::i()->comments ) ? \IPS\Request::i()->comments : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_comments' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_comments', isset( \IPS\Request::i()->search_min_comments ) ? \IPS\Request::i()->search_min_comments : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_comments' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
if ( $haveReplyClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_replies', isset( \IPS\Request::i()->replies ) ? \IPS\Request::i()->replies : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_replies' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_replies', isset( \IPS\Request::i()->search_min_replies ) ? \IPS\Request::i()->search_min_replies : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_replies' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
if ( $haveReviewClass )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_reviews', isset( \IPS\Request::i()->reviews ) ? \IPS\Request::i()->reviews : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_reviews' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_reviews', isset( \IPS\Request::i()->search_min_reviews ) ? \IPS\Request::i()->search_min_reviews : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_reviews' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_views', isset( \IPS\Request::i()->views ) ? \IPS\Request::i()->views : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_views' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'search_min_views', isset( \IPS\Request::i()->search_min_views ) ? \IPS\Request::i()->search_min_views : 0, FALSE, array(), NULL, NULL, NULL, 'search_min_views' ), NULL, 'search_tab_content' );
|
||||
}
|
||||
|
||||
/* Member group and joined */
|
||||
$groups = \IPS\Member\Group::groups(TRUE, FALSE);
|
||||
$form->add(new \IPS\Helpers\Form\CheckboxSet('group', (isset(\IPS\Request::i()->group)) ? array_keys(\IPS\Request::i()->group) : array_keys( $groups ), FALSE, array('options' => $groups, 'parse' => 'normal'), NULL, NULL, NULL, 'core_members_group'), NULL, 'search_tab_member' );
|
||||
$form->add(new \IPS\Helpers\Form\Select('joinedDate', (isset(\IPS\Request::i()->start_before) or (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after))) ? 'custom' : \IPS\Request::i()->start_after, FALSE, array('options' => $dateOptions, 'toggles' => array('custom' => array('elCustomDate_joinedDate'))), NULL, NULL, NULL, 'joinedDate'), NULL, 'search_tab_member' );
|
||||
$form->add(new \IPS\Helpers\Form\DateRange('joinedDateCustom', array('start' => (isset(\IPS\Request::i()->start_after) and is_numeric(\IPS\Request::i()->start_after)) ? \IPS\DateTime::ts(\IPS\Request::i()->start_after) : NULL, 'end' => isset(\IPS\Request::i()->start_before) ? \IPS\DateTime::ts(\IPS\Request::i()->start_before) : NULL)), NULL, 'search_tab_member' );
|
||||
|
||||
/* Profile fields for member searches */
|
||||
$memberFields = array();
|
||||
@@ -697,15 +743,15 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach( $fieldsToAdd as $field )
|
||||
{
|
||||
$form->add( $field );
|
||||
$form->add( $field, NULL, 'search_tab_member' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If they submitted the advanced search form, redirect back (searching is a GET not a POST) */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if( !\IPS\Request::i()->isAjax() AND ( ( $values['q'] or $values['tags'] ) or $values['searchType'] == 'core_members' ) )
|
||||
if( !\IPS\Request::i()->isAjax() AND ( ( $values['q'] or $values['tags'] ) or $values['type'] == 'core_members' ) )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( 'app=core&module=search&controller=search', 'front', 'search' );
|
||||
|
||||
@@ -721,13 +767,13 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$url = $url->setQueryString( 'eitherTermsOrTags', $values['eitherTermsOrTags'] );
|
||||
}
|
||||
if ( $values['searchType'] )
|
||||
if ( $values['type'] )
|
||||
{
|
||||
$url = $url->setQueryString( 'type', $values['searchType'] );
|
||||
$url = $url->setQueryString( 'type', $values['type'] );
|
||||
|
||||
if ( isset( $values[ $values['searchType'] . '_node' ] ) and !empty( $values[ $values['searchType'] . '_node' ] ) )
|
||||
if ( isset( $values[ $values['type'] . '_node' ] ) and !empty( $values[ $values['type'] . '_node' ] ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'nodes', implode( ',', array_keys( $values[ $values['searchType'] . '_node' ] ) ) );
|
||||
$url = $url->setQueryString( 'nodes', implode( ',', array_keys( $values[ $values['type'] . '_node' ] ) ) );
|
||||
}
|
||||
|
||||
if ( isset( $values['search_min_comments'] ) and $values['search_min_comments'] )
|
||||
@@ -771,7 +817,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$url = $url->setQueryString( $fieldName, $values[ $fieldName ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( isset( $values['joinedDate'] ) AND $values['joinedDate'] != 'custom' )
|
||||
{
|
||||
$url = $url->setQueryString( 'start_after', $values['joinedDate'] );
|
||||
@@ -825,19 +871,34 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
$types = array();
|
||||
foreach ( \IPS\Content::routedClasses( TRUE, FALSE, TRUE ) as $class )
|
||||
{
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) and $class::$includeInSiteSearch )
|
||||
{
|
||||
$key = mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) );
|
||||
$types[ $key ] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Application\Module::get( 'core', 'members', 'front' )->can('view') )
|
||||
{
|
||||
$types['core_members'] = 'IPS\Member';
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the search term into distinct matches
|
||||
* e.g. one "two three" beccomes ['one', 'two three']
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _splitTermsForDisplay()
|
||||
{
|
||||
if( !isset( \IPS\Request::i()->q ) ){
|
||||
return json_encode( array() );
|
||||
}
|
||||
|
||||
return $types;
|
||||
$words = preg_split("/[\s]*\\\"([^\\\"]+)\\\"[\s]*|[\s]*'([^']+)'[\s]*|[\s]+/", \IPS\Request::i()->q, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
foreach( $words as $idx => $word ){
|
||||
$words[ $idx ] = htmlentities( $word, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
|
||||
return json_encode( $words );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -847,6 +908,6 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function globalFilterOptions()
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'search' )->globalSearchMenuOptions() );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'search' )->globalSearchMenuOptions( \IPS\Request::i()->checked ) );
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class _ajaxcreate extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->error('node_error', '2C231/2', 403, '');
|
||||
}
|
||||
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id and !\IPS\Member::loggedIn()->pp_setting_count_comments )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Member::loggedIn()->url()->setQueryString( 'tab', 'statuses' ) );
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Status Updates Feed
|
||||
* @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 15 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\status;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status Updates Feed
|
||||
*/
|
||||
class _feed extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Status Updates Feed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
if ( !\IPS\Settings::i()->profile_comments )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C231/2', 403, '' );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->following ) AND !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C231/1', 403, '' );
|
||||
}
|
||||
|
||||
$where = array();
|
||||
$statuses = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->following ) )
|
||||
{
|
||||
$members = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_member_id=?', 'core', 'member', \IPS\Member::loggedIn()->member_id ) ) AS $follow )
|
||||
{
|
||||
$members[] = $follow['follow_rel_id'];
|
||||
}
|
||||
|
||||
if ( count( $members ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'status_author_id', $members ) . ' OR ' . \IPS\Db::i()->in( 'status_member_id', $members ) );
|
||||
}
|
||||
}
|
||||
$statuses = array();
|
||||
if ( !isset( \IPS\Request::i()->following ) OR count( $where ) > 0 )
|
||||
{
|
||||
$offset = ( intval( ( \IPS\Request::i()->statusPage AND \IPS\Request::i()->statusPage > 0 ) ? \IPS\Request::i()->statusPage : 1 ) - 1 ) * 25;
|
||||
$select = \IPS\core\Statuses\Status::getItemsWithPermission( $where, NULL, array( $offset, 25 ), 'read', NULL );
|
||||
$statuses['count'] = (int) \IPS\Db::i()->select( 'COUNT(*)', 'core_member_status_updates' )->first();
|
||||
|
||||
$statuses['statuses'] = iterator_to_array( $select );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'status_updates' );
|
||||
|
||||
if ( isset( \IPS\Request::i()->following ) )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'people_i_follow' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/statuses.css' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/statuses_responsive.css' ) );
|
||||
}
|
||||
|
||||
if ( \IPS\core\Statuses\Status::canCreate( \IPS\Member::loggedIn() ) AND !isset( \IPS\Request::i()->following ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'new_status', 'status_new' );
|
||||
foreach( \IPS\core\Statuses\Status::formElements() AS $k => $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$status = \IPS\core\Statuses\Status::createFromForm( $values );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'profile', 'core', 'front' )->statusContainer( $status ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $status->url() );
|
||||
}
|
||||
}
|
||||
|
||||
$formTpl = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'statusTemplate' ) );
|
||||
|
||||
if ( \IPS\core\Statuses\Status::moderateNewItems( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
$formTpl = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . $formTpl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$formTpl = NULL;
|
||||
}
|
||||
|
||||
$pagination = ( isset( $statuses['count'] ) ) ? trim( \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( isset( \IPS\Request::i()->following ) ? \IPS\Http\Url::internal( 'app=core&module=status&controller=feed&following=1', NULL, 'status_following' ) : \IPS\Http\Url::internal( 'app=core&module=status&controller=feed', NULL, 'status' ), ceil( $statuses['count'] / 25 ), \IPS\Request::i()->statusPage ?: 1, 25, TRUE, 'statusPage' ) ) : NULL;
|
||||
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'status' )->feed( $statuses, $formTpl, $pagination );
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
$results[] = array(
|
||||
'id' => $member->member_id,
|
||||
'value' => $member->name,
|
||||
'name' => \IPS\Dispatcher::i()->controllerLocation == 'admin' ? $member->group['prefix'] . htmlentities( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . $member->group['suffix'] : htmlentities( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'name' => \IPS\Dispatcher::i()->controllerLocation == 'admin' ? $member->group['prefix'] . htmlspecialchars( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . $member->group['suffix'] : htmlspecialchars( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'extra' => \IPS\Dispatcher::i()->controllerLocation == 'admin' ? $member->email : $member->groupName,
|
||||
'photo' => (string) $member->photo,
|
||||
);
|
||||
@@ -194,7 +194,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
public function topContributors()
|
||||
{
|
||||
/* How many? */
|
||||
$limit = intval( ( isset( \IPS\Request::i()->limit ) and \IPS\Request::i()->limit < 20 ) ? \IPS\Request::i()->limit : 5 );
|
||||
$limit = intval( ( isset( \IPS\Request::i()->limit ) and \IPS\Request::i()->limit <= 25 ) ? \IPS\Request::i()->limit : 5 );
|
||||
|
||||
/* What timeframe? */
|
||||
$where = array( array( 'member_received > 0' ) );
|
||||
@@ -240,4 +240,86 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->output = $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu Preview
|
||||
*
|
||||
* @retun void
|
||||
*/
|
||||
public function menuPreview()
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->theme ) )
|
||||
{
|
||||
\IPS\Theme::switchTheme( \IPS\Request::i()->theme, FALSE );
|
||||
}
|
||||
|
||||
$preview = \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->navBar( TRUE );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/menumanager.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'applications', 'core', 'admin' )->menuPreviewWrapper( $preview ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Instant Notifications
|
||||
*
|
||||
* @retun void
|
||||
*/
|
||||
public function instantNotifications()
|
||||
{
|
||||
/* If auto-polling isn't enabled, kill the polling now */
|
||||
if ( !\IPS\Settings::i()->auto_polling_enabled )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'error' => 'auto_polling_disabled' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the intitial counts */
|
||||
$return = array( 'notifications' => array( 'count' => \IPS\Member::loggedIn()->notification_cnt, 'data' => array() ), 'messages' => array( 'count' => \IPS\Member::loggedIn()->msg_count_new, 'data' => array() ) );
|
||||
|
||||
/* If there's new notifications, get the actual data */
|
||||
if ( \IPS\Request::i()->notifications < $return['notifications']['count'] )
|
||||
{
|
||||
$notificationsDifference = $return['notifications']['count'] - \IPS\Request::i()->notifications;
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_notifications', array( 'member=? AND ( read_time IS NULL OR read_time<? )', \IPS\Member::loggedIn()->member_id, time() ), 'updated_time DESC', $notificationsDifference ), 'IPS\Notification\Inline' ) as $notification )
|
||||
{
|
||||
$data = $notification->getData();
|
||||
|
||||
$return['notifications']['data'][] = array(
|
||||
'id' => $notification->id,
|
||||
'title' => $data['title'],
|
||||
'url' => (string) $data['url'],
|
||||
'content' => isset( $data['content'] ) ? $data['content'] : NULL,
|
||||
'date' => $notification->updated_time->getTimestamp(),
|
||||
'author_photo' => $data['author'] ? $data['author']->photo : NULL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* If there's new messages, get the actual data */
|
||||
if ( !\IPS\Member::loggedIn()->members_disable_pm and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'messaging' ) ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->messages < $return['messages']['count'] )
|
||||
{
|
||||
$messagesDifference = $return['messages']['count'] - \IPS\Request::i()->messages;
|
||||
|
||||
foreach ( \IPS\Db::i()->select( 'map_topic_id', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1 AND map_has_unread=1 AND map_ignore_notification=0', \IPS\Member::loggedIn()->member_id ), 'map_last_topic_reply DESC', $messagesDifference ) as $conversationId )
|
||||
{
|
||||
$conversation = \IPS\core\Messenger\Conversation::load( $conversationId );
|
||||
$message = $conversation->comments( 1, 0, 'date', 'desc' );
|
||||
|
||||
$return['messages']['data'][] = array(
|
||||
'id' => $conversation->id,
|
||||
'title' => $conversation->title,
|
||||
'url' => (string) $conversation->url()->setQueryString( 'latest', 1 ),
|
||||
'message' => $message->truncated(),
|
||||
'date' => $message->mapped('date'),
|
||||
'author_photo' => (string) $message->author()->photo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* And return */
|
||||
\IPS\Output::i()->json( $return );
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,18 @@ class _editor extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function link()
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->link( \IPS\Request::i()->current, \IPS\Request::i()->editorId );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->link( \IPS\Request::i()->current, \IPS\Request::i()->editorId, isset( \IPS\Request::i()->block ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Code Dialog
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function code()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'codemirror/codemirror.css', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->code( \IPS\Request::i()->val, \IPS\Request::i()->editorId, md5( uniqid() ), \IPS\Request::i()->lang ?: 'html' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,21 +54,20 @@ class _editor extends \IPS\Dispatcher\Controller
|
||||
$maxImageDims = \IPS\Settings::i()->attachment_image_size ? explode( 'x', \IPS\Settings::i()->attachment_image_size ) : array( 1000, 750 );
|
||||
$maxWidth = ( \IPS\Request::i()->actualWidth < $maxImageDims[0] ) ? \IPS\Request::i()->actualWidth : $maxImageDims[0];
|
||||
$maxHeight = ( \IPS\Request::i()->actualHeight < $maxImageDims[1] ) ? \IPS\Request::i()->actualHeight : $maxImageDims[1];
|
||||
|
||||
$ratio = round( \IPS\Request::i()->height / \IPS\Request::i()->width, 2 );
|
||||
|
||||
if ( \IPS\Request::i()->width > $maxWidth )
|
||||
{
|
||||
$ratio = \IPS\Request::i()->height / \IPS\Request::i()->width;
|
||||
{
|
||||
\IPS\Request::i()->width = $maxWidth;
|
||||
\IPS\Request::i()->height = floor( \IPS\Request::i()->width * $ratio );
|
||||
}
|
||||
if ( \IPS\Request::i()->height > $maxHeight )
|
||||
{
|
||||
$ratio = \IPS\Request::i()->height / \IPS\Request::i()->width;
|
||||
\IPS\Request::i()->height = $maxHeight;
|
||||
\IPS\Request::i()->width = floor( \IPS\Request::i()->height * $ratio );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->image( \IPS\Request::i()->editorId, \IPS\Request::i()->width, \IPS\Request::i()->height, $maxWidth, $maxHeight, \IPS\Request::i()->border, \IPS\Request::i()->margin, \IPS\Request::i()->float, \IPS\Request::i()->link );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'editor', 'core', 'global' )->image( \IPS\Request::i()->editorId, \IPS\Request::i()->width, \IPS\Request::i()->height, $maxWidth, $maxHeight, \IPS\Request::i()->float, \IPS\Request::i()->link, $ratio );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,6 +149,9 @@ class _editor extends \IPS\Dispatcher\Controller
|
||||
|
||||
$emoticons[ $row['emo_set'] ]['emoticons'][] = array(
|
||||
'src' => \IPS\File::get( 'core_Emoticons', $row['image'] )->url,
|
||||
'srcset' => $row['image_2x'] ? \IPS\File::get( 'core_Emoticons', $row['image_2x'] )->url . ' 2x' : FALSE,
|
||||
'height' => $row['height'] ?: FALSE,
|
||||
'width' => $row['width'] ?: FALSE,
|
||||
'text' => $row['typed']
|
||||
);
|
||||
}
|
||||
@@ -159,7 +172,7 @@ class _editor extends \IPS\Dispatcher\Controller
|
||||
protected function myMedia()
|
||||
{
|
||||
/* Init */
|
||||
$perPage = 7;
|
||||
$perPage = 12;
|
||||
$search = isset( \IPS\Request::i()->search ) ? \IPS\Request::i()->search : null;
|
||||
|
||||
/* Get all our available sources */
|
||||
|
||||
@@ -109,9 +109,10 @@ class _followed extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('my_followed_content');
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_system.js', 'core' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu_followed_content');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('my_followed_content') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('menu_followed_content') );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->followedContent( $types, $currentAppModule, $currentType, $output );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,7 +324,10 @@ class _ignore extends \IPS\Dispatcher\Controller
|
||||
$ignore->ignore_id = $member->member_id;
|
||||
$ignore->save();
|
||||
}
|
||||
|
||||
|
||||
\IPS\Member::loggedIn()->members_bitoptions['has_no_ignored_users'] = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'result' => 'ok' ) );
|
||||
|
||||
@@ -91,6 +91,7 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
/* Display Login Form */
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('login');
|
||||
@@ -117,7 +118,7 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
\IPS\Request::i()->setCookie( 'anon_login', 1 );
|
||||
}
|
||||
|
||||
$member->checkLoginKey();
|
||||
\IPS\Session::i()->setMember( $member );
|
||||
|
||||
if ( $rememberMe )
|
||||
{
|
||||
@@ -202,7 +203,16 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$redirectUrl = ( !empty( $_SERVER['HTTP_REFERER'] ) ) ? \IPS\Http\Url::external( $_SERVER['HTTP_REFERER'] ) : \IPS\Http\Url::internal( '' );
|
||||
if( !empty( $_SERVER['HTTP_REFERER'] ) )
|
||||
{
|
||||
$referrer = new \IPS\Http\Url( $_SERVER['HTTP_REFERER'] );
|
||||
$redirectUrl = ( $referrer->isInternal and isset( $referrer->queryString['do'] ) and $referrer->queryString['do'] != 'validating' ) ? $referrer : \IPS\Http\Url::internal('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirectUrl = \IPS\Http\Url::internal( '' );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::loggedIn();
|
||||
|
||||
/* Are we logging out back to an admin user? */
|
||||
|
||||
@@ -111,7 +111,7 @@ class _metatags extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'meta_editor_no_admin', '2C155/1', 403, '' );
|
||||
}
|
||||
|
||||
if( !\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'seo_manage' ) )
|
||||
if( !\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'seo_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'meta_editor_no_acpperm', '3C155/2', 403, '' );
|
||||
}
|
||||
|
||||
@@ -115,7 +115,21 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
'daily' => \IPS\Member::loggedIn()->language()->addToStack('follow_type_daily'),
|
||||
'weekly' => \IPS\Member::loggedIn()->language()->addToStack('follow_type_weekly')
|
||||
) ), NULL, NULL, NULL, 'auto_track_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'show_pm_popup', \IPS\Member::loggedIn()->members_bitoptions['show_pm_popup'] ) );
|
||||
/* Changed in 4.1: since email_notifications_once is new, combined show_pm_popup in and made a checkbox set for better organization */
|
||||
$notificationPrefValues = array();
|
||||
if ( \IPS\Member::loggedIn()->members_bitoptions['show_pm_popup'] )
|
||||
{
|
||||
$notificationPrefValues[] = 'show_pm_popup';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->members_bitoptions['email_notifications_once'] )
|
||||
{
|
||||
$notificationPrefValues[] = 'email_notifications_once';
|
||||
}
|
||||
if ( !\IPS\Member::loggedIn()->members_bitoptions['disable_notification_sounds'] )
|
||||
{
|
||||
$notificationPrefValues[] = 'enable_notification_sounds';
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'notification_prefs', $notificationPrefValues, FALSE, array( 'options' => array( 'show_pm_popup' => 'show_pm_popup', 'email_notifications_once' => 'email_notifications_once', 'enable_notification_sounds' => 'enable_notification_sounds' ), 'multiple' => TRUE ) ) );
|
||||
$form->addMatrix( 'notifications', \IPS\Notification::buildMatrix( \IPS\Member::loggedIn() ) );
|
||||
|
||||
/* Handle submissions */
|
||||
@@ -127,21 +141,34 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
'comments' => ( is_array( $values['auto_track'] ) AND in_array( 'comments', $values['auto_track'] ) ) ? 1 : 0,
|
||||
'method' => $values['auto_track_type']
|
||||
) );
|
||||
\IPS\Member::loggedIn()->members_bitoptions['show_pm_popup'] = $values['show_pm_popup'];
|
||||
if ( isset( $values['notifications']['report_center'] ) and !$values['notifications']['report_center']['member_notifications_inline'] )
|
||||
|
||||
\IPS\Member::loggedIn()->members_bitoptions['show_pm_popup'] = ( is_array( $values['notification_prefs'] ) AND in_array( 'show_pm_popup', $values['notification_prefs'] ) ) ? 1 : 0;
|
||||
\IPS\Member::loggedIn()->members_bitoptions['email_notifications_once'] = ( is_array( $values['notification_prefs'] ) AND in_array( 'email_notifications_once', $values['notification_prefs'] ) ) ? 1 : 0;
|
||||
\IPS\Member::loggedIn()->members_bitoptions['disable_notification_sounds'] = ( is_array( $values['notification_prefs'] ) AND in_array( 'enable_notification_sounds', $values['notification_prefs'] ) ) ? 0 : 1;
|
||||
|
||||
\IPS\Notification::saveMatrix( \IPS\Member::loggedIn(), $values );
|
||||
|
||||
/* Refetch config to see if inline report center notification is set. We have to do this because if toggling report center
|
||||
option is disabled but inline is forced on by the admin, the setting won't be included in the $values array but the saveMatrix()
|
||||
method will automatically set it and calling notificationsConfiguration() will pull the data directly from the db. */
|
||||
$config = \IPS\Member::loggedIn()->notificationsConfiguration();
|
||||
|
||||
if ( isset( $config['report_center'] ) and !in_array( 'inline', $config['report_center'] ) )
|
||||
{
|
||||
\IPS\Member::loggedIn()->members_bitoptions['no_report_count'] = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->members_bitoptions['no_report_count'] = FALSE;
|
||||
}
|
||||
\IPS\Notification::saveMatrix( \IPS\Member::loggedIn(), $values );
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->save();
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=notifications&do=options', 'front', 'notifications_options' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_system.js', 'core' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/notification_settings.css' ) );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'system' ), 'notificationsSettings' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notification_options');
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=system&controller=notifications', 'front', 'notifications' ), \IPS\Member::loggedIn()->language()->addToStack('notifications') );
|
||||
@@ -218,6 +245,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Get thing */
|
||||
$thing = NULL;
|
||||
$indexId = NULL;
|
||||
try
|
||||
{
|
||||
if ( in_array( 'IPS\Node\Model', class_parents( $class ) ) )
|
||||
@@ -240,6 +268,13 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$thing = $class::loadAndCheckPerms( \IPS\Request::i()->follow_id );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'follow_thing', FALSE, array( 'sprintf' => array( $thing->mapped('title') ) ) );
|
||||
|
||||
/* Work out the index ID */
|
||||
try
|
||||
{
|
||||
$indexId = \IPS\Content\Search\Index::i()->getIndexId( $thing );
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
/* Set navigation */
|
||||
$container = NULL;
|
||||
@@ -259,7 +294,8 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$thing = $class::load( \IPS\Request::i()->follow_id );
|
||||
$thing = $class::load( \IPS\Request::i()->follow_id );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('follow_thing', FALSE, array( 'sprintf' => array( $thing->name ) ) );
|
||||
|
||||
/* Set navigation */
|
||||
@@ -386,7 +422,8 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
'follow_notify_meta' => '',
|
||||
'follow_notify_freq' => ( $class == "IPS\Member" ) ? 'immediate' : $values['follow_type'],
|
||||
'follow_notify_sent' => 0,
|
||||
'follow_visible' => 1
|
||||
'follow_visible' => 1,
|
||||
'follow_index_id' => $indexId,
|
||||
);
|
||||
if ( $current )
|
||||
{
|
||||
@@ -634,13 +671,27 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2C154/6', 404, '' );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->follow_area == 'member' )
|
||||
if ( \IPS\Request::i()->follow_area == 'member' && ( !isset( \IPS\Request::i()->button_type ) || \IPS\Request::i()->button_type === 'search' ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile' )->memberFollowButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id, $count );
|
||||
if ( isset( \IPS\Request::i()->button_type ) && \IPS\Request::i()->button_type === 'search' )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile' )->memberSearchFollowButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id, $count );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'profile' )->memberFollowButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id, $count );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->followButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id, $count );
|
||||
if ( \IPS\Request::i()->button_type == 'manage' )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->manageFollowButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->followButton( \IPS\Request::i()->follow_app, \IPS\Request::i()->follow_area, \IPS\Request::i()->follow_id, $count );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,8 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->allow_reg and \IPS\Request::i()->do !== 'complete'
|
||||
and \IPS\Request::i()->do !== 'changeEmail' and \IPS\Request::i()->do !== 'validate' and \IPS\Request::i()->do !== 'validating' )
|
||||
and \IPS\Request::i()->do !== 'changeEmail' and \IPS\Request::i()->do !== 'validate'
|
||||
and \IPS\Request::i()->do !== 'validating' and \IPS\Request::i()->do !== 'reconfirm' )
|
||||
{
|
||||
\IPS\Output::i()->error( 'reg_disabled', '2S129/5', 403, '' );
|
||||
}
|
||||
@@ -152,7 +153,7 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Set Session Location */
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=core&module=system&controller=register', NULL, 'register' ), array(), 'loc_registering' );
|
||||
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('registration');
|
||||
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( $steps, \IPS\Http\Url::internal( 'app=core&module=system&controller=register' ), FALSE );
|
||||
}
|
||||
@@ -447,10 +448,20 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Member::loggedIn()->email = $values['email_address'];
|
||||
|
||||
if( \IPS\Member::loggedIn()->spamService() == 4 )
|
||||
if( \IPS\Settings::i()->spam_service_enabled )
|
||||
{
|
||||
\IPS\Member::loggedIn()->delete();
|
||||
\IPS\Output::i()->error( 'spam_denied_account', '2S272/1', 403, '' );
|
||||
if( \IPS\Member::loggedIn()->spamService() == 4 )
|
||||
{
|
||||
$action = \IPS\Settings::i()->spam_service_action_4;
|
||||
|
||||
/* Any other action will automatically be handled by the call to spamService() */
|
||||
if( $action == 4 )
|
||||
{
|
||||
\IPS\Member::loggedIn()->delete();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( 'spam_denied_account', '2S272/1', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/* If email validation is enabled add a validating record */
|
||||
@@ -570,4 +581,37 @@ class _register extends \IPS\Dispatcher\Controller
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( '' ), 'reg_canceled' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconfirm terms or privacy policy
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reconfirm()
|
||||
{
|
||||
/* Generate form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'reconfirm_checkbox', NULL, FALSE, array(), function( $val )
|
||||
{
|
||||
if ( !$val )
|
||||
{
|
||||
throw new \InvalidArgumentException('reg_not_agreed_terms');
|
||||
}
|
||||
} ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->members_bitoptions['must_reaccept_privacy'] = FALSE;
|
||||
\IPS\Member::loggedIn()->members_bitoptions['must_reaccept_terms'] = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('') );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('terms_of_use');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('system')->reconfirmTerms( \IPS\Member::loggedIn()->members_bitoptions['must_reaccept_terms'], \IPS\Member::loggedIn()->members_bitoptions['must_reaccept_privacy'], $form );
|
||||
}
|
||||
}
|
||||
@@ -507,7 +507,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$options['export'] = \IPS\Member::loggedIn()->language()->addToStack('profilesync_export_status', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $serviceName ) ) ) );
|
||||
}
|
||||
$options[''] = \IPS\Member::loggedIn()->language()->addToStack('profilesync_status_none');
|
||||
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack('profilesync_status_none');
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'profilesync_status', $settings['status'], FALSE, array(
|
||||
'labelSprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $serviceName ) ),
|
||||
|
||||
@@ -1,694 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief New Content
|
||||
* @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 18 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\front\system;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* New Content
|
||||
*/
|
||||
class _vnc extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* New Content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
/* Flood control */
|
||||
\IPS\Request::floodCheck();
|
||||
|
||||
if( isset( \IPS\Request::i()->nodes ) )
|
||||
{
|
||||
\IPS\Request::i()->nodes = urldecode( \IPS\Request::i()->nodes );
|
||||
}
|
||||
|
||||
/* Logged in only */
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission_guest', '2C232/1', 403, '' );
|
||||
}
|
||||
elseif( !\IPS\Request::i()->updateFilters )
|
||||
{
|
||||
$preferences = json_decode( \IPS\Member::loggedIn()->vnc_preferences, TRUE );
|
||||
|
||||
if( isset( $preferences['onlyFollowed'] ) AND !isset( \IPS\Request::i()->onlyFollowed ) )
|
||||
{
|
||||
\IPS\Request::i()->onlyFollowed = $preferences['onlyFollowed'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['onlyParticipated'] ) AND !isset( \IPS\Request::i()->onlyParticipated ) )
|
||||
{
|
||||
\IPS\Request::i()->onlyParticipated = $preferences['onlyParticipated'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['onlyStarted'] ) AND !isset( \IPS\Request::i()->onlyStarted ) )
|
||||
{
|
||||
\IPS\Request::i()->onlyStarted = $preferences['onlyStarted'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['onlyUnread'] ) AND !isset( \IPS\Request::i()->onlyUnread ) )
|
||||
{
|
||||
\IPS\Request::i()->onlyUnread = $preferences['onlyUnread'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['searchType'] ) AND !isset( \IPS\Request::i()->type ) )
|
||||
{
|
||||
\IPS\Request::i()->type = $preferences['searchType'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['vncTimePeriod'] ) AND !isset( \IPS\Request::i()->vncTimePeriod ) )
|
||||
{
|
||||
\IPS\Request::i()->vncTimePeriod = $preferences['vncTimePeriod'];
|
||||
}
|
||||
|
||||
if( isset( $preferences['container'] ) AND !isset( \IPS\Request::i()->nodes ) )
|
||||
{
|
||||
\IPS\Request::i()->nodes = $preferences['container'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Though this isn't part of search, disabling the search module will disable it */
|
||||
if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'search' ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C232/2', 403, '' );
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=system&controller=vnc&updateFilters=1', 'front', 'vnc' );
|
||||
$nodeSelect = NULL;
|
||||
$nodeTitle = NULL;
|
||||
|
||||
/* Get types */
|
||||
$types = array();
|
||||
foreach ( \IPS\Content::routedClasses( TRUE, FALSE, TRUE ) as $class )
|
||||
{
|
||||
if( is_subclass_of( $class, 'IPS\Content\ReadMarkers' ) )
|
||||
{
|
||||
$key = mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) );
|
||||
$types[ $key ] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
/* If a user last filtered by "downloads_file" and then the download manager app was disabled we need to clear this otherwise you get a fatal error */
|
||||
if ( \IPS\Request::i()->type AND \IPS\Request::i()->type !== 'all' AND !isset( $types[ \IPS\Request::i()->type ] ) )
|
||||
{
|
||||
\IPS\Request::i()->type = '';
|
||||
}
|
||||
|
||||
/* Force a type if only one available */
|
||||
if( count( $types ) == 1 )
|
||||
{
|
||||
$keys = array_keys( $types );
|
||||
\IPS\Request::i()->type = array_shift( $keys );
|
||||
}
|
||||
|
||||
/* Set filters */
|
||||
$where = array();
|
||||
$start = NULL;
|
||||
$end = NULL;
|
||||
$onlyUnread = FALSE;
|
||||
if ( isset( \IPS\Request::i()->onlyUnread ) and \IPS\Request::i()->onlyUnread )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'onlyUnread', 1 );
|
||||
$onlyUnread = TRUE;
|
||||
}
|
||||
$onlyFollowed = FALSE;
|
||||
if ( isset( \IPS\Request::i()->onlyFollowed ) and \IPS\Request::i()->onlyFollowed )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'onlyFollowed', 1 );
|
||||
$onlyFollowed = TRUE;
|
||||
$where[] = array( 'follow_id IS NOT NULL AND follow_member_id =?', \IPS\Member::loggedIn()->member_id );
|
||||
}
|
||||
$onlyParticipated = FALSE;
|
||||
if ( isset( \IPS\Request::i()->onlyParticipated ) and \IPS\Request::i()->onlyParticipated )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'onlyParticipated', 1 );
|
||||
$onlyParticipated = TRUE;
|
||||
}
|
||||
$onlyStarted = FALSE;
|
||||
if ( isset( \IPS\Request::i()->onlyStarted ) and \IPS\Request::i()->onlyStarted )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'onlyStarted', 1 );
|
||||
$onlyStarted = TRUE;
|
||||
}
|
||||
|
||||
/* Get cutoff */
|
||||
$interval = NULL;
|
||||
$vncTimePeriod = NULL;
|
||||
if ( isset( \IPS\Request::i()->vncTimePeriod ) )
|
||||
{
|
||||
$vncTimePeriod = \IPS\Request::i()->vncTimePeriod;
|
||||
$baseUrl = $baseUrl->setQueryString( 'vncTimePeriod', $vncTimePeriod );
|
||||
if ( isset( \IPS\Request::i()->vncTime ) )
|
||||
{
|
||||
$start = \IPS\DateTime::ts( \IPS\Request::i()->vncTime, TRUE );
|
||||
}
|
||||
|
||||
switch ( $vncTimePeriod )
|
||||
{
|
||||
case 'all':
|
||||
$cutoff = NULL;
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$interval = new \DateInterval( 'P1D' );
|
||||
if ( !$start )
|
||||
{
|
||||
$start = \IPS\DateTime::ts( \IPS\DateTime::create()->getTimestamp(), TRUE )->sub( $interval );
|
||||
}
|
||||
else
|
||||
{
|
||||
$end = \IPS\DateTime::ts( $start->getTimestamp(), TRUE )->add( $interval );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$interval = new \DateInterval( 'P1W' );
|
||||
if ( !$start )
|
||||
{
|
||||
$start = \IPS\DateTime::ts( \IPS\DateTime::create()->getTimestamp(), TRUE )->sub( $interval );
|
||||
}
|
||||
else
|
||||
{
|
||||
$end = \IPS\DateTime::ts( $start->getTimestamp(), TRUE )->add( $interval );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$interval = new \DateInterval( 'P1M' );
|
||||
if ( !$start )
|
||||
{
|
||||
$start = \IPS\DateTime::create()->sub( $interval );
|
||||
}
|
||||
else
|
||||
{
|
||||
$end = \IPS\DateTime::ts( $start->getTimestamp(), TRUE )->add( $interval );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$start = \IPS\DateTime::ts( \IPS\Member::loggedIn()->last_visit, TRUE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$start = \IPS\DateTime::ts( \IPS\Member::loggedIn()->last_visit, TRUE );
|
||||
}
|
||||
|
||||
if( \IPS\Member::loggedIn()->member_id and isset( \IPS\Request::i()->updateFilters ) )
|
||||
{
|
||||
$vncPreferences = json_encode( array(
|
||||
'onlyFollowed' => $onlyFollowed,
|
||||
'onlyParticipated' => $onlyParticipated,
|
||||
'onlyStarted' => $onlyStarted,
|
||||
'onlyUnread' => $onlyUnread,
|
||||
'searchType' => \IPS\Request::i()->type ?: NULL,
|
||||
'vncTimePeriod' => $vncTimePeriod,
|
||||
'container' => \IPS\Request::i()->nodes ?: NULL,
|
||||
) );
|
||||
|
||||
if ( $vncPreferences != \IPS\Member::loggedIn()->vnc_preferences )
|
||||
{
|
||||
\IPS\Member::loggedIn()->vnc_preferences = $vncPreferences;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
|
||||
/* Get results - if we're just searching one type, it's a bit simpler */
|
||||
if ( \IPS\Request::i()->type AND \IPS\Request::i()->type !== 'all' )
|
||||
{
|
||||
/* Init */
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
$class = $types[ \IPS\Request::i()->type ];
|
||||
|
||||
if ( $onlyUnread )
|
||||
{
|
||||
$unreadWhere = $this->_getUnreadWhere( $class );
|
||||
|
||||
if ( count( $unreadWhere ) )
|
||||
{
|
||||
foreach( $unreadWhere as $id => $item )
|
||||
{
|
||||
$where[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Where */
|
||||
if ( $onlyParticipated or $onlyStarted )
|
||||
{
|
||||
if( isset( $class::$databaseColumnMap['author'] ) )
|
||||
{
|
||||
$participatedWhere[] = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id;
|
||||
}
|
||||
if ( !$onlyStarted )
|
||||
{
|
||||
if( isset( $class::$commentClass ) )
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
|
||||
$participatedWhere[] = '(' . str_replace( "`", '', (string) \IPS\Db::i()->select( 'COUNT(*)', $commentClass::$databaseTable, $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id . ' AND ' .
|
||||
$commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . '=' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId ) ) . ') > 0';
|
||||
}
|
||||
if( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$reviewClass = $class::$reviewClass;
|
||||
|
||||
$participatedWhere[] = '(' . str_replace( "`", '', (string) \IPS\Db::i()->select( 'COUNT(*)', $reviewClass::$databaseTable, $reviewClass::$databaseTable . '.' . $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id . ' AND ' .
|
||||
$reviewClass::$databaseTable . '.' . $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['item'] . '=' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId ) ) . ') > 0';
|
||||
}
|
||||
}
|
||||
$where[] = array( '( ' . implode( ' OR ', $participatedWhere ) . ' )' );
|
||||
}
|
||||
|
||||
/* Node Filter */
|
||||
if ( $class::$containerNodeClass )
|
||||
{
|
||||
$node = NULL;
|
||||
$nodeClass = $class::$containerNodeClass;
|
||||
$nodeTitle = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle );
|
||||
if ( isset( \IPS\Request::i()->nodes ) and \IPS\Request::i()->nodes )
|
||||
{
|
||||
try
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'nodes', \IPS\Request::i()->nodes );
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], is_array( \IPS\Request::i()->nodes ) ? \IPS\Request::i()->nodes : explode( ',', \IPS\Request::i()->nodes ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
$nodeSelect = new \IPS\Helpers\Form\Node( 'nodes', ( is_array( \IPS\Request::i()->nodes ) ) ? \IPS\Request::i()->nodes : explode( ',', \IPS\Request::i()->nodes ), FALSE, array( 'class' => $class::$containerNodeClass, 'permissionCheck' => 'view', 'url' => $baseUrl, 'multiple' => TRUE ) );
|
||||
}
|
||||
|
||||
/* Cutoff */
|
||||
$dateColumnExpression = $this->_getDateExpression( $class );
|
||||
|
||||
if ( $start )
|
||||
{
|
||||
$where[] = array( $dateColumnExpression . '>?', $start->getTimestamp() );
|
||||
}
|
||||
if ( $end )
|
||||
{
|
||||
$where[] = array( $dateColumnExpression . '<?', $end->getTimestamp() );
|
||||
}
|
||||
|
||||
if ( isset( $class::$databaseColumnMap['state'] ) )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['state'] . "!=?", 'link' );
|
||||
}
|
||||
|
||||
/* Create table */
|
||||
$table = new \IPS\Helpers\Table\Content( $class, $baseUrl, $where, NULL, NULL, 'read', FALSE );
|
||||
$table->classes[] = 'ipsDataList_zebra';
|
||||
$table->sortOptions = array();
|
||||
$table->noModerate = TRUE;
|
||||
|
||||
/* Joins */
|
||||
if ( $onlyFollowed )
|
||||
{
|
||||
$followArea = mb_strtolower( mb_substr( $class, mb_strrpos( $class, '\\' ) + 1 ) );
|
||||
$table->joins[] = array( 'from' => 'core_follow', 'where' => array( "follow_app=? AND follow_area=? AND follow_member_id=? AND follow_rel_id={$class::$databasePrefix}{$class::$databaseColumnId}", $class::$application, $followArea, \IPS\Member::loggedIn()->member_id ) );
|
||||
}
|
||||
}
|
||||
/* If we're searching them all, we need to go all union */
|
||||
else
|
||||
{
|
||||
/* Build the selects */
|
||||
$selects = array();
|
||||
foreach ( $types as $key => $class )
|
||||
{
|
||||
$dateColumnExpression = $this->_getDateExpression( $class );
|
||||
|
||||
/* Normalize the columns */
|
||||
$contentWhere = array();
|
||||
|
||||
$columns = array(
|
||||
$class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnId => 'id',
|
||||
$dateColumnExpression => 'date',
|
||||
$class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnMap['author'] => 'author'
|
||||
);
|
||||
if ( in_array( 'IPS\Content\Hideable', class_implements( $class ) ) and !\IPS\Member::loggedIn()->modPermission( "can_view_hidden_content" ) )
|
||||
{
|
||||
if ( $class::$databaseColumnMap['approved'] )
|
||||
{
|
||||
$columns[ $class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnMap['approved'] . '-1' ] = 'hidden';
|
||||
$contentWhere[] = array( $class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnMap['approved'] . '-1=0' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$columns[ $class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnMap['hidden'] ] = 'hidden';
|
||||
$contentWhere[] = array( $class::$databaseTable . "." . $class::$databasePrefix.$class::$databaseColumnMap['hidden'] . '=0' );
|
||||
}
|
||||
}
|
||||
|
||||
$select = array( "'".str_replace( '\\', '\\\\' , $class ) ."' AS class" );
|
||||
foreach ( $columns as $local => $normalized )
|
||||
{
|
||||
$select[] = "{$local} AS {$normalized}";
|
||||
}
|
||||
|
||||
if ( $onlyFollowed )
|
||||
{
|
||||
$select[] = "'".$class::$application."' AS _app";
|
||||
$followArea = mb_strtolower( mb_substr( $class, mb_strrpos( $class, '\\' ) + 1 ) );
|
||||
$select[] = "'{$followArea}' AS _follow_area";
|
||||
}
|
||||
$select = implode( ', ', $select );
|
||||
|
||||
/* Permissions */
|
||||
if ( in_array( 'IPS\Content\Permissions', class_implements( $class ) ) )
|
||||
{
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
$categories = array();
|
||||
foreach( \IPS\Db::i()->select( 'perm_type_id', 'core_permission_index', array( "core_permission_index.app='" . $containerClass::$permApp . "' AND core_permission_index.perm_type='" . $containerClass::$permType . "' AND (" . \IPS\Db::i()->findInSet( 'perm_' . $containerClass::$permissionMap['read'], \IPS\Member::loggedIn()->groups ) . ' OR ' . 'perm_' . $containerClass::$permissionMap['read'] . "='*' )" ) ) as $result )
|
||||
{
|
||||
$categories[] = $result;
|
||||
}
|
||||
|
||||
if( count( $categories ) )
|
||||
{
|
||||
$contentWhere[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . ' IN(' . implode( ',', $categories ) . ')' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$contentWhere[] = array( $class::$databaseTable . "." . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=0' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Future */
|
||||
if ( in_array( 'IPS\Content\FuturePublishing', class_implements( $class ) ) and !$class::canViewFutureItems() )
|
||||
{
|
||||
$authorCol = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'];
|
||||
$col = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['is_future_entry'];
|
||||
$contentWhere[] = array( "( {$col}=0 OR ( {$col}=1 AND {$authorCol}=" . \IPS\Member::loggedIn()->member_id . " ) )" );
|
||||
}
|
||||
|
||||
/* Add app-sepcific wheres */
|
||||
$joinContainer = FALSE;
|
||||
$joins = array();
|
||||
$vncWhere = $class::vncWhere( $joinContainer, $joins );
|
||||
|
||||
if ( is_array( $vncWhere ) )
|
||||
{
|
||||
foreach( $vncWhere as $key => $value )
|
||||
{
|
||||
if ( $key ==='item' )
|
||||
{
|
||||
$contentWhere = array_merge( $contentWhere, $value );
|
||||
}
|
||||
else if ( $key === 'container' )
|
||||
{
|
||||
$contentWhere = array_merge( $contentWhere, $value );
|
||||
}
|
||||
else
|
||||
{
|
||||
$contentWhere[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Only unread */
|
||||
if ( $onlyUnread )
|
||||
{
|
||||
$unreadWhere = $this->_getUnreadWhere( $class );
|
||||
|
||||
if ( count( $unreadWhere ) )
|
||||
{
|
||||
foreach( $unreadWhere as $id => $item )
|
||||
{
|
||||
$contentWhere[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Participated Only */
|
||||
if ( $onlyParticipated or $onlyStarted )
|
||||
{
|
||||
$participatedWhere = array();
|
||||
if( isset( $class::$databaseColumnMap['author'] ) )
|
||||
{
|
||||
$participatedWhere[] = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id;
|
||||
}
|
||||
if ( !$onlyStarted )
|
||||
{
|
||||
if( isset( $class::$commentClass ) )
|
||||
{
|
||||
$commentClass = $class::$commentClass;
|
||||
|
||||
$participatedWhere[] = '(' . str_replace( "`", '', (string) \IPS\Db::i()->select( 'COUNT(*)', $commentClass::$databaseTable, $commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id . ' AND ' .
|
||||
$commentClass::$databaseTable . '.' . $commentClass::$databasePrefix . $commentClass::$databaseColumnMap['item'] . '=' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId ) ) . ') > 0';
|
||||
}
|
||||
if( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$reviewClass = $class::$reviewClass;
|
||||
|
||||
$participatedWhere[] = '(' . str_replace( "`", '', (string) \IPS\Db::i()->select( 'COUNT(*)', $reviewClass::$databaseTable, $reviewClass::$databaseTable . '.' . $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['author'] . '=' . \IPS\Member::loggedIn()->member_id . ' AND ' .
|
||||
$reviewClass::$databaseTable . '.' . $reviewClass::$databasePrefix . $reviewClass::$databaseColumnMap['item'] . '=' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId ) ) . ') > 0';
|
||||
}
|
||||
}
|
||||
|
||||
$contentWhere[] = '( ' . implode( ' OR ', $participatedWhere ) . ' )';
|
||||
}
|
||||
|
||||
if ( isset( $class::$databaseColumnMap['state'] ) )
|
||||
{
|
||||
$contentWhere[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['state'] . "!='link'" );
|
||||
}
|
||||
|
||||
/* Add to the list */
|
||||
$select = \IPS\Db::i()->select( $select, $class::$databaseTable, $contentWhere );
|
||||
if ( $joinContainer )
|
||||
{
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
$select->join( $containerClass::$databaseTable, $class::$databaseTable . "." . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=' . $containerClass::$databaseTable . "." . $containerClass::$databasePrefix . $containerClass::$databaseColumnId );
|
||||
}
|
||||
if ( count( $joins ) )
|
||||
{
|
||||
foreach ( $joins as $join )
|
||||
{
|
||||
$select->join( $join['from'], $join['where'] );
|
||||
}
|
||||
}
|
||||
$selects[] = $select;
|
||||
}
|
||||
|
||||
/* Cutoff */
|
||||
if ( $start )
|
||||
{
|
||||
$where[] = array( 'date>?', $start->getTimestamp() );
|
||||
}
|
||||
if ( $end )
|
||||
{
|
||||
$where[] = array( 'date<?', $end->getTimestamp() );
|
||||
}
|
||||
|
||||
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
/* Run */
|
||||
$results = \IPS\Db::i()->union( $selects, 'date DESC', array( ( ( $page - 1 ) * 25 ), 25 ), ( $onlyFollowed ) ? '_app, _follow_area, id' : NULL, FALSE, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, $where );
|
||||
|
||||
/* Joins */
|
||||
if ( $onlyFollowed )
|
||||
{
|
||||
$results->join( 'core_follow', "follow_app=_app AND follow_area=_follow_area AND follow_rel_id=id" );
|
||||
}
|
||||
|
||||
$resultPages = ceil( $results->count( TRUE ) / 25 );
|
||||
|
||||
/* Build a table */
|
||||
$table = new \IPS\Helpers\Table\Custom( iterator_to_array( $results ), $baseUrl );
|
||||
$table->classes[] = 'ipsDataList_zebra';
|
||||
$table->pages = $resultPages;
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'vnc' ), 'genericRows' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array(
|
||||
'sidebar' => \IPS\Theme::i()->getTemplate('vnc')->filters( $baseUrl, $types, $nodeSelect, $nodeTitle ),
|
||||
'content' => \IPS\Theme::i()->getTemplate('vnc')->results( $baseUrl, (string) $table, \IPS\Request::i()->vncTimePeriod, $interval, $start, $end ?: \IPS\DateTime::create() ),
|
||||
) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_vnc.js', 'core' ) );
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('search_vnc_title') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('search_vnc_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('vnc')->template( $baseUrl, $types, (string) $table, \IPS\Request::i()->vncTimePeriod, $interval, $start, $end ?: \IPS\DateTime::create(), $nodeSelect, $nodeTitle );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the 'unread' where SQL
|
||||
*
|
||||
* @param string $class Content class (\IPS\forums\Forum)
|
||||
* @return array
|
||||
*/
|
||||
protected function _getUnreadWhere( $class )
|
||||
{
|
||||
$classBits = explode( "\\", $class );
|
||||
$application = $classBits[1];
|
||||
$resetTimes = \IPS\Member::loggedIn()->markersResetTimes( $application );
|
||||
$oldestTime = time();
|
||||
$markers = array();
|
||||
$excludeIds = array();
|
||||
$where = array();
|
||||
$unreadWheres = array();
|
||||
$containerIds = array();
|
||||
$containerClass = ( $class::$containerNodeClass ) ? $class::$containerNodeClass : NULL;
|
||||
|
||||
/* What is the best date column? */
|
||||
$dateColumns = array();
|
||||
foreach ( array( 'updated', 'last_comment', 'last_review' ) as $k )
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap[ $k ] ) )
|
||||
{
|
||||
if ( is_array( $class::$databaseColumnMap[ $k ] ) )
|
||||
{
|
||||
foreach ( $class::$databaseColumnMap[ $k ] as $v )
|
||||
{
|
||||
$dateColumns[] = " IFNULL( " . $class::$databaseTable . '.'. $class::$databasePrefix . $v . ", 0 )";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$dateColumns[] = " IFNULL( " . $class::$databaseTable . '.'. $class::$databasePrefix . $class::$databaseColumnMap[ $k ] . ", 0 )";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dateColumnExpression = count( $dateColumns ) > 1 ? ( 'GREATEST(' . implode( ',', $dateColumns ) . ')' ) : array_pop( $dateColumns );
|
||||
|
||||
foreach( $resetTimes as $containerId => $timestamp )
|
||||
{
|
||||
$container = NULL;
|
||||
|
||||
if( $containerId AND $containerClass )
|
||||
{
|
||||
try
|
||||
{
|
||||
$container = $containerClass::load( $containerId );
|
||||
}
|
||||
catch ( \OutOfRangeException $e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$timestamp = $timestamp ?: \IPS\Member::loggedIn()->marked_site_read;
|
||||
|
||||
$containerIds[] = $containerId;
|
||||
$unreadWheres[] = '( ' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=' . $containerId . ' AND ' . $dateColumnExpression . ' > ' . (int) $timestamp . ')';
|
||||
|
||||
$items = \IPS\Member::loggedIn()->markersItems( $application, \IPS\Content\Item::makeMarkerKey( $container ) );
|
||||
|
||||
if ( count( $items ) )
|
||||
{
|
||||
foreach( $items as $mid => $mtime )
|
||||
{
|
||||
if ( $mtime > $timestamp )
|
||||
{
|
||||
$markers[ $mtime . '.' . $mid ] = $mid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $containerIds ) )
|
||||
{
|
||||
$unreadWheres[] = "( " . $dateColumnExpression . " > " . \IPS\Member::loggedIn()->marked_site_read . " AND ( " . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . " NOT IN(" . implode( ',', $containerIds ) . ") ) )";
|
||||
}
|
||||
else
|
||||
{
|
||||
$unreadWheres[] = "( " . $dateColumnExpression . " > " . \IPS\Member::loggedIn()->marked_site_read . ")";
|
||||
}
|
||||
|
||||
if( count( $unreadWheres ) )
|
||||
{
|
||||
$where[] = array( "(" . implode( " OR ", $unreadWheres ) . ")" );
|
||||
}
|
||||
|
||||
if ( count( $markers ) )
|
||||
{
|
||||
/* Avoid packet issues */
|
||||
krsort( $markers );
|
||||
$useIds = array_flip( array_slice( $markers, 0, 500, TRUE ) );
|
||||
$select = '';
|
||||
$from = '';
|
||||
$notIn = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId. ' as _id, ' . $dateColumnExpression . ' as _date', $class::$databaseTable, \IPS\Db::i()->in( $class::$databasePrefix . $class::$databaseColumnId, array_keys( $useIds ) ) ) as $row )
|
||||
{
|
||||
if ( isset( $useIds[ $row['_id'] ] ) )
|
||||
{
|
||||
if ( $useIds[ $row['_id'] ] >= $row['_date'] )
|
||||
{
|
||||
/* Still read */
|
||||
$notIn[] = intval( $row['_id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $notIn ) )
|
||||
{
|
||||
$where[] = array( "( " . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId . " NOT IN (" . implode( ',', $notIn ) . ") )" );
|
||||
}
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date Column expression
|
||||
*
|
||||
* @param string $class Content class (\IPS\forums\Forum)
|
||||
* @return string
|
||||
*/
|
||||
protected function _getDateExpression( $class )
|
||||
{
|
||||
/* What is the best date column? */
|
||||
$dateColumns = array();
|
||||
foreach ( array( 'updated', 'last_comment', 'last_review' ) as $k )
|
||||
{
|
||||
if ( isset( $class::$databaseColumnMap[ $k ] ) )
|
||||
{
|
||||
if ( is_array( $class::$databaseColumnMap[ $k ] ) )
|
||||
{
|
||||
foreach ( $class::$databaseColumnMap[ $k ] as $v )
|
||||
{
|
||||
$dateColumns[] = " IFNULL( " . $class::$databaseTable . '.'. $class::$databasePrefix . $v . ", 0 )";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$dateColumns[] = " IFNULL( " . $class::$databaseTable . '.'. $class::$databasePrefix . $class::$databaseColumnMap[ $k ] . ", 0 )";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count( $dateColumns ) > 1 ? ( 'GREATEST(' . implode( ',', $dateColumns ) . ')' ) : array_pop( $dateColumns );
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class _vse extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$field = new $class( "core_theme_setting_title_{$data['sc_id']}", $value, false, $options );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $data['sc_title'] );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $data['sc_title'], FALSE, array( 'escape' => true ) );
|
||||
$form->add( $field );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ class _warnings extends \IPS\Content\Controller
|
||||
$reason = \IPS\core\Warnings\Reason::load( \IPS\Request::i()->id );
|
||||
|
||||
/* Add in the remove properties */
|
||||
if ( $reason->remove )
|
||||
if ( $reason->remove AND $reason->remove != -1 )
|
||||
{
|
||||
$date = \IPS\DateTime::create();
|
||||
if ( $reason->remove_unit == 'h' )
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* @package IPS Social Suite
|
||||
* @since 2 Apr 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @modified 13.09.2015 by IAF
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\setup\install;
|
||||
@@ -32,7 +31,7 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
public function manage()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'license', 'continue', \IPS\Http\Url::external( ( \IPS\Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?controller=license' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'lkey', 'Nulled by IAF | 13.09.2015', TRUE, array( 'size' => 50 ), function( $val ) //Filling "License key" input and block it
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'lkey', NULL, TRUE, array( 'size' => 50 ), function( $val )
|
||||
{
|
||||
\IPS\IPS::checkLicenseKey( $val, ( \IPS\Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . mb_substr( $_SERVER['SCRIPT_NAME'], 0, -mb_strlen( \IPS\CP_DIRECTORY . '/install/index.php' ) ) );
|
||||
}, NULL, '<a href="' . \IPS\Http\Url::ips( 'docs/find_lkey' ) . '" target="_blank">' . \IPS\Member::loggedIn()->language()->addToStack('lkey_help') . '</a>' ) );
|
||||
@@ -53,7 +52,7 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
$values['lkey'] = mb_substr( $values['lkey'], 0, -12 );
|
||||
}
|
||||
|
||||
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( array( 'lkey' => 'LICENSE KEY GOES HERE!-123456789' ), TRUE ) . ';'; //Writing another "key"
|
||||
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( array( 'lkey' => $values['lkey'] ), TRUE ) . ';';
|
||||
|
||||
try
|
||||
{
|
||||
@@ -94,6 +93,4 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'license', $form, TRUE, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'validate' => function( $element ) use ( $defaultTicks )
|
||||
{
|
||||
$uninstallable = array_diff( array_keys( $element->value ), $defaultTicks );
|
||||
$uninstallable = ( $element->value === NULL ) ? NULL : array_diff( array_keys( $element->value ), $defaultTicks );
|
||||
|
||||
if ( !empty( $uninstallable ) )
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* @package IPS Social Suite
|
||||
* @since 25 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @modified 13.09.2015 by IAF (Nulling)
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
@@ -26,14 +25,114 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show Form... Or not.
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) ); //Simply skip this (License) step
|
||||
}
|
||||
}
|
||||
/* Check license key */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
$licenseData = NULL;
|
||||
|
||||
/* Nulled by IandroidFan (IAF) */
|
||||
try
|
||||
{
|
||||
$license = \IPS\Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
|
||||
$licenseData = unserialize( $license['cs_value'] );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
|
||||
if( isset( $licenseData['key'] ) AND !isset( $licenseData['expires'] ) )
|
||||
{
|
||||
$licenseData = $this->getLicenseData();
|
||||
}
|
||||
|
||||
if ( !$licenseData or !isset( $licenseData['expires'] ) )
|
||||
{
|
||||
|
||||
$response = NULL;
|
||||
$active = NULL;
|
||||
$form = new \IPS\Helpers\Form( 'licensekey', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
\IPS\IPS::checkLicenseKey( $val, \IPS\Settings::i()->base_url );
|
||||
} ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$values['ipb_reg_number'] = trim( $values['ipb_reg_number'] );
|
||||
|
||||
if ( mb_substr( $values['ipb_reg_number'], -12 ) === '-TESTINSTALL' )
|
||||
{
|
||||
$values['ipb_reg_number'] = mb_substr( $values['ipb_reg_number'], 0, -12 );
|
||||
}
|
||||
|
||||
/* Save */
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Refresh the locally stored license info */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->license_data );
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Call the main server */
|
||||
$licenseData = $this->getLicenseData();
|
||||
}
|
||||
|
||||
/* Reset some vars now */
|
||||
$form = NULL;
|
||||
$active = isset( $licenseData['expires'] ) ? strtotime( $licenseData['expires'] ) > time() : NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$active = isset( $licenseData['expires'] ) ? strtotime( $licenseData['expires'] ) > time() : NULL;
|
||||
}
|
||||
|
||||
if( $active )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->license( $form, $active );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve license data from license server
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getLicenseData()
|
||||
{
|
||||
/* Call the main server */
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::ips( 'license/' . \IPS\Settings::i()->ipb_reg_number )->request()->get();
|
||||
if ( $response->httpResponseCode == 404 )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$licenseData = $response->decodeJson();
|
||||
}
|
||||
|
||||
\IPS\Db::i()->replace( 'cache_store', array( 'cs_key' => 'licenseData', 'cs_array' => 1, 'cs_value' => serialize( $licenseData ) ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
}
|
||||
|
||||
return $licenseData;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,18 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Are we automatically logging in? */
|
||||
if ( isset( \IPS\Request::i()->adsess ) )
|
||||
{
|
||||
$session = \IPS\Db::i()->select( '*', 'core_sys_cp_sessions', array( 'session_id=?', \IPS\Request::i()->adsess ) )->first();
|
||||
$member = $session['session_member_id'] ? \IPS\Member::load( $session['session_member_id'] ) : new \IPS\Member;
|
||||
if ( $member->member_id and $member->isAdmin() and ( !\IPS\Settings::i()->match_ipaddress or ( $session['session_ip_address'] === \IPS\Request::i()->ipAddress() ) ) )
|
||||
{
|
||||
$_SESSION['uniqueKey'] = md5( uniqid( microtime(), TRUE ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
$login = new \IPS\Login( \IPS\Http\Url::internal( "controller=login&start=1", NULL, NULL, NULL, \IPS\Settings::i()->logins_over_https ) );
|
||||
$login->flagOptions = FALSE;
|
||||
|
||||
|
||||
@@ -50,8 +50,36 @@ class _systemcheck extends \IPS\Dispatcher\Controller
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
|
||||
/* Get requirements */
|
||||
$requirements = \IPS\core\Setup\Upgrade::systemRequirements();
|
||||
$designersModeEnabled = ( \IPS\Application::load('core')->long_version >= 40000 and \IPS\Theme::designersModeEnabled() ) ? TRUE : FALSE;
|
||||
|
||||
/* Can we just skip this screen? */
|
||||
$canProceed = FALSE;
|
||||
if ( !$designersModeEnabled )
|
||||
{
|
||||
$canProceed = !isset( $requirements['advice'] ) or !count( $requirements['advice'] );
|
||||
if ( $canProceed )
|
||||
{
|
||||
foreach ( $requirements['requirements'] as $k => $_requirements )
|
||||
{
|
||||
foreach ( $_requirements as $item )
|
||||
{
|
||||
if ( !$item['success'] )
|
||||
{
|
||||
$canProceed = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $canProceed )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("controller=license&key={$_SESSION['uniqueKey']}") );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->healthcheck( \IPS\core\Setup\Upgrade::systemRequirements(), ( \IPS\Application::load('core')->long_version >= 40000 and \IPS\Theme::designersModeEnabled() ) ? TRUE : FALSE );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->healthcheck( $requirements, $designersModeEnabled );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user