mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-13 12:14:06 +02:00
[feature/oauth] Merge branch 'develop' of git://github.com/phpbb/phpbb3 into feature/oauth
Conflicts: phpBB/composer.json phpBB/composer.lock phpBB/develop/create_schema_files.php phpBB/includes/ucp/ucp_register.php PHPBB3-11673
This commit is contained in:
@@ -93,7 +93,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||
// Make sure getimagesize works...
|
||||
if (function_exists('getimagesize'))
|
||||
{
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = getimagesize($url)) === false))
|
||||
if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false))
|
||||
{
|
||||
$error[] = 'UNABLE_GET_IMAGE_SIZE';
|
||||
return false;
|
||||
|
70
phpBB/phpbb/cache/driver/file.php
vendored
70
phpBB/phpbb/cache/driver/file.php
vendored
@@ -205,28 +205,34 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
||||
function purge()
|
||||
{
|
||||
// Purge all phpbb cache files
|
||||
$dir = @opendir($this->cache_dir);
|
||||
|
||||
if (!$dir)
|
||||
try
|
||||
{
|
||||
$iterator = new DirectoryIterator($this->cache_dir);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (($entry = readdir($dir)) !== false)
|
||||
foreach ($iterator as $fileInfo)
|
||||
{
|
||||
if (strpos($entry, 'container_') !== 0 &&
|
||||
strpos($entry, 'url_matcher') !== 0 &&
|
||||
strpos($entry, 'sql_') !== 0 &&
|
||||
strpos($entry, 'data_') !== 0 &&
|
||||
strpos($entry, 'ctpl_') !== 0 &&
|
||||
strpos($entry, 'tpl_') !== 0)
|
||||
if ($fileInfo->isDot())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->remove_file($this->cache_dir . $entry);
|
||||
$filename = $fileInfo->getFilename();
|
||||
if ($fileInfo->isDir())
|
||||
{
|
||||
$this->remove_dir($fileInfo->getPathname());
|
||||
}
|
||||
elseif (strpos($filename, 'container_') === 0 ||
|
||||
strpos($filename, 'url_matcher') === 0 ||
|
||||
strpos($filename, 'sql_') === 0 ||
|
||||
strpos($filename, 'data_') === 0)
|
||||
{
|
||||
$this->remove_file($fileInfo->getPathname());
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
unset($this->vars);
|
||||
unset($this->var_expires);
|
||||
@@ -241,6 +247,44 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
||||
$this->is_modified = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove directory
|
||||
*
|
||||
* @param string $dir Directory to remove
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function remove_dir($dir)
|
||||
{
|
||||
try
|
||||
{
|
||||
$iterator = new DirectoryIterator($dir);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($iterator as $fileInfo)
|
||||
{
|
||||
if ($fileInfo->isDot())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($fileInfo->isDir())
|
||||
{
|
||||
$this->remove_dir($fileInfo->getPathname());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->remove_file($fileInfo->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
|
@@ -360,6 +360,11 @@ class phpbb_content_visibility
|
||||
// Sync the first/last topic information if needed
|
||||
if (!$is_starter && $is_latest)
|
||||
{
|
||||
if (!function_exists('update_post_information'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext);
|
||||
}
|
||||
|
||||
// update_post_information can only update the last post info ...
|
||||
if ($topic_id)
|
||||
{
|
||||
|
@@ -35,6 +35,12 @@ class phpbb_controller_helper
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Request object
|
||||
* @var phpbb_request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* phpBB root path
|
||||
* @var string
|
||||
@@ -55,10 +61,11 @@ class phpbb_controller_helper
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $php_ext PHP extension
|
||||
*/
|
||||
public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext)
|
||||
public function __construct(phpbb_template $template, phpbb_user $user, phpbb_request_interface $request, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->request = $request;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
@@ -102,22 +109,16 @@ class phpbb_controller_helper
|
||||
$route = substr($route, 0, $route_delim);
|
||||
}
|
||||
|
||||
if (is_array($params) && !empty($params))
|
||||
{
|
||||
$params = array_merge(array(
|
||||
'controller' => $route,
|
||||
), $params);
|
||||
}
|
||||
else if (is_string($params) && $params)
|
||||
{
|
||||
$params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params;
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = array('controller' => $route);
|
||||
}
|
||||
$request_uri = $this->request->variable('REQUEST_URI', '', false, phpbb_request::SERVER);
|
||||
$script_name = $this->request->variable('SCRIPT_NAME', '', false, phpbb_request::SERVER);
|
||||
|
||||
return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id);
|
||||
// If the app.php file is being used (no rewrite) keep it in the URL.
|
||||
// Otherwise, don't include it.
|
||||
$route_prefix = $this->phpbb_root_path;
|
||||
$parts = explode('/', $script_name);
|
||||
$route_prefix .= strpos($request_uri, $script_name) === 0 ? array_pop($parts) . '/' : '';
|
||||
|
||||
return append_sid($route_prefix . "$route" . $route_params, $params, $is_amp, $session_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,23 +38,23 @@ class phpbb_controller_resolver implements ControllerResolverInterface
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* phpbb_style object
|
||||
* @var phpbb_style
|
||||
* phpbb_template object
|
||||
* @var phpbb_template
|
||||
*/
|
||||
protected $style;
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* Construct method
|
||||
*
|
||||
* @param phpbb_user $user User Object
|
||||
* @param ContainerInterface $container ContainerInterface object
|
||||
* @param phpbb_style $style
|
||||
* @param phpbb_template $template
|
||||
*/
|
||||
public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null)
|
||||
public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->container = $container;
|
||||
$this->style = $style;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,13 +96,13 @@ class phpbb_controller_resolver implements ControllerResolverInterface
|
||||
$controller_dir = explode('_', get_class($controller_object));
|
||||
|
||||
// 0 phpbb, 1 ext, 2 vendor, 3 extension name, ...
|
||||
if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext')
|
||||
if (!is_null($this->template) && isset($controller_dir[3]) && $controller_dir[1] === 'ext')
|
||||
{
|
||||
$controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles';
|
||||
|
||||
if (is_dir($controller_style_dir))
|
||||
{
|
||||
$this->style->set_style(array($controller_style_dir, 'styles'));
|
||||
$this->template->set_style(array($controller_style_dir, 'styles'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.10', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.10', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.10-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.10-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration
|
||||
return array(
|
||||
array('config.add', array('email_max_chunk_size', 50)),
|
||||
|
||||
array('config.update', array('version', '3.0.10-rc1')),
|
||||
array('config.update', array('version', '3.0.10-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.10-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.10-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.10-rc2')),
|
||||
array('config.update', array('version', '3.0.10-RC2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.10-rc3', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.10-RC3', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.10-rc3')),
|
||||
array('config.update', array('version', '3.0.10-RC3')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.11', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.11', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.11-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.11-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -25,7 +25,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration
|
||||
array('custom', array(array(&$this, 'cleanup_deactivated_styles'))),
|
||||
array('custom', array(array(&$this, 'delete_orphan_private_messages'))),
|
||||
|
||||
array('config.update', array('version', '3.0.11-rc1')),
|
||||
array('config.update', array('version', '3.0.11-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.11-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.11-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -44,7 +44,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.11-rc2')),
|
||||
array('config.update', array('version', '3.0.11-RC2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.12-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.12-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -28,7 +28,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration
|
||||
array('custom', array(array(&$this, 'update_bots'))),
|
||||
array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))),
|
||||
|
||||
array('config.update', array('version', '3.0.12-rc1')),
|
||||
array('config.update', array('version', '3.0.12-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration
|
||||
WHERE user_id = $bot_user_id";
|
||||
$this->sql_query($sql);
|
||||
|
||||
user_delete('remove', $bot_user_id);
|
||||
user_delete('retain', $bot_user_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.1-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.1-RC1', '>=');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
@@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration
|
||||
array('custom', array(array(&$this, 'fix_unset_last_view_time'))),
|
||||
array('custom', array(array(&$this, 'reset_smiley_size'))),
|
||||
|
||||
array('config.update', array('version', '3.0.1-rc1')),
|
||||
array('config.update', array('version', '3.0.1-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.2-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.2-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -26,7 +26,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('check_attachment_content', '1')),
|
||||
array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')),
|
||||
|
||||
array('config.update', array('version', '3.0.2-rc1')),
|
||||
array('config.update', array('version', '3.0.2-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.2-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.2-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.2-rc2')),
|
||||
array('config.update', array('version', '3.0.2-RC2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_3 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.3', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.3', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.3-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.3-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -60,7 +60,7 @@ class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration
|
||||
array('permission.add', array('u_masspm_group', true, 'u_masspm')),
|
||||
array('custom', array(array(&$this, 'correct_acp_email_permissions'))),
|
||||
|
||||
array('config.update', array('version', '3.0.3-rc1')),
|
||||
array('config.update', array('version', '3.0.3-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_4 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.4', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.4', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.4-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.4-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -76,7 +76,7 @@ class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_custom_profile_fields'))),
|
||||
|
||||
array('config.update', array('version', '3.0.4-rc1')),
|
||||
array('config.update', array('version', '3.0.4-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.5', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.5', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.5-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.5-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -36,7 +36,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.5-rc1')),
|
||||
array('config.update', array('version', '3.0.5-RC1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.6', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.6', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.6-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.6-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -185,7 +185,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration
|
||||
array('custom', array(array(&$this, 'add_newly_registered_group'))),
|
||||
array('custom', array(array(&$this, 'set_user_options_default'))),
|
||||
|
||||
array('config.update', array('version', '3.0.6-rc1')),
|
||||
array('config.update', array('version', '3.0.6-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.6-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.6-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.6-rc2')),
|
||||
array('config.update', array('version', '3.0.6-RC2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.6-rc3', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.6-RC3', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_cp_fields'))),
|
||||
|
||||
array('config.update', array('version', '3.0.6-rc3')),
|
||||
array('config.update', array('version', '3.0.6-RC3')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.6-rc4', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.6-RC4', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.6-rc4')),
|
||||
array('config.update', array('version', '3.0.6-RC4')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.7', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.7', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_pl1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.7-pl1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.7-pl1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.7-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.7-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -62,7 +62,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])),
|
||||
array('custom', array(array(&$this, 'delete_text_templates'))),
|
||||
|
||||
array('config.update', array('version', '3.0.7-rc1')),
|
||||
array('config.update', array('version', '3.0.7-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.7-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.7-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_email_hash'))),
|
||||
|
||||
array('config.update', array('version', '3.0.7-rc2')),
|
||||
array('config.update', array('version', '3.0.7-RC2')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_8 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.8', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.8', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.8-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.8-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -38,7 +38,7 @@ class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration
|
||||
array('config.update_if_equals', array(600, 'queue_interval', 60)),
|
||||
array('config.update_if_equals', array(50, 'email_package_size', 20)),
|
||||
|
||||
array('config.update', array('version', '3.0.8-rc1')),
|
||||
array('config.update', array('version', '3.0.8-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.9', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.9', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.9-rc1', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.9-RC1', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration
|
||||
array('custom', array(array(&$this, 'update_file_extension_group_names'))),
|
||||
array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))),
|
||||
|
||||
array('config.update', array('version', '3.0.9-rc1')),
|
||||
array('config.update', array('version', '3.0.9-RC1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.9-rc2', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.9-RC2', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc2')),
|
||||
array('config.update', array('version', '3.0.9-RC2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.9-rc3', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.9-RC3', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc3')),
|
||||
array('config.update', array('version', '3.0.9-RC3')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return version_compare($this->config['version'], '3.0.9-rc4', '>=');
|
||||
return phpbb_version_compare($this->config['version'], '3.0.9-RC4', '>=');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
@@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc4')),
|
||||
array('config.update', array('version', '3.0.9-RC4')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ class phpbb_db_migration_data_310_signature_module_auth extends phpbb_db_migrati
|
||||
AND module_basename = 'ucp_profile'
|
||||
AND module_mode = 'signature'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$module_auth = $this->db_sql_fetchfield('module_auth');
|
||||
$module_auth = $this->db->sql_fetchfield('module_auth');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_auth === 'acl_u_sig' || $module_auth === false;
|
||||
|
55
phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php
Normal file
55
phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_softdelete_mcp_modules extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
$sql = 'SELECT module_id
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_class = 'mcp'
|
||||
AND module_basename = 'mcp_queue'
|
||||
AND module_mode = 'deleted_topics'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$module_id = $this->db->sql_fetchfield('module_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_id !== false;
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'phpbb_db_migration_data_310_dev',
|
||||
'phpbb_db_migration_data_310_softdelete_p2',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('module.add', array(
|
||||
'mcp',
|
||||
'MCP_QUEUE',
|
||||
array(
|
||||
'module_basename' => 'mcp_queue',
|
||||
'modes' => array('deleted_topics'),
|
||||
),
|
||||
)),
|
||||
array('module.add', array(
|
||||
'mcp',
|
||||
'MCP_QUEUE',
|
||||
array(
|
||||
'module_basename' => 'mcp_queue',
|
||||
'modes' => array('deleted_posts'),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
1219
phpBB/phpbb/db/schema_data.php
Normal file
1219
phpBB/phpbb/db/schema_data.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -37,247 +37,257 @@ class phpbb_db_tools
|
||||
* The Column types for every database we support
|
||||
* @var array
|
||||
*/
|
||||
var $dbms_type_map = array(
|
||||
'mysql_41' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'smallint(4) UNSIGNED',
|
||||
'BOOL' => 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'text',
|
||||
'XSTEXT_UNI'=> 'varchar(100)',
|
||||
'STEXT' => 'text',
|
||||
'STEXT_UNI' => 'varchar(255)',
|
||||
'TEXT' => 'text',
|
||||
'TEXT_UNI' => 'text',
|
||||
'MTEXT' => 'mediumtext',
|
||||
'MTEXT_UNI' => 'mediumtext',
|
||||
'TIMESTAMP' => 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar(255)',
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
var $dbms_type_map = array();
|
||||
|
||||
'mysql_40' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'smallint(4) UNSIGNED',
|
||||
'BOOL' => 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varbinary(255)',
|
||||
'VCHAR:' => 'varbinary(%d)',
|
||||
'CHAR:' => 'binary(%d)',
|
||||
'XSTEXT' => 'blob',
|
||||
'XSTEXT_UNI'=> 'blob',
|
||||
'STEXT' => 'blob',
|
||||
'STEXT_UNI' => 'blob',
|
||||
'TEXT' => 'blob',
|
||||
'TEXT_UNI' => 'blob',
|
||||
'MTEXT' => 'mediumblob',
|
||||
'MTEXT_UNI' => 'mediumblob',
|
||||
'TIMESTAMP' => 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'blob',
|
||||
'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')),
|
||||
'VCHAR_CI' => 'blob',
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
/**
|
||||
* Get the column types for every database we support
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_dbms_type_map()
|
||||
{
|
||||
return array(
|
||||
'mysql_41' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'smallint(4) UNSIGNED',
|
||||
'BOOL' => 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'text',
|
||||
'XSTEXT_UNI'=> 'varchar(100)',
|
||||
'STEXT' => 'text',
|
||||
'STEXT_UNI' => 'varchar(255)',
|
||||
'TEXT' => 'text',
|
||||
'TEXT_UNI' => 'text',
|
||||
'MTEXT' => 'mediumtext',
|
||||
'MTEXT_UNI' => 'mediumtext',
|
||||
'TIMESTAMP' => 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar(255)',
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
|
||||
'firebird' => array(
|
||||
'INT:' => 'INTEGER',
|
||||
'BINT' => 'DOUBLE PRECISION',
|
||||
'UINT' => 'INTEGER',
|
||||
'UINT:' => 'INTEGER',
|
||||
'TINT:' => 'INTEGER',
|
||||
'USINT' => 'INTEGER',
|
||||
'BOOL' => 'INTEGER',
|
||||
'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE',
|
||||
'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE',
|
||||
'CHAR:' => 'CHAR(%d) CHARACTER SET NONE',
|
||||
'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8',
|
||||
'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
|
||||
'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
|
||||
'TIMESTAMP' => 'INTEGER',
|
||||
'DECIMAL' => 'DOUBLE PRECISION',
|
||||
'DECIMAL:' => 'DOUBLE PRECISION',
|
||||
'PDECIMAL' => 'DOUBLE PRECISION',
|
||||
'PDECIMAL:' => 'DOUBLE PRECISION',
|
||||
'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8',
|
||||
'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'VARBINARY' => 'CHAR(255) CHARACTER SET NONE',
|
||||
),
|
||||
'mysql_40' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'smallint(4) UNSIGNED',
|
||||
'BOOL' => 'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varbinary(255)',
|
||||
'VCHAR:' => 'varbinary(%d)',
|
||||
'CHAR:' => 'binary(%d)',
|
||||
'XSTEXT' => 'blob',
|
||||
'XSTEXT_UNI'=> 'blob',
|
||||
'STEXT' => 'blob',
|
||||
'STEXT_UNI' => 'blob',
|
||||
'TEXT' => 'blob',
|
||||
'TEXT_UNI' => 'blob',
|
||||
'MTEXT' => 'mediumblob',
|
||||
'MTEXT_UNI' => 'mediumblob',
|
||||
'TIMESTAMP' => 'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'blob',
|
||||
'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')),
|
||||
'VCHAR_CI' => 'blob',
|
||||
'VARBINARY' => 'varbinary(255)',
|
||||
),
|
||||
|
||||
'mssql' => array(
|
||||
'INT:' => '[int]',
|
||||
'BINT' => '[float]',
|
||||
'UINT' => '[int]',
|
||||
'UINT:' => '[int]',
|
||||
'TINT:' => '[int]',
|
||||
'USINT' => '[int]',
|
||||
'BOOL' => '[int]',
|
||||
'VCHAR' => '[varchar] (255)',
|
||||
'VCHAR:' => '[varchar] (%d)',
|
||||
'CHAR:' => '[char] (%d)',
|
||||
'XSTEXT' => '[varchar] (1000)',
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
'firebird' => array(
|
||||
'INT:' => 'INTEGER',
|
||||
'BINT' => 'DOUBLE PRECISION',
|
||||
'UINT' => 'INTEGER',
|
||||
'UINT:' => 'INTEGER',
|
||||
'TINT:' => 'INTEGER',
|
||||
'USINT' => 'INTEGER',
|
||||
'BOOL' => 'INTEGER',
|
||||
'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE',
|
||||
'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE',
|
||||
'CHAR:' => 'CHAR(%d) CHARACTER SET NONE',
|
||||
'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
|
||||
'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8',
|
||||
'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
|
||||
'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
|
||||
'TIMESTAMP' => 'INTEGER',
|
||||
'DECIMAL' => 'DOUBLE PRECISION',
|
||||
'DECIMAL:' => 'DOUBLE PRECISION',
|
||||
'PDECIMAL' => 'DOUBLE PRECISION',
|
||||
'PDECIMAL:' => 'DOUBLE PRECISION',
|
||||
'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8',
|
||||
'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8',
|
||||
'VARBINARY' => 'CHAR(255) CHARACTER SET NONE',
|
||||
),
|
||||
|
||||
'mssqlnative' => array(
|
||||
'INT:' => '[int]',
|
||||
'BINT' => '[float]',
|
||||
'UINT' => '[int]',
|
||||
'UINT:' => '[int]',
|
||||
'TINT:' => '[int]',
|
||||
'USINT' => '[int]',
|
||||
'BOOL' => '[int]',
|
||||
'VCHAR' => '[varchar] (255)',
|
||||
'VCHAR:' => '[varchar] (%d)',
|
||||
'CHAR:' => '[char] (%d)',
|
||||
'XSTEXT' => '[varchar] (1000)',
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
'mssql' => array(
|
||||
'INT:' => '[int]',
|
||||
'BINT' => '[float]',
|
||||
'UINT' => '[int]',
|
||||
'UINT:' => '[int]',
|
||||
'TINT:' => '[int]',
|
||||
'USINT' => '[int]',
|
||||
'BOOL' => '[int]',
|
||||
'VCHAR' => '[varchar] (255)',
|
||||
'VCHAR:' => '[varchar] (%d)',
|
||||
'CHAR:' => '[char] (%d)',
|
||||
'XSTEXT' => '[varchar] (1000)',
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
|
||||
'oracle' => array(
|
||||
'INT:' => 'number(%d)',
|
||||
'BINT' => 'number(20)',
|
||||
'UINT' => 'number(8)',
|
||||
'UINT:' => 'number(%d)',
|
||||
'TINT:' => 'number(%d)',
|
||||
'USINT' => 'number(4)',
|
||||
'BOOL' => 'number(1)',
|
||||
'VCHAR' => 'varchar2(255)',
|
||||
'VCHAR:' => 'varchar2(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'varchar2(1000)',
|
||||
'STEXT' => 'varchar2(3000)',
|
||||
'TEXT' => 'clob',
|
||||
'MTEXT' => 'clob',
|
||||
'XSTEXT_UNI'=> 'varchar2(300)',
|
||||
'STEXT_UNI' => 'varchar2(765)',
|
||||
'TEXT_UNI' => 'clob',
|
||||
'MTEXT_UNI' => 'clob',
|
||||
'TIMESTAMP' => 'number(11)',
|
||||
'DECIMAL' => 'number(5, 2)',
|
||||
'DECIMAL:' => 'number(%d, 2)',
|
||||
'PDECIMAL' => 'number(6, 3)',
|
||||
'PDECIMAL:' => 'number(%d, 3)',
|
||||
'VCHAR_UNI' => 'varchar2(765)',
|
||||
'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')),
|
||||
'VCHAR_CI' => 'varchar2(255)',
|
||||
'VARBINARY' => 'raw(255)',
|
||||
),
|
||||
'mssqlnative' => array(
|
||||
'INT:' => '[int]',
|
||||
'BINT' => '[float]',
|
||||
'UINT' => '[int]',
|
||||
'UINT:' => '[int]',
|
||||
'TINT:' => '[int]',
|
||||
'USINT' => '[int]',
|
||||
'BOOL' => '[int]',
|
||||
'VCHAR' => '[varchar] (255)',
|
||||
'VCHAR:' => '[varchar] (%d)',
|
||||
'CHAR:' => '[char] (%d)',
|
||||
'XSTEXT' => '[varchar] (1000)',
|
||||
'STEXT' => '[varchar] (3000)',
|
||||
'TEXT' => '[varchar] (8000)',
|
||||
'MTEXT' => '[text]',
|
||||
'XSTEXT_UNI'=> '[varchar] (100)',
|
||||
'STEXT_UNI' => '[varchar] (255)',
|
||||
'TEXT_UNI' => '[varchar] (4000)',
|
||||
'MTEXT_UNI' => '[text]',
|
||||
'TIMESTAMP' => '[int]',
|
||||
'DECIMAL' => '[float]',
|
||||
'DECIMAL:' => '[float]',
|
||||
'PDECIMAL' => '[float]',
|
||||
'PDECIMAL:' => '[float]',
|
||||
'VCHAR_UNI' => '[varchar] (255)',
|
||||
'VCHAR_UNI:'=> '[varchar] (%d)',
|
||||
'VCHAR_CI' => '[varchar] (255)',
|
||||
'VARBINARY' => '[varchar] (255)',
|
||||
),
|
||||
|
||||
'sqlite' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED',
|
||||
'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'text(65535)',
|
||||
'STEXT' => 'text(65535)',
|
||||
'TEXT' => 'text(65535)',
|
||||
'MTEXT' => 'mediumtext(16777215)',
|
||||
'XSTEXT_UNI'=> 'text(65535)',
|
||||
'STEXT_UNI' => 'text(65535)',
|
||||
'TEXT_UNI' => 'text(65535)',
|
||||
'MTEXT_UNI' => 'mediumtext(16777215)',
|
||||
'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar(255)',
|
||||
'VARBINARY' => 'blob',
|
||||
),
|
||||
'oracle' => array(
|
||||
'INT:' => 'number(%d)',
|
||||
'BINT' => 'number(20)',
|
||||
'UINT' => 'number(8)',
|
||||
'UINT:' => 'number(%d)',
|
||||
'TINT:' => 'number(%d)',
|
||||
'USINT' => 'number(4)',
|
||||
'BOOL' => 'number(1)',
|
||||
'VCHAR' => 'varchar2(255)',
|
||||
'VCHAR:' => 'varchar2(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'varchar2(1000)',
|
||||
'STEXT' => 'varchar2(3000)',
|
||||
'TEXT' => 'clob',
|
||||
'MTEXT' => 'clob',
|
||||
'XSTEXT_UNI'=> 'varchar2(300)',
|
||||
'STEXT_UNI' => 'varchar2(765)',
|
||||
'TEXT_UNI' => 'clob',
|
||||
'MTEXT_UNI' => 'clob',
|
||||
'TIMESTAMP' => 'number(11)',
|
||||
'DECIMAL' => 'number(5, 2)',
|
||||
'DECIMAL:' => 'number(%d, 2)',
|
||||
'PDECIMAL' => 'number(6, 3)',
|
||||
'PDECIMAL:' => 'number(%d, 3)',
|
||||
'VCHAR_UNI' => 'varchar2(765)',
|
||||
'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')),
|
||||
'VCHAR_CI' => 'varchar2(255)',
|
||||
'VARBINARY' => 'raw(255)',
|
||||
),
|
||||
|
||||
'postgres' => array(
|
||||
'INT:' => 'INT4',
|
||||
'BINT' => 'INT8',
|
||||
'UINT' => 'INT4', // unsigned
|
||||
'UINT:' => 'INT4', // unsigned
|
||||
'USINT' => 'INT2', // unsigned
|
||||
'BOOL' => 'INT2', // unsigned
|
||||
'TINT:' => 'INT2',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'varchar(1000)',
|
||||
'STEXT' => 'varchar(3000)',
|
||||
'TEXT' => 'varchar(8000)',
|
||||
'MTEXT' => 'TEXT',
|
||||
'XSTEXT_UNI'=> 'varchar(100)',
|
||||
'STEXT_UNI' => 'varchar(255)',
|
||||
'TEXT_UNI' => 'varchar(4000)',
|
||||
'MTEXT_UNI' => 'TEXT',
|
||||
'TIMESTAMP' => 'INT4', // unsigned
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar_ci',
|
||||
'VARBINARY' => 'bytea',
|
||||
),
|
||||
);
|
||||
'sqlite' => array(
|
||||
'INT:' => 'int(%d)',
|
||||
'BINT' => 'bigint(20)',
|
||||
'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED',
|
||||
'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED',
|
||||
'TINT:' => 'tinyint(%d)',
|
||||
'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED',
|
||||
'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'text(65535)',
|
||||
'STEXT' => 'text(65535)',
|
||||
'TEXT' => 'text(65535)',
|
||||
'MTEXT' => 'mediumtext(16777215)',
|
||||
'XSTEXT_UNI'=> 'text(65535)',
|
||||
'STEXT_UNI' => 'text(65535)',
|
||||
'TEXT_UNI' => 'text(65535)',
|
||||
'MTEXT_UNI' => 'mediumtext(16777215)',
|
||||
'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED',
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar(255)',
|
||||
'VARBINARY' => 'blob',
|
||||
),
|
||||
|
||||
'postgres' => array(
|
||||
'INT:' => 'INT4',
|
||||
'BINT' => 'INT8',
|
||||
'UINT' => 'INT4', // unsigned
|
||||
'UINT:' => 'INT4', // unsigned
|
||||
'USINT' => 'INT2', // unsigned
|
||||
'BOOL' => 'INT2', // unsigned
|
||||
'TINT:' => 'INT2',
|
||||
'VCHAR' => 'varchar(255)',
|
||||
'VCHAR:' => 'varchar(%d)',
|
||||
'CHAR:' => 'char(%d)',
|
||||
'XSTEXT' => 'varchar(1000)',
|
||||
'STEXT' => 'varchar(3000)',
|
||||
'TEXT' => 'varchar(8000)',
|
||||
'MTEXT' => 'TEXT',
|
||||
'XSTEXT_UNI'=> 'varchar(100)',
|
||||
'STEXT_UNI' => 'varchar(255)',
|
||||
'TEXT_UNI' => 'varchar(4000)',
|
||||
'MTEXT_UNI' => 'TEXT',
|
||||
'TIMESTAMP' => 'INT4', // unsigned
|
||||
'DECIMAL' => 'decimal(5,2)',
|
||||
'DECIMAL:' => 'decimal(%d,2)',
|
||||
'PDECIMAL' => 'decimal(6,3)',
|
||||
'PDECIMAL:' => 'decimal(%d,3)',
|
||||
'VCHAR_UNI' => 'varchar(255)',
|
||||
'VCHAR_UNI:'=> 'varchar(%d)',
|
||||
'VCHAR_CI' => 'varchar_ci',
|
||||
'VARBINARY' => 'bytea',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of types being unsigned for better reference in some db's
|
||||
@@ -308,6 +318,8 @@ class phpbb_db_tools
|
||||
$this->db = $db;
|
||||
$this->return_statements = $return_statements;
|
||||
|
||||
$this->dbms_type_map = self::get_dbms_type_map();
|
||||
|
||||
// Determine mapping database type
|
||||
switch ($this->db->sql_layer)
|
||||
{
|
||||
|
@@ -26,19 +26,19 @@ use Symfony\Component\Config\FileLocator;
|
||||
class phpbb_di_extension_core extends Extension
|
||||
{
|
||||
/**
|
||||
* phpBB Root path
|
||||
* Config path
|
||||
* @var string
|
||||
*/
|
||||
protected $root_path;
|
||||
protected $config_path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $root_path Root path
|
||||
* @param string $config_path Config path
|
||||
*/
|
||||
public function __construct($root_path)
|
||||
public function __construct($config_path)
|
||||
{
|
||||
$this->root_path = $root_path;
|
||||
$this->config_path = $config_path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class phpbb_di_extension_core extends Extension
|
||||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config')));
|
||||
$loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path)));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,6 @@ class phpbb_event_extension_subscriber_loader
|
||||
$finder = $this->extension_manager->get_finder();
|
||||
$subscriber_classes = $finder
|
||||
->extension_directory('/event')
|
||||
->suffix('listener')
|
||||
->core_path('event/')
|
||||
->get_classes();
|
||||
|
||||
|
@@ -72,7 +72,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base
|
||||
),
|
||||
),
|
||||
'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
|
||||
AND ' . $this->content_visibility->get_visibility_sql('post', array(), 'p.') . '
|
||||
AND ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ids, 'p.') . '
|
||||
AND p.post_time >= ' . $min_post_time . '
|
||||
AND u.user_id = p.poster_id',
|
||||
'ORDER_BY' => 'p.post_time DESC',
|
||||
|
@@ -43,7 +43,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
|
||||
|
||||
function open()
|
||||
{
|
||||
$sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type
|
||||
$sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
LEFT JOIN ' . FORUMS_TABLE . ' f
|
||||
ON (f.forum_id = t.forum_id)
|
||||
@@ -60,7 +60,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
|
||||
$this->forum_id = (int) $this->topic_data['forum_id'];
|
||||
|
||||
// Make sure topic is either approved or user authed
|
||||
if (!$this->topic_data['topic_approved'] && !$this->auth->acl_get('m_approve', $this->forum_id))
|
||||
if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id))
|
||||
{
|
||||
trigger_error('SORRY_AUTH_READ');
|
||||
}
|
||||
|
340
phpBB/phpbb/permissions.php
Normal file
340
phpBB/phpbb/permissions.php
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* DO NOT CHANGE
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class phpbb_permissions
|
||||
{
|
||||
/**
|
||||
* Event dispatcher object
|
||||
* @var phpbb_event_dispatcher
|
||||
*/
|
||||
protected $dispatcher;
|
||||
|
||||
/**
|
||||
* User object
|
||||
* @var phpbb_user
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param phpbb_event_dispatcher $phpbb_dispatcher Event dispatcher
|
||||
* @param phpbb_user $user User Object
|
||||
* @return null
|
||||
*/
|
||||
public function __construct(phpbb_event_dispatcher $phpbb_dispatcher, phpbb_user $user)
|
||||
{
|
||||
$this->dispatcher = $phpbb_dispatcher;
|
||||
$this->user = $user;
|
||||
|
||||
$categories = $this->categories;
|
||||
$types = $this->types;
|
||||
$permissions = $this->permissions;
|
||||
|
||||
/**
|
||||
* Allows to specify additional permission categories, types and permissions
|
||||
*
|
||||
* @event core.permissions
|
||||
* @var array types Array with permission types (a_, u_, m_, etc.)
|
||||
* @var array categories Array with permission categories (pm, post, settings, misc, etc.)
|
||||
* @var array permissions Array with permissions. Each Permission has the following layout:
|
||||
* '<type><permission>' => array(
|
||||
* 'lang' => 'Language Key with a Short description', // Optional, if not set,
|
||||
* // the permissions identifier '<type><permission>' is used with
|
||||
* // all uppercase.
|
||||
* 'cat' => 'Identifier of the category, the permission should be displayed in',
|
||||
* ),
|
||||
* Example:
|
||||
* 'u_viewprofile' => array(
|
||||
* 'lang' => 'ACL_U_VIEWPROFILE',
|
||||
* 'cat' => 'profile',
|
||||
* ),
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('types', 'categories', 'permissions');
|
||||
extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars)));
|
||||
|
||||
$this->categories = $categories;
|
||||
$this->types = $types;
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the permission categories (pm, post, settings, misc, etc.)
|
||||
*
|
||||
* @return array Layout: cat-identifier => Language key
|
||||
*/
|
||||
public function get_categories()
|
||||
{
|
||||
return $this->categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language string of a permission category
|
||||
*
|
||||
* @param string $category Identifier of the category
|
||||
* @return string Language string
|
||||
*/
|
||||
public function get_category_lang($category)
|
||||
{
|
||||
return $this->user->lang($this->categories[$category]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the permission types (a_, u_, m_, etc.)
|
||||
*
|
||||
* @return array Layout: type-identifier => Language key
|
||||
*/
|
||||
public function get_types()
|
||||
{
|
||||
return $this->types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language string of a permission type
|
||||
*
|
||||
* @param string $type Identifier of the type
|
||||
* @param mixed $scope Scope of the type (should be 'global', 'local' or false)
|
||||
* @return string Language string
|
||||
*/
|
||||
public function get_type_lang($type, $scope = false)
|
||||
{
|
||||
if ($scope && isset($this->types[$scope][$type]))
|
||||
{
|
||||
$lang_key = $this->types[$scope][$type];
|
||||
}
|
||||
else if (isset($this->types[$type]))
|
||||
{
|
||||
$lang_key = $this->types[$type];
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type);
|
||||
}
|
||||
|
||||
return $this->user->lang($lang_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the permissions.
|
||||
* Each Permission has the following layout:
|
||||
* '<type><permission>' => array(
|
||||
* 'lang' => 'Language Key with a Short description', // Optional, if not set,
|
||||
* // the permissions identifier '<type><permission>' is used with
|
||||
* // all uppercase.
|
||||
* 'cat' => 'Identifier of the category, the permission should be displayed in',
|
||||
* ),
|
||||
* Example:
|
||||
* 'u_viewprofile' => array(
|
||||
* 'lang' => 'ACL_U_VIEWPROFILE',
|
||||
* 'cat' => 'profile',
|
||||
* ),
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_permissions()
|
||||
{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the category of a permission
|
||||
*
|
||||
* @param string $permission Identifier of the permission
|
||||
* @return string Returns the category identifier of the permission
|
||||
*/
|
||||
public function get_permission_category($permission)
|
||||
{
|
||||
return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language string of a permission
|
||||
*
|
||||
* @param string $permission Identifier of the permission
|
||||
* @return string Language string
|
||||
*/
|
||||
public function get_permission_lang($permission)
|
||||
{
|
||||
return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission));
|
||||
}
|
||||
|
||||
protected $types = array(
|
||||
'u_' => 'ACL_TYPE_U_',
|
||||
'a_' => 'ACL_TYPE_A_',
|
||||
'm_' => 'ACL_TYPE_M_',
|
||||
'f_' => 'ACL_TYPE_F_',
|
||||
'global' => array(
|
||||
'm_' => 'ACL_TYPE_GLOBAL_M_',
|
||||
),
|
||||
);
|
||||
|
||||
protected $categories = array(
|
||||
'actions' => 'ACL_CAT_ACTIONS',
|
||||
'content' => 'ACL_CAT_CONTENT',
|
||||
'forums' => 'ACL_CAT_FORUMS',
|
||||
'misc' => 'ACL_CAT_MISC',
|
||||
'permissions' => 'ACL_CAT_PERMISSIONS',
|
||||
'pm' => 'ACL_CAT_PM',
|
||||
'polls' => 'ACL_CAT_POLLS',
|
||||
'post' => 'ACL_CAT_POST',
|
||||
'post_actions' => 'ACL_CAT_POST_ACTIONS',
|
||||
'posting' => 'ACL_CAT_POSTING',
|
||||
'profile' => 'ACL_CAT_PROFILE',
|
||||
'settings' => 'ACL_CAT_SETTINGS',
|
||||
'topic_actions' => 'ACL_CAT_TOPIC_ACTIONS',
|
||||
'user_group' => 'ACL_CAT_USER_GROUP',
|
||||
);
|
||||
|
||||
protected $permissions = array(
|
||||
// User Permissions
|
||||
'u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'),
|
||||
'u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'),
|
||||
'u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'),
|
||||
'u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'),
|
||||
'u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'),
|
||||
'u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'),
|
||||
'u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'),
|
||||
|
||||
'u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'),
|
||||
'u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'),
|
||||
'u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'),
|
||||
'u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'),
|
||||
'u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'),
|
||||
|
||||
'u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'),
|
||||
'u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'),
|
||||
'u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'),
|
||||
'u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'),
|
||||
'u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'),
|
||||
'u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'),
|
||||
'u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'),
|
||||
'u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'),
|
||||
'u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'),
|
||||
'u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'),
|
||||
'u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'),
|
||||
'u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'),
|
||||
'u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'),
|
||||
'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'),
|
||||
'u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'),
|
||||
|
||||
'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'),
|
||||
'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'),
|
||||
'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'),
|
||||
'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'),
|
||||
'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'),
|
||||
'u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'),
|
||||
|
||||
// Forum Permissions
|
||||
'f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'),
|
||||
'f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'),
|
||||
'f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'),
|
||||
'f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'),
|
||||
'f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'),
|
||||
'f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'),
|
||||
'f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'),
|
||||
'f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'),
|
||||
'f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'),
|
||||
'f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'),
|
||||
|
||||
'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'),
|
||||
'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'),
|
||||
'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'),
|
||||
'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'),
|
||||
'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'),
|
||||
'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'),
|
||||
'f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'),
|
||||
'f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'),
|
||||
'f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'),
|
||||
|
||||
'f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'),
|
||||
'f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'),
|
||||
'f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'),
|
||||
'f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'),
|
||||
'f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'),
|
||||
'f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'),
|
||||
'f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'),
|
||||
|
||||
'f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'),
|
||||
'f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'),
|
||||
'f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'),
|
||||
|
||||
// Moderator Permissions
|
||||
'm_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'),
|
||||
'm_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'),
|
||||
'm_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'),
|
||||
'm_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'),
|
||||
'm_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'),
|
||||
|
||||
'm_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'),
|
||||
'm_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'),
|
||||
'm_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'),
|
||||
'm_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'),
|
||||
|
||||
'm_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'misc'),
|
||||
'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'),
|
||||
'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'),
|
||||
|
||||
// Admin Permissions
|
||||
'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'),
|
||||
'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'),
|
||||
'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'),
|
||||
'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'),
|
||||
|
||||
'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'),
|
||||
'a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'),
|
||||
'a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'),
|
||||
'a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'),
|
||||
|
||||
'a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'),
|
||||
'a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'),
|
||||
'a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'),
|
||||
'a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'),
|
||||
|
||||
'a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'),
|
||||
'a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'),
|
||||
'a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'),
|
||||
'a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'),
|
||||
'a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'),
|
||||
'a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'),
|
||||
'a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'),
|
||||
'a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'),
|
||||
'a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'),
|
||||
|
||||
'a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'),
|
||||
'a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'),
|
||||
'a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'),
|
||||
'a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'),
|
||||
'a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'),
|
||||
'a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'),
|
||||
'a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'),
|
||||
'a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'),
|
||||
'a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'),
|
||||
|
||||
'a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'),
|
||||
'a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'),
|
||||
'a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'),
|
||||
'a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'),
|
||||
'a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'),
|
||||
'a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'),
|
||||
'a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'),
|
||||
'a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'),
|
||||
'a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'),
|
||||
'a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'),
|
||||
'a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'),
|
||||
);
|
||||
}
|
@@ -1022,7 +1022,8 @@ class phpbb_session
|
||||
{
|
||||
include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx);
|
||||
}
|
||||
phpbb_captcha_factory::garbage_collect($config['captcha_plugin']);
|
||||
$captcha_factory = new phpbb_captcha_factory();
|
||||
$captcha_factory->garbage_collect($config['captcha_plugin']);
|
||||
|
||||
$sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . '
|
||||
WHERE attempt_time < ' . (time() - (int) $config['ip_login_limit_time']);
|
||||
|
@@ -1,137 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with core style paths and extension style paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_extension_path_provider extends phpbb_extension_provider implements phpbb_style_path_provider_interface
|
||||
{
|
||||
/**
|
||||
* Optional prefix for style paths searched within extensions.
|
||||
*
|
||||
* Empty by default. Relative to the extension directory. As an example, it
|
||||
* could be adm/ for admin style.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ext_dir_prefix = '';
|
||||
|
||||
/**
|
||||
* A provider of paths to be searched for styles
|
||||
* @var phpbb_style_path_provider
|
||||
*/
|
||||
protected $base_path_provider;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Constructor stores extension manager
|
||||
*
|
||||
* @param phpbb_extension_manager $extension_manager phpBB extension manager
|
||||
* @param phpbb_style_path_provider $base_path_provider A simple path provider
|
||||
* to provide paths to be located in extensions
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
*/
|
||||
public function __construct(phpbb_extension_manager $extension_manager, phpbb_style_path_provider $base_path_provider, $phpbb_root_path)
|
||||
{
|
||||
parent::__construct($extension_manager);
|
||||
$this->base_path_provider = $base_path_provider;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a prefix for style paths searched within extensions.
|
||||
*
|
||||
* The prefix is inserted between the extension's path e.g. ext/foo/ and
|
||||
* the looked up style path, e.g. styles/bar/. So it should not have a
|
||||
* leading slash, but should have a trailing slash.
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
||||
{
|
||||
$this->ext_dir_prefix = $ext_dir_prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds style paths using the extension manager
|
||||
*
|
||||
* Locates a path (e.g. styles/prosilver/) in all active extensions.
|
||||
* Then appends the core style paths based in the current working
|
||||
* directory.
|
||||
*
|
||||
* @return array List of style paths
|
||||
*/
|
||||
public function find()
|
||||
{
|
||||
$directories = array();
|
||||
|
||||
$finder = $this->extension_manager->get_finder();
|
||||
foreach ($this->base_path_provider as $key => $paths)
|
||||
{
|
||||
if ($key == 'style')
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$directories['style'][] = $path;
|
||||
if ($path && !phpbb_is_absolute($path))
|
||||
{
|
||||
// Remove phpBB root path from the style path,
|
||||
// so the finder is able to find extension styles,
|
||||
// when the root path is not ./
|
||||
if (strpos($path, $this->phpbb_root_path) === 0)
|
||||
{
|
||||
$path = substr($path, strlen($this->phpbb_root_path));
|
||||
}
|
||||
|
||||
$result = $finder->directory('/' . $this->ext_dir_prefix . $path)
|
||||
->get_directories(true, false, true);
|
||||
foreach ($result as $ext => $ext_path)
|
||||
{
|
||||
// Make sure $ext_path has no ending slash
|
||||
if (substr($ext_path, -1) === '/')
|
||||
{
|
||||
$ext_path = substr($ext_path, 0, -1);
|
||||
}
|
||||
$directories[$ext][] = $ext_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles)
|
||||
{
|
||||
$this->base_path_provider->set_styles($styles);
|
||||
$this->items = null;
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface
|
||||
{
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* Ignores the extension dir prefix
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* The first element of the passed styles map, is considered the main
|
||||
* style.
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles)
|
||||
{
|
||||
$this->paths = array('style' => $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an iterator over all style paths
|
||||
*
|
||||
* @return ArrayIterator An iterator for the array of style paths
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->paths);
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a style resource locator with paths
|
||||
*
|
||||
* Finds installed style paths and makes them available to the resource locator.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
interface phpbb_style_path_provider_interface extends Traversable
|
||||
{
|
||||
/**
|
||||
* Defines a prefix to use for style paths in extensions
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix);
|
||||
|
||||
/**
|
||||
* Overwrites the current style paths
|
||||
*
|
||||
* @param array $styles An array of style paths. The first element is the main style.
|
||||
* @return null
|
||||
*/
|
||||
public function set_styles(array $styles);
|
||||
}
|
@@ -1,348 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Style resource locator.
|
||||
* Maintains mapping from template handles to source template file paths.
|
||||
* Locates style files: resources (such as .js and .css files) and templates.
|
||||
*
|
||||
* Style resource locator is aware of styles tree, and can return actual
|
||||
* filesystem paths (i.e., the "child" style or the "parent" styles)
|
||||
* depending on what files exist.
|
||||
*
|
||||
* Root paths stored in locator are paths to style directories. Templates are
|
||||
* stored in subdirectory that $template_path points to.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style_resource_locator implements phpbb_template_locator
|
||||
{
|
||||
/**
|
||||
* Paths to style directories.
|
||||
* @var array
|
||||
*/
|
||||
private $roots = array();
|
||||
|
||||
/**
|
||||
* Location of templates directory within style directories.
|
||||
* Must have trailing slash. Empty if templates are stored in root
|
||||
* style directory, such as admin control panel templates.
|
||||
* @var string
|
||||
*/
|
||||
private $template_path;
|
||||
|
||||
/**
|
||||
* Map from root index to handles to source template file paths.
|
||||
* Normally it only contains paths for handles that are used
|
||||
* (or are likely to be used) by the page being rendered and not
|
||||
* all templates that exist on the filesystem.
|
||||
* @var array
|
||||
*/
|
||||
private $files = array();
|
||||
|
||||
/**
|
||||
* Map from handles to source template file names.
|
||||
* Covers the same data as $files property but maps to basenames
|
||||
* instead of paths.
|
||||
* @var array
|
||||
*/
|
||||
private $filenames = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Sets default template path to template/.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->set_default_template_path();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of style paths
|
||||
*
|
||||
* These paths will be searched for style files in the provided order.
|
||||
* Paths may be outside of phpBB, but templates loaded from these paths
|
||||
* will still be cached.
|
||||
*
|
||||
* @param array $style_paths An array of paths to style directories
|
||||
* @return null
|
||||
*/
|
||||
public function set_paths($style_paths)
|
||||
{
|
||||
$this->roots = array();
|
||||
$this->files = array();
|
||||
$this->filenames = array();
|
||||
|
||||
foreach ($style_paths as $key => $paths)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
// Make sure $path has no ending slash
|
||||
if (substr($path, -1) === '/')
|
||||
{
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
$this->roots[$key][] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of templates directory within style directories.
|
||||
*
|
||||
* The location must be a relative path, with a trailing slash.
|
||||
* Typically it is one directory level deep, e.g. "template/".
|
||||
*
|
||||
* @param string $template_path Relative path to templates directory within style directories
|
||||
* @return null
|
||||
*/
|
||||
public function set_template_path($template_path)
|
||||
{
|
||||
$this->template_path = $template_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of templates directory within style directories
|
||||
* to the default, which is "template/".
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function set_default_template_path()
|
||||
{
|
||||
$this->template_path = 'template/';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set_filenames(array $filename_array)
|
||||
{
|
||||
foreach ($filename_array as $handle => $filename)
|
||||
{
|
||||
if (empty($filename))
|
||||
{
|
||||
trigger_error("style resource locator: set_filenames: Empty filename specified for $handle", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$this->filename[$handle] = $filename;
|
||||
|
||||
foreach ($this->roots as $root_key => $root_paths)
|
||||
{
|
||||
foreach ($root_paths as $root_index => $root)
|
||||
{
|
||||
$this->files[$root_key][$root_index][$handle] = $root . '/' . $this->template_path . $filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_filename_for_handle($handle)
|
||||
{
|
||||
if (!isset($this->filename[$handle]))
|
||||
{
|
||||
trigger_error("style resource locator: get_filename_for_handle: No file specified for handle $handle", E_USER_ERROR);
|
||||
}
|
||||
return $this->filename[$handle];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_virtual_source_file_for_handle($handle)
|
||||
{
|
||||
// If we don't have a file assigned to this handle, die.
|
||||
if (!isset($this->files['style'][0][$handle]))
|
||||
{
|
||||
trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR);
|
||||
}
|
||||
|
||||
$source_file = $this->files['style'][0][$handle];
|
||||
return $source_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_source_file_for_handle($handle, $find_all = false)
|
||||
{
|
||||
// If we don't have a file assigned to this handle, die.
|
||||
if (!isset($this->files['style'][0][$handle]))
|
||||
{
|
||||
trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// locate a source file that exists
|
||||
$source_file = $this->files['style'][0][$handle];
|
||||
$tried = $source_file;
|
||||
$found = false;
|
||||
$found_all = array();
|
||||
foreach ($this->roots as $root_key => $root_paths)
|
||||
{
|
||||
foreach ($root_paths as $root_index => $root)
|
||||
{
|
||||
$source_file = $this->files[$root_key][$root_index][$handle];
|
||||
$tried .= ', ' . $source_file;
|
||||
if (file_exists($source_file))
|
||||
{
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($found)
|
||||
{
|
||||
if ($find_all)
|
||||
{
|
||||
$found_all[] = $source_file;
|
||||
$found = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// search failed
|
||||
if (!$found && !$find_all)
|
||||
{
|
||||
trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return ($find_all) ? $found_all : $source_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get_first_file_location($files, $return_default = false, $return_full_path = true)
|
||||
{
|
||||
// set default value
|
||||
$default_result = false;
|
||||
|
||||
// check all available paths
|
||||
foreach ($this->roots as $root_paths)
|
||||
{
|
||||
foreach ($root_paths as $path)
|
||||
{
|
||||
// check all files
|
||||
foreach ($files as $filename)
|
||||
{
|
||||
$source_file = $path . '/' . $filename;
|
||||
if (file_exists($source_file))
|
||||
{
|
||||
return ($return_full_path) ? $source_file : $filename;
|
||||
}
|
||||
|
||||
// assign first file as result if $return_default is true
|
||||
if ($return_default && $default_result === false)
|
||||
{
|
||||
$default_result = $source_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// search failed
|
||||
return $default_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains filesystem path for a template file.
|
||||
*
|
||||
* The simplest use is specifying a single template file as a string
|
||||
* in the first argument. This template file should be a basename
|
||||
* of a template file in the selected style, or its parent styles
|
||||
* if template inheritance is being utilized.
|
||||
*
|
||||
* Note: "selected style" is whatever style the style resource locator
|
||||
* is configured for.
|
||||
*
|
||||
* The return value then will be a path, relative to the current
|
||||
* directory or absolute, to the template file in the selected style
|
||||
* or its closest parent.
|
||||
*
|
||||
* If the selected style does not have the template file being searched,
|
||||
* (and if inheritance is involved, none of the parents have it either),
|
||||
* false will be returned.
|
||||
*
|
||||
* Specifying true for $return_default will cause the function to
|
||||
* return the first path which was checked for existence in the event
|
||||
* that the template file was not found, instead of false.
|
||||
* This is the path in the selected style itself, not any of its
|
||||
* parents.
|
||||
*
|
||||
* $files can be given an array of templates instead of a single
|
||||
* template. When given an array, the function will try to resolve
|
||||
* each template in the array to a path, and will return the first
|
||||
* path that exists, or false if none exist.
|
||||
*
|
||||
* If $files is an array and template inheritance is involved, first
|
||||
* each of the files will be checked in the selected style, then each
|
||||
* of the files will be checked in the immediate parent, and so on.
|
||||
*
|
||||
* If $return_full_path is false, then instead of returning a usable
|
||||
* path (when the template is found) only the template's basename
|
||||
* will be returned. This can be used to check which of the templates
|
||||
* specified in $files exists. Naturally more than one template must
|
||||
* be given in $files.
|
||||
*
|
||||
* This function works identically to get_first_file_location except
|
||||
* it operates on a list of templates, not files. Practically speaking,
|
||||
* the templates given in the first argument first are prepended with
|
||||
* the template path (property in this class), then given to
|
||||
* get_first_file_location for the rest of the processing.
|
||||
*
|
||||
* Templates given to this function can be relative paths for templates
|
||||
* located in subdirectories of the template directories. The paths
|
||||
* should be relative to the templates directory (template/ by default).
|
||||
*
|
||||
* @param string or array $files List of templates to locate. If there is only
|
||||
* one template, $files can be a string to make code easier to read.
|
||||
* @param bool $return_default Determines what to return if template does not
|
||||
* exist. If true, function will return location where template is
|
||||
* supposed to be. If false, function will return false.
|
||||
* @param bool $return_full_path If true, function will return full path
|
||||
* to template. If false, function will return template file name.
|
||||
* This parameter can be used to check which one of set of template
|
||||
* files is available.
|
||||
* @return string or boolean Source template path if template exists or $return_default is
|
||||
* true. False if template does not exist and $return_default is false
|
||||
*/
|
||||
public function get_first_template_location($templates, $return_default = false, $return_full_path = true)
|
||||
{
|
||||
// add template path prefix
|
||||
$files = array();
|
||||
if (is_string($templates))
|
||||
{
|
||||
$files[] = $this->template_path . $templates;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($templates as $template)
|
||||
{
|
||||
$files[] = $this->template_path . $template;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->get_first_file_location($files, $return_default, $return_full_path);
|
||||
}
|
||||
}
|
@@ -1,241 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base Style class.
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_style
|
||||
{
|
||||
/**
|
||||
* Template class.
|
||||
* Handles everything related to templates.
|
||||
* @var phpbb_template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
/**
|
||||
* phpBB root path
|
||||
* @var string
|
||||
*/
|
||||
private $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* PHP file extension
|
||||
* @var string
|
||||
*/
|
||||
private $php_ext;
|
||||
|
||||
/**
|
||||
* phpBB config instance
|
||||
* @var phpbb_config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Current user
|
||||
* @var phpbb_user
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Style resource locator
|
||||
* @var phpbb_style_resource_locator
|
||||
*/
|
||||
private $locator;
|
||||
|
||||
/**
|
||||
* Style path provider
|
||||
* @var phpbb_style_path_provider
|
||||
*/
|
||||
private $provider;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param user $user current user
|
||||
* @param phpbb_style_resource_locator $locator style resource locator
|
||||
* @param phpbb_style_path_provider $provider style path provider
|
||||
* @param phpbb_template $template template
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
$this->locator = $locator;
|
||||
$this->provider = $provider;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style tree of the style preferred by the current user
|
||||
*
|
||||
* @return array Style tree, most specific first
|
||||
*/
|
||||
public function get_user_style()
|
||||
{
|
||||
$style_list = array(
|
||||
$this->user->style['style_path'],
|
||||
);
|
||||
|
||||
if ($this->user->style['style_parent_id'])
|
||||
{
|
||||
$style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree'])));
|
||||
}
|
||||
|
||||
return $style_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style location based on (current) user's chosen style.
|
||||
*
|
||||
* @param array $style_directories The directories to add style paths for
|
||||
* E.g. array('ext/foo/bar/styles', 'styles')
|
||||
* Default: array('styles') (phpBB's style directory)
|
||||
* @return bool true
|
||||
*/
|
||||
public function set_style($style_directories = array('styles'))
|
||||
{
|
||||
$this->names = $this->get_user_style();
|
||||
|
||||
$paths = array();
|
||||
foreach ($style_directories as $directory)
|
||||
{
|
||||
foreach ($this->names as $name)
|
||||
{
|
||||
$path = $this->get_style_path($name, $directory);
|
||||
|
||||
if (is_dir($path))
|
||||
{
|
||||
$paths[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->provider->set_styles($paths);
|
||||
$this->locator->set_paths($this->provider);
|
||||
|
||||
$new_paths = array();
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$new_paths[] = $path . '/template/';
|
||||
}
|
||||
|
||||
$this->template->set_style_names($this->names, $new_paths, ($style_directories === array('styles')));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom style location (able to use directory outside of phpBB).
|
||||
*
|
||||
* Note: Templates are still compiled to phpBB's cache directory.
|
||||
*
|
||||
* @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver"
|
||||
* @param array or string $paths Array of style paths, relative to current root directory
|
||||
* @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used.
|
||||
* @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/).
|
||||
* @return bool true
|
||||
*/
|
||||
public function set_custom_style($name, $paths, $names = array(), $template_path = false)
|
||||
{
|
||||
if (is_string($paths))
|
||||
{
|
||||
$paths = array($paths);
|
||||
}
|
||||
|
||||
if (empty($names))
|
||||
{
|
||||
$names = array($name);
|
||||
}
|
||||
$this->names = $names;
|
||||
|
||||
$this->provider->set_styles($paths);
|
||||
$this->locator->set_paths($this->provider);
|
||||
|
||||
if ($template_path !== false)
|
||||
{
|
||||
$this->locator->set_template_path($template_path);
|
||||
}
|
||||
|
||||
$new_paths = array();
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/');
|
||||
}
|
||||
|
||||
$this->template->set_style_names($names, $new_paths);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get location of style directory for specific style_path
|
||||
*
|
||||
* @param string $path Style path, such as "prosilver"
|
||||
* @param string $style_base_directory The base directory the style is in
|
||||
* E.g. 'styles', 'ext/foo/bar/styles'
|
||||
* Default: 'styles'
|
||||
* @return string Path to style directory, relative to current path
|
||||
*/
|
||||
public function get_style_path($path, $style_base_directory = 'styles')
|
||||
{
|
||||
return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a prefix to use for style paths in extensions
|
||||
*
|
||||
* @param string $ext_dir_prefix The prefix including trailing slash
|
||||
* @return null
|
||||
*/
|
||||
public function set_ext_dir_prefix($ext_dir_prefix)
|
||||
{
|
||||
$this->provider->set_ext_dir_prefix($ext_dir_prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates source file path, accounting for styles tree and verifying that
|
||||
* the path exists.
|
||||
*
|
||||
* @param string or array $files List of files to locate. If there is only
|
||||
* one file, $files can be a string to make code easier to read.
|
||||
* @param bool $return_default Determines what to return if file does not
|
||||
* exist. If true, function will return location where file is
|
||||
* supposed to be. If false, function will return false.
|
||||
* @param bool $return_full_path If true, function will return full path
|
||||
* to file. If false, function will return file name. This
|
||||
* parameter can be used to check which one of set of files
|
||||
* is available.
|
||||
* @return string or boolean Source file path if file exists or $return_default is
|
||||
* true. False if file does not exist and $return_default is false
|
||||
*/
|
||||
public function locate($files, $return_default = false, $return_full_path = true)
|
||||
{
|
||||
// convert string to array
|
||||
if (is_string($files))
|
||||
{
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
// use resource locator to find files
|
||||
return $this->locator->get_first_file_location($files, $return_default, $return_full_path);
|
||||
}
|
||||
}
|
148
phpBB/phpbb/template/base.php
Normal file
148
phpBB/phpbb/template/base.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
abstract class phpbb_template_base implements phpbb_template
|
||||
{
|
||||
/**
|
||||
* Template context.
|
||||
* Stores template data used during template rendering.
|
||||
*
|
||||
* @var phpbb_template_context
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Array of filenames assigned to set_filenames
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $filenames = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_filenames(array $filename_array)
|
||||
{
|
||||
$this->filenames = array_merge($this->filenames, $filename_array);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filename from the handle
|
||||
*
|
||||
* @param string $handle
|
||||
* @return string
|
||||
*/
|
||||
protected function get_filename_from_handle($handle)
|
||||
{
|
||||
return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
$this->context->clear();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function destroy_block_vars($blockname)
|
||||
{
|
||||
$this->context->destroy_block_vars($blockname);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function assign_vars(array $vararray)
|
||||
{
|
||||
foreach ($vararray as $key => $val)
|
||||
{
|
||||
$this->assign_var($key, $val);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function assign_var($varname, $varval)
|
||||
{
|
||||
$this->context->assign_var($varname, $varval);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append_var($varname, $varval)
|
||||
{
|
||||
$this->context->append_var($varname, $varval);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function assign_block_vars($blockname, array $vararray)
|
||||
{
|
||||
$this->context->assign_block_vars($blockname, $vararray);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
|
||||
{
|
||||
return $this->context->alter_block_array($blockname, $vararray, $key, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls hook if any is defined.
|
||||
*
|
||||
* @param string $handle Template handle being displayed.
|
||||
* @param string $method Method name of the caller.
|
||||
*/
|
||||
protected function call_hook($handle, $method)
|
||||
{
|
||||
global $phpbb_hook;
|
||||
|
||||
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this))
|
||||
{
|
||||
if ($phpbb_hook->hook_return(array(__CLASS__, $method)))
|
||||
{
|
||||
$result = $phpbb_hook->hook_return_result(array(__CLASS__, $method));
|
||||
return array($result);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,163 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resource locator interface.
|
||||
*
|
||||
* Objects implementing this interface maintain mapping from template handles
|
||||
* to source template file paths and locate templates.
|
||||
*
|
||||
* Locates style files.
|
||||
*
|
||||
* Resource locator is aware of styles tree, and can return actual
|
||||
* filesystem paths (i.e., the "child" style or the "parent" styles)
|
||||
* depending on what files exist.
|
||||
*
|
||||
* Root paths stored in locator are paths to style directories. Templates are
|
||||
* stored in subdirectory that $template_path points to.
|
||||
*
|
||||
* @package phpBB3
|
||||
*/
|
||||
interface phpbb_template_locator
|
||||
{
|
||||
/**
|
||||
* Sets the template filenames for handles. $filename_array
|
||||
* should be a hash of handle => filename pairs.
|
||||
*
|
||||
* @param array $filename_array Should be a hash of handle => filename pairs.
|
||||
*/
|
||||
public function set_filenames(array $filename_array);
|
||||
|
||||
/**
|
||||
* Determines the filename for a template handle.
|
||||
*
|
||||
* The filename comes from array used in a set_filenames call,
|
||||
* which should have been performed prior to invoking this function.
|
||||
* Return value is a file basename (without path).
|
||||
*
|
||||
* @param $handle string Template handle
|
||||
* @return string Filename corresponding to the template handle
|
||||
*/
|
||||
public function get_filename_for_handle($handle);
|
||||
|
||||
/**
|
||||
* Determines the source file path for a template handle without
|
||||
* regard for styles tree.
|
||||
*
|
||||
* This function returns the path in "primary" style directory
|
||||
* corresponding to the given template handle. That path may or
|
||||
* may not actually exist on the filesystem. Because this function
|
||||
* does not perform stat calls to determine whether the path it
|
||||
* returns actually exists, it is faster than get_source_file_for_handle.
|
||||
*
|
||||
* Use get_source_file_for_handle to obtain the actual path that is
|
||||
* guaranteed to exist (which might come from the parent style
|
||||
* directory if primary style has parent styles).
|
||||
*
|
||||
* This function will trigger an error if the handle was never
|
||||
* associated with a template file via set_filenames.
|
||||
*
|
||||
* @param $handle string Template handle
|
||||
* @return string Path to source file path in primary style directory
|
||||
*/
|
||||
public function get_virtual_source_file_for_handle($handle);
|
||||
|
||||
/**
|
||||
* Determines the source file path for a template handle, accounting
|
||||
* for styles tree and verifying that the path exists.
|
||||
*
|
||||
* This function returns the actual path that may be compiled for
|
||||
* the specified template handle. It will trigger an error if
|
||||
* the template handle was never associated with a template path
|
||||
* via set_filenames or if the template file does not exist on the
|
||||
* filesystem.
|
||||
*
|
||||
* Use get_virtual_source_file_for_handle to just resolve a template
|
||||
* handle to a path without any filesystem or styles tree checks.
|
||||
*
|
||||
* @param string $handle Template handle (i.e. "friendly" template name)
|
||||
* @param bool $find_all If true, each root path will be checked and function
|
||||
* will return array of files instead of string and will not
|
||||
* trigger a error if template does not exist
|
||||
* @return string Source file path
|
||||
*/
|
||||
public function get_source_file_for_handle($handle, $find_all = false);
|
||||
|
||||
/**
|
||||
* Obtains a complete filesystem path for a file in a style.
|
||||
*
|
||||
* This function traverses the style tree (selected style and
|
||||
* its parents in order, if inheritance is being used) and finds
|
||||
* the first file on the filesystem matching specified relative path,
|
||||
* or the first of the specified paths if more than one path is given.
|
||||
*
|
||||
* This function can be used to determine filesystem path of any
|
||||
* file under any style, with the consequence being that complete
|
||||
* relative to the style directory path must be provided as an argument.
|
||||
*
|
||||
* In particular, this function can be used to locate templates
|
||||
* and javascript files.
|
||||
*
|
||||
* For locating templates get_first_template_location should be used
|
||||
* as it prepends the configured template path to the template basename.
|
||||
*
|
||||
* Note: "selected style" is whatever style the style resource locator
|
||||
* is configured for.
|
||||
*
|
||||
* The return value then will be a path, relative to the current
|
||||
* directory or absolute, to the first existing file in the selected
|
||||
* style or its closest parent.
|
||||
*
|
||||
* If the selected style does not have the file being searched,
|
||||
* (and if inheritance is involved, none of the parents have it either),
|
||||
* false will be returned.
|
||||
*
|
||||
* Multiple files can be specified, in which case the first file in
|
||||
* the list that can be found on the filesystem is returned.
|
||||
*
|
||||
* If multiple files are specified and inheritance is involved,
|
||||
* first each of the specified files is checked in the selected style,
|
||||
* then each of the specified files is checked in the immediate parent,
|
||||
* etc.
|
||||
*
|
||||
* Specifying true for $return_default will cause the function to
|
||||
* return the first path which was checked for existence in the event
|
||||
* that the template file was not found, instead of false.
|
||||
* This is always a path in the selected style itself, not any of its
|
||||
* parents.
|
||||
*
|
||||
* If $return_full_path is false, then instead of returning a usable
|
||||
* path (when the file is found) the file's path relative to the style
|
||||
* directory will be returned. This is the same path as was given to
|
||||
* the function as a parameter. This can be used to check which of the
|
||||
* files specified in $files exists. Naturally this requires passing
|
||||
* more than one file in $files.
|
||||
*
|
||||
* @param array $files List of files to locate.
|
||||
* @param bool $return_default Determines what to return if file does not
|
||||
* exist. If true, function will return location where file is
|
||||
* supposed to be. If false, function will return false.
|
||||
* @param bool $return_full_path If true, function will return full path
|
||||
* to file. If false, function will return file name. This
|
||||
* parameter can be used to check which one of set of files
|
||||
* is available.
|
||||
* @return string or boolean Source file path if file exists or $return_default is
|
||||
* true. False if file does not exist and $return_default is false
|
||||
*/
|
||||
public function get_first_file_location($files, $return_default = false, $return_full_path = true);
|
||||
}
|
@@ -34,14 +34,32 @@ interface phpbb_template
|
||||
public function set_filenames(array $filename_array);
|
||||
|
||||
/**
|
||||
* Sets the style names/paths corresponding to style hierarchy being compiled
|
||||
* and/or rendered.
|
||||
* Get the style tree of the style preferred by the current user
|
||||
*
|
||||
* @param array $style_names List of style names in inheritance tree order
|
||||
* @param array $style_paths List of style paths in inheritance tree order
|
||||
* @return array Style tree, most specific first
|
||||
*/
|
||||
public function get_user_style();
|
||||
|
||||
/**
|
||||
* Set style location based on (current) user's chosen style.
|
||||
*
|
||||
* @param array $style_directories The directories to add style paths for
|
||||
* E.g. array('ext/foo/bar/styles', 'styles')
|
||||
* Default: array('styles') (phpBB's style directory)
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function set_style_names(array $style_names, array $style_paths);
|
||||
public function set_style($style_directories = array('styles'));
|
||||
|
||||
/**
|
||||
* Set custom style location (able to use directory outside of phpBB).
|
||||
*
|
||||
* Note: Templates are still compiled to phpBB's cache directory.
|
||||
*
|
||||
* @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions.
|
||||
* @param string|array or string $paths Array of style paths, relative to current root directory
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function set_custom_style($names, $paths);
|
||||
|
||||
/**
|
||||
* Clears all variables and blocks assigned to this template.
|
||||
|
@@ -126,10 +126,14 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
{
|
||||
$callback = function($matches)
|
||||
{
|
||||
// Remove any quotes that may have been used in different implementations
|
||||
// E.g. DEFINE $TEST = 'blah' vs INCLUDE foo
|
||||
// Replace {} with start/end to parse variables (' ~ TEST ~ '.html)
|
||||
$matches[2] = str_replace(array('"', "'", '{', '}'), array('', '', "' ~ ", " ~ '"), $matches[2]);
|
||||
// Remove matching quotes at the beginning/end if a statement;
|
||||
// E.g. 'asdf'"' -> asdf'"
|
||||
// E.g. "asdf'"" -> asdf'"
|
||||
// E.g. 'asdf'" -> 'asdf'"
|
||||
$matches[2] = preg_replace('#^([\'"])?(.*?)\1$#', '$2', $matches[2]);
|
||||
|
||||
// Replace template variables with start/end to parse variables (' ~ TEST ~ '.html)
|
||||
$matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]);
|
||||
|
||||
// Surround the matches in single quotes ('' ~ TEST ~ '.html')
|
||||
return "<!-- {$matches[1]} '{$matches[2]}' -->";
|
||||
@@ -187,20 +191,18 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
// Recursive...fix any child nodes
|
||||
$body = $parent_class->fix_begin_tokens($body, $parent_nodes);
|
||||
|
||||
// Rename loopname vars (to prevent collisions, loop children are named (loop name)_loop_element)
|
||||
$body = str_replace($name . '.', $name . '_loop_element.', $body);
|
||||
|
||||
// Need the parent variable name
|
||||
array_pop($parent_nodes);
|
||||
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '_loop_element.' : '';
|
||||
$parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : '';
|
||||
|
||||
if ($subset !== '')
|
||||
{
|
||||
$subset = '|subset(' . $subset . ')';
|
||||
}
|
||||
|
||||
// Turn into a Twig for loop, using (loop name)_loop_element for each child
|
||||
return "{% for {$name}_loop_element in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||
$parent = ($parent) ?: 'loops.';
|
||||
// Turn into a Twig for loop
|
||||
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
|
||||
};
|
||||
|
||||
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
|
||||
@@ -217,21 +219,28 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||
*/
|
||||
protected function fix_if_tokens($code)
|
||||
{
|
||||
$callback = function($matches)
|
||||
{
|
||||
// Replace $TEST with definition.TEST
|
||||
$matches[1] = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $matches[1]);
|
||||
|
||||
// Replace .test with test|length
|
||||
$matches[1] = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $matches[1]);
|
||||
|
||||
return '<!-- IF' . $matches[1] . '-->';
|
||||
};
|
||||
// Replace ELSE IF with ELSEIF
|
||||
$code = preg_replace('#<!-- ELSE IF (.+?) -->#', '<!-- ELSEIF $1 -->', $code);
|
||||
|
||||
// Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces)
|
||||
$code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code);
|
||||
|
||||
return preg_replace_callback('#<!-- IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
|
||||
$callback = function($matches)
|
||||
{
|
||||
$inner = $matches[2];
|
||||
// Replace $TEST with definition.TEST
|
||||
$inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner);
|
||||
|
||||
// Replace .foo with loops.foo|length
|
||||
$inner = preg_replace('#\s\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', ' loops.$1|length$2', $inner);
|
||||
|
||||
// Replace .foo.bar with foo.bar|length
|
||||
$inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', ' $1|length$2', $inner);
|
||||
|
||||
return "<!-- {$matches[1]}IF{$inner}-->";
|
||||
};
|
||||
|
||||
return preg_replace_callback('#<!-- (ELSE)?IF((.*)[\s][\$|\.|!]([^\s]+)(.*))-->#', $callback, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,12 @@ if (!defined('IN_PHPBB'))
|
||||
|
||||
class phpbb_template_twig_node_event extends Twig_Node
|
||||
{
|
||||
/**
|
||||
* The subdirectory in which all template listener files must be placed
|
||||
* @var string
|
||||
*/
|
||||
protected $listener_directory = 'event/';
|
||||
|
||||
/** @var Twig_Environment */
|
||||
protected $environment;
|
||||
|
||||
@@ -37,7 +43,7 @@ class phpbb_template_twig_node_event extends Twig_Node
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$location = $this->getNode('expr')->getAttribute('name');
|
||||
$location = $this->listener_directory . $this->getNode('expr')->getAttribute('name');
|
||||
|
||||
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
|
||||
{
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||
abstract class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||
{
|
||||
/** @var Twig_Environment */
|
||||
protected $environment;
|
||||
@@ -57,4 +57,19 @@ class phpbb_template_twig_node_includeasset extends Twig_Node
|
||||
->raw("\n');\n")
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the definition name
|
||||
*
|
||||
* @return string (e.g. 'SCRIPTS')
|
||||
*/
|
||||
abstract public function get_definition_name();
|
||||
|
||||
/**
|
||||
* Append the output code for the asset
|
||||
*
|
||||
* @param Twig_Compiler A Twig_Compiler instance
|
||||
* @return null
|
||||
*/
|
||||
abstract protected function append_asset(Twig_Compiler $compiler);
|
||||
}
|
||||
|
@@ -9,16 +9,17 @@
|
||||
|
||||
class phpbb_template_twig_node_includecss extends phpbb_template_twig_node_includeasset
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_definition_name()
|
||||
{
|
||||
return 'STYLESHEETS';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler A Twig_Compiler instance
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function append_asset(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
|
@@ -9,16 +9,17 @@
|
||||
|
||||
class phpbb_template_twig_node_includejs extends phpbb_template_twig_node_includeasset
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_definition_name()
|
||||
{
|
||||
return 'SCRIPTS';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the node to PHP.
|
||||
*
|
||||
* @param Twig_Compiler A Twig_Compiler instance
|
||||
*/
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function append_asset(Twig_Compiler $compiler)
|
||||
{
|
||||
$config = $this->environment->get_phpbb_config();
|
||||
|
@@ -19,15 +19,8 @@ if (!defined('IN_PHPBB'))
|
||||
* Twig Template class.
|
||||
* @package phpBB3
|
||||
*/
|
||||
class phpbb_template_twig implements phpbb_template
|
||||
class phpbb_template_twig extends phpbb_template_base
|
||||
{
|
||||
/**
|
||||
* Template context.
|
||||
* Stores template data used during template rendering.
|
||||
* @var phpbb_template_context
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Path of the cache directory for the template
|
||||
*
|
||||
@@ -43,12 +36,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* adm relative path
|
||||
* @var string
|
||||
*/
|
||||
protected $adm_relative_path;
|
||||
|
||||
/**
|
||||
* PHP file extension
|
||||
* @var string
|
||||
@@ -74,16 +61,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* Name of the style that the template being compiled and/or rendered
|
||||
* belongs to, and its parents, in inheritance tree order.
|
||||
*
|
||||
* Used to invoke style-specific template events.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $style_names;
|
||||
|
||||
/**
|
||||
* Twig Environment
|
||||
*
|
||||
@@ -91,13 +68,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
*/
|
||||
protected $twig;
|
||||
|
||||
/**
|
||||
* Array of filenames assigned to set_filenames
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $filenames = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -112,7 +82,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null, $adm_relative_path = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->adm_relative_path = $adm_relative_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->config = $config;
|
||||
$this->user = $user;
|
||||
@@ -147,6 +116,12 @@ class phpbb_template_twig implements phpbb_template
|
||||
$lexer = new phpbb_template_twig_lexer($this->twig);
|
||||
|
||||
$this->twig->setLexer($lexer);
|
||||
|
||||
// Add admin namespace
|
||||
if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/'))
|
||||
{
|
||||
$this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,51 +140,90 @@ class phpbb_template_twig implements phpbb_template
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the template filenames for handles.
|
||||
* Get the style tree of the style preferred by the current user
|
||||
*
|
||||
* @param array $filename_array Should be a hash of handle => filename pairs.
|
||||
* @return array Style tree, most specific first
|
||||
*/
|
||||
public function get_user_style()
|
||||
{
|
||||
$style_list = array(
|
||||
$this->user->style['style_path'],
|
||||
);
|
||||
|
||||
if ($this->user->style['style_parent_id'])
|
||||
{
|
||||
$style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree'])));
|
||||
}
|
||||
|
||||
return $style_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style location based on (current) user's chosen style.
|
||||
*
|
||||
* @param array $style_directories The directories to add style paths for
|
||||
* E.g. array('ext/foo/bar/styles', 'styles')
|
||||
* Default: array('styles') (phpBB's style directory)
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function set_filenames(array $filename_array)
|
||||
public function set_style($style_directories = array('styles'))
|
||||
{
|
||||
$this->filenames = array_merge($this->filenames, $filename_array);
|
||||
if ($style_directories !== array('styles') && $this->twig->getLoader()->getPaths('core') === array())
|
||||
{
|
||||
// We should set up the core styles path since not already setup
|
||||
$this->set_style();
|
||||
}
|
||||
|
||||
$names = $this->get_user_style();
|
||||
|
||||
$paths = array();
|
||||
foreach ($style_directories as $directory)
|
||||
{
|
||||
foreach ($names as $name)
|
||||
{
|
||||
$path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/template/";
|
||||
|
||||
if (is_dir($path))
|
||||
{
|
||||
$paths[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we're setting up the main phpBB styles directory and the core
|
||||
// namespace isn't setup yet, we will set it up now
|
||||
if ($style_directories === array('styles') && $this->twig->getLoader()->getPaths('core') === array())
|
||||
{
|
||||
// Set up the core style paths namespace
|
||||
$this->twig->getLoader()->setPaths($paths, 'core');
|
||||
}
|
||||
|
||||
$this->set_custom_style($names, $paths);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style names/paths corresponding to style hierarchy being compiled
|
||||
* and/or rendered.
|
||||
* Set custom style location (able to use directory outside of phpBB).
|
||||
*
|
||||
* @param array $style_names List of style names in inheritance tree order
|
||||
* @param array $style_paths List of style paths in inheritance tree order
|
||||
* @param bool $is_core True if the style names are the "core" styles for this page load
|
||||
* Core means the main phpBB template files
|
||||
* Note: Templates are still compiled to phpBB's cache directory.
|
||||
*
|
||||
* @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions.
|
||||
* @param string|array or string $paths Array of style paths, relative to current root directory
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function set_style_names(array $style_names, array $style_paths, $is_core = false)
|
||||
public function set_custom_style($names, $paths)
|
||||
{
|
||||
$this->style_names = $style_names;
|
||||
$paths = (is_string($paths)) ? array($paths) : $paths;
|
||||
$names = (is_string($names)) ? array($names) : $names;
|
||||
|
||||
// Set as __main__ namespace
|
||||
$this->twig->getLoader()->setPaths($style_paths);
|
||||
|
||||
// Core style namespace from phpbb_style::set_style()
|
||||
if ($is_core)
|
||||
{
|
||||
$this->twig->getLoader()->setPaths($style_paths, 'core');
|
||||
}
|
||||
|
||||
// Add admin namespace
|
||||
if (is_dir($this->phpbb_root_path . $this->adm_relative_path . 'style/'))
|
||||
{
|
||||
$this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->adm_relative_path . 'style/', 'admin');
|
||||
}
|
||||
$this->twig->getLoader()->setPaths($paths);
|
||||
|
||||
// Add all namespaces for all extensions
|
||||
if ($this->extension_manager instanceof phpbb_extension_manager)
|
||||
{
|
||||
$style_names[] = 'all';
|
||||
$names[] = 'all';
|
||||
|
||||
foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path)
|
||||
{
|
||||
@@ -217,7 +231,7 @@ class phpbb_template_twig implements phpbb_template
|
||||
$namespace = str_replace('/', '_', $ext_namespace);
|
||||
$paths = array();
|
||||
|
||||
foreach ($style_names as $style_name)
|
||||
foreach ($names as $style_name)
|
||||
{
|
||||
$ext_style_path = $ext_path . 'styles/' . $style_name . '/template';
|
||||
|
||||
@@ -234,31 +248,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all variables and blocks assigned to this template.
|
||||
*
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
$this->context = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset/empty complete block
|
||||
*
|
||||
* @param string $blockname Name of block to destroy
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function destroy_block_vars($blockname)
|
||||
{
|
||||
$this->context->destroy_block_vars($blockname);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a template for provided handle.
|
||||
*
|
||||
@@ -282,28 +271,6 @@ class phpbb_template_twig implements phpbb_template
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls hook if any is defined.
|
||||
*
|
||||
* @param string $handle Template handle being displayed.
|
||||
* @param string $method Method name of the caller.
|
||||
*/
|
||||
protected function call_hook($handle, $method)
|
||||
{
|
||||
global $phpbb_hook;
|
||||
|
||||
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this))
|
||||
{
|
||||
if ($phpbb_hook->hook_return(array(__CLASS__, $method)))
|
||||
{
|
||||
$result = $phpbb_hook->hook_return_result(array(__CLASS__, $method));
|
||||
return array($result);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the handle and assign the output to a template variable
|
||||
* or return the compiled result.
|
||||
@@ -325,134 +292,30 @@ class phpbb_template_twig implements phpbb_template
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign key variable pairs from an array
|
||||
*
|
||||
* @param array $vararray A hash of variable name => value pairs
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function assign_vars(array $vararray)
|
||||
{
|
||||
foreach ($vararray as $key => $val)
|
||||
{
|
||||
$this->assign_var($key, $val);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a single scalar value to a single key.
|
||||
*
|
||||
* Value can be a string, an integer or a boolean.
|
||||
*
|
||||
* @param string $varname Variable name
|
||||
* @param string $varval Value to assign to variable
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function assign_var($varname, $varval)
|
||||
{
|
||||
$this->context->assign_var($varname, $varval);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append text to the string value stored in a key.
|
||||
*
|
||||
* Text is appended using the string concatenation operator (.).
|
||||
*
|
||||
* @param string $varname Variable name
|
||||
* @param string $varval Value to append to variable
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function append_var($varname, $varval)
|
||||
{
|
||||
$this->context->append_var($varname, $varval);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign key variable pairs from an array to a specified block
|
||||
* @param string $blockname Name of block to assign $vararray to
|
||||
* @param array $vararray A hash of variable name => value pairs
|
||||
* @return phpbb_template $this
|
||||
*/
|
||||
public function assign_block_vars($blockname, array $vararray)
|
||||
{
|
||||
$this->context->assign_block_vars($blockname, $vararray);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change already assigned key variable pair (one-dimensional - single loop entry)
|
||||
*
|
||||
* An example of how to use this function:
|
||||
* {@example alter_block_array.php}
|
||||
*
|
||||
* @param string $blockname the blockname, for example 'loop'
|
||||
* @param array $vararray the var array to insert/add or merge
|
||||
* @param mixed $key Key to search for
|
||||
*
|
||||
* array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
|
||||
*
|
||||
* int: Position [the position to change or insert at directly given]
|
||||
*
|
||||
* If key is false the position is set to 0
|
||||
* If key is true the position is set to the last entry
|
||||
*
|
||||
* @param string $mode Mode to execute (valid modes are 'insert' and 'change')
|
||||
*
|
||||
* If insert, the vararray is inserted at the given position (position counting from zero).
|
||||
* If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
|
||||
*
|
||||
* Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
|
||||
* and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
|
||||
*
|
||||
* @return bool false on error, true on success
|
||||
*/
|
||||
public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
|
||||
{
|
||||
return $this->context->alter_block_array($blockname, $vararray, $key, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template vars in a format Twig will use (from the context)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars()
|
||||
protected function get_template_vars()
|
||||
{
|
||||
$context_vars = $this->context->get_data_ref();
|
||||
|
||||
$vars = array_merge(
|
||||
$context_vars['.'][0], // To get normal vars
|
||||
$context_vars, // To get loops
|
||||
array(
|
||||
'definition' => new phpbb_template_twig_definition(),
|
||||
'user' => $this->user,
|
||||
'loops' => $context_vars, // To get loops
|
||||
)
|
||||
);
|
||||
|
||||
// cleanup
|
||||
unset($vars['.']);
|
||||
unset($vars['loops']['.']);
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filename from the handle
|
||||
*
|
||||
* @param string $handle
|
||||
* @return string
|
||||
*/
|
||||
protected function get_filename_from_handle($handle)
|
||||
{
|
||||
return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to template for handle (required for BBCode parser)
|
||||
*
|
||||
|
@@ -75,7 +75,7 @@ class phpbb_user extends phpbb_session
|
||||
*/
|
||||
function setup($lang_set = false, $style_id = false)
|
||||
{
|
||||
global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
|
||||
global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
if ($this->data['user_id'] != ANONYMOUS)
|
||||
@@ -128,6 +128,7 @@ class phpbb_user extends phpbb_session
|
||||
}
|
||||
|
||||
$user_data = $this->data;
|
||||
$lang_set_ext = array();
|
||||
|
||||
/**
|
||||
* Event to load language files and modify user data on every page
|
||||
@@ -139,10 +140,18 @@ class phpbb_user extends phpbb_session
|
||||
* @var string user_timezone User's timezone, should be one of
|
||||
* http://www.php.net/manual/en/timezones.php
|
||||
* @var mixed lang_set String or array of language files
|
||||
* @var array lang_set_ext Array containing entries of format
|
||||
* array(
|
||||
* 'ext_name' => (string) [extension name],
|
||||
* 'lang_set' => (string|array) [language files],
|
||||
* )
|
||||
* For performance reasons, only load translations
|
||||
* that are absolutely needed globally using this
|
||||
* event. Use local events otherwise.
|
||||
* @var mixed style_id Style we are going to display
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$vars = array('user_data', 'user_lang_name', 'user_date_format', 'user_timezone', 'lang_set', 'style_id');
|
||||
$vars = array('user_data', 'user_lang_name', 'user_date_format', 'user_timezone', 'lang_set', 'lang_set_ext', 'style_id');
|
||||
extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars)));
|
||||
|
||||
$this->data = $user_data;
|
||||
@@ -173,6 +182,12 @@ class phpbb_user extends phpbb_session
|
||||
$this->add_lang($lang_set);
|
||||
unset($lang_set);
|
||||
|
||||
foreach ($lang_set_ext as $ext_lang_pair)
|
||||
{
|
||||
$this->add_lang_ext($ext_lang_pair['ext_name'], $ext_lang_pair['lang_set']);
|
||||
}
|
||||
unset($lang_set_ext);
|
||||
|
||||
$style_request = request_var('style', 0);
|
||||
if ($style_request && $auth->acl_get('a_styles') && !defined('ADMIN_START'))
|
||||
{
|
||||
@@ -236,7 +251,7 @@ class phpbb_user extends phpbb_session
|
||||
}
|
||||
}
|
||||
|
||||
$phpbb_style->set_style();
|
||||
$template->set_style();
|
||||
|
||||
$this->img_lang = $this->lang_name;
|
||||
|
||||
@@ -590,6 +605,13 @@ class phpbb_user extends phpbb_session
|
||||
$language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx;
|
||||
}
|
||||
|
||||
// If we are in install, try to use the updated version, when available
|
||||
$install_language_filename = str_replace('language/', 'install/update/new/language/', $language_filename);
|
||||
if (defined('IN_INSTALL') && file_exists($install_language_filename))
|
||||
{
|
||||
$language_filename = $install_language_filename;
|
||||
}
|
||||
|
||||
if (!file_exists($language_filename))
|
||||
{
|
||||
global $config;
|
||||
|
Reference in New Issue
Block a user