Merge pull request #188 from marc1706/feature/module_services

Feature/module services
This commit is contained in:
Marc Alexander
2013-11-16 07:48:15 -08:00
53 changed files with 2288 additions and 1576 deletions

View File

@@ -22,9 +22,12 @@ class portal_module
public $u_action; public $u_action;
public $new_config = array(); public $new_config = array();
protected $c_class; protected $c_class;
protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx; protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;
protected $root_path, $mod_version_check; protected $root_path, $mod_version_check;
/** @var \phpbb\di\service_collection Portal modules */
protected $modules;
public function __construct() public function __construct()
{ {
global $db, $user, $cache, $template; global $db, $user, $cache, $template;
@@ -46,7 +49,9 @@ class portal_module
$this->phpbb_admin_path = $phpbb_admin_path; $this->phpbb_admin_path = $phpbb_admin_path;
$this->portal_root_path = $this->root_path . 'portal/'; $this->portal_root_path = $this->root_path . 'portal/';
$this->php_ex = $phpEx; $this->php_ex = $phpEx;
$this->mod_version_check = $phpbb_container->get('board3.version.check'); $this->phpbb_container = $phpbb_container;
$this->mod_version_check = $this->phpbb_container->get('board3.version.check');
$this->register_modules($this->phpbb_container->get('board3.module_collection'));
if (!function_exists('column_string_const')) if (!function_exists('column_string_const'))
{ {
@@ -103,23 +108,33 @@ class portal_module
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
if ($module_data !== false) if ($module_data !== false)
{
if (!isset($this->modules[$module_data['module_classname']]))
{ {
$class = 'portal_' . $module_data['module_classname'] . '_module'; $class = 'portal_' . $module_data['module_classname'] . '_module';
if (!class_exists($class)) if (!class_exists($class))
{ {
include($this->root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex); include($this->root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex);
} }
if (!class_exists($class)) if (class_exists($class))
{ {
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); $this->c_class = new $class();
}
else
{
continue;
}
}
else
{
$this->c_class = $this->modules[$module_data['module_classname']];
} }
$this->c_class = new $class(); if ($this->c_class->get_language())
if ($this->c_class->language)
{ {
$this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->language); $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->get_language());
} }
$module_name = $this->user->lang[$this->c_class->name]; $module_name = $this->user->lang[$this->c_class->get_name()];
$display_vars = $this->c_class->get_template_acp($module_id); $display_vars = $this->c_class->get_template_acp($module_id);
$this->template->assign_vars(array( $this->template->assign_vars(array(
'MODULE_NAME' => (isset($this->c_class->hide_name) && $this->c_class->hide_name == true)? '' : $module_data['module_name'], 'MODULE_NAME' => (isset($this->c_class->hide_name) && $this->c_class->hide_name == true)? '' : $module_data['module_name'],
@@ -277,7 +292,7 @@ class portal_module
{ {
add_log('admin', 'LOG_PORTAL_CONFIG', $this->user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']); add_log('admin', 'LOG_PORTAL_CONFIG', $this->user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']);
} }
trigger_error($this->user->lang['CONFIG_UPDATED'] . ((!empty($img_error) ? '<br /><br />' . $this->user->lang['MODULE_IMAGE_ERROR'] . '<br />' . $img_error : '')) . adm_back_link(($module_id) ? append_sid("{$this->phpbb_root_path}adm/index.{$this->php_ex}", 'i=portal&amp;mode=modules') : $this->u_action)); trigger_error($this->user->lang['CONFIG_UPDATED'] . ((!empty($img_error) ? '<br /><br />' . $this->user->lang['MODULE_IMAGE_ERROR'] . '<br />' . $img_error : '')) . adm_back_link(($module_id) ? append_sid("{$this->phpbb_root_path}adm/index.{$this->php_ex}", 'i=\board3\portal\acp\portal_module&amp;mode=modules') : $this->u_action));
} }
// show custom HTML files on the settings page of the modules instead of the standard board3 portal one, if chosen by module // show custom HTML files on the settings page of the modules instead of the standard board3 portal one, if chosen by module
@@ -408,7 +423,6 @@ class portal_module
if ($submit) if ($submit)
{ {
$module_classname = request_var('module_classname', ''); $module_classname = request_var('module_classname', '');
$class = 'portal_' . $module_classname . '_module';
$column_string = column_num_string($add_column); $column_string = column_num_string($add_column);
@@ -440,6 +454,14 @@ class portal_module
trigger_error($this->user->lang['MODULE_ADD_ONCE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->user->lang['MODULE_ADD_ONCE'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
if (isset($this->modules[$module_classname]))
{
$this->c_class = $this->modules[$module_classname];
}
else
{
$class = 'portal_' . $module_classname . '_module';
if (!class_exists($class)) if (!class_exists($class))
{ {
include($directory . 'portal_' . $module_classname . '.' . $this->php_ex); include($directory . 'portal_' . $module_classname . '.' . $this->php_ex);
@@ -449,6 +471,9 @@ class portal_module
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
} }
$this->c_class = new $class();
}
$sql = 'SELECT module_order $sql = 'SELECT module_order
FROM ' . PORTAL_MODULES_TABLE . ' FROM ' . PORTAL_MODULES_TABLE . '
WHERE module_column = ' . $add_column . ' WHERE module_column = ' . $add_column . '
@@ -457,8 +482,6 @@ class portal_module
$module_order = 1 + (int) $this->db->sql_fetchfield('module_order'); $module_order = 1 + (int) $this->db->sql_fetchfield('module_order');
$this->db->sql_freeresult($result); $this->db->sql_freeresult($result);
$this->c_class = new $class();
$sql_ary = array( $sql_ary = array(
'module_classname' => $module_classname, 'module_classname' => $module_classname,
'module_column' => $add_column, 'module_column' => $add_column,
@@ -507,6 +530,7 @@ class portal_module
$this->template->assign_var('S_EDIT', true); $this->template->assign_var('S_EDIT', true);
$fileinfo = array(); $fileinfo = array();
// @todo: remove old school way of getting modules
$dh = @opendir($directory); $dh = @opendir($directory);
if (!$dh) if (!$dh)
{ {
@@ -558,13 +582,13 @@ class portal_module
$this->c_class = new $class(); $this->c_class = new $class();
if ($this->c_class->columns & column_string_const($add_module)) if ($this->c_class->columns & column_string_const($add_module))
{ {
if ($this->c_class->language) if ($this->c_class->get_language())
{ {
$this->user->add_lang('mods/portal/' . $this->c_class->language); $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->get_language());
} }
$fileinfo[] = array( $fileinfo[] = array(
'module' => substr($class, 7, -7), 'module' => substr($class, 7, -7),
'name' => $this->user->lang[$this->c_class->name], 'name' => $this->user->lang[$this->c_class->get_name()],
); );
} }
} }
@@ -572,6 +596,46 @@ class portal_module
} }
closedir($dh); closedir($dh);
// Find new modules
foreach ($this->modules as $module_class => $module)
{
if ($module_class !== '\board3\portal\modules\custom')
{
if (in_array($column_string, array('left', 'right')))
{
// does the module already exist in the side columns?
if (isset($module_column[$module_class]) &&
(in_array('left', $module_column[$module_class]) || in_array('right', $module_column[$module_class])))
{
continue;
}
}
elseif (in_array($column_string, array('center', 'top', 'bottom')))
{
// does the module already exist in the center columns?
if (isset($module_column[$module_class]) &&
(in_array('center', $module_column[$module_class]) ||
in_array('top', $module_column[$module_class]) ||
in_array('bottom', $module_column[$module_class])))
{
continue;
}
}
}
if ($module->get_allowed_columns() & column_string_const($add_module))
{
if ($module->get_language())
{
$this->user->add_lang_ext('board3/portal', 'mods/portal/' . $module->get_language());
}
$fileinfo[] = array(
'module' => $module_class,
'name' => $this->user->lang[$module->get_name()],
);
}
}
// we sort the $fileinfo array by the name of the modules // we sort the $fileinfo array by the name of the modules
foreach($fileinfo as $key => $cur_file) foreach($fileinfo as $key => $cur_file)
{ {
@@ -600,26 +664,36 @@ class portal_module
$portal_modules = obtain_portal_modules(); $portal_modules = obtain_portal_modules();
foreach($portal_modules as $row) foreach($portal_modules as $row)
{
if (!isset($this->modules[$row['module_classname']]))
{ {
$class = 'portal_' . $row['module_classname'] . '_module'; $class = 'portal_' . $row['module_classname'] . '_module';
if (!class_exists($class)) if (!class_exists($class))
{ {
include($directory . 'portal_' . $row['module_classname'] . '.' . $this->php_ex); include($directory . 'portal_' . $row['module_classname'] . '.' . $this->php_ex);
} }
if (!class_exists($class)) if (class_exists($class))
{ {
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR); $this->c_class = new $class();
}
else
{
continue;
}
}
else
{
$this->c_class = $this->modules[$row['module_classname']];
} }
$this->c_class = new $class(); if ($this->c_class->get_language())
if ($this->c_class->language)
{ {
$this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->language); $this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->get_language());
} }
$template_column = column_num_string($row['module_column']); $template_column = column_num_string($row['module_column']);
// find out of we can move modules to the left or right // find out of we can move modules to the left or right
if(($this->c_class->columns & column_string_const(column_num_string($row['module_column'] + 1))) || ($this->c_class->columns & column_string_const(column_num_string($row['module_column'] + 2)) && $row['module_column'] != 2)) if(($this->c_class->get_allowed_columns() & column_string_const(column_num_string($row['module_column'] + 1))) || ($this->c_class->get_allowed_columns() & column_string_const(column_num_string($row['module_column'] + 2)) && $row['module_column'] != 2))
{ {
/** /**
* check if we can actually move * check if we can actually move
@@ -652,7 +726,7 @@ class portal_module
$move_right = false; $move_right = false;
} }
if(($this->c_class->columns & column_string_const(column_num_string($row['module_column'] - 1))) || ($this->c_class->columns & column_string_const(column_num_string($row['module_column'] - 2)) && $row['module_column'] != 2)) if(($this->c_class->get_allowed_columns() & column_string_const(column_num_string($row['module_column'] - 1))) || ($this->c_class->get_allowed_columns() & column_string_const(column_num_string($row['module_column'] - 2)) && $row['module_column'] != 2))
{ {
/** /**
* check if we can actually move * check if we can actually move
@@ -1199,4 +1273,23 @@ class portal_module
{ {
return preg_replace(array('/i=[0-9]+/', '/mode=[a-zA-Z0-9_]+/'), array('i=\\' . __CLASS__, 'mode=' . $mode), $this->u_action) . '&amp;module_id=' . $module_id; return preg_replace(array('/i=[0-9]+/', '/mode=[a-zA-Z0-9_]+/'), array('i=\\' . __CLASS__, 'mode=' . $mode), $this->u_action) . '&amp;module_id=' . $module_id;
} }
/**
* Register list of Board3 Portal modules
*
* @param \phpbb\di\service_collection $modules Board3 Modules service
* collection
* @return null
*/
protected function register_modules($modules)
{
foreach ($modules as $current_module)
{
$class_name = '\\' . get_class($current_module);
if (!isset($this->modules[$class_name]))
{
$this->modules[$class_name] = $current_module;
}
}
}
} }

View File

@@ -331,11 +331,13 @@ function storeCaret(textEl)
/** /**
* Color pallette * Color pallette
*/ */
function colorPalette(dir, width, height) function colorPalette(dir, width, height) {
{ var r = 0,
var r = 0, g = 0, b = 0; g = 0,
var numberList = new Array(6); b = 0,
var color = ''; numberList = new Array(6),
color = '',
html = '';
numberList[0] = '00'; numberList[0] = '00';
numberList[1] = '40'; numberList[1] = '40';
@@ -343,44 +345,47 @@ function colorPalette(dir, width, height)
numberList[3] = 'BF'; numberList[3] = 'BF';
numberList[4] = 'FF'; numberList[4] = 'FF';
document.writeln('<table cellspacing="1" cellpadding="0" border="0">'); html += '<table>';
for (r = 0; r < 5; r++) for (r = 0; r < 5; r++) {
{ if (dir == 'h') {
if (dir == 'h') html += '<tr>';
{
document.writeln('<tr>');
} }
for (g = 0; g < 5; g++) for (g = 0; g < 5; g++) {
{ if (dir == 'v') {
if (dir == 'v') html += '<tr>';
{
document.writeln('<tr>');
} }
for (b = 0; b < 5; b++) for (b = 0; b < 5; b++) {
{
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
document.write('<td bgcolor="#' + color + '" style="width: ' + width + 'px; height: ' + height + 'px;">'); html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' + height + 'px;">';
document.write('<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;" style="margin: -4px 0px -4px 2px;"><img src="images/spacer.gif" width="' + width + '" height="' + (height+10) + '" alt="#' + color + '" title="#' + color + '" style="margin: -4px;" /></a>'); html += '<a href="#" onclick="bbfontstyle(\'[color=#' + color + ']\', \'[/color]\'); return false;" style="display: block; width: ' + width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
document.writeln('</td>'); html += '</td>';
} }
if (dir == 'v') if (dir == 'v') {
{ html += '</tr>';
document.writeln('</tr>');
} }
} }
if (dir == 'h') if (dir == 'h') {
{ html += '</tr>';
document.writeln('</tr>');
} }
} }
document.writeln('</table>'); html += '</table>';
return html;
} }
(function($) {
$(document).ready(function() {
$('#color_palette_placeholder').each(function() {
$(this).html(colorPalette('h', 5, 10));
});
});
})(jQuery);
/** /**
* Caret Position object * Caret Position object

View File

@@ -1,6 +1,6 @@
<!-- INCLUDE overall_header.html --> <!-- INCLUDE overall_header.html -->
<script type="text/javascript" src="{ROOT_PATH}style/portal/acp_portal.js"></script> <!-- INCLUDEJS portal/acp_portal.js -->
<script type="text/javascript"> <script type="text/javascript">
// <![CDATA[ // <![CDATA[
/** /**
@@ -53,6 +53,21 @@ var help_line = {
<!-- END custom_tags --> <!-- END custom_tags -->
} }
function change_palette()
{
dE('colour_palette');
e = document.getElementById('colour_palette');
if (e.style.display == 'block')
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR_HIDE}';
}
else
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR}';
}
}
// ]]> // ]]>
</script> </script>
@@ -131,41 +146,16 @@ var help_line = {
<fieldset> <fieldset>
<legend>{L_PORTAL_CUSTOM}</legend> <legend>{L_PORTAL_CUSTOM}</legend>
<dl id="bbcode-buttons"<!-- IF not CUSTOM_USE_BBCODE --> style="display: none;"<!-- ENDIF -->> <dl id="bbcode-buttons"<!-- IF not CUSTOM_USE_BBCODE --> style="display: none;"<!-- ENDIF -->>
<dt></dt>
<dd> <dd>
<div id="colour_palette" style="display: none;"> <div id="colour_palette" style="display: none;">
<dl style="clear: left;"> <dl style="clear: left;">
<dt style="border: none;"><label>{L_FONT_COLOR}:</label><br /></dt> <dt style="border: none;"><label>{L_FONT_COLOR}{L_COLON}</label></dt>
<dd></dd>
</dl> </dl>
<dl style="clear: left;"> <dl style="clear: left;">
<dt style="border: none;"> <dt id="color_palette_placeholder" style="border: none;"></dt>
<script type="text/javascript"> <dd></dd>
// <![CDATA[
function change_palette()
{
e = document.getElementById('colour_palette');
if(e.style.display == 'block')
{
dE('colour_palette', -1);
}
else
{
dE('colour_palette', 1);
}
if (e.style.display == 'block')
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR_HIDE}';
}
else
{
document.getElementById('bbpalette').value = '{LA_FONT_COLOR}';
}
}
colorPalette('h', 10, 5);
// ]]>
</script>
</dt>
</dl> </dl>
</div> </div>
<div id="format-buttons"> <div id="format-buttons">

View File

@@ -40,6 +40,145 @@ services:
tags: tags:
- { name: service_collection, tag: board3.module } - { name: service_collection, tag: board3.module }
board3.module.announcements:
class: \board3\portal\modules\announcements
arguments:
- @auth
- @cache
- @config
- @template
- @dbal.conn
- %core.php_ext%
- %core.root_path%
- @user
tags:
- { name: board3.module }
board3.module.attachments:
class: \board3\portal\modules\attachments
arguments:
- @auth
- @config
- @template
- @dbal.conn
- %core.php_ext%
- %core.root_path%
- @user
tags:
- { name: board3.module }
board3.module.birthday_list:
class: \board3\portal\modules\birthday_list
arguments:
- @config
- @template
- @dbal.conn
- @user
tags:
- { name: board3.module }
board3.module.calendar:
class: \board3\portal\modules\calendar
arguments:
- @config
- @template
- @dbal.conn
- %core.root_path%
- %core.php_ext%
- @user
- @path_helper
tags:
- { name: board3.module }
board3.module.custom:
class: \board3\portal\modules\custom
arguments:
- @config
- @template
- @dbal.conn
- %core.root_path%
- %core.php_ext%
- @user
tags:
- { name: board3.module }
board3.module.forumlist:
class: \board3\portal\modules\forumlist
arguments:
- @auth
- @config
- @template
- %core.root_path%
- %core.php_ext%
- @user
tags:
- { name: board3.module }
board3.module.friends:
class: \board3\portal\modules\friends
arguments:
- @auth
- @config
- @dbal.conn
- @template
- @user
tags:
- { name: board3.module }
board3.module.latest_bots:
class: \board3\portal\modules\latest_bots
arguments:
- @config
- @dbal.conn
- @template
- @user
tags:
- { name: board3.module }
board3.module.latest_members:
class: \board3\portal\modules\latest_members
arguments:
- @config
- @dbal.conn
- @template
- @user
tags:
- { name: board3.module }
board3.module.leaders:
class: \board3\portal\modules\leaders
arguments:
- @auth
- @config
- @dbal.conn
- @template
- %core.root_path%
- %core.php_ext%
- @user
tags:
- { name: board3.module }
board3.module.link_us:
class: \board3\portal\modules\link_us
arguments:
- @config
- @template
- @user
tags:
- { name: board3.module }
board3.module.links:
class: \board3\portal\modules\links
arguments:
- @config
- @dbal.conn
- @template
- %core.root_path%
- %core.php_ext%
- @user
tags:
- { name: board3.module }
board3.module.stylechanger: board3.module.stylechanger:
class: \board3\portal\modules\stylechanger class: \board3\portal\modules\stylechanger
arguments: arguments:
@@ -51,3 +190,17 @@ services:
- @user - @user
tags: tags:
- { name: board3.module } - { name: board3.module }
board3.module.clock:
class: \board3\portal\modules\clock
tags:
- { name: board3.module }
board3.module.donation:
class: \board3\portal\modules\donation
arguments:
- @config
- @template
- @user
tags:
- { name: board3.module }

View File

@@ -115,7 +115,7 @@ class main
* *
* @param \phpbb\di\service_collection $modules Board3 Modules service * @param \phpbb\di\service_collection $modules Board3 Modules service
* collection * collection
* @return void * @return null
*/ */
protected function register_modules($modules) protected function register_modules($modules)
{ {

View File

@@ -13,6 +13,7 @@ define('IN_PHPBB', true);
define('B3_MODULE_ENABLED', 1); define('B3_MODULE_ENABLED', 1);
define('GROUPS_TABLE', '$this->table_prefix . \'groups'); define('GROUPS_TABLE', '$this->table_prefix . \'groups');
$phpbb_root_path = '../../../../'; $phpbb_root_path = '../../../../';
$root_path = '../'; // one directory down
include($phpbb_root_path . 'includes/startup.php'); include($phpbb_root_path . 'includes/startup.php');
$php_ex = substr(strrchr(__FILE__, '.'), 1); $php_ex = substr(strrchr(__FILE__, '.'), 1);
$phpEx = $php_ex; $phpEx = $php_ex;
@@ -27,8 +28,14 @@ $phpbb_class_loader_ext->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php");
$phpbb_class_loader->register(); $phpbb_class_loader->register();
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx);
require($root_path . 'develop/phpbb_functions.' . $phpEx);
// Set up container
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
$config_entry = $portal_config_entry = $db_data = array(); $config_entry = $portal_config_entry = $db_data = array();
$root_path = '../'; // one directory down
function set_config($name, $val) function set_config($name, $val)
{ {
@@ -46,7 +53,13 @@ function set_config($name, $val)
function handle_string(&$str) function handle_string(&$str)
{ {
if (is_string($str)) if (is_string($str) && strpos($str, '$') === 0)
{
// @codingStandardsIgnoreStart
$str = str_replace(',', ' . \',\' . ', $str);
// @codingStandardsIgnoreEnd
}
else if (is_string($str))
{ {
$str = "'$str'"; $str = "'$str'";
} }
@@ -109,14 +122,14 @@ board3_get_install_data($db, $root_path, $php_ex, $db_data);
echo 'set_config entries for migrations:<br /><pre>'; echo 'set_config entries for migrations:<br /><pre>';
foreach ($config_entry as $name => $val) foreach ($config_entry as $name => $val)
{ {
echo 'array(\'config.add\', array(\'' . $name . '\', ' . $val . ')),<br />'; echo ' array(\'config.add\', array(\'' . $name . '\', ' . $val . ')),<br />';
} }
echo '</pre>'; echo '</pre>';
echo '<br /><br />set_portal_config entries for migrations:<br /><pre>'; echo '<br /><br />set_portal_config entries for migrations:<br /><pre>';
foreach ($portal_config_entry as $name => $val) foreach ($portal_config_entry as $name => $val)
{ {
echo ' set_portal_config(\'' . $name . '\', ' . $val . ');<br />'; echo ' $this->set_portal_config(\'' . $name . '\', ' . $val . ');<br />';
} }
echo '</pre>'; echo '</pre>';
@@ -135,6 +148,8 @@ echo $db_data . '</pre><br />';
*/ */
function board3_get_install_data($db, $root_path, $php_ex, &$db_data) function board3_get_install_data($db, $root_path, $php_ex, &$db_data)
{ {
global $phpbb_container;
$directory = $root_path . 'portal/modules/'; $directory = $root_path . 'portal/modules/';
$db_data = ' $board3_sql_query = array(<br />'; $db_data = ' $board3_sql_query = array(<br />';
@@ -172,6 +187,14 @@ function board3_get_install_data($db, $root_path, $php_ex, &$db_data)
); );
foreach ($modules_ary as $module_name => $module_data) foreach ($modules_ary as $module_name => $module_data)
{
$new_module_name = '\\board3\\portal\\modules\\' . str_replace('portal_', '', $module_name);
if (class_exists($new_module_name))
{
$c_class = $phpbb_container->get('board3.module.' . str_replace('portal_', '', $module_name));
$module_name = $new_module_name;
}
else
{ {
$class_name = $module_name . '_module'; $class_name = $module_name . '_module';
if (!class_exists($class_name)) if (!class_exists($class_name))
@@ -180,17 +203,19 @@ function board3_get_install_data($db, $root_path, $php_ex, &$db_data)
} }
if (!class_exists($class_name)) if (!class_exists($class_name))
{ {
trigger_error('Class not found', E_USER_ERROR); trigger_error('Class not found: ' . $class_name, E_USER_ERROR);
} }
$c_class = new $class_name(); $c_class = new $class_name();
$module_name = substr($module_name, 7);
}
$sql_ary = array( $sql_ary = array(
'module_classname' => substr($module_name, 7), 'module_classname' => $module_name,
'module_column' => $module_data[0], 'module_column' => $module_data[0],
'module_order' => $module_data[1], 'module_order' => $module_data[1],
'module_name' => $c_class->get_name, 'module_name' => $c_class->get_name(),
'module_image_src' => $c_class->get_image, 'module_image_src' => $c_class->get_image(),
'module_group_ids' => '', 'module_group_ids' => '',
'module_image_width' => 16, 'module_image_width' => 16,
'module_image_height' => 16, 'module_image_height' => 16,
@@ -297,7 +322,7 @@ class db
} }
} }
$this->int_pointer++; $this->int_pointer++;
return $ret; return $this->preg_replace_value($ret);
} }
} }
} }
@@ -306,4 +331,55 @@ class db
return false; return false;
} }
} }
protected function preg_replace_value($value)
{
return preg_replace("/\{foobar\.group_id\.\s*([A-Z_]+?)\s*+\}/", "\$groups_ary['$1']", $value);
}
}
/**
* Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name.
*
* If $dbms is a valid 3.1 db driver class name, returns it unchanged.
* Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms
* to 3.1 db driver class name.
*
* @param string $dbms dbms parameter
* @return db driver class
*/
function phpbb_convert_30_dbms_to_31($dbms)
{
// Note: this check is done first because mysqli extension
// supplies a mysqli class, and class_exists($dbms) would return
// true for mysqli class.
// However, per the docblock any valid 3.1 driver name should be
// recognized by this function, and have priority over 3.0 dbms.
if (class_exists('phpbb\db\driver\\' . $dbms))
{
return 'phpbb\db\driver\\' . $dbms;
}
if (class_exists($dbms))
{
// Additionally we could check that $dbms extends phpbb\db\driver\driver.
// http://php.net/manual/en/class.reflectionclass.php
// Beware of possible performance issues:
// http://stackoverflow.com/questions/294582/php-5-reflection-api-performance
// We could check for interface implementation in all paths or
// only when we do not prepend phpbb\db\driver\.
/*
$reflection = new \ReflectionClass($dbms);
if ($reflection->isSubclassOf('phpbb\db\driver\driver'))
{
return $dbms;
}
*/
return $dbms;
}
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
} }

View File

@@ -0,0 +1,47 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2013 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
namespace phpbb\di\extension;
if (!function_exists('realpath'))
{
/**
* A wrapper for realpath
* @ignore
*/
function phpbb_realpath($path)
{
return phpbb_own_realpath($path);
}
}
else
{
/**
* A wrapper for realpath
*/
function phpbb_realpath($path)
{
$realpath = realpath($path);
// Strangely there are provider not disabling realpath but returning strange values. :o
// We at least try to cope with them.
if ($realpath === $path || $realpath === false)
{
return phpbb_own_realpath($path);
}
// Check for DIRECTORY_SEPARATOR at the end (and remove it!)
if (substr($realpath, -1) == DIRECTORY_SEPARATOR)
{
$realpath = substr($realpath, 0, -1);
}
return $realpath;
}
}

View File

@@ -314,7 +314,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'stylechanger', 'module_classname' => '\board3\portal\modules\stylechanger',
'module_column' => 1, 'module_column' => 1,
'module_order' => 2, 'module_order' => 2,
'module_name' => 'BOARD_STYLE', 'module_name' => 'BOARD_STYLE',
@@ -325,7 +325,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'birthday_list', 'module_classname' => '\board3\portal\modules\birthday_list',
'module_column' => 1, 'module_column' => 1,
'module_order' => 3, 'module_order' => 3,
'module_name' => 'BIRTHDAYS', 'module_name' => 'BIRTHDAYS',
@@ -336,7 +336,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'clock', 'module_classname' => '\board3\portal\modules\clock',
'module_column' => 1, 'module_column' => 1,
'module_order' => 4, 'module_order' => 4,
'module_name' => 'CLOCK', 'module_name' => 'CLOCK',
@@ -358,7 +358,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'attachments', 'module_classname' => '\board3\portal\modules\attachments',
'module_column' => 1, 'module_column' => 1,
'module_order' => 6, 'module_order' => 6,
'module_name' => 'PORTAL_ATTACHMENTS', 'module_name' => 'PORTAL_ATTACHMENTS',
@@ -380,7 +380,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'latest_members', 'module_classname' => '\board3\portal\modules\latest_members',
'module_column' => 1, 'module_column' => 1,
'module_order' => 8, 'module_order' => 8,
'module_name' => 'LATEST_MEMBERS', 'module_name' => 'LATEST_MEMBERS',
@@ -391,7 +391,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'link_us', 'module_classname' => '\board3\portal\modules\link_us',
'module_column' => 1, 'module_column' => 1,
'module_order' => 9, 'module_order' => 9,
'module_name' => 'LINK_US', 'module_name' => 'LINK_US',
@@ -424,7 +424,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'announcements', 'module_classname' => '\board3\portal\modules\announcements',
'module_column' => 2, 'module_column' => 2,
'module_order' => 3, 'module_order' => 3,
'module_name' => 'GLOBAL_ANNOUNCEMENTS', 'module_name' => 'GLOBAL_ANNOUNCEMENTS',
@@ -490,7 +490,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'calendar', 'module_classname' => '\board3\portal\modules\calendar',
'module_column' => 3, 'module_column' => 3,
'module_order' => 3, 'module_order' => 3,
'module_name' => 'PORTAL_CALENDAR', 'module_name' => 'PORTAL_CALENDAR',
@@ -501,7 +501,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'leaders', 'module_classname' => '\board3\portal\modules\leaders',
'module_column' => 3, 'module_column' => 3,
'module_order' => 4, 'module_order' => 4,
'module_name' => 'THE_TEAM', 'module_name' => 'THE_TEAM',
@@ -512,7 +512,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'latest_bots', 'module_classname' => '\board3\portal\modules\latest_bots',
'module_column' => 3, 'module_column' => 3,
'module_order' => 5, 'module_order' => 5,
'module_name' => 'LATEST_BOTS', 'module_name' => 'LATEST_BOTS',
@@ -523,7 +523,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1, 'module_status' => 1,
), ),
array( array(
'module_classname' => 'links', 'module_classname' => '\board3\portal\modules\links',
'module_column' => 3, 'module_column' => 3,
'module_order' => 6, 'module_order' => 6,
'module_name' => 'PORTAL_LINKS', 'module_name' => 'PORTAL_LINKS',

529
modules/announcements.php Normal file
View File

@@ -0,0 +1,529 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
namespace board3\portal\modules;
/**
* @package Modulname
*/
class announcements extends module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'GLOBAL_ANNOUNCEMENTS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_announcements_module';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\cache\driver */
protected $cache;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct an announcements object
*
* @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\cache\driver $cache phpBB cache driver
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($auth, $cache, $config, $template, $db, $phpEx, $phpbb_root_path, $user)
{
$this->auth = $auth;
$this->cache = $cache;
$this->config = $config;
$this->template = $template;
$this->db = $db;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id)
{
$announcement = request_var('announcement', -1);
$announcement = ($announcement > $this->config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement;
$start = request_var('ap', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
$portal_announcement_length = ($announcement < 0) ? $this->config['board3_announcements_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_global_announcements_forum_' . $module_id], $this->config['board3_announcements_permissions_' . $module_id], $this->config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $this->config['board3_announcements_day_' . $module_id], 'announcements', $start, $this->config['board3_announcements_forum_exclude_' . $module_id]);
// Any announcements present? If not terminate it here.
if (sizeof($fetch_news) == 0)
{
$this->template->assign_block_vars('announcements_center_row', array(
'S_NO_TOPICS' => true,
'S_NOT_LAST' => false
));
$this->template->assign_var('S_CAN_READ', false);
}
else
{
// Count number of posts for announcements archive, considering if permission check is dis- or enabled.
if ($this->config['board3_announcements_archive_' . $module_id])
{
$permissions = $this->config['board3_announcements_permissions_' . $module_id];
$forum_from = $this->config['board3_global_announcements_forum_' . $module_id];
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$time = ($this->config['board3_announcements_day_' . $module_id] == 0) ? 0 : $this->config['board3_announcements_day_' . $module_id];
$post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400);
$str_where = '';
if($permissions == true)
{
$disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
if($this->config['board3_announcements_forum_exclude_' . $module_id] == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
$global_f = 0;
if(sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if(!sizeof($disallow_access))
{
return array();
}
foreach($disallow_access as $acc_id)
{
$str_where .= 'forum_id = ' . (int) $acc_id . ' OR ';
if($global_f < 1 && $acc_id > 0)
{
$global_f = $acc_id;
}
}
}
else
{
foreach($disallow_access as $acc_id)
{
$str_where .= 'forum_id <> ' . (int) $acc_id . ' AND ';
}
}
$str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . '
WHERE ((topic_type = ' . POST_GLOBAL . ')
OR topic_type = ' . POST_ANNOUNCE . ')
AND topic_visibility = 1
AND topic_moved_id = 0
' . $post_time . '
' . $str_where;
$result = $this->db->sql_query($sql);
$total_announcements = (int) $this->db->sql_fetchfield('num_topics');
$this->db->sql_freeresult($result);
}
$topic_tracking_info = (get_portal_tracking_info($fetch_news));
if($announcement < 0)
// Show the announcements overview
{
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; $i++)
{
if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
{
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $this->user->lang['READ_FULL'];
}
else
{
$open_bracket = '';
$close_bracket = '';
$read_full = '';
}
// unread?
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
//$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&amp;announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($this->config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
$folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
switch ($fetch_news[$i]['topic_type'])
{
case POST_GLOBAL:
$folder = 'global_read';
$folder_new = 'global_unread';
break;
case POST_ANNOUNCE:
$folder = 'announce_read';
$folder_new = 'announce_unread';
break;
default:
$folder = 'topic_read';
$folder_new = 'topic_unread';
if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
}
break;
}
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
{
$folder .= '_locked';
$folder_new .= '_locked';
}
if ($fetch_news[$i]['topic_type'] == POST_GLOBAL)
{
$global_announce_list[$fetch_news[$i]['topic_id']] = true;
}
if ($fetch_news[$i]['topic_posted'])
{
$folder .= '_mine';
$folder_new .= '_mine';
}
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Grab icons
$icons = $this->cache->obtain_icons();
$this->template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $fetch_news[$i]['user_id']) : '',
'TIME' => $fetch_news[$i]['topic_time'],
'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']),
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt),
'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt],
'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'),
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;view=unread#unread'),
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_READ_FULL' => append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", $read_full_url),
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
phpbb_generate_template_pagination($this->template, $view_topic_url, 'announcements_center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true);
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$this->template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($this->config['board3_number_of_announcements_' . $module_id] != 0 && $this->config['board3_announcements_archive_' . $module_id])
{
$this->template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
else
// Show "read full" page
{
$i = $announcement;
/**
* redirect to portal page if the specified announcement does not exist
* force #top anchor in order to get rid of the #a anchor
*/
if (!isset($fetch_news[$i]))
{
redirect(append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, '/portal#top'));
}
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $this->user->lang['BACK'];
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "ap=$start#a$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#a$i");
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($this->config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$this->template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'TIME' => $fetch_news[$i]['topic_time'],
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'U_READ_FULL' => $read_full_url,
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
phpbb_generate_template_pagination($this->template, $view_topic_url, 'announcements_center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true);
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$this->template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($this->config['board3_number_of_announcements_' . $module_id] <> 0 && $this->config['board3_announcements_archive_' . $module_id])
{
$this->template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
$topic_icons = false;
if(!empty($fetch_news['topic_icons']))
{
$topic_icons = true;
}
$this->template->assign_vars(array(
'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'),
'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($this->config['board3_show_announcements_replies_views_' . $module_id]) ? true : false,
'S_TOPIC_ICONS' => $topic_icons,
));
if ($this->config['board3_announcements_style_' . $module_id])
{
return 'announcements_center_compact.html';
}
else
{
return 'announcements_center.html';
}
}
/**
* @inheritdoc
*/
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
),
);
}
/**
* @inheritdoc
*/
public function install($module_id)
{
set_config('board3_announcements_style_' . $module_id, 0);
set_config('board3_number_of_announcements_' . $module_id, 1);
set_config('board3_announcements_day_' . $module_id, 0);
set_config('board3_announcements_length_' . $module_id, 200);
set_config('board3_global_announcements_forum_' . $module_id, '');
set_config('board3_announcements_forum_exclude_' . $module_id, 0);
set_config('board3_announcements_archive_' . $module_id, 1);
set_config('board3_announcements_permissions_' . $module_id, 1);
set_config('board3_show_announcements_replies_views_' . $module_id, 1);
return true;
}
/**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{
$del_config = array(
'board3_announcements_style_' . $module_id,
'board3_number_of_announcements_' . $module_id,
'board3_announcements_day_' . $module_id,
'board3_announcements_length_' . $module_id,
'board3_global_announcements_forum_' . $module_id,
'board3_announcements_forum_exclude_' . $module_id,
'board3_announcements_archive_' . $module_id,
'board3_announcements_permissions_' . $module_id,
'board3_show_announcements_replies_views_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
/**
* Create forum select box
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return string Forum select box HTML
*/
public function select_forums($value, $key, $module_id)
{
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
{
$selected = explode(',', $this->config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
/**
* Store selected forums
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function store_selected_forums($key, $module_id)
{
// Get selected forums
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
}

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Attachments * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Modulname * @package Modulname
*/ */
class portal_attachments_module extends \board3\portal\modules\module_base class attachments extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,16 +41,68 @@ class portal_attachments_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_attachments_module'; public $language = 'portal_attachments_module';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct an attachments object
*
* @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($auth, $config, $template, $db, $phpEx, $phpbb_root_path, $user)
{
$this->auth = $auth;
$this->config = $config;
$this->template = $template;
$this->db = $db;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id) public function get_template_center($module_id)
{ {
return $this->parse_template($module_id, 'center'); return $this->parse_template($module_id, 'center');
} }
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
return $this->parse_template($module_id, 'side'); return $this->parse_template($module_id, 'side');
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -74,7 +120,7 @@ class portal_attachments_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -87,10 +133,11 @@ class portal_attachments_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_attachments_number_' . $module_id, 'board3_attachments_number_' . $module_id,
'board3_attach_max_length_' . $module_id, 'board3_attach_max_length_' . $module_id,
@@ -104,26 +151,32 @@ class portal_attachments_module extends \board3\portal\modules\module_base
return $db->sql_query($sql); return $db->sql_query($sql);
} }
// Create select box for attachment filetype /**
* Create select box for attachment filetype
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return string Forum select box HTML
*/
public function select_filetype($value, $key, $module_id) public function select_filetype($value, $key, $module_id)
{ {
global $db, $user, $config;
// Get extensions // Get extensions
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . EXTENSIONS_TABLE . ' FROM ' . EXTENSIONS_TABLE . '
ORDER BY extension ASC'; ORDER BY extension ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$extensions[] = $row; $extensions[] = $row;
} }
$selected = array(); $selected = array();
if(isset($config['board3_attachments_filetype_' . $module_id]) && strlen($config['board3_attachments_filetype_' . $module_id]) > 0) if(isset($this->config['board3_attachments_filetype_' . $module_id]) && strlen($this->config['board3_attachments_filetype_' . $module_id]) > 0)
{ {
$selected = explode(',', $config['board3_attachments_filetype_' . $module_id]); $selected = explode(',', $this->config['board3_attachments_filetype_' . $module_id]);
} }
// Build options // Build options
@@ -137,11 +190,16 @@ class portal_attachments_module extends \board3\portal\modules\module_base
return $ext_options; return $ext_options;
} }
// Store selected filetypes /**
* Store selected filetypes
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function store_filetypes($key, $module_id) public function store_filetypes($key, $module_id)
{ {
global $db, $cache;
// Get selected extensions // Get selected extensions
$values = request_var($key, array(0 => '')); $values = request_var($key, array(0 => ''));
@@ -151,17 +209,23 @@ class portal_attachments_module extends \board3\portal\modules\module_base
} }
// Create forum select box /**
* Create forum select box
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return string Forum select box HTML
*/
public function select_forums($value, $key) public function select_forums($value, $key)
{ {
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true); $forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array(); $selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0) if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
{ {
$selected = explode(',', $config[$key]); $selected = explode(',', $this->config[$key]);
} }
// Build forum options // Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">'; $s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
@@ -175,11 +239,16 @@ class portal_attachments_module extends \board3\portal\modules\module_base
} }
// Store selected forums /**
* Store selected forums
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function store_selected_forums($key) public function store_selected_forums($key)
{ {
global $db, $cache;
// Get selected extensions // Get selected extensions
$values = request_var($key, array(0 => '')); $values = request_var($key, array(0 => ''));
$news = implode(',', $values); $news = implode(',', $values);
@@ -191,27 +260,28 @@ class portal_attachments_module extends \board3\portal\modules\module_base
* *
* @param int $module_id Module ID * @param int $module_id Module ID
* @param string $type Module type (center or side) * @param string $type Module type (center or side)
*
* @return string Template file name or false if nothing should
* be displayed
*/ */
protected function parse_template($module_id, $type) protected function parse_template($module_id, $type)
{ {
global $config, $template, $db, $user, $auth, $phpEx, $phpbb_root_path;
$attach_forums = false; $attach_forums = false;
$where = ''; $where = '';
$filetypes = array(); $filetypes = array();
// Get filetypes and put them into an array // Get filetypes and put them into an array
if(isset($config['board3_attachments_filetype_' . $module_id]) && strlen($config['board3_attachments_filetype_' . $module_id]) > 0) if(isset($this->config['board3_attachments_filetype_' . $module_id]) && strlen($this->config['board3_attachments_filetype_' . $module_id]) > 0)
{ {
$filetypes = explode(',', $config['board3_attachments_filetype_' . $module_id]); $filetypes = explode(',', $this->config['board3_attachments_filetype_' . $module_id]);
} }
if($config['board3_attachments_forum_ids_' . $module_id] !== '') if($this->config['board3_attachments_forum_ids_' . $module_id] !== '')
{ {
$attach_forums_config = (strpos($config['board3_attachments_forum_ids_' . $module_id], ',') !== false) ? explode(',', $config['board3_attachments_forum_ids_' . $module_id]) : array($config['board3_attachments_forum_ids_' . $module_id]); $attach_forums_config = (strpos($this->config['board3_attachments_forum_ids_' . $module_id], ',') !== false) ? explode(',', $this->config['board3_attachments_forum_ids_' . $module_id]) : array($this->config['board3_attachments_forum_ids_' . $module_id]);
$forum_list = array_unique(array_keys($auth->acl_getf('f_read', true))); $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true)));
if($config['board3_attachments_forum_exclude_' . $module_id]) if($this->config['board3_attachments_forum_exclude_' . $module_id])
{ {
$forum_list = array_unique(array_diff($forum_list, $attach_forums_config)); $forum_list = array_unique(array_diff($forum_list, $attach_forums_config));
} }
@@ -222,24 +292,24 @@ class portal_attachments_module extends \board3\portal\modules\module_base
} }
else else
{ {
$forum_list = array_unique(array_keys($auth->acl_getf('f_read', true))); $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true)));
} }
if(sizeof($forum_list)) if(sizeof($forum_list))
{ {
$attach_forums = true; $attach_forums = true;
$where = 'AND ' . $db->sql_in_set('t.forum_id', $forum_list); $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list);
} }
if(sizeof($filetypes)) if(sizeof($filetypes))
{ {
if($config['board3_attachments_exclude_' . $module_id]) if($this->config['board3_attachments_exclude_' . $module_id])
{ {
$where .= ' AND ' . $db->sql_in_set('a.extension', $filetypes, true); $where .= ' AND ' . $this->db->sql_in_set('a.extension', $filetypes, true);
} }
else else
{ {
$where .= ' AND ' . $db->sql_in_set('a.extension', $filetypes); $where .= ' AND ' . $this->db->sql_in_set('a.extension', $filetypes);
} }
} }
@@ -257,20 +327,20 @@ class portal_attachments_module extends \board3\portal\modules\module_base
AND a.topic_id = t.topic_id AND a.topic_id = t.topic_id
' . $where . ' ' . $where . '
ORDER BY ORDER BY
filetime ' . ((!$config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC'; filetime ' . ((!$this->config['display_order']) ? 'DESC' : 'ASC') . ', post_msg_id ASC';
$result = $db->sql_query_limit($sql, $config['board3_attachments_number_' . $module_id]); $result = $this->db->sql_query_limit($sql, $this->config['board3_attachments_number_' . $module_id]);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$size_lang = ($row['filesize'] >= 1048576) ? $user->lang['MIB'] : (($row['filesize'] >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); $size_lang = ($row['filesize'] >= 1048576) ? $this->user->lang['MIB'] : (($row['filesize'] >= 1024) ? $this->user->lang['KIB'] : $this->user->lang['BYTES']);
$row['filesize'] = ($row['filesize'] >= 1048576) ? round((round($row['filesize'] / 1048576 * 100) / 100), 2) : (($row['filesize'] >= 1024) ? round((round($row['filesize'] / 1024 * 100) / 100), 2) : $row['filesize']); $row['filesize'] = ($row['filesize'] >= 1048576) ? round((round($row['filesize'] / 1048576 * 100) / 100), 2) : (($row['filesize'] >= 1024) ? round((round($row['filesize'] / 1024 * 100) / 100), 2) : $row['filesize']);
$raw_filename = utf8_substr($row['real_filename'], 0, strrpos($row['real_filename'], '.')); $raw_filename = utf8_substr($row['real_filename'], 0, strrpos($row['real_filename'], '.'));
$replace = character_limit($raw_filename, $config['board3_attach_max_length_' . $module_id]); $replace = character_limit($raw_filename, $this->config['board3_attach_max_length_' . $module_id]);
$template->assign_block_vars('attach_' . $type, array( $this->template->assign_block_vars('attach_' . $type, array(
'FILESIZE' => $row['filesize'] . ' ' . $size_lang, 'FILESIZE' => $row['filesize'] . ' ' . $size_lang,
'FILETIME' => $user->format_date($row['filetime']), 'FILETIME' => $this->user->format_date($row['filetime']),
'DOWNLOAD_COUNT' => (int) $row['download_count'], // grab downloads count 'DOWNLOAD_COUNT' => (int) $row['download_count'], // grab downloads count
'FILENAME' => $replace, 'FILENAME' => $replace,
'REAL_FILENAME' => $row['real_filename'], 'REAL_FILENAME' => $row['real_filename'],
@@ -278,17 +348,17 @@ class portal_attachments_module extends \board3\portal\modules\module_base
'ATTACH_ID' => $row['attach_id'], 'ATTACH_ID' => $row['attach_id'],
'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '', 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? $post_ids[$row['attach_id']] : '',
'POST_MSG_ID' => $row['post_msg_id'], // grab post ID to redirect to post 'POST_MSG_ID' => $row['post_msg_id'], // grab post ID to redirect to post
'U_FILE' => append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $row['attach_id']), 'U_FILE' => append_sid($this->phpbb_root_path . 'download/file.' . $this->php_ext, 'id=' . $row['attach_id']),
'U_TOPIC' => append_sid($phpbb_root_path . 'viewtopic.'.$phpEx, 'p='.$row['post_msg_id'].'#p'.$row['post_msg_id']), 'U_TOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, 'p='.$row['post_msg_id'].'#p'.$row['post_msg_id']),
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$template->assign_var('S_DISPLAY_ATTACHMENTS', true); $this->template->assign_var('S_DISPLAY_ATTACHMENTS', true);
} }
else else
{ {
$template->assign_var('S_DISPLAY_ATTACHMENTS', false); $this->template->assign_var('S_DISPLAY_ATTACHMENTS', false);
} }
return 'attachments_' . $type . '.html'; return 'attachments_' . $type . '.html';

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Birthday List * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Birthday List * @package Birthday List
*/ */
class portal_birthday_list_module extends \board3\portal\modules\module_base class birthday_list extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,28 +41,57 @@ class portal_birthday_list_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_birthday_list_module'; public $language = 'portal_birthday_list_module';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\user */
protected $user;
/**
* Construct a birthday_list object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $template, $db, $user)
{
$this->config = $config;
$this->template = $template;
$this->db = $db;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $db, $user, $phpbb_root_path;
// Generate birthday list if required ... / borrowed from index.php 3.0.6 // Generate birthday list if required ... / borrowed from index.php 3.0.6
$birthday_list = $birthday_ahead_list = ''; $birthday_list = $birthday_ahead_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays']) if ($this->config['load_birthdays'] && $this->config['allow_birthdays'])
{ {
$time = $user->create_datetime(); $time = $this->user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$cache_days = $config['board3_birthdays_ahead_' . $module_id]; $cache_days = $this->config['board3_birthdays_ahead_' . $module_id];
$sql_days = ''; $sql_days = '';
while ($cache_days > 0) while ($cache_days > 0)
{ {
$day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset()); $day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset());
$like_expression = $db->sql_like_expression($db->any_char . (sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . $db->any_char); $like_expression = $this->db->sql_like_expression($this->db->any_char . (sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . $this->db->any_char);
$sql_days .= " OR u.user_birthday " . $like_expression . ""; $sql_days .= " OR u.user_birthday " . $like_expression . "";
$cache_days--; $cache_days--;
} }
switch ($db->sql_layer) switch ($this->db->sql_layer)
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':
@@ -85,47 +108,50 @@ class portal_birthday_list_module extends \board3\portal\modules\module_base
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid) LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1) OR b.ban_exclude = 1)
AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days}) AND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days})
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
ORDER BY ' . $order_by; ORDER BY ' . $order_by;
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$today = sprintf('%2d-%2d-', $now['mday'], $now['mon']); $today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
if (substr($row['user_birthday'], 0, 6) == $today) if (substr($row['user_birthday'], 0, 6) == $today)
{ {
$birthday_list = true; $birthday_list = true;
$template->assign_block_vars('board3_birthday_list', array( $this->template->assign_block_vars('board3_birthday_list', array(
'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '', 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '',
)); ));
} }
elseif ($config['board3_birthdays_ahead_' . $module_id] > 0) elseif ($this->config['board3_birthdays_ahead_' . $module_id] > 0)
{ {
$birthday_ahead_list = true; $birthday_ahead_list = true;
$template->assign_block_vars('board3_birthday_ahead_list', array( $this->template->assign_block_vars('board3_birthday_ahead_list', array(
'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '', 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '',
'DATE' => $this->format_birthday($user, $row['user_birthday'], 'd M'), 'DATE' => $this->format_birthday($this->user, $row['user_birthday'], 'd M'),
)); ));
} }
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
} }
// Assign index specific vars // Assign index specific vars
$template->assign_vars(array( $this->template->assign_vars(array(
'BIRTHDAY_LIST' => $birthday_list, 'BIRTHDAY_LIST' => $birthday_list,
'BIRTHDAYS_AHEAD_LIST' => ($config['board3_birthdays_ahead_' . $module_id]) ? $birthday_ahead_list : '', 'BIRTHDAYS_AHEAD_LIST' => ($this->config['board3_birthdays_ahead_' . $module_id]) ? $birthday_ahead_list : '',
'L_BIRTHDAYS_AHEAD' => sprintf($user->lang['BIRTHDAYS_AHEAD'], $config['board3_birthdays_ahead_' . $module_id]), 'L_BIRTHDAYS_AHEAD' => sprintf($this->user->lang['BIRTHDAYS_AHEAD'], $this->config['board3_birthdays_ahead_' . $module_id]),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false, 'S_DISPLAY_BIRTHDAY_LIST' => ($this->config['load_birthdays']) ? true : false,
'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => ($config['board3_birthdays_ahead_' . $module_id] > 0) ? true : false, 'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => ($this->config['board3_birthdays_ahead_' . $module_id] > 0) ? true : false,
)); ));
return 'birthdays_side.html'; return 'birthdays_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -138,7 +164,7 @@ class portal_birthday_list_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -146,10 +172,11 @@ class portal_birthday_list_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_birthdays_ahead_' . $module_id, 'board3_birthdays_ahead_' . $module_id,
); );

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Calendar * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Calendar * @package Calendar
*/ */
class portal_calendar_module extends \board3\portal\modules\module_base class calendar extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -56,12 +50,12 @@ class portal_calendar_module extends \board3\portal\modules\module_base
/** /**
* additional variables * additional variables
*/ */
private $mini_cal_fdow; protected $mini_cal_fdow;
/** /**
* User datetime object * User datetime object
*/ */
private $time; protected $time;
/** /**
* constants * constants
@@ -70,14 +64,83 @@ class portal_calendar_module extends \board3\portal\modules\module_base
const DAYS_PER_WEEK = 6; // indexes start at 0 const DAYS_PER_WEEK = 6; // indexes start at 0
const MONTHS_PER_YEAR = 12; const MONTHS_PER_YEAR = 12;
/** @var year in numeric format (YYYY) */
protected $dateYYY;
/** @var month in numeric format (MM) */
protected $dateMM;
/** @var day in numeric format (DD) */
protected $dateDD;
/** @var extended month (e.g. February) */
protected $ext_dateMM;
/** @var count of days in month */
protected $daysMonth;
/** @var timestamp */
protected $stamp;
/** @var return array s.a. */
protected $day;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/** @var \phpbb\path_helper */
protected $path_helper;
/** @var Portal root path */
protected $portal_root_path;
/**
* Construct a calendar object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
* @param \phpbb\path_helper $path_helper phpBB path helper
*/
public function __construct($config, $template, $db, $phpbb_root_path, $phpEx, $user, $path_helper)
{
$this->config = $config;
$this->template = $template;
$this->db = $db;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
$this->path_helper = $path_helper;
$this->portal_root_path = $this->path_helper->get_web_root_path() . $this->phpbb_root_path . 'ext/board3/portal/';
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $user, $phpbb_root_path, $phpEx, $db, $portal_root_path;
$portal_config = obtain_portal_config(); $portal_config = obtain_portal_config();
// 0 = Sunday first - 1 = Monday first. ;-) // 0 = Sunday first - 1 = Monday first. ;-)
if ($config['board3_sunday_first_' . $module_id]) if ($this->config['board3_sunday_first_' . $module_id])
{ {
$this->mini_cal_fdow = 0; $this->mini_cal_fdow = 0;
} }
@@ -94,7 +157,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
// initialise some variables // initialise some variables
$this->time = $user->create_datetime(); $this->time = $this->user->create_datetime();
$now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset()); $now = phpbb_gmgetdate($this->time->getTimestamp() + $this->time->getOffset());
$today_timestamp = $now[0]; $today_timestamp = $now[0];
$mini_cal_today = date('Ymd', $today_timestamp - date('Z')); $mini_cal_today = date('Ymd', $today_timestamp - date('Z'));
@@ -110,22 +173,22 @@ class portal_calendar_module extends \board3\portal\modules\module_base
// output our general calendar bits // output our general calendar bits
$down = $this->mini_cal_month - 1; $down = $this->mini_cal_month - 1;
$up = $this->mini_cal_month + 1; $up = $this->mini_cal_month + 1;
$prev_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$down#minical$module_id") . '"><img src="./../' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>'; $prev_month = '<a href="' . append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "m$module_id=$down#minical$module_id") . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $this->user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>';
$next_month = '<a href="' . append_sid("{$phpbb_root_path}app.$phpEx", "controller=portal&amp;m$module_id=$up#minical$module_id") . '"><img src="./../' . $portal_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>'; $next_month = '<a href="' . append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "m$module_id=$up#minical$module_id") . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $this->user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>';
$template->assign_block_vars('minical', array( $this->template->assign_block_vars('minical', array(
'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false, 'S_SUNDAY_FIRST' => ($this->config['board3_sunday_first_' . $module_id]) ? true : false,
'L_MINI_CAL_MONTH' => (($config['board3_long_month_' . $module_id]) ? $user->lang['mini_cal']['long_month'][$this->day[0][1]] : $user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2], 'L_MINI_CAL_MONTH' => (($this->config['board3_long_month_' . $module_id]) ? $this->user->lang['mini_cal']['long_month'][$this->day[0][1]] : $this->user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2],
'L_MINI_CAL_SUN' => '<span style="color: ' . $config['board3_calendar_sunday_color_' . $module_id] . ';">' . $user->lang['mini_cal']['day'][1] . '</span>', 'L_MINI_CAL_SUN' => '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $this->user->lang['mini_cal']['day'][1] . '</span>',
'L_MINI_CAL_MON' => $user->lang['mini_cal']['day'][2], 'L_MINI_CAL_MON' => $this->user->lang['mini_cal']['day'][2],
'L_MINI_CAL_TUE' => $user->lang['mini_cal']['day'][3], 'L_MINI_CAL_TUE' => $this->user->lang['mini_cal']['day'][3],
'L_MINI_CAL_WED' => $user->lang['mini_cal']['day'][4], 'L_MINI_CAL_WED' => $this->user->lang['mini_cal']['day'][4],
'L_MINI_CAL_THU' => $user->lang['mini_cal']['day'][5], 'L_MINI_CAL_THU' => $this->user->lang['mini_cal']['day'][5],
'L_MINI_CAL_FRI' => $user->lang['mini_cal']['day'][6], 'L_MINI_CAL_FRI' => $this->user->lang['mini_cal']['day'][6],
'L_MINI_CAL_SAT' => $user->lang['mini_cal']['day'][7], 'L_MINI_CAL_SAT' => $this->user->lang['mini_cal']['day'][7],
'U_PREV_MONTH' => $prev_month, 'U_PREV_MONTH' => $prev_month,
'U_NEXT_MONTH' => $next_month, 'U_NEXT_MONTH' => $next_month,
'S_DISPLAY_EVENTS' => ($config['board3_display_events_' . $module_id]) ? true : false, 'S_DISPLAY_EVENTS' => ($this->config['board3_display_events_' . $module_id]) ? true : false,
'MODULE_ID' => $module_id, 'MODULE_ID' => $module_id,
)); ));
@@ -135,7 +198,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
// is this the first day of the week? // is this the first day of the week?
if($mini_cal_count == $this->mini_cal_fdow) if($mini_cal_count == $this->mini_cal_fdow)
{ {
$template->assign_block_vars('minical.mini_cal_row', array( $this->template->assign_block_vars('minical.mini_cal_row', array(
'MODULE_ID' => $module_id, 'MODULE_ID' => $module_id,
)); ));
} }
@@ -146,17 +209,17 @@ class portal_calendar_module extends \board3\portal\modules\module_base
$mini_cal_this_day = $this->day[$i][0]; $mini_cal_this_day = $this->day[$i][0];
$d_mini_cal_today = $mini_cal_this_year . (($mini_cal_this_month <= 9) ? '0' . $mini_cal_this_month : $mini_cal_this_month) . (($mini_cal_this_day <= 9) ? '0' . $mini_cal_this_day : $mini_cal_this_day); $d_mini_cal_today = $mini_cal_this_year . (($mini_cal_this_month <= 9) ? '0' . $mini_cal_this_month : $mini_cal_this_month) . (($mini_cal_this_day <= 9) ? '0' . $mini_cal_this_day : $mini_cal_this_day);
$mini_cal_day = ($mini_cal_today == $d_mini_cal_today) ? '<span style="font-weight: bold; color: ' . $config['board3_calendar_today_color_' . $module_id] . ';">' . $mini_cal_this_day . '</span>' : $mini_cal_this_day; $mini_cal_day = ($mini_cal_today == $d_mini_cal_today) ? '<span style="font-weight: bold; color: ' . $this->config['board3_calendar_today_color_' . $module_id] . ';">' . $mini_cal_this_day . '</span>' : $mini_cal_this_day;
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array( $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ($mini_cal_count == 0) ? '<span style="color: ' . $config['board3_calendar_sunday_color_' . $module_id] . ';">' . $mini_cal_day . '</span>' : $mini_cal_day) 'MINI_CAL_DAY' => ($mini_cal_count == 0) ? '<span style="color: ' . $this->config['board3_calendar_sunday_color_' . $module_id] . ';">' . $mini_cal_day . '</span>' : $mini_cal_day)
); );
$i++; $i++;
} }
// no day // no day
else else
{ {
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array( $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ' ') 'MINI_CAL_DAY' => ' ')
); );
} }
@@ -177,7 +240,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
// fill table with empty strings // fill table with empty strings
while ($mini_cal_count <= self::DAYS_PER_WEEK) while ($mini_cal_count <= self::DAYS_PER_WEEK)
{ {
$template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array( $this->template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array(
'MINI_CAL_DAY' => ' ') 'MINI_CAL_DAY' => ' ')
); );
$mini_cal_count++; $mini_cal_count++;
@@ -189,7 +252,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
*/ */
$events = $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]); $events = $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]);
if(!empty($events) && $config['board3_display_events_' . $module_id]) if(!empty($events) && $this->config['board3_display_events_' . $module_id])
{ {
// we sort the $events array by the start time // we sort the $events array by the start time
foreach($events as $key => $cur_event) foreach($events as $key => $cur_event)
@@ -202,9 +265,9 @@ class portal_calendar_module extends \board3\portal\modules\module_base
foreach($events as $key => $cur_event) foreach($events as $key => $cur_event)
{ {
if(($cur_event['start_time'] + $user->timezone + $user->dst) >= $today_timestamp || if(($cur_event['start_time'] + $this->time->getOffset()) >= $today_timestamp ||
($cur_event['end_time'] + $user->timezone + $user->dst) >= $today_timestamp || ($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp ||
(($cur_event['start_time'] + $user->timezone + $user->dst + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day'])) (($cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day']))
{ {
$cur_permissions = explode(',', $cur_event['permission']); $cur_permissions = explode(',', $cur_event['permission']);
$permission_check = array_intersect($groups_ary, $cur_permissions); $permission_check = array_intersect($groups_ary, $cur_permissions);
@@ -228,31 +291,31 @@ class portal_calendar_module extends \board3\portal\modules\module_base
* - We have an all day event and the start of that event is less than 1 day (86400 seconds) away * - We have an all day event and the start of that event is less than 1 day (86400 seconds) away
* - We have a normal event with a start that is less then 1 day away and that hasn't ended yet * - We have a normal event with a start that is less then 1 day away and that hasn't ended yet
*/ */
if((($cur_event['start_time'] + $user->timezone + $user->dst - $today_timestamp) <= self::TIME_DAY && $cur_event['all_day']) || if((($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp) <= self::TIME_DAY && $cur_event['all_day']) ||
(($cur_event['start_time'] + $user->timezone + $user->dst - $today_timestamp) <= self::TIME_DAY && ($cur_event['end_time'] + $user->timezone + $user->dst) >= $today_timestamp)) (($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp) <= self::TIME_DAY && ($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp))
{ {
$template->assign_block_vars('minical.cur_events', array( $this->template->assign_block_vars('minical.cur_events', array(
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'], 'EVENT_TITLE' => $cur_event['title'],
'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'), 'START_TIME' => $this->user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => (!empty($cur_event['end_time'])) ? $user->format_date($cur_event['end_time'], 'j. M Y, H:i') : false, 'END_TIME' => (!empty($cur_event['end_time'])) ? $this->user->format_date($cur_event['end_time'], 'j. M Y, H:i') : false,
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => ($cur_event['all_day']) ? true : false, 'ALL_DAY' => ($cur_event['all_day']) ? true : false,
'MODULE_ID' => $module_id, 'MODULE_ID' => $module_id,
'EVENT_URL_NEW_WINDOW' => ($is_external && $config['board3_events_url_new_window_' . $module_id]) ? true : false, 'EVENT_URL_NEW_WINDOW' => ($is_external && $this->config['board3_events_url_new_window_' . $module_id]) ? true : false,
)); ));
} }
else else
{ {
$template->assign_block_vars('minical.upcoming_events', array( $this->template->assign_block_vars('minical.upcoming_events', array(
'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '',
'EVENT_TITLE' => $cur_event['title'], 'EVENT_TITLE' => $cur_event['title'],
'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'), 'START_TIME' => $this->user->format_date($cur_event['start_time'], 'j. M Y, H:i'),
'END_TIME' => (!$cur_event['all_day']) ? $user->format_date($cur_event['end_time'], 'j. M Y, H:i') : '', 'END_TIME' => (!$cur_event['all_day']) ? $this->user->format_date($cur_event['end_time'], 'j. M Y, H:i') : '',
'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '',
'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false, 'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false,
'MODULE_ID' => $module_id, 'MODULE_ID' => $module_id,
'EVENT_URL_NEW_WINDOW' => ($is_external && $config['board3_events_url_new_window_' . $module_id]) ? true : false, 'EVENT_URL_NEW_WINDOW' => ($is_external && $this->config['board3_events_url_new_window_' . $module_id]) ? true : false,
)); ));
} }
} }
@@ -263,6 +326,9 @@ class portal_calendar_module extends \board3\portal\modules\module_base
return 'calendar_side.html'; return 'calendar_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -281,7 +347,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -297,10 +363,11 @@ class portal_calendar_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_calendar_events_' . $module_id, 'board3_calendar_events_' . $module_id,
); );
@@ -323,10 +390,17 @@ class portal_calendar_module extends \board3\portal\modules\module_base
return $db->sql_query($sql); return $db->sql_query($sql);
} }
/**
* Manage events
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function manage_events($value, $key, $module_id) public function manage_events($value, $key, $module_id)
{ {
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path;
$action = request_var('action', ''); $action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action; $action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action; $action = (isset($_POST['save'])) ? 'save' : $action;
@@ -335,7 +409,8 @@ class portal_calendar_module extends \board3\portal\modules\module_base
$events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]) : array(); $events = (strlen($portal_config['board3_calendar_events_' . $module_id]) >= 1) ? $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]) : array();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id); // append_sid() adds adm/ already, no need to add it here
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&amp;mode=config&amp;module_id=' . $module_id);
switch($action) switch($action)
{ {
@@ -343,7 +418,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
case 'save': case 'save':
if (!check_form_key('acp_portal')) if (!check_form_key('acp_portal'))
{ {
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
} }
$event_title = utf8_normalize_nfc(request_var('event_title', ' ', true)); $event_title = utf8_normalize_nfc(request_var('event_title', ' ', true));
@@ -363,11 +438,11 @@ class portal_calendar_module extends \board3\portal\modules\module_base
*/ */
if(strlen($event_start_day) < 9 || strlen($event_start_day) > 10 || (strlen($event_start_time) < 4 && !$event_all_day) || strlen($event_start_time) > 5) if(strlen($event_start_day) < 9 || strlen($event_start_day) > 10 || (strlen($event_start_time) < 4 && !$event_all_day) || strlen($event_start_time) > 5)
{ {
trigger_error($user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
} }
elseif((strlen($event_end_day) < 9 || strlen($event_end_day) > 10 || strlen($event_end_time) < 4 || strlen($event_end_time) > 5) && !$event_all_day) elseif((strlen($event_end_day) < 9 || strlen($event_end_day) > 10 || strlen($event_end_time) < 4 || strlen($event_end_time) > 5) && !$event_all_day)
{ {
trigger_error($user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
} }
// Now get the needed numbers out of the entered information // Now get the needed numbers out of the entered information
$first_start_hyphen = strpos($event_start_day, '-', 0); $first_start_hyphen = strpos($event_start_day, '-', 0);
@@ -396,28 +471,28 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
// UNIX timestamps // UNIX timestamps
$start_time = gmmktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year) - $user->timezone - $user->dst; $start_time = gmmktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year);
$end_time = (!$event_all_day) ? gmmktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year) - $user->timezone - $user->dst : ''; $end_time = (!$event_all_day) ? gmmktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year) : '';
if(($end_time) <= time() && !(($start_time + self::TIME_DAY) >= time() && $event_all_day)) if(($end_time) <= time() && !(($start_time + self::TIME_DAY) >= time() && $event_all_day))
{ {
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST']. adm_back_link($u_action), E_USER_WARNING);
} }
elseif($end_time < $start_time && !$event_all_day) elseif($end_time < $start_time && !$event_all_day)
{ {
trigger_error($user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST']. adm_back_link($u_action), E_USER_WARNING);
} }
// get groups and check if the selected groups actually exist // get groups and check if the selected groups actually exist
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$groups_ary[] = $row['group_id']; $groups_ary[] = $row['group_id'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$event_permission = array_intersect($event_permission, $groups_ary); $event_permission = array_intersect($event_permission, $groups_ary);
$event_permission = implode(',', $event_permission); $event_permission = implode(',', $event_permission);
@@ -425,18 +500,18 @@ class portal_calendar_module extends \board3\portal\modules\module_base
// Check for errors // Check for errors
if (!$event_title) if (!$event_title)
{ {
trigger_error($user->lang['NO_EVENT_TITLE'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['NO_EVENT_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
} }
if (!$start_time || $start_time == 0) if (!$start_time || $start_time == 0)
{ {
trigger_error($user->lang['NO_EVENT_START'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['NO_EVENT_START'] . adm_back_link($u_action), E_USER_WARNING);
} }
// overwrite already existing events and make sure we don't try to save an event outside of the normal array size of $events // overwrite already existing events and make sure we don't try to save an event outside of the normal array size of $events
if (isset($link_id) && $link_id < sizeof($events)) if (isset($link_id) && $link_id < sizeof($events))
{ {
$message = $user->lang['EVENT_UPDATED']; $message = $this->user->lang['EVENT_UPDATED'];
$events[$link_id] = array( $events[$link_id] = array(
'title' => $event_title, 'title' => $event_title,
@@ -452,7 +527,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
else else
{ {
$message = $user->lang['EVENT_ADDED']; $message = $this->user->lang['EVENT_ADDED'];
$events[] = array( $events[] = array(
'title' => $event_title, 'title' => $event_title,
@@ -484,7 +559,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
if (!isset($link_id) && $link_id >= sizeof($events)) if (!isset($link_id) && $link_id >= sizeof($events))
{ {
trigger_error($user->lang['NO_EVENT'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['NO_EVENT'] . adm_back_link($u_action), E_USER_WARNING);
} }
if (confirm_box(true)) if (confirm_box(true))
@@ -501,7 +576,7 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
else else
{ {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id, 'link_id' => $link_id,
'action' => 'delete', 'action' => 'delete',
))); )));
@@ -514,13 +589,13 @@ class portal_calendar_module extends \board3\portal\modules\module_base
case 'add': case 'add':
$event_all_day = (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false; $event_all_day = (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false;
$template->assign_vars(array( $this->template->assign_vars(array(
'EVENT_TITLE' => (isset($events[$link_id]['title']) && $action != 'add') ? $events[$link_id]['title'] : '', 'EVENT_TITLE' => (isset($events[$link_id]['title']) && $action != 'add') ? $events[$link_id]['title'] : '',
'EVENT_DESC' => (isset($events[$link_id]['desc']) && $action != 'add') ? $events[$link_id]['desc'] : '', 'EVENT_DESC' => (isset($events[$link_id]['desc']) && $action != 'add') ? $events[$link_id]['desc'] : '',
'EVENT_START_DAY' => ($action != 'add') ? $user->format_date($events[$link_id]['start_time'], 'd-m-Y') : '', 'EVENT_START_DAY' => ($action != 'add') ? $this->user->format_date($events[$link_id]['start_time'], 'd-m-Y') : '',
'EVENT_START_TIME' => ($action != 'add') ? $user->format_date($events[$link_id]['start_time'], 'G:i') : '', 'EVENT_START_TIME' => ($action != 'add') ? $this->user->format_date($events[$link_id]['start_time'], 'G:i') : '',
'EVENT_END_DAY' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$link_id]['end_time'], 'd-m-Y') : '', 'EVENT_END_DAY' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$link_id]['end_time'], 'd-m-Y') : '',
'EVENT_END_TIME' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$link_id]['end_time'], 'G:i') : '', 'EVENT_END_TIME' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$link_id]['end_time'], 'G:i') : '',
'EVENT_ALL_DAY' => (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false, 'EVENT_ALL_DAY' => (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false,
'EVENT_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? $events[$link_id]['url'] : '', 'EVENT_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? $events[$link_id]['url'] : '',
@@ -536,16 +611,16 @@ class portal_calendar_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id, group_name $sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$template->assign_block_vars('permission_setting_calendar', array( $this->template->assign_block_vars('permission_setting_calendar', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_NAME' => (isset($this->user->lang['G_' . $row['group_name']])) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'], 'GROUP_ID' => $row['group_id'],
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
return; return;
@@ -555,14 +630,17 @@ class portal_calendar_module extends \board3\portal\modules\module_base
for ($i = 0; $i < sizeof($events); $i++) for ($i = 0; $i < sizeof($events); $i++)
{ {
$event_all_day = ($events[$i]['all_day'] == true) ? true : false; $event_all_day = ($events[$i]['all_day'] == true) ? true : false;
$start_time_format = (!intval($user->format_date($events[$i]['start_time'], 'H')) && !intval($user->format_date($events[$i]['start_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i'; $start_time_format = (!intval($this->user->format_date($events[$i]['start_time'], 'H')) && !intval($this->user->format_date($events[$i]['start_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i';
$end_time_format = (!intval($user->format_date($events[$i]['end_time'], 'H')) && !intval($user->format_date($events[$i]['end_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i'; if (!empty($events[$i]['end_time']))
{
$end_time_format = (!intval($this->user->format_date($events[$i]['end_time'], 'H')) && !intval($this->user->format_date($events[$i]['end_time'], 'i'))) ? 'j. M Y' : 'j. M Y, H:i';
}
$template->assign_block_vars('events', array( $this->template->assign_block_vars('events', array(
'EVENT_TITLE' => ($action != 'add') ? ((isset($user->lang[$events[$i]['title']])) ? $user->lang[$events[$i]['title']] : $events[$i]['title']) : '', 'EVENT_TITLE' => ($action != 'add') ? ((isset($this->user->lang[$events[$i]['title']])) ? $this->user->lang[$events[$i]['title']] : $events[$i]['title']) : '',
'EVENT_DESC' => ($action != 'add') ? $events[$i]['desc'] : '', 'EVENT_DESC' => ($action != 'add') ? $events[$i]['desc'] : '',
'EVENT_START' => ($action != 'add') ? $user->format_date($events[$i]['start_time'], $start_time_format) : '', 'EVENT_START' => ($action != 'add') ? $this->user->format_date($events[$i]['start_time'], $start_time_format) : '',
'EVENT_END' => ($action != 'add' && !$event_all_day) ? $user->format_date($events[$i]['end_time'], $end_time_format) : '', 'EVENT_END' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$i]['end_time'], $end_time_format) : '',
'EVENT_URL' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $this->validate_url($events[$i]['url']) : '', 'EVENT_URL' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $this->validate_url($events[$i]['url']) : '',
'EVENT_URL_RAW' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $events[$i]['url'] : '', 'EVENT_URL_RAW' => ($action != 'add' && isset($events[$i]['url']) && !empty($events[$i]['url'])) ? $events[$i]['url'] : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i, 'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
@@ -573,40 +651,46 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
/**
* Update events
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function update_events($key, $module_id) public function update_events($key, $module_id)
{ {
$this->manage_events('', $key, $module_id); $this->manage_events('', $key, $module_id);
} }
private $dateYYY; // year in numeric format (YYYY)
private $dateMM; // month in numeric format (MM)
private $dateDD; // day in numeric format (DD)
private $ext_dateMM; // extended month (e.g. February)
private $daysMonth; // count of days in month
private $stamp; // timestamp
private $day; // return array s.a.
/** /**
* convert date->timestamp * Convert date->timestamp to time
**/ *
private function makeTimestamp($date) * @param string $date Date to convert
*
* @return string Converted time
*/
protected function makeTimestamp($date)
{ {
$this->stamp = strtotime($date); $this->stamp = strtotime($date);
return ($this->stamp); return ($this->stamp);
} }
/** /**
* get date listed in array * Get date listed in array
**/ *
private function getMonth($callDate) * @param string $callDate Date
*
* @return null
*/
protected function getMonth($callDate)
{ {
global $user;
$this->makeTimestamp($callDate); $this->makeTimestamp($callDate);
// last or first day of some months need to be treated in a special way // last or first day of some months need to be treated in a special way
if (!empty($this->mini_cal_month)) if (!empty($this->mini_cal_month))
{ {
$time = $user->create_datetime(); $time = $this->user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset()); $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$today_timestamp = $now[0]; $today_timestamp = $now[0];
$cur_month = date("n", $today_timestamp); $cur_month = date("n", $today_timestamp);
@@ -656,20 +740,28 @@ class portal_calendar_module extends \board3\portal\modules\module_base
} }
} }
// Unserialize links array /**
private function utf_unserialize($serial_str) * Unserialize links array
*
* @param string $serial_str Serialized string
*
* @return array Unserialized array
*/
protected function utf_unserialize($serial_str)
{ {
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str ); $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
return unserialize($out); return unserialize($out);
} }
/** /**
* validate URLs and execute apppend_sid if necessary * Validate URLs and execute apppend_sid if necessary
*
* @param string $url URL to process
*
* @return string Processed URL
*/ */
private function validate_url($url) protected function validate_url($url)
{ {
global $config;
$url = str_replace("\r\n", "\n", str_replace('\"', '"', trim($url))); $url = str_replace("\r\n", "\n", str_replace('\"', '"', trim($url)));
$url = str_replace(' ', '%20', $url); $url = str_replace(' ', '%20', $url);
$url = str_replace('&', '&amp;', $url); $url = str_replace('&', '&amp;', $url);

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Clock * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Clock * @package Clock
*/ */
class portal_clock_module extends \board3\portal\modules\module_base class clock extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,11 +41,17 @@ class portal_clock_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_clock_module'; public $language = 'portal_clock_module';
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
return 'clock_side.html'; return 'clock_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -59,17 +59,4 @@ class portal_clock_module extends \board3\portal\modules\module_base
'vars' => array(), 'vars' => array(),
); );
} }
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
} }

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Custom * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Custom * @package Custom
*/ */
class portal_custom_module extends \board3\portal\modules\module_base class custom extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -53,16 +47,63 @@ class portal_custom_module extends \board3\portal\modules\module_base
*/ */
public $custom_acp_tpl = 'acp_portal_custom'; public $custom_acp_tpl = 'acp_portal_custom';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct a custom module object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $template, $db, $phpbb_root_path, $phpEx, $user)
{
$this->config = $config;
$this->template = $template;
$this->db = $db;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id) public function get_template_center($module_id)
{ {
return $this->parse_template($module_id); return $this->parse_template($module_id);
} }
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
return $this->parse_template($module_id, 'side'); return $this->parse_template($module_id, 'side');
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -75,7 +116,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -90,10 +131,11 @@ class portal_custom_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_custom_' . $module_id . '_code', 'board3_custom_' . $module_id . '_code',
); );
@@ -115,17 +157,24 @@ class portal_custom_module extends \board3\portal\modules\module_base
return ((!$check) ? $check : $db->sql_query($sql)); // if something went wrong, make sure we are aware of the first query return ((!$check) ? $check : $db->sql_query($sql)); // if something went wrong, make sure we are aware of the first query
} }
/**
* Manage custom module
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function manage_custom($value, $key, $module_id) public function manage_custom($value, $key, $module_id)
{ {
global $db, $portal_config, $config, $template, $user, $phpEx, $phpbb_admin_path, $phpbb_root_path;
$action = (isset($_POST['reset'])) ? 'reset' : ''; $action = (isset($_POST['reset'])) ? 'reset' : '';
$action = (isset($_POST['submit'])) ? 'save' : $action; $action = (isset($_POST['submit'])) ? 'save' : $action;
$action = (isset($_POST['preview'])) ? 'preview' : $action; $action = (isset($_POST['preview'])) ? 'preview' : $action;
$portal_config = obtain_portal_config(); $portal_config = obtain_portal_config();
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id); $u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&amp;mode=config&amp;module_id=' . $module_id);
switch($action) switch($action)
{ {
@@ -133,7 +182,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
case 'save': case 'save':
if (!check_form_key('acp_portal')) if (!check_form_key('acp_portal'))
{ {
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
} }
$custom_code = utf8_normalize_nfc(request_var('custom_code', '', true)); $custom_code = utf8_normalize_nfc(request_var('custom_code', '', true));
@@ -152,33 +201,33 @@ class portal_custom_module extends \board3\portal\modules\module_base
// first check for obvious errors, we don't want to waste server resources // first check for obvious errors, we don't want to waste server resources
if(empty($custom_code)) if(empty($custom_code))
{ {
trigger_error($user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
} }
// get groups and check if the selected groups actually exist // get groups and check if the selected groups actually exist
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$groups_ary[] = $row['group_id']; $groups_ary[] = $row['group_id'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$custom_permission = array_intersect($custom_permission, $groups_ary); $custom_permission = array_intersect($custom_permission, $groups_ary);
$custom_permission = implode(',', $custom_permission); $custom_permission = implode(',', $custom_permission);
if (isset($user->lang[$custom_title])) if (isset($this->user->lang[$custom_title]))
{ {
$log_title = $user->lang[$custom_title]; $log_title = $this->user->lang[$custom_title];
} }
else else
{ {
$log_title = $custom_title; $log_title = $custom_title;
} }
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['PORTAL_CUSTOM'] . ':&nbsp;' . $log_title); add_log('admin', 'LOG_PORTAL_CONFIG', $this->user->lang['PORTAL_CUSTOM'] . ':&nbsp;' . $log_title);
// set_portal_config will take care of escaping the welcome message // set_portal_config will take care of escaping the welcome message
set_portal_config('board3_custom_' . $module_id . '_code', $custom_code); set_portal_config('board3_custom_' . $module_id . '_code', $custom_code);
@@ -189,7 +238,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
set_config('board3_custom_' . $module_id . '_bitfield', $bitfield); set_config('board3_custom_' . $module_id . '_bitfield', $bitfield);
set_config('board3_custom_' . $module_id . '_permission', $custom_permission); set_config('board3_custom_' . $module_id . '_permission', $custom_permission);
//trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=modules') : $u_action)); //trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=portal&mode=modules') : $u_action));
break; break;
@@ -204,18 +253,14 @@ class portal_custom_module extends \board3\portal\modules\module_base
// first check for obvious errors, we don't want to waste server resources // first check for obvious errors, we don't want to waste server resources
if(empty($custom_code)) if(empty($custom_code))
{ {
trigger_error($user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['ACP_PORTAL_CUSTOM_CODE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
} }
if (!class_exists('parse_message'))
{
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
}
if($custom_bbcode) if($custom_bbcode)
{ {
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS; $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$uid = (isset($config['board3_custom_' . $module_id . '_uid'])) ? $config['board3_custom_' . $module_id . '_uid'] : ''; $uid = (isset($this->config['board3_custom_' . $module_id . '_uid'])) ? $this->config['board3_custom_' . $module_id . '_uid'] : '';
$bitfield = (isset($config['board3_custom_' . $module_id . '_bitfield'])) ? $config['board3_custom_' . $module_id . '_bitfield'] : ''; $bitfield = (isset($this->config['board3_custom_' . $module_id . '_bitfield'])) ? $this->config['board3_custom_' . $module_id . '_bitfield'] : '';
$options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS; $options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true); generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
@@ -226,7 +271,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
$text = htmlspecialchars_decode($text, ENT_QUOTES); $text = htmlspecialchars_decode($text, ENT_QUOTES);
} }
$template->assign_vars(array( $this->template->assign_vars(array(
'PREVIEW_TEXT' => $text, 'PREVIEW_TEXT' => $text,
'S_PREVIEW' => true, 'S_PREVIEW' => true,
)); ));
@@ -235,12 +280,12 @@ class portal_custom_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$groups_ary[] = $row['group_id']; $groups_ary[] = $row['group_id'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$temp_permissions = array_intersect($custom_permission, $groups_ary); $temp_permissions = array_intersect($custom_permission, $groups_ary);
@@ -249,12 +294,12 @@ class portal_custom_module extends \board3\portal\modules\module_base
default: default:
if(!isset($custom_code)) if(!isset($custom_code))
{ {
$custom_code = generate_text_for_edit($portal_config['board3_custom_' . $module_id . '_code'], $config['board3_custom_' . $module_id . '_uid'], ''); $custom_code = generate_text_for_edit($portal_config['board3_custom_' . $module_id . '_code'], $this->config['board3_custom_' . $module_id . '_uid'], '');
} }
$template->assign_vars(array( $this->template->assign_vars(array(
'CUSTOM_CODE' => (is_array($custom_code)) ? $custom_code['text'] : $custom_code, 'CUSTOM_CODE' => (is_array($custom_code)) ? $custom_code['text'] : $custom_code,
'CUSTOM_USE_BBCODE' => (isset($custom_bbcode)) ? $custom_bbcode : (($config['board3_custom_' . $module_id . '_bbcode'] != '') ? $config['board3_custom_' . $module_id . '_bbcode'] : true), // BBCodes are selected by default 'CUSTOM_USE_BBCODE' => (isset($custom_bbcode)) ? $custom_bbcode : (($this->config['board3_custom_' . $module_id . '_bbcode'] != '') ? $this->config['board3_custom_' . $module_id . '_bbcode'] : true), // BBCodes are selected by default
//'U_BACK' => $u_action, //'U_BACK' => $u_action,
'U_ACTION' => $u_action, 'U_ACTION' => $u_action,
'S_EDIT' => true, 'S_EDIT' => true,
@@ -263,39 +308,47 @@ class portal_custom_module extends \board3\portal\modules\module_base
'S_BBCODE_FLASH' => true, 'S_BBCODE_FLASH' => true,
'S_BBCODE_QUOTE' => true, 'S_BBCODE_QUOTE' => true,
'S_BBCODE_ALLOWED' => true, 'S_BBCODE_ALLOWED' => true,
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], 'MAX_FONT_SIZE' => (int) $this->config['max_post_font_size'],
)); ));
$groups_ary = (isset($temp_permissions)) ? $temp_permissions : ((isset($config['board3_custom_' . $module_id . '_permission'])) ? explode(',', $config['board3_custom_' . $module_id . '_permission']) : array()); $groups_ary = (isset($temp_permissions)) ? $temp_permissions : ((isset($this->config['board3_custom_' . $module_id . '_permission'])) ? explode(',', $this->config['board3_custom_' . $module_id . '_permission']) : array());
// get group info from database and assign the block vars // get group info from database and assign the block vars
$sql = 'SELECT group_id, group_name $sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$template->assign_block_vars('permission_setting', array( $this->template->assign_block_vars('permission_setting', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_NAME' => (isset($this->user->lang['G_' . $row['group_name']])) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'], 'GROUP_ID' => $row['group_id'],
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
if(!function_exists('display_forums')) if(!function_exists('display_forums'))
{ {
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
} }
// Build custom bbcodes array // Build custom bbcodes array
display_custom_bbcodes(); display_custom_bbcodes();
$user->add_lang('posting'); $this->user->add_lang('posting');
break; break;
} }
} }
/**
* Update custom module
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function update_custom($key, $module_id) public function update_custom($key, $module_id)
{ {
$this->manage_custom('', $key, $module_id); $this->manage_custom('', $key, $module_id);
@@ -311,18 +364,18 @@ class portal_custom_module extends \board3\portal\modules\module_base
*/ */
protected function parse_template($module_id, $type = 'center') protected function parse_template($module_id, $type = 'center')
{ {
global $config, $template, $portal_config, $user; $portal_config = obtain_portal_config();
/* /*
* Run generate_text_for_display if the user uses BBCode for designing his custom block * Run generate_text_for_display if the user uses BBCode for designing his custom block
* HTML won't be parsed if the user chooses to use BBCodes in the ACP * HTML won't be parsed if the user chooses to use BBCodes in the ACP
* If BBCodes are turned off, the custom Block code will be directly assigned and HTML will be parsed * If BBCodes are turned off, the custom Block code will be directly assigned and HTML will be parsed
*/ */
if ($config['board3_custom_' . $module_id . '_bbcode']) if ($this->config['board3_custom_' . $module_id . '_bbcode'])
{ {
// Generate text for display and assign template vars // Generate text for display and assign template vars
$uid = $config['board3_custom_' . $module_id . '_uid']; $uid = $this->config['board3_custom_' . $module_id . '_uid'];
$bitfield = $config['board3_custom_' . $module_id . '_bitfield']; $bitfield = $this->config['board3_custom_' . $module_id . '_bitfield'];
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS; $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
$assign_code = generate_text_for_display($portal_config['board3_custom_' . $module_id . '_code'], $uid, $bitfield, $bbcode_options); $assign_code = generate_text_for_display($portal_config['board3_custom_' . $module_id . '_code'], $uid, $bitfield, $bbcode_options);
} }
@@ -331,7 +384,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
$assign_code = htmlspecialchars_decode($portal_config['board3_custom_' . $module_id . '_code'], ENT_QUOTES); $assign_code = htmlspecialchars_decode($portal_config['board3_custom_' . $module_id . '_code'], ENT_QUOTES);
} }
$title = (!empty($config['board3_custom_' . $module_id . '_title'])) ? ((isset($user->lang[$config['board3_custom_' . $module_id . '_title']])) ? $user->lang[$config['board3_custom_' . $module_id . '_title']] : $config['board3_custom_' . $module_id . '_title']) : $user->lang[$this->name]; $title = (!empty($this->config['board3_custom_' . $module_id . '_title'])) ? ((isset($this->user->lang[$this->config['board3_custom_' . $module_id . '_title']])) ? $this->user->lang[$this->config['board3_custom_' . $module_id . '_title']] : $this->config['board3_custom_' . $module_id . '_title']) : $this->user->lang[$this->name];
if(!empty($assign_code)) if(!empty($assign_code))
{ {
@@ -340,7 +393,7 @@ class portal_custom_module extends \board3\portal\modules\module_base
'title' => $title, 'title' => $title,
'code' => $assign_code, 'code' => $assign_code,
// no image for center blocks // no image for center blocks
'image_src' => ($type === 'center') ? '' : ((!empty($config['board3_custom_' . $module_id . '_image_src'])) ? $config['board3_custom_' . $module_id . '_image_src'] : $this->image_src), 'image_src' => ($type === 'center') ? '' : ((!empty($this->config['board3_custom_' . $module_id . '_image_src'])) ? $this->config['board3_custom_' . $module_id . '_image_src'] : $this->image_src),
); );
} }
} }

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Default * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Modulname * @package Modulname
*/ */
class portal_modulename_module extends \board3\portal\modules\module_base class modulename extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -58,10 +52,29 @@ class portal_modulename_module extends \board3\portal\modules\module_base
*/ */
public $hide_name = false; public $hide_name = false;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/**
* Construct a default module object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
*/
public function __construct($config, $template)
{
$this->config = $config;
$this->template = $template;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id) public function get_template_center($module_id)
{ {
global $config, $template;
$template->assign_vars(array( $template->assign_vars(array(
'EXAMPLE' => $config['board3_configname_' . $module_id], 'EXAMPLE' => $config['board3_configname_' . $module_id],
)); ));
@@ -69,10 +82,11 @@ class portal_modulename_module extends \board3\portal\modules\module_base
return 'modulename_center.html'; return 'modulename_center.html';
} }
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template;
$template->assign_vars(array( $template->assign_vars(array(
'EXAMPLE' => $config['board3_configname2_' . $module_id], 'EXAMPLE' => $config['board3_configname2_' . $module_id],
)); ));
@@ -80,6 +94,9 @@ class portal_modulename_module extends \board3\portal\modules\module_base
return 'modulename_side.html'; return 'modulename_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -93,7 +110,7 @@ class portal_modulename_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -102,10 +119,11 @@ class portal_modulename_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_configname_' . $module_id, 'board3_configname_' . $module_id,
'board3_configname2_' . $module_id, 'board3_configname2_' . $module_id,

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Donation * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Donation * @package Donation
*/ */
class portal_donation_module extends \board3\portal\modules\module_base class donation extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,30 +41,58 @@ class portal_donation_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_donation_module'; public $language = 'portal_donation_module';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/**
* Construct a stylechanger object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $template, $user)
{
$this->config = $config;
$this->template = $template;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id) public function get_template_center($module_id)
{ {
global $config, $template, $user; $this->template->assign_vars(array(
'PAY_ACC_CENTER' => $this->config['board3_pay_acc_' . $module_id],
$template->assign_vars(array( 'PAY_CUSTOM_CENTER' => (!empty($this->config['board3_pay_custom_' . $module_id])) ? $this->user->data['username_clean'] : false,
'PAY_ACC_CENTER' => $config['board3_pay_acc_' . $module_id],
'PAY_CUSTOM_CENTER' => (!empty($config['board3_pay_custom_' . $module_id])) ? $user->data['username_clean'] : false,
)); ));
return 'donation_center.html'; return 'donation_center.html';
} }
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $user; $this->template->assign_vars(array(
'PAY_ACC_SIDE' => $this->config['board3_pay_acc_' . $module_id],
$template->assign_vars(array( 'PAY_CUSTOM_SIDE' => (!empty($this->config['board3_pay_custom_' . $module_id])) ? $this->user->data['username_clean'] : false,
'PAY_ACC_SIDE' => $config['board3_pay_acc_' . $module_id],
'PAY_CUSTOM_SIDE' => (!empty($config['board3_pay_custom_' . $module_id])) ? $user->data['username_clean'] : false,
)); ));
return 'donation_side.html'; return 'donation_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -84,7 +106,7 @@ class portal_donation_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -93,10 +115,11 @@ class portal_donation_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_pay_acc_' . $module_id, 'board3_pay_acc_' . $module_id,
'board3_pay_custom_' . $module_id, 'board3_pay_custom_' . $module_id,

117
modules/forumlist.php Normal file
View File

@@ -0,0 +1,117 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
namespace board3\portal\modules;
/**
* @package Forumlist
*/
class forumlist extends module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_FORUMLIST';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_forumlist_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct a forumlist object
*
* @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($auth, $config, $template, $phpbb_root_path, $phpEx, $user)
{
$this->auth = $auth;
$this->config = $config;
$this->template = $template;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_center($module_id)
{
display_forums('', $this->config['load_moderators'], false);
$this->template->assign_vars(array(
'FORUM_IMG' => $this->user->img('forum_read', 'NO_NEW_POSTS'),
'FORUM_NEW_IMG' => $this->user->img('forum_unread', 'NEW_POSTS'),
'FORUM_LOCKED_IMG' => $this->user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
'FORUM_NEW_LOCKED_IMG' => $this->user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? append_sid("{$this->phpbb_root_path}index.{$this->php_ext}", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
'U_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&amp;mode=front', true, $this->user->session_id) : '',
));
return 'forumlist.html';
}
/**
* @inheritdoc
*/
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_FORUMLIST',
'vars' => array(),
);
}
}

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Friends * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Friends * @package Friends
*/ */
class portal_friends_module extends \board3\portal\modules\module_base class friends extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,16 +41,50 @@ class portal_friends_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_friends_module'; public $language = 'portal_friends_module';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/**
* Construct a friends object
*
* @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user object
*/
public function __construct($auth, $config, $db, $template, $user)
{
$this->auth = $auth;
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $db, $user, $auth;
$s_display_friends = false; $s_display_friends = false;
// Output listing of friends online // Output listing of friends online
$update_time = $config['load_online_time'] * 60; $update_time = $this->config['load_online_time'] * 60;
$sql = $db->sql_build_query('SELECT_DISTINCT', array( $sql = $this->db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
'FROM' => array( 'FROM' => array(
USERS_TABLE => 'u', USERS_TABLE => 'u',
@@ -70,21 +98,21 @@ class portal_friends_module extends \board3\portal\modules\module_base
) )
), ),
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . ' 'WHERE' => 'z.user_id = ' . $this->user->data['user_id'] . '
AND z.friend = 1 AND z.friend = 1
AND u.user_id = z.zebra_id', AND u.user_id = z.zebra_id',
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.username_clean, u.user_allow_viewonline, u.user_colour', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.username_clean, u.user_allow_viewonline, u.user_colour',
'ORDER_BY' => 'u.username_clean ASC', 'ORDER_BY' => 'u.username_clean ASC',
)); ));
$result = $db->sql_query_limit($sql, $config['board3_max_online_friends_' . $module_id]); $result = $this->db->sql_query_limit($sql, $this->config['board3_max_online_friends_' . $module_id]);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline'; $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $this->auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
$s_display_friends = ($row['user_id']) ? true : false; $s_display_friends = ($row['user_id']) ? true : false;
$template->assign_block_vars("b3p_friends_{$which}", array( $this->template->assign_block_vars("b3p_friends_{$which}", array(
'USER_ID' => $row['user_id'], 'USER_ID' => $row['user_id'],
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
@@ -92,16 +120,19 @@ class portal_friends_module extends \board3\portal\modules\module_base
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])) 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
); );
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
// Assign specific vars // Assign specific vars
$template->assign_vars(array( $this->template->assign_vars(array(
'S_DISPLAY_FRIENDS' => $s_display_friends, 'S_DISPLAY_FRIENDS' => $s_display_friends,
)); ));
return 'friends_side.html'; return 'friends_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -114,7 +145,7 @@ class portal_friends_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -122,10 +153,11 @@ class portal_friends_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_max_online_friends_' . $module_id, 'board3_max_online_friends_' . $module_id,
); );

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Latest Bots * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Latest Bots * @package Latest Bots
*/ */
class portal_latest_bots_module extends \board3\portal\modules\module_base class latest_bots extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -52,37 +46,68 @@ class portal_latest_bots_module extends \board3\portal\modules\module_base
*/ */
public $hide_name = false; public $hide_name = false;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/**
* Construct a latest bots object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $db, $template, $user)
{
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $db, $user;
// Last x visited bots // Last x visited bots
$sql = 'SELECT username, user_colour, user_lastvisit $sql = 'SELECT username, user_colour, user_lastvisit
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_type = ' . USER_IGNORE . ' WHERE user_type = ' . USER_IGNORE . '
AND user_lastvisit > 0 AND user_lastvisit > 0
ORDER BY user_lastvisit DESC'; ORDER BY user_lastvisit DESC';
$result = $db->sql_query_limit($sql, $config['board3_last_visited_bots_number_' . $module_id]); $result = $this->db->sql_query_limit($sql, $this->config['board3_last_visited_bots_number_' . $module_id]);
$show_module = false; $show_module = false;
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$template->assign_block_vars('last_visited_bots', array( $this->template->assign_block_vars('last_visited_bots', array(
'BOT_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']), 'BOT_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']),
'LAST_VISIT_DATE' => $user->format_date($row['user_lastvisit']), 'LAST_VISIT_DATE' => $this->user->format_date($row['user_lastvisit']),
)); ));
$show_module = true; $show_module = true;
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
if($show_module) if ($show_module)
{ {
return 'latest_bots_side.html'; return 'latest_bots_side.html';
} }
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -95,7 +120,7 @@ class portal_latest_bots_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -103,10 +128,11 @@ class portal_latest_bots_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_last_visited_bots_number_' . $module_id, 'board3_last_visited_bots_number_' . $module_id,
); );

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Latest Members * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Modulname * @package Latest members
*/ */
class portal_latest_members_module extends \board3\portal\modules\module_base class latest_members extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,29 +41,61 @@ class portal_latest_members_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_latest_members_module'; public $language = 'portal_latest_members_module';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/**
* Construct a latest_members object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $db, $template, $user)
{
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $db, $user;
$sql = 'SELECT user_id, username, user_regdate, user_colour $sql = 'SELECT user_id, username, user_regdate, user_colour
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . ' WHERE user_type <> ' . USER_IGNORE . '
AND user_inactive_time = 0 AND user_inactive_time = 0
ORDER BY user_regdate DESC'; ORDER BY user_regdate DESC';
$result = $db->sql_query_limit($sql, $config['board3_max_last_member_' . $module_id]); $result = $this->db->sql_query_limit($sql, $this->config['board3_max_last_member_' . $module_id]);
while(($row = $db->sql_fetchrow($result)) && ($row['username'])) while(($row = $this->db->sql_fetchrow($result)) && ($row['username']))
{ {
$template->assign_block_vars('latest_members', array( $this->template->assign_block_vars('latest_members', array(
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
'JOINED' => $user->format_date($row['user_regdate'], $format = 'd M'), 'JOINED' => $this->user->format_date($row['user_regdate'], $format = 'd M'),
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
return 'latest_members_side.html'; return 'latest_members_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -82,7 +108,7 @@ class portal_latest_members_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -90,10 +116,11 @@ class portal_latest_members_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_max_last_member_' . $module_id, 'board3_max_last_member_' . $module_id,
); );

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Leaders * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Leaders * @package Leaders
*/ */
class portal_leaders_module extends \board3\portal\modules\module_base class leaders extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,19 +41,63 @@ class portal_leaders_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_leaders_module'; public $language = 'portal_leaders_module';
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct a leaders object
*
* @param \phpbb\auth\auth $auth phpBB auth service
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($auth, $config, $db, $template, $phpbb_root_path, $phpEx, $user)
{
$this->auth = $auth;
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;
// Display a listing of board admins, moderators // Display a listing of board admins, moderators
$user->add_lang('groups'); $this->user->add_lang('groups');
if($config['board3_leaders_ext_' . $module_id]) if($this->config['board3_leaders_ext_' . $module_id])
{ {
$legends = array(); $legends = array();
$groups = array(); $groups = array();
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{ {
$sql = 'SELECT group_id, group_name, group_colour, group_type $sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
@@ -73,16 +111,16 @@ class portal_leaders_module extends \board3\portal\modules\module_base
LEFT JOIN ' . USER_GROUP_TABLE . ' ug LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON ( ON (
g.group_id = ug.group_id g.group_id = ug.group_id
AND ug.user_id = ' . $user->data['user_id'] . ' AND ug.user_id = ' . $this->user->data['user_id'] . '
AND ug.user_pending = 0 AND ug.user_pending = 0
) )
WHERE g.group_legend = 1 WHERE g.group_legend = 1
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ') AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $this->user->data['user_id'] . ')
ORDER BY g.group_name ASC'; ORDER BY g.group_name ASC';
} }
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$groups[$row['group_id']] = array( $groups[$row['group_id']] = array(
'group_name' => $row['group_name'], 'group_name' => $row['group_name'],
@@ -92,7 +130,7 @@ class portal_leaders_module extends \board3\portal\modules\module_base
); );
$legends[] = $row['group_id']; $legends[] = $row['group_id'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
if(sizeof($legends)) if(sizeof($legends))
{ {
@@ -104,11 +142,11 @@ class portal_leaders_module extends \board3\portal\modules\module_base
' . USER_GROUP_TABLE . ' AS ug ' . USER_GROUP_TABLE . ' AS ug
WHERE WHERE
ug.user_id = u.user_id ug.user_id = u.user_id
AND '. $db->sql_in_set('ug.group_id', $legends) . ' AND '. $this->db->sql_in_set('ug.group_id', $legends) . '
ORDER BY u.username_clean ASC'; ORDER BY u.username_clean ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$groups[$row['group_id']]['group_users'][] = array( $groups[$row['group_id']]['group_users'][] = array(
'user_id' => $row['user_id'], 'user_id' => $row['user_id'],
@@ -116,7 +154,7 @@ class portal_leaders_module extends \board3\portal\modules\module_base
'user_colour' => $row['user_colour'], 'user_colour' => $row['user_colour'],
); );
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
} }
if(sizeof($groups)) if(sizeof($groups))
@@ -125,10 +163,10 @@ class portal_leaders_module extends \board3\portal\modules\module_base
{ {
if(sizeof($group['group_users'])) if(sizeof($group['group_users']))
{ {
$group_name = ($group['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group['group_name']] : $group['group_name']; $group_name = ($group['group_type'] == GROUP_SPECIAL) ? $this->user->lang['G_' . $group['group_name']] : $group['group_name'];
$u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $group_id); $u_group = append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $group_id);
$template->assign_block_vars('group', array( $this->template->assign_block_vars('group', array(
'GROUP_NAME' => $group_name, 'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => $group['group_colour'], 'GROUP_COLOUR' => $group['group_colour'],
'U_GROUP' => $u_group, 'U_GROUP' => $u_group,
@@ -136,7 +174,7 @@ class portal_leaders_module extends \board3\portal\modules\module_base
foreach($group['group_users'] as $group_user) foreach($group['group_users'] as $group_user)
{ {
$template->assign_block_vars('group.member', array( $this->template->assign_block_vars('group.member', array(
'USER_ID' => $group_user['user_id'], 'USER_ID' => $group_user['user_id'],
'USERNAME_FULL' => get_username_string('full', $group_user['user_id'], $group_user['username'], $group_user['user_colour']), 'USERNAME_FULL' => get_username_string('full', $group_user['user_id'], $group_user['username'], $group_user['user_colour']),
)); ));
@@ -148,7 +186,7 @@ class portal_leaders_module extends \board3\portal\modules\module_base
} }
else else
{ {
$sql = $db->sql_build_query('SELECT', array( $sql = $this->db->sql_build_query('SELECT', array(
'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.user_colour, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id', 'SELECT' => 'u.user_id, u.group_id as default_group, u.username, u.user_colour, u.user_allow_pm, g.group_id, g.group_name, g.group_colour, g.group_type, ug.user_id as ug_user_id',
'FROM' => array( 'FROM' => array(
USERS_TABLE => 'u', USERS_TABLE => 'u',
@@ -157,15 +195,15 @@ class portal_leaders_module extends \board3\portal\modules\module_base
'LEFT_JOIN' => array( 'LEFT_JOIN' => array(
array( array(
'FROM' => array(USER_GROUP_TABLE => 'ug'), 'FROM' => array(USER_GROUP_TABLE => 'ug'),
'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $user->data['user_id'] 'ON' => 'ug.group_id = g.group_id AND ug.user_pending = 0 AND ug.user_id = ' . $this->user->data['user_id']
)), )),
'WHERE' => 'u.group_id = g.group_id AND ' . $db->sql_in_set('g.group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS')), 'WHERE' => 'u.group_id = g.group_id AND ' . $this->db->sql_in_set('g.group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS')),
'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC' 'ORDER_BY' => 'g.group_name ASC, u.username_clean ASC'
)); ));
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
if ($row['group_name'] == 'ADMINISTRATORS') if ($row['group_name'] == 'ADMINISTRATORS')
{ {
@@ -176,18 +214,18 @@ class portal_leaders_module extends \board3\portal\modules\module_base
$which_row = 'b3p_moderators'; $which_row = 'b3p_moderators';
} }
if ($row['group_type'] == GROUP_HIDDEN && !$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $user->data['user_id']) if ($row['group_type'] == GROUP_HIDDEN && !$this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') && $row['ug_user_id'] != $this->user->data['user_id'])
{ {
$group_name = $user->lang['GROUP_UNDISCLOSED']; $group_name = $this->user->lang['GROUP_UNDISCLOSED'];
$u_group = ''; $u_group = '';
} }
else else
{ {
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
$u_group = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']); $u_group = append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&amp;g=' . $row['group_id']);
} }
$template->assign_block_vars($which_row, array( $this->template->assign_block_vars($which_row, array(
'USER_ID' => $row['user_id'], 'USER_ID' => $row['user_id'],
'GROUP_NAME' => $group_name, 'GROUP_NAME' => $group_name,
'GROUP_COLOR' => $row['group_colour'], 'GROUP_COLOR' => $row['group_colour'],
@@ -200,11 +238,14 @@ class portal_leaders_module extends \board3\portal\modules\module_base
'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
return 'leaders_side.html'; return 'leaders_side.html';
} }
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -217,7 +258,7 @@ class portal_leaders_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
@@ -226,10 +267,11 @@ class portal_leaders_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_leaders_ext_' . $module_id, 'board3_leaders_ext_' . $module_id,
); );

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Link us * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Clock * @package Link Us
*/ */
class portal_link_us_module extends \board3\portal\modules\module_base class link_us extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -47,22 +41,52 @@ class portal_link_us_module extends \board3\portal\modules\module_base
*/ */
public $language = 'portal_link_us_module'; public $language = 'portal_link_us_module';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/**
* Construct a link us object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $template, $user)
{
$this->config = $config;
$this->template = $template;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $user;
//doing the easy way ;) //doing the easy way ;)
$u_link = generate_board_url(); $u_link = generate_board_url();
// Assign specific vars // Assign specific vars
$template->assign_vars(array( $this->template->assign_vars(array(
'LINK_US_TXT' => sprintf($user->lang['LINK_US_TXT'], $config['sitename']), 'LINK_US_TXT' => sprintf($this->user->lang['LINK_US_TXT'], $this->config['sitename']),
'U_LINK_US' => '&lt;a&nbsp;href=&quot;' . $u_link . '&quot;&nbsp;' . (($config['site_desc']) ? 'title=&quot;' . $config['site_desc'] . '&quot;' : '' ) . '&gt;' . (($config['sitename']) ? $config['sitename'] : $u_link ) . '&lt;/a&gt;', 'U_LINK_US' => '&lt;a&nbsp;href=&quot;' . $u_link . '&quot;&nbsp;' . (($this->config['site_desc']) ? 'title=&quot;' . $this->config['site_desc'] . '&quot;' : '' ) . '&gt;' . (($this->config['sitename']) ? $this->config['sitename'] : $u_link ) . '&lt;/a&gt;',
)); ));
return 'link_us_side.html'; return 'link_us_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
return array( return array(
@@ -70,17 +94,4 @@ class portal_link_us_module extends \board3\portal\modules\module_base
'vars' => array(), 'vars' => array(),
); );
} }
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
} }

View File

@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* @package Board3 Portal v2 - Links * @package Board3 Portal v2.1
* @copyright (c) Board3 Group ( www.board3.de ) * @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
/** namespace board3\portal\modules;
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Links * @package Links
*/ */
class portal_links_module extends \board3\portal\modules\module_base class links extends module_base
{ {
/** /**
* Allowed columns: Just sum up your options (Exp: left + right = 10) * Allowed columns: Just sum up your options (Exp: left + right = 10)
@@ -59,10 +53,49 @@ class portal_links_module extends \board3\portal\modules\module_base
const LINK_INT = 1; const LINK_INT = 1;
const LINK_EXT = 2; const LINK_EXT = 2;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\db\driver */
protected $db;
/** @var \phpbb\template */
protected $template;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct a links object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\db\driver $db phpBB db driver
* @param \phpbb\template $template phpBB template
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $db, $template, $phpbb_root_path, $phpEx, $user)
{
$this->config = $config;
$this->db = $db;
$this->template = $template;
$this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
$this->user = $user;
}
/**
* @inheritdoc
*/
public function get_template_side($module_id) public function get_template_side($module_id)
{ {
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
$links = array(); $links = array();
$portal_config = obtain_portal_config(); $portal_config = obtain_portal_config();
@@ -76,7 +109,7 @@ class portal_links_module extends \board3\portal\modules\module_base
if($links[$i]['type'] == self::LINK_INT) if($links[$i]['type'] == self::LINK_INT)
{ {
$links[$i]['url'] = str_replace('&', '&amp;', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors $links[$i]['url'] = str_replace('&', '&amp;', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors
$cur_url = append_sid($phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is $cur_url = append_sid($this->phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
} }
else else
{ {
@@ -88,11 +121,11 @@ class portal_links_module extends \board3\portal\modules\module_base
if(!empty($permission_check) || $links[$i]['permission'] == '') if(!empty($permission_check) || $links[$i]['permission'] == '')
{ {
$template->assign_block_vars('portallinks', array( $this->template->assign_block_vars('portallinks', array(
'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'], 'LINK_TITLE' => (isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title'],
'LINK_URL' => $cur_url, 'LINK_URL' => $cur_url,
'MODULE_ID' => $module_id, 'MODULE_ID' => $module_id,
'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $config['board3_links_url_new_window_' . $module_id]) ? true : false, 'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $this->config['board3_links_url_new_window_' . $module_id]) ? true : false,
)); ));
} }
} }
@@ -100,6 +133,9 @@ class portal_links_module extends \board3\portal\modules\module_base
return 'links_side.html'; return 'links_side.html';
} }
/**
* @inheritdoc
*/
public function get_template_acp($module_id) public function get_template_acp($module_id)
{ {
// do not remove this as it is needed in order to run manage_links // do not remove this as it is needed in order to run manage_links
@@ -114,12 +150,10 @@ class portal_links_module extends \board3\portal\modules\module_base
} }
/** /**
* API functions * @inheritdoc
*/ */
public function install($module_id) public function install($module_id)
{ {
global $phpbb_root_path, $db;
$links = array(); $links = array();
$links_titles = array( $links_titles = array(
@@ -160,10 +194,11 @@ class portal_links_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) /**
* @inheritdoc
*/
public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_links_array_' . $module_id, 'board3_links_array_' . $module_id,
); );
@@ -181,11 +216,17 @@ class portal_links_module extends \board3\portal\modules\module_base
return $db->sql_query($sql); return $db->sql_query($sql);
} }
// Manage the menu links /**
* Manage the links
*
* @param mixed $value Value of input
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function manage_links($value, $key, $module_id) public function manage_links($value, $key, $module_id)
{ {
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
$action = request_var('action', ''); $action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action; $action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action; $action = (isset($_POST['save'])) ? 'save' : $action;
@@ -196,7 +237,7 @@ class portal_links_module extends \board3\portal\modules\module_base
$links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]); $links = $this->utf_unserialize($portal_config['board3_links_array_' . $module_id]);
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&amp;mode=config&amp;module_id=' . $module_id); $u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&amp;mode=config&amp;module_id=' . $module_id);
switch ($action) switch ($action)
{ {
@@ -204,7 +245,7 @@ class portal_links_module extends \board3\portal\modules\module_base
case 'save': case 'save':
if (!check_form_key('acp_portal')) if (!check_form_key('acp_portal'))
{ {
trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
} }
$link_title = utf8_normalize_nfc(request_var('link_title', ' ', true)); $link_title = utf8_normalize_nfc(request_var('link_title', ' ', true));
@@ -218,12 +259,12 @@ class portal_links_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id $sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$groups_ary[] = $row['group_id']; $groups_ary[] = $row['group_id'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$link_permissions = array_intersect($link_permission, $groups_ary); $link_permissions = array_intersect($link_permission, $groups_ary);
$link_permissions = implode(',', $link_permissions); $link_permissions = implode(',', $link_permissions);
@@ -231,18 +272,18 @@ class portal_links_module extends \board3\portal\modules\module_base
// Check for errors // Check for errors
if (!$link_title) if (!$link_title)
{ {
trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
} }
if (!$link_url) if (!$link_url)
{ {
trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
} }
// overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links // overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links
if (isset($link_id) && $link_id < sizeof($links)) if (isset($link_id) && $link_id < sizeof($links))
{ {
$message = $user->lang['LINK_UPDATED']; $message = $this->user->lang['LINK_UPDATED'];
$links[$link_id] = array( $links[$link_id] = array(
'title' => $link_title, 'title' => $link_title,
@@ -255,7 +296,7 @@ class portal_links_module extends \board3\portal\modules\module_base
} }
else else
{ {
$message = $user->lang['LINK_ADDED']; $message = $this->user->lang['LINK_ADDED'];
$links[] = array( $links[] = array(
'title' => $link_title, 'title' => $link_title,
@@ -278,7 +319,7 @@ class portal_links_module extends \board3\portal\modules\module_base
if (!isset($link_id) && $link_id >= sizeof($links)) if (!isset($link_id) && $link_id >= sizeof($links))
{ {
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
} }
if (confirm_box(true)) if (confirm_box(true))
@@ -295,7 +336,7 @@ class portal_links_module extends \board3\portal\modules\module_base
} }
else else
{ {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id, 'link_id' => $link_id,
'action' => 'delete', 'action' => 'delete',
))); )));
@@ -309,7 +350,7 @@ class portal_links_module extends \board3\portal\modules\module_base
if (!isset($link_id) && $link_id >= sizeof($links)) if (!isset($link_id) && $link_id >= sizeof($links))
{ {
trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING); trigger_error($this->user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
} }
// make sure we don't try to move a link where it can't be moved // make sure we don't try to move a link where it can't be moved
@@ -352,7 +393,7 @@ class portal_links_module extends \board3\portal\modules\module_base
// Edit or add menu item // Edit or add menu item
case 'edit': case 'edit':
case 'add': case 'add':
$template->assign_vars(array( $this->template->assign_vars(array(
'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '', 'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '',
'LINK_URL' => (isset($links[$link_id]['url']) && $action != 'add') ? str_replace('&', '&amp;', $links[$link_id]['url']) : '', 'LINK_URL' => (isset($links[$link_id]['url']) && $action != 'add') ? str_replace('&', '&amp;', $links[$link_id]['url']) : '',
@@ -369,16 +410,16 @@ class portal_links_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id, group_name $sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC'; ORDER BY group_id ASC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) while($row = $this->db->sql_fetchrow($result))
{ {
$template->assign_block_vars('permission_setting_link', array( $this->template->assign_block_vars('permission_setting_link', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_NAME' => (isset($this->user->lang['G_' . $row['group_name']])) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'], 'GROUP_ID' => $row['group_id'],
)); ));
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
return; return;
@@ -387,8 +428,8 @@ class portal_links_module extends \board3\portal\modules\module_base
for ($i = 0; $i < sizeof($links); $i++) for ($i = 0; $i < sizeof($links); $i++)
{ {
$template->assign_block_vars('links', array( $this->template->assign_block_vars('links', array(
'LINK_TITLE' => ($action != 'add') ? ((isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title']) : '', 'LINK_TITLE' => ($action != 'add') ? ((isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
'LINK_URL' => ($action != 'add') ? str_replace('&', '&amp;', $links[$i]['url']) : '', 'LINK_URL' => ($action != 'add') ? str_replace('&', '&amp;', $links[$i]['url']) : '',
'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i, 'U_EDIT' => $u_action . '&amp;action=edit&amp;id=' . $i,
@@ -399,12 +440,26 @@ class portal_links_module extends \board3\portal\modules\module_base
} }
} }
/**
* Update links
*
* @param string $key Key name
* @param int $module_id Module ID
*
* @return null
*/
public function update_links($key, $module_id) public function update_links($key, $module_id)
{ {
$this->manage_links('', $key, $module_id); $this->manage_links('', $key, $module_id);
} }
// Unserialize links array /**
* Unserialize links array
*
* @param string $serial_str Serialized string
*
* @return string Unserialized string
*/
private function utf_unserialize($serial_str) private function utf_unserialize($serial_str)
{ {
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str ); $out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );

View File

@@ -9,14 +9,6 @@
namespace board3\portal\modules; namespace board3\portal\modules;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package module_base * @package module_base
*/ */
@@ -89,7 +81,7 @@ class module_base implements module_interface
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
return true; return true;
} }

View File

@@ -9,14 +9,6 @@
namespace board3\portal\modules; namespace board3\portal\modules;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package module_interface * @package module_interface
*/ */
@@ -101,8 +93,9 @@ interface module_interface
* Executes any additional commands for uninstalling the module * Executes any additional commands for uninstalling the module
* *
* @param int $module_id Module's ID * @param int $module_id Module's ID
* @param \phpbb\db\driver $db phpBB dbal driver
* *
* @return bool True if uninstall was successful, false if not * @return bool True if uninstall was successful, false if not
*/ */
public function uninstall($module_id); public function uninstall($module_id, $db);
} }

View File

@@ -9,14 +9,6 @@
namespace board3\portal\modules; namespace board3\portal\modules;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/** /**
* @package Stylechanger * @package Stylechanger
*/ */
@@ -49,6 +41,34 @@ class stylechanger extends module_base
*/ */
public $language = 'portal_stylechanger_module'; public $language = 'portal_stylechanger_module';
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template */
protected $template;
/** @var \phpbb\db\driver */
protected $db;
/** @var php file extension */
protected $php_ext;
/** @var phpbb root path */
protected $phpbb_root_path;
/** @var \phpbb\user */
protected $user;
/**
* Construct a stylechanger object
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template $template phpBB template
* @param \phpbb\db\driver $db Database driver
* @param string $phpEx php file extension
* @param string $phpbb_root_path phpBB root path
* @param \phpbb\user $user phpBB user object
*/
public function __construct($config, $template, $db, $phpEx, $phpbb_root_path, $user) public function __construct($config, $template, $db, $phpEx, $phpbb_root_path, $user)
{ {
$this->config = $config; $this->config = $config;

View File

@@ -1,185 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
define('IN_PORTAL', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'portal/includes/constants.' . $phpEx);
$portal_root_path = PORTAL_ROOT_PATH;
include($phpbb_root_path . $portal_root_path . 'includes/functions_modules.' . $phpEx);
include($phpbb_root_path . $portal_root_path . 'includes/functions.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/portal');
/**
* Make sure we do an isset first,
* else we will get errors if someone uninstalls the portal and forgets to remove portal.php
*/
if (!isset($config['board3_enable']) || !$config['board3_enable'] || !$auth->acl_get('u_view_portal'))
{
redirect(append_sid($phpbb_root_path . 'index.' . $phpEx));
}
/**
* get initial data
*/
$portal_config = obtain_portal_config();
$portal_modules = obtain_portal_modules();
/**
* set up column_count array
* with this we can hide unneeded parts of the portal
*/
$module_count = array(
'total' => 0,
'top' => 0,
'left' => 0,
'center' => 0,
'right' => 0,
'bottom' => 0,
);
/**
* start assigning block vars
*/
foreach ($portal_modules as $row)
{
if($row['module_status'] == B3_MODULE_DISABLED)
{
continue;
}
$class_name = 'portal_' . $row['module_classname'] . '_module';
if (!class_exists($class_name))
{
include("{$phpbb_root_path}{$portal_root_path}modules/portal_{$row['module_classname']}.$phpEx");
}
if (!class_exists($class_name))
{
trigger_error(sprintf($user->lang['CLASS_NOT_FOUND'], $class_name, 'portal_' . $row['module_classname']), E_USER_ERROR);
}
$module = new $class_name();
/**
* Check for permissions before loading anything
* the default group of a user always defines his/her permission (KISS)
*/
$group_ary = (!empty($row['module_group_ids'])) ? explode(',', $row['module_group_ids']) : '';
if ((is_array($group_ary) && !in_array($user->data['group_id'], $group_ary)))
{
continue;
}
if ($module->language)
{
$user->add_lang('mods/portal/' . $module->language);
}
if ($row['module_column'] == column_string_num('left') && $config['board3_left_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'left';
++$module_count['left'];
}
if ($row['module_column'] == column_string_num('center'))
{
$template_module = $module->get_template_center($row['module_id']);
$template_column = 'center';
++$module_count['center'];
}
if ($row['module_column'] == column_string_num('right') && $config['board3_right_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'right';
++$module_count['right'];
}
if ($row['module_column'] == column_string_num('top'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['top'];
}
if ($row['module_column'] == column_string_num('bottom'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['bottom'];
}
if (!isset($template_module))
{
continue;
}
// Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file
if (is_array($template_module))
{
$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'],
'IMAGE_SRC' => $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $template_module['image_src'],
'TITLE' => $template_module['title'],
'CODE' => $template_module['code'],
'MODULE_ID' => $row['module_id'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
));
}
else
{
$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module,
'IMAGE_SRC' => $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $row['module_image_src'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
'MODULE_ID' => $row['module_id'],
'TITLE' => (isset($user->lang[$row['module_name']])) ? $user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']),
));
}
unset($template_module);
}
$module_count['total'] = sizeof($portal_modules);
// Redirect to index if there are currently no active modules
if($module_count['total'] < 1)
{
redirect(append_sid($phpbb_root_path . 'index.' . $phpEx));
}
// Assign specific vars
$template->assign_vars(array(
// 'S_SMALL_BLOCK' => true,
'S_PORTAL_LEFT_COLUMN' => $config['board3_left_column_width'],
'S_PORTAL_RIGHT_COLUMN' => $config['board3_right_column_width'],
'S_LEFT_COLUMN' => ($module_count['left'] > 0 && $config['board3_left_column']) ? true : false,
'S_CENTER_COLUMN' => ($module_count['center'] > 0) ? true : false,
'S_RIGHT_COLUMN' => ($module_count['right'] > 0 && $config['board3_right_column']) ? true : false,
'S_TOP_COLUMN' => ($module_count['top'] > 0) ? true : false,
'S_BOTTOM_COLUMN' => ($module_count['bottom'] > 0) ? true : false,
'S_DISPLAY_PHPBB_MENU' => $config['board3_phpbb_menu'],
'B3P_DISPLAY_JUMPBOX' => $config['board3_display_jumpbox'],
));
// Output page
page_header($user->lang['PORTAL']);
$template->set_filenames(array(
'body' => 'portal/portal_body.html')
);
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();

View File

@@ -72,7 +72,7 @@ function obtain_portal_modules()
{ {
global $db, $cache, $portal_modules; global $db, $cache, $portal_modules;
if (($portal_modules = $cache->get('portal_modules')) === false) if (($portal_modules = $cache->get('portal_modules')) === false || defined('DEBUG'))
{ {
$portal_modules = $portal_cached_modules = array(); $portal_modules = $portal_cached_modules = array();
@@ -813,18 +813,17 @@ function check_file_src($value, $key, $module_id, $force_error = true)
$error = ''; $error = '';
// We check if the chosen file is present in all active styles // We check if the chosen file is present in all active styles
$sql = 'SELECT st.theme_path $sql = 'SELECT style_path
FROM ' . STYLES_THEME_TABLE . ' st FROM ' . STYLES_TABLE . '
LEFT JOIN ' . STYLES_TABLE . ' s WHERE style_active = 1';
ON (st.theme_id = s.style_id)
WHERE s.style_active = 1';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
if (!file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/images/portal/' . $value)) if (!file_exists($phpbb_root_path . 'styles/' . $row['style_path'] . '/theme/images/portal/' . $value) &&
!file_exists($phpbb_root_path . 'ext/board3/portal/styles/' . $row['style_path'] . '/theme/images/portal/' . $value))
{ {
$error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['theme_path'] . '/theme/images/portal/' . $value . '<br />'; $error .= $user->lang['B3P_FILE_NOT_FOUND'] . ': styles/' . $row['style_path'] . '/theme/images/portal/' . $value . '<br />';
} }
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
@@ -833,7 +832,7 @@ function check_file_src($value, $key, $module_id, $force_error = true)
{ {
if ($force_error) if ($force_error)
{ {
trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&amp;mode=config&amp;module_id=' . $module_id)), E_USER_WARNING ); trigger_error($error . adm_back_link(append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=\board3\portal\acp\portal_module&amp;mode=config&amp;module_id=' . $module_id)), E_USER_WARNING);
} }
else else
{ {

View File

@@ -1,470 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2 - Announcements
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Modulname
*/
class portal_announcements_module extends \board3\portal\modules\module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'GLOBAL_ANNOUNCEMENTS';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_announcements_module';
public function get_template_center($module_id)
{
global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
$announcement = request_var('announcement', -1);
$announcement = ($announcement > $config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement;
$start = request_var('ap', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
$portal_announcement_length = ($announcement < 0) ? $config['board3_announcements_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $config['board3_global_announcements_forum_' . $module_id], $config['board3_announcements_permissions_' . $module_id], $config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $config['board3_announcements_day_' . $module_id], 'announcements', $start, $config['board3_announcements_forum_exclude_' . $module_id]);
// Any announcements present? If not terminate it here.
if (sizeof($fetch_news) == 0)
{
$template->assign_block_vars('announcements_center_row', array(
'S_NO_TOPICS' => true,
'S_NOT_LAST' => false
));
$template->assign_var('S_CAN_READ', false);
}
else
{
// Count number of posts for announcements archive, considering if permission check is dis- or enabled.
if ($config['board3_announcements_archive_' . $module_id])
{
$permissions = $config['board3_announcements_permissions_' . $module_id];
$forum_from = $config['board3_global_announcements_forum_' . $module_id];
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$time = ($config['board3_announcements_day_' . $module_id] == 0) ? 0 : $config['board3_announcements_day_' . $module_id];
$post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400);
$str_where = '';
if($permissions == true)
{
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
if($config['board3_announcements_forum_exclude_' . $module_id] == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
$global_f = 0;
if(sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if(!sizeof($disallow_access))
{
return array();
}
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id = $acc_id OR ";
if($global_f < 1 && $acc_id > 0)
{
$global_f = $acc_id;
}
}
}
else
{
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "forum_id <> $acc_id AND ";
}
}
$str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . '
WHERE ((topic_type = ' . POST_GLOBAL . ')
OR topic_type = ' . POST_ANNOUNCE . ')
AND topic_visibility = 1
AND topic_moved_id = 0
' . $post_time . '
' . $str_where;
$result = $db->sql_query($sql);
$total_announcements = (int) $db->sql_fetchfield('num_topics');
$db->sql_freeresult($result);
}
$topic_tracking_info = (get_portal_tracking_info($fetch_news));
if($announcement < 0)
// Show the announcements overview
{
$count = $fetch_news['topic_count'];
for ($i = 0; $i < $count; $i++)
{
if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
{
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['READ_FULL'];
}
else
{
$open_bracket = '';
$close_bracket = '';
$read_full = '';
}
// unread?
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
//$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&amp;announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
$folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
switch ($fetch_news[$i]['topic_type'])
{
case POST_GLOBAL:
$folder = 'global_read';
$folder_new = 'global_unread';
break;
case POST_ANNOUNCE:
$folder = 'announce_read';
$folder_new = 'announce_unread';
break;
default:
$folder = 'topic_read';
$folder_new = 'topic_unread';
if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
}
break;
}
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
{
$folder .= '_locked';
$folder_new .= '_locked';
}
if ($fetch_news[$i]['topic_type'] == POST_GLOBAL)
{
$global_announce_list[$fetch_news[$i]['topic_id']] = true;
}
if ($fetch_news[$i]['topic_posted'])
{
$folder .= '_mine';
$folder_new .= '_mine';
}
$folder_img = ($unread_topic) ? $folder_new : $folder;
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Grab icons
$icons = $cache->obtain_icons();
$template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $fetch_news[$i]['user_id']) : '',
'TIME' => $fetch_news[$i]['topic_time'],
'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']),
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;view=unread#unread'),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_announcements_' . $module_id] != 0 && $config['board3_announcements_archive_' . $module_id])
{
$template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
else
// Show "read full" page
{
$i = $announcement;
/**
* redirect to portal page if the specified announcement does not exist
* force #top anchor in order to get rid of the #a anchor
*/
if (!isset($fetch_news[$i]))
{
redirect(append_sid($phpbb_root_path . 'portal.' . $phpEx, '#top'));
}
$forum_id = $fetch_news[$i]['forum_id'];
$topic_id = $fetch_news[$i]['topic_id'];
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $user->lang['BACK'];
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
$read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i");
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&amp;t=' . $topic_id);
if ($config['board3_announcements_archive_' . $module_id])
{
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
}
$template->assign_block_vars('announcements_center_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'TIME' => $fetch_news[$i]['topic_time'],
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'A_ID' => $i,
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id . '&amp;p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&amp;' . (($real_forum_id) ? 'f=' . $real_forum_id . '&amp;' : '') . 't=' . $topic_id),
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'U_READ_FULL' => $read_full_url,
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
$template->assign_block_vars('announcements_center_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
if ($config['board3_number_of_announcements_' . $module_id] <> 0 && $config['board3_announcements_archive_' . $module_id])
{
$template->assign_vars(array(
'AP_PAGINATION' => $pagination,
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
);
}
}
}
$topic_icons = false;
if(!empty($fetch_news['topic_icons']))
{
$topic_icons = true;
}
$template->assign_vars(array(
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($config['board3_show_announcements_replies_views_' . $module_id]) ? true : false,
'S_TOPIC_ICONS' => $topic_icons,
));
if ($config['board3_announcements_style_' . $module_id])
{
return 'announcements_center_compact.html';
}
else
{
return 'announcements_center.html';
}
}
public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
),
);
}
/**
* API functions
*/
public function install($module_id)
{
set_config('board3_announcements_style_' . $module_id, 0);
set_config('board3_number_of_announcements_' . $module_id, 1);
set_config('board3_announcements_day_' . $module_id, 0);
set_config('board3_announcements_length_' . $module_id, 200);
set_config('board3_global_announcements_forum_' . $module_id, '');
set_config('board3_announcements_forum_exclude_' . $module_id, 0);
set_config('board3_announcements_archive_' . $module_id, 1);
set_config('board3_announcements_permissions_' . $module_id, 1);
set_config('board3_show_announcements_replies_views_' . $module_id, 1);
return true;
}
public function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_announcements_style_' . $module_id,
'board3_number_of_announcements_' . $module_id,
'board3_announcements_day_' . $module_id,
'board3_announcements_length_' . $module_id,
'board3_global_announcements_forum_' . $module_id,
'board3_announcements_forum_exclude_' . $module_id,
'board3_announcements_archive_' . $module_id,
'board3_announcements_permissions_' . $module_id,
'board3_show_announcements_replies_views_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}
// Create forum select box
public function select_forums($value, $key, $module_id)
{
global $user, $config;
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
if(isset($config[$key]) && strlen($config[$key]) > 0)
{
$selected = explode(',', $config[$key]);
}
// Build forum options
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
foreach ($forum_list as $f_id => $f_row)
{
$s_forum_options .= '<option value="' . $f_id . '"' . ((in_array($f_id, $selected)) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>';
}
$s_forum_options .= '</select>';
return $s_forum_options;
}
// Store selected forums
public function store_selected_forums($key, $module_id)
{
global $db, $cache;
// Get selected forums
$values = request_var($key, array(0 => ''));
$news = implode(',', $values);
set_config($key, $news);
}
}

View File

@@ -1,94 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2 - Forumlist
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Forumlist
*/
class portal_forumlist_module extends \board3\portal\modules\module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 21;
/**
* Default modulename
*/
public $name = 'PORTAL_FORUMLIST';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = '';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_forumlist_module';
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
public $custom_acp_tpl = '';
public function get_template_center($module_id)
{
global $config, $template, $user, $auth, $phpbb_root_path, $phpEx;
display_forums('', $config['load_moderators'], false);
$template->assign_vars(array(
'FORUM_IMG' => $user->img('forum_read', 'NO_NEW_POSTS'),
'FORUM_NEW_IMG' => $user->img('forum_unread', 'NEW_POSTS'),
'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
'FORUM_NEW_LOCKED_IMG' => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
));
return 'forumlist.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'PORTAL_FORUMLIST',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -216,10 +216,8 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_menu_array_' . $module_id, 'board3_menu_array_' . $module_id,
); );

View File

@@ -394,10 +394,8 @@ class portal_news_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_news_length_' . $module_id, 'board3_news_length_' . $module_id,
'board3_news_forum_' . $module_id, 'board3_news_forum_' . $module_id,

View File

@@ -91,10 +91,8 @@ class portal_poll_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_poll_allow_vote_' . $module_id, 'board3_poll_allow_vote_' . $module_id,
'board3_poll_topic_id_' . $module_id, 'board3_poll_topic_id_' . $module_id,
@@ -216,10 +214,10 @@ class portal_poll_module extends \board3\portal\modules\module_base
if($s_can_up_vote) if($s_can_up_vote)
{ {
$redirect_url = append_sid("{$phpbb_root_path}app.$phpEx/portal");
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id)) if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
{ {
$redirect_url = append_sid("{$phpbb_root_path}portal.$phpEx");
meta_refresh(5, $redirect_url); meta_refresh(5, $redirect_url);
if (!sizeof($voted_id)) if (!sizeof($voted_id))
{ {
@@ -297,8 +295,6 @@ class portal_poll_module extends \board3\portal\modules\module_base
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
$db->sql_query($sql); $db->sql_query($sql);
$redirect_url = append_sid("{$phpbb_root_path}portal.$phpEx");
meta_refresh(5, $redirect_url); meta_refresh(5, $redirect_url);
trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>')); trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>'));
} }
@@ -439,8 +435,8 @@ class portal_poll_module extends \board3\portal\modules\module_base
} }
$poll_view_str = urlencode(implode(',', $make_poll_view)); $poll_view_str = urlencode(implode(',', $make_poll_view));
$portalpoll_url= append_sid("{$phpbb_root_path}portal.$phpEx", "polls=$poll_view_str"); $portalpoll_url= append_sid("{$phpbb_root_path}app.$phpEx/portal", "polls=$poll_view_str");
$portalvote_url= append_sid("{$phpbb_root_path}portal.$phpEx", "f=$forum_id&amp;t=$topic_id"); $portalvote_url= append_sid("{$phpbb_root_path}app.$phpEx/portal", "f=$forum_id&amp;t=$topic_id");
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id"); $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id");
$poll_end = $data['poll_length'] + $data['poll_start']; $poll_end = $data['poll_length'] + $data['poll_start'];
@@ -472,7 +468,7 @@ class portal_poll_module extends \board3\portal\modules\module_base
'POLL_LENGTH' => $data['poll_length'], 'POLL_LENGTH' => $data['poll_length'],
'TOPIC_ID' => $topic_id, 'TOPIC_ID' => $topic_id,
'TOTAL_VOTES' => $poll_total_votes, 'TOTAL_VOTES' => $poll_total_votes,
'L_MAX_VOTES' => ($data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $data['poll_max_options']), 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', $data['poll_max_options']),
'L_POLL_LENGTH' => ($data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '', 'L_POLL_LENGTH' => ($data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',
'S_CAN_VOTE' => $s_can_vote, 'S_CAN_VOTE' => $s_can_vote,
'S_DISPLAY_RESULTS' => $s_display_results, 'S_DISPLAY_RESULTS' => $s_display_results,

View File

@@ -135,7 +135,7 @@ class portal_random_member_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
return true; return true;
} }

View File

@@ -196,10 +196,8 @@ class portal_recent_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_max_topics_' . $module_id, 'board3_max_topics_' . $module_id,
'board3_recent_title_limit_' . $module_id, 'board3_recent_title_limit_' . $module_id,

View File

@@ -78,7 +78,7 @@ class portal_search_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
return true; return true;
} }

View File

@@ -153,7 +153,7 @@ class portal_statistics_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
return true; return true;
} }

View File

@@ -1,110 +0,0 @@
<?php
/**
*
* @package Board3 Portal v2 - Stylechanger
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package Stylechanger
*/
class portal_stylechanger_module extends \board3\portal\modules\module_base
{
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
public $columns = 10;
/**
* Default modulename
*/
public $name = 'BOARD_STYLE';
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
public $image_src = 'portal_style.png';
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
public $language = 'portal_stylechanger_module';
public function get_template_side($module_id)
{
global $config, $template, $db, $phpEx, $phpbb_root_path, $user;
$style_count = 0;
$style_select = '';
$sql = 'SELECT style_id, style_name
FROM ' . STYLES_TABLE . '
WHERE style_active = 1
ORDER BY LOWER(style_name) ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$style = request_var('style', 0);
if (!empty($style))
{
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], append_sid("{$phpbb_root_path}app.$phpEx/portal"));
}
else
{
$url = append_sid("{$phpbb_root_path}app.$phpEx/portal", 'style=' . $row['style_id']);
}
++$style_count;
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $user->style['style_id'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row['style_name']) . '</option>';
}
$db->sql_freeresult($result);
if(strlen($style_select))
{
$template->assign_var('STYLE_SELECT', $style_select);
}
// Assign specific vars
$template->assign_vars(array(
'S_STYLE_OPTIONS' => ($config['override_user_style'] || $style_count < 2) ? '' : style_select($user->data['user_style']),
));
return 'stylechanger_side.html';
}
public function get_template_acp($module_id)
{
return array(
'title' => 'BOARD_STYLE',
'vars' => array(),
);
}
/**
* API functions
*/
public function install($module_id)
{
return true;
}
public function uninstall($module_id)
{
return true;
}
}

View File

@@ -98,10 +98,8 @@ class portal_topposters_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_topposters_' . $module_id, 'board3_topposters_' . $module_id,
); );

View File

@@ -167,10 +167,8 @@ class portal_user_menu_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_user_menu_register_' . $module_id, 'board3_user_menu_register_' . $module_id,
); );

View File

@@ -93,10 +93,8 @@ class portal_welcome_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
global $db;
$del_config = array( $del_config = array(
'board3_welcome_message_' . $module_id, 'board3_welcome_message_' . $module_id,
); );

View File

@@ -130,7 +130,7 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
return true; return true;
} }
public function uninstall($module_id) public function uninstall($module_id, $db)
{ {
return true; return true;
} }

View File

@@ -4,11 +4,11 @@
<!-- IF .attach_center --> <!-- IF .attach_center -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;"><strong>{L_FILENAME}</strong></span><br /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;"><strong>{L_FILENAME}</strong></span><br />
<!-- BEGIN attach_center --> <!-- BEGIN attach_center -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><img src="{T_THEME_PATH}/images/portal/icon_topic_attach.gif" alt="" />&nbsp;<a href="{attach_center.U_TOPIC}" title="{attach_center.REAL_FILENAME}"><strong>{attach_center.FILENAME}</strong></a></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><img src="{T_EXT_THEME_PATH}/images/portal/icon_topic_attach.gif" alt="" />&nbsp;<a href="{attach_center.U_TOPIC}" title="{attach_center.REAL_FILENAME}"><strong>{attach_center.FILENAME}</strong></a></span><br style="clear:both" />
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_FILESIZE}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_center.FILESIZE}</strong></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_FILESIZE}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_center.FILESIZE}</strong></span><br style="clear:both" />
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_DOWNLOADS}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_center.DOWNLOAD_COUNT}</strong></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_DOWNLOADS}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_center.DOWNLOAD_COUNT}</strong></span><br style="clear:both" />
<!-- IF not attach_center.S_LAST_ROW --><hr class="dashed" /><!-- ENDIF --> <!-- IF not attach_center.S_LAST_ROW --><hr class="dashed" /><!-- ENDIF -->
<!-- END .attach_center --> <!-- END attach_center -->
<!-- ELSE --> <!-- ELSE -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><strong>{L_NO_ATTACHMENTS}</strong></span><br /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><strong>{L_NO_ATTACHMENTS}</strong></span><br />
<!-- ENDIF --> <!-- ENDIF -->

View File

@@ -2,11 +2,11 @@
<!-- IF .attach_side --> <!-- IF .attach_side -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;"><strong>{L_FILENAME}</strong></span><br /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;"><strong>{L_FILENAME}</strong></span><br />
<!-- BEGIN attach_side --> <!-- BEGIN attach_side -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><img src="{T_THEME_PATH}/images/portal/icon_topic_attach.gif" alt="" />&nbsp;<a href="{attach_side.U_TOPIC}" title="{attach_side.REAL_FILENAME}"><strong>{attach_side.FILENAME}</strong></a></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><img src="{T_EXT_THEME_PATH}/images/portal/icon_topic_attach.gif" alt="" />&nbsp;<a href="{attach_side.U_TOPIC}" title="{attach_side.REAL_FILENAME}"><strong>{attach_side.FILENAME}</strong></a></span><br style="clear:both" />
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_FILESIZE}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_side.FILESIZE}</strong></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_FILESIZE}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_side.FILESIZE}</strong></span><br style="clear:both" />
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_DOWNLOADS}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_side.DOWNLOAD_COUNT}</strong></span><br style="clear:both" /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;">{L_DOWNLOADS}:</span><span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->;padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:10px;" class="portal-gensmall"><strong>{attach_side.DOWNLOAD_COUNT}</strong></span><br style="clear:both" />
<!-- IF not attach_side.S_LAST_ROW --><hr class="dashed" /><!-- ENDIF --> <!-- IF not attach_side.S_LAST_ROW --><hr class="dashed" /><!-- ENDIF -->
<!-- END .attach_side --> <!-- END attach_side -->
<!-- ELSE --> <!-- ELSE -->
<span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><strong>{L_NO_ATTACHMENTS}</strong></span><br /> <span style="float:<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->;" class="portal-gensmall"><strong>{L_NO_ATTACHMENTS}</strong></span><br />
<!-- ENDIF --> <!-- ENDIF -->

View File

@@ -26,7 +26,6 @@
<a href="{news_row.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <a href="{news_row.U_NEWEST_POST}">{NEWEST_POST_IMG}</a>
<!-- ENDIF --> <!-- ENDIF -->
<!-- IF news_row.ATTACH_ICON_IMG -->{news_row.ATTACH_ICON_IMG} <!-- ENDIF --> <!-- IF news_row.ATTACH_ICON_IMG -->{news_row.ATTACH_ICON_IMG} <!-- ENDIF -->
<!-- IF news_row.S_POLL --><strong>{L_VIEW_TOPIC_POLL}</strong><!-- ENDIF -->
<div class="list-inner"> <div class="list-inner">
<a href="{news_row.U_VIEW_COMMENTS}" title="{news_row.TITLE}" class="topictitle">{news_row.TITLE}</a><!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --> &bull; <a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> &bull; <!-- ENDIF --> <a href="{news_row.U_VIEW_COMMENTS}" title="{news_row.TITLE}" class="topictitle">{news_row.TITLE}</a><!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --> &bull; <a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> &bull; <!-- ENDIF -->
<!-- IF news_row.PAGINATION --> <!-- IF news_row.PAGINATION -->

View File

@@ -46,7 +46,7 @@
</div> </div>
<!-- IF poll_side.S_CAN_VOTE -->{poll_side.S_HIDDEN_FIELDS}<!-- ENDIF --> <!-- IF poll_side.S_CAN_VOTE -->{poll_side.S_HIDDEN_FIELDS}<!-- ENDIF -->
<!-- IF poll_side.S_CAN_VOTE --></form><!-- ENDIF --> <!-- IF poll_side.S_CAN_VOTE --></form><!-- ENDIF -->
<!-- END poll --> <!-- END poll_side -->
</div> </div>
<!-- ELSE --> <!-- ELSE -->
<div class="panel bg1" style="margin-bottom: 0px"> <div class="panel bg1" style="margin-bottom: 0px">

View File

@@ -30,7 +30,7 @@
<!-- IF S_TOPIC_ICONS --><td class="row1" width="25" align="center"><!-- IF news_row.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{news_row.TOPIC_ICON_IMG}" width="{news_row.TOPIC_ICON_IMG_WIDTH}" height="{news_row.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td><!-- ENDIF --> <!-- IF S_TOPIC_ICONS --><td class="row1" width="25" align="center"><!-- IF news_row.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{news_row.TOPIC_ICON_IMG}" width="{news_row.TOPIC_ICON_IMG_WIDTH}" height="{news_row.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td><!-- ENDIF -->
<td class="row1"> <td class="row1">
<!-- IF news_row.PAGINATION --><span style="float: right; font-size:0.9em;"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {news_row.PAGINATION} ] </span><!-- ENDIF --> <!-- IF news_row.PAGINATION --><span style="float: right; font-size:0.9em;"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {news_row.PAGINATION} ] </span><!-- ENDIF -->
{news_row.ATTACH_ICON_IMG} <!-- IF news_row.S_POLL --> <strong style="font-size:1.1em;">{L_VIEW_TOPIC_POLL}: </strong><!-- ENDIF --><a title="{news_row.TITLE}" href="{news_row.U_VIEW_COMMENTS}" class="topictitle">{news_row.TITLE}</a> {news_row.ATTACH_ICON_IMG} <!-- IF news_row.S_POLL --> <strong style="font-size:1.1em;">{L_VIEW_TOPIC_POLL}</strong><!-- ENDIF --><a title="{news_row.TITLE}" href="{news_row.U_VIEW_COMMENTS}" class="topictitle">{news_row.TITLE}</a>
<p class="gensmall">{L_POSTED} {L_POST_BY_AUTHOR} {news_row.POSTER_FULL} &raquo; {news_row.TIME} <p class="gensmall">{L_POSTED} {L_POST_BY_AUTHOR} {news_row.POSTER_FULL} &raquo; {news_row.TIME}
<!-- IF news_row.FORUM_NAME --> <!-- IF news_row.FORUM_NAME -->
<br />{L_FORUM}: <a href="{news_row.U_VIEWFORUM}" style="font-weight: bold;">{news_row.FORUM_NAME}</a> <br />{L_FORUM}: <a href="{news_row.U_VIEWFORUM}" style="font-weight: bold;">{news_row.FORUM_NAME}</a>

View File

@@ -0,0 +1,41 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 Board3 Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_portal_no_error_test extends \board3\portal\tests\testframework\functional_test_case
{
public function setUp()
{
parent::setUp();
$this->login();
$this->admin_login();
$this->enable_board3_portal_ext();
}
public function test_vanilla_board()
{
$crawler = self::request('GET', 'app.php?portal');
}
public function test_with_poll()
{
// Create topic with poll
$data = $this->create_topic(2, 'Portal-poll', 'This is a poll for the portal', array(
'poll_title' => 'Is this a poll?',
'poll_option_text' => "Yes\nNo\nMaybe",
));
if (isset($data))
{
$crawler = self::request('GET', 'app.php?portal');
}
}
}

View File

@@ -20,28 +20,6 @@ class phpbb_functional_portal_redirect_test extends \board3\portal\tests\testfra
$this->enable_board3_portal_ext(); $this->enable_board3_portal_ext();
} }
protected function enable_board3_portal_ext()
{
$enable_portal = false;
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$disabled_extensions = $crawler->filter('tr.ext_disabled')->extract(array('_text'));
foreach ($disabled_extensions as $extension)
{
if (strpos($extension, 'Board3 Portal') !== false)
{
$enable_portal = true;
}
}
if ($enable_portal)
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=board3%2fportal&sid=' . $this->sid);
$form = $crawler->selectButton('Enable')->form();
$crawler = self::submit($form);
$this->assertContains('The extension was enabled successfully', $crawler->text());
}
}
public function test_redirect() public function test_redirect()
{ {
if (function_exists('apache_get_modules')) if (function_exists('apache_get_modules'))

View File

@@ -0,0 +1,41 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once(dirname(__FILE__) . '/../../portal/includes/functions.php');
require_once(dirname(__FILE__) . '/../../../../../includes/functions_acp.php');
class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframework\database_test_case
{
public function setUp()
{
parent::setUp();
global $db, $phpbb_root_path, $phpEx, $user;
$user = new phpbb_mock_user();
}
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/styles.xml');
}
public function test_check_file_src()
{
$this->assertFalse(check_file_src('portal_attach.png', '', 15, false));
$this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15, false));
}
public function test_check_file_src_error()
{
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->setExpectedTriggerError(E_USER_WARNING);
$this->assertEquals(': styles/prosilver/theme/images/portal/portal_foobar.png<br />', check_file_src('portal_foobar.png', '', 15));
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_styles">
<column>style_path</column>
<column>style_name</column>
<column>style_active</column>
<column>style_parent_tree</column>
<row>
<value>subsilver2</value>
<value>subsilver2</value>
<value>0</value>
<value></value>
</row>
<row>
<value>prosilver</value>
<value>prosilver</value>
<value>1</value>
<value></value>
</row>
</table>
</dataset>

View File

@@ -11,4 +11,34 @@ namespace board3\portal\tests\testframework;
abstract class functional_test_case extends \phpbb_functional_test_case abstract class functional_test_case extends \phpbb_functional_test_case
{ {
protected $portal_enabled = false;
public function enable_board3_portal_ext()
{
$enable_portal = false;
if ($this->portal_enabled === true)
{
return;
}
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$disabled_extensions = $crawler->filter('tr.ext_disabled')->extract(array('_text'));
foreach ($disabled_extensions as $extension)
{
if (strpos($extension, 'Board3 Portal') !== false)
{
$enable_portal = true;
}
}
if ($enable_portal)
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=board3%2fportal&sid=' . $this->sid);
$form = $crawler->selectButton('Enable')->form();
$crawler = self::submit($form);
$this->assertContains('The extension was enabled successfully', $crawler->text());
$this->portal_enabled = true;
}
}
} }

View File

@@ -9,7 +9,7 @@
namespace board3\portal\tests\testframework; namespace board3\portal\tests\testframework;
abstract class test_case_helpers extends \phpbb_test_case_helpers class test_case_helpers extends \phpbb_test_case_helpers
{ {
/** /**
* Copied from phpbb_test_case_helpers::get_test_config() to fix some paths * Copied from phpbb_test_case_helpers::get_test_config() to fix some paths