Merge pull request #192 from marc1706/feature/module_services
[feature/module_services]
This commit is contained in:
@@ -418,8 +418,6 @@ class portal_module
|
||||
if ($add_column)
|
||||
{
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
$directory = $this->root_path . 'portal/modules/';
|
||||
|
||||
if ($submit)
|
||||
{
|
||||
$module_classname = request_var('module_classname', '');
|
||||
@@ -460,18 +458,7 @@ class portal_module
|
||||
}
|
||||
else
|
||||
{
|
||||
$class = 'portal_' . $module_classname . '_module';
|
||||
|
||||
if (!class_exists($class))
|
||||
{
|
||||
include($directory . 'portal_' . $module_classname . '.' . $this->php_ex);
|
||||
}
|
||||
if (!class_exists($class))
|
||||
{
|
||||
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
|
||||
}
|
||||
|
||||
$this->c_class = new $class();
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = 'SELECT module_order
|
||||
@@ -486,8 +473,8 @@ class portal_module
|
||||
'module_classname' => $module_classname,
|
||||
'module_column' => $add_column,
|
||||
'module_order' => $module_order,
|
||||
'module_name' => $this->c_class->name,
|
||||
'module_image_src' => $this->c_class->image_src,
|
||||
'module_name' => $this->c_class->get_name(),
|
||||
'module_image_src' => $this->c_class->get_image(),
|
||||
'module_group_ids' => '',
|
||||
'module_image_height' => 16,
|
||||
'module_image_width' => 16,
|
||||
@@ -529,72 +516,7 @@ class portal_module
|
||||
|
||||
$this->template->assign_var('S_EDIT', true);
|
||||
$fileinfo = array();
|
||||
|
||||
// @todo: remove old school way of getting modules
|
||||
$dh = @opendir($directory);
|
||||
if (!$dh)
|
||||
{
|
||||
return $fileinfo;
|
||||
}
|
||||
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
// Is module?
|
||||
if (preg_match('/^portal_.+\.' . $this->php_ex . '$/', $file))
|
||||
{
|
||||
$class = str_replace(".{$this->php_ex}", '', $file) . '_module';
|
||||
$module_class = str_replace(array('portal_', ".{$this->php_ex}"), '', $file);
|
||||
$column_string = column_num_string($add_column);
|
||||
|
||||
// do we want to add the module to the side columns or to the center columns?
|
||||
if ($module_class != '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 (!class_exists($class))
|
||||
{
|
||||
include($directory . $file);
|
||||
}
|
||||
|
||||
// Get module title tag
|
||||
if (class_exists($class))
|
||||
{
|
||||
$this->c_class = new $class();
|
||||
if ($this->c_class->columns & column_string_const($add_module))
|
||||
{
|
||||
if ($this->c_class->get_language())
|
||||
{
|
||||
$this->user->add_lang_ext('board3/portal', 'mods/portal/' . $this->c_class->get_language());
|
||||
}
|
||||
$fileinfo[] = array(
|
||||
'module' => substr($class, 7, -7),
|
||||
'name' => $this->user->lang[$this->c_class->get_name()],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
$column_string = column_num_string($add_column);
|
||||
|
||||
// Find new modules
|
||||
foreach ($this->modules as $module_class => $module)
|
||||
@@ -659,27 +581,13 @@ class portal_module
|
||||
}
|
||||
else
|
||||
{
|
||||
$directory = $this->root_path . 'portal/modules/';
|
||||
|
||||
$portal_modules = obtain_portal_modules();
|
||||
|
||||
foreach($portal_modules as $row)
|
||||
{
|
||||
if (!isset($this->modules[$row['module_classname']]))
|
||||
{
|
||||
$class = 'portal_' . $row['module_classname'] . '_module';
|
||||
if (!class_exists($class))
|
||||
{
|
||||
include($directory . 'portal_' . $row['module_classname'] . '.' . $this->php_ex);
|
||||
}
|
||||
if (class_exists($class))
|
||||
{
|
||||
$this->c_class = new $class();
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1207,25 +1115,19 @@ class portal_module
|
||||
$module_data = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$directory = $this->root_path . 'portal/modules/';
|
||||
|
||||
if ($module_data !== false)
|
||||
{
|
||||
$module_classname = request_var('module_classname', '');
|
||||
$class = 'portal_' . $module_classname . '_module';
|
||||
if (!class_exists($class))
|
||||
{
|
||||
include($directory . 'portal_' . $module_classname . '.' . $this->php_ex);
|
||||
}
|
||||
if (!class_exists($class))
|
||||
|
||||
if (!isset($this->modules[$module_classname]))
|
||||
{
|
||||
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$this->c_class = new $class();
|
||||
$this->c_class->uninstall($module_data['module_id']);
|
||||
$this->c_class = $this->modules[$module_classname];
|
||||
$this->c_class->uninstall($module_data['module_id'], $this->db);
|
||||
|
||||
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . '
|
||||
WHERE module_id = ' . (int) $module_id;
|
||||
@@ -1243,10 +1145,10 @@ class portal_module
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->c_class = new $class();
|
||||
if ($this->c_class->language)
|
||||
$this->c_class = $this->modules[$module_classname];
|
||||
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());
|
||||
}
|
||||
$confirm_text = (isset($this->user->lang[$module_data['module_name']])) ? sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], $this->user->lang[$module_data['module_name']]) : sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name']));
|
||||
confirm_box(false, $confirm_text, build_hidden_fields(array(
|
||||
|
||||
@@ -53,20 +53,20 @@ var help_line = {
|
||||
<!-- END custom_tags -->
|
||||
}
|
||||
|
||||
function change_palette()
|
||||
{
|
||||
dE('colour_palette');
|
||||
e = document.getElementById('colour_palette');
|
||||
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}';
|
||||
}
|
||||
if (e.style.display == 'block')
|
||||
{
|
||||
document.getElementById('bbpalette').value = '{LA_FONT_COLOR_HIDE}';
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById('bbpalette').value = '{LA_FONT_COLOR}';
|
||||
}
|
||||
}
|
||||
|
||||
// ]]>
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!-- INCLUDE overall_header.html -->
|
||||
|
||||
<script type="text/javascript" src="{B3P_ACP_ROOT}adm/style/portal/acp_portal.js"></script>
|
||||
<!-- INCLUDEJS portal/acp_portal.js -->
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
/**
|
||||
@@ -53,6 +53,21 @@ var help_line = {
|
||||
<!-- 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>
|
||||
|
||||
@@ -134,38 +149,12 @@ var help_line = {
|
||||
<dd>
|
||||
<div id="colour_palette" style="display: none;">
|
||||
<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 style="clear: left;">
|
||||
<dt style="border: none;">
|
||||
<script type="text/javascript">
|
||||
// <![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>
|
||||
<dt id="color_palette_placeholder" style="border: none;"></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div id="format-buttons">
|
||||
|
||||
292
config/modules.yml
Normal file
292
config/modules.yml
Normal file
@@ -0,0 +1,292 @@
|
||||
services:
|
||||
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.clock:
|
||||
class: \board3\portal\modules\clock
|
||||
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.donation:
|
||||
class: \board3\portal\modules\donation
|
||||
arguments:
|
||||
- @config
|
||||
- @template
|
||||
- @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.main_menu:
|
||||
class: \board3\portal\modules\main_menu
|
||||
arguments:
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.news:
|
||||
class: \board3\portal\modules\news
|
||||
arguments:
|
||||
- @auth
|
||||
- @cache
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.poll:
|
||||
class: \board3\portal\modules\poll
|
||||
arguments:
|
||||
- @auth
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.random_member:
|
||||
class: \board3\portal\modules\random_member
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.recent:
|
||||
class: \board3\portal\modules\recent
|
||||
arguments:
|
||||
- @auth
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.search:
|
||||
class: \board3\portal\modules\search
|
||||
arguments:
|
||||
- @template
|
||||
- %core.php_ext%
|
||||
- %core.root_path%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.statistics:
|
||||
class: \board3\portal\modules\statistics
|
||||
arguments:
|
||||
- @cache
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.stylechanger:
|
||||
class: \board3\portal\modules\stylechanger
|
||||
arguments:
|
||||
- @config
|
||||
- @template
|
||||
- @dbal.conn
|
||||
- %core.php_ext%
|
||||
- %core.root_path%
|
||||
- @user
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.topposters:
|
||||
class: \board3\portal\modules\topposters
|
||||
arguments:
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.user_menu:
|
||||
class: \board3\portal\modules\user_menu
|
||||
arguments:
|
||||
- @auth
|
||||
- @config
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.welcome:
|
||||
class: \board3\portal\modules\welcome
|
||||
arguments:
|
||||
- @config
|
||||
- @template
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.whois_online:
|
||||
class: \board3\portal\modules\whois_online
|
||||
arguments:
|
||||
- @auth
|
||||
- @dbal.conn
|
||||
- @template
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
@@ -1,3 +1,6 @@
|
||||
imports:
|
||||
- { resource: modules.yml }
|
||||
|
||||
parameters:
|
||||
board3.version_data:
|
||||
author: Marc
|
||||
@@ -10,7 +13,6 @@ parameters:
|
||||
- board3_portal.xml
|
||||
|
||||
services:
|
||||
|
||||
board3.portal.main:
|
||||
class: \board3\portal\controller\main
|
||||
arguments:
|
||||
@@ -39,177 +41,3 @@ services:
|
||||
- @service_container
|
||||
tags:
|
||||
- { 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.search:
|
||||
class: \board3\portal\modules\search
|
||||
arguments:
|
||||
- @template
|
||||
- %core.php_ext%
|
||||
- %core.root_path%
|
||||
tags:
|
||||
- { name: board3.module }
|
||||
|
||||
board3.module.stylechanger:
|
||||
class: \board3\portal\modules\stylechanger
|
||||
arguments:
|
||||
- @config
|
||||
- @template
|
||||
- @dbal.conn
|
||||
- %core.php_ext%
|
||||
- %core.root_path%
|
||||
- @user
|
||||
tags:
|
||||
- { 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 }
|
||||
|
||||
@@ -303,7 +303,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
// Populate module table
|
||||
$board3_sql_query = array(
|
||||
array(
|
||||
'module_classname' => 'main_menu',
|
||||
'module_classname' => '\board3\portal\modules\main_menu',
|
||||
'module_column' => 1,
|
||||
'module_order' => 1,
|
||||
'module_name' => 'M_MENU',
|
||||
@@ -369,7 +369,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'topposters',
|
||||
'module_classname' => '\board3\portal\modules\topposters',
|
||||
'module_column' => 1,
|
||||
'module_order' => 7,
|
||||
'module_name' => 'TOPPOSTERS',
|
||||
@@ -402,7 +402,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'welcome',
|
||||
'module_classname' => '\board3\portal\modules\welcome',
|
||||
'module_column' => 2,
|
||||
'module_order' => 1,
|
||||
'module_name' => 'PORTAL_WELCOME',
|
||||
@@ -413,7 +413,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'recent',
|
||||
'module_classname' => '\board3\portal\modules\recent',
|
||||
'module_column' => 2,
|
||||
'module_order' => 2,
|
||||
'module_name' => 'PORTAL_RECENT',
|
||||
@@ -435,7 +435,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'news',
|
||||
'module_classname' => '\board3\portal\modules\news',
|
||||
'module_column' => 2,
|
||||
'module_order' => 4,
|
||||
'module_name' => 'LATEST_NEWS',
|
||||
@@ -446,7 +446,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'poll',
|
||||
'module_classname' => '\board3\portal\modules\poll',
|
||||
'module_column' => 2,
|
||||
'module_order' => 5,
|
||||
'module_name' => 'PORTAL_POLL',
|
||||
@@ -457,7 +457,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'whois_online',
|
||||
'module_classname' => '\board3\portal\modules\whois_online',
|
||||
'module_column' => 2,
|
||||
'module_order' => 6,
|
||||
'module_name' => 'PORTAL_WHOIS_ONLINE',
|
||||
@@ -468,7 +468,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'user_menu',
|
||||
'module_classname' => '\board3\portal\modules\user_menu',
|
||||
'module_column' => 3,
|
||||
'module_order' => 1,
|
||||
'module_name' => 'USER_MENU',
|
||||
@@ -479,7 +479,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
|
||||
'module_status' => 1,
|
||||
),
|
||||
array(
|
||||
'module_classname' => 'statistics',
|
||||
'module_classname' => '\board3\portal\modules\statistics',
|
||||
'module_column' => 3,
|
||||
'module_order' => 2,
|
||||
'module_name' => 'STATISTICS',
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Main Menu
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Main Menu
|
||||
*/
|
||||
class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
class main_menu extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -60,10 +54,49 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
const LINK_INT = 1;
|
||||
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 main menu object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
* @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->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
|
||||
|
||||
$links = array();
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
@@ -76,8 +109,8 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
{
|
||||
if($links[$i]['type'] == self::LINK_CAT)
|
||||
{
|
||||
$template->assign_block_vars('portalmenu', array(
|
||||
'CAT_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||
$this->template->assign_block_vars('portalmenu', array(
|
||||
'CAT_TITLE' => (isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||
'MODULE_ID' => $module_id,
|
||||
));
|
||||
}
|
||||
@@ -86,7 +119,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
if($links[$i]['type'] == self::LINK_INT)
|
||||
{
|
||||
$links[$i]['url'] = str_replace('&', '&', $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
|
||||
{
|
||||
@@ -98,10 +131,10 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
if(!empty($permission_check) || $links[$i]['permission'] == '')
|
||||
{
|
||||
$template->assign_block_vars('portalmenu.links', array(
|
||||
'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||
$this->template->assign_block_vars('portalmenu.links', array(
|
||||
'LINK_TITLE' => (isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title'],
|
||||
'LINK_URL' => $cur_url,
|
||||
'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $config['board3_menu_url_new_window_' . $module_id]) ? true : false,
|
||||
'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $this->config['board3_menu_url_new_window_' . $module_id]) ? true : false,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -110,9 +143,11 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
return 'main_menu_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
// do not remove this as it is needed in order to run manage_links
|
||||
return array(
|
||||
'title' => 'ACP_PORTAL_MENU',
|
||||
'vars' => array(
|
||||
@@ -124,18 +159,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $db;
|
||||
|
||||
// get the correct group IDs from the database
|
||||
$in_ary = array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA');
|
||||
|
||||
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('group_name', $in_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
$sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE ' . $this->db->sql_in_set('group_name', $in_ary);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$groups_ary[$row['group_name']] = $row['group_id'];
|
||||
}
|
||||
@@ -172,16 +205,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
$links_urls = array(
|
||||
'',
|
||||
'index.' . $phpEx,
|
||||
'search.' . $phpEx,
|
||||
'ucp.' . $phpEx . '?mode=register',
|
||||
'memberlist.' . $phpEx,
|
||||
'memberlist.' . $phpEx . '?mode=leaders',
|
||||
'index.' . $this->php_ext,
|
||||
'search.' . $this->php_ext,
|
||||
'ucp.' . $this->php_ext . '?mode=register',
|
||||
'memberlist.' . $this->php_ext,
|
||||
'memberlist.' . $this->php_ext . '?mode=leaders',
|
||||
'',
|
||||
'faq.' . $phpEx,
|
||||
'faq.' . $phpEx . '?mode=bbcode',
|
||||
'ucp.' . $phpEx . '?mode=terms',
|
||||
'ucp.' . $phpEx . '?mode=privacy',
|
||||
'faq.' . $this->php_ext,
|
||||
'faq.' . $this->php_ext . '?mode=bbcode',
|
||||
'ucp.' . $this->php_ext . '?mode=terms',
|
||||
'ucp.' . $this->php_ext . '?mode=privacy',
|
||||
);
|
||||
|
||||
$links_permissions = array(
|
||||
@@ -216,6 +249,9 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
@@ -235,11 +271,17 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Manage the menu links
|
||||
/**
|
||||
* Manage the menu 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)
|
||||
{
|
||||
global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
|
||||
|
||||
$action = request_var('action', '');
|
||||
$action = (isset($_POST['add'])) ? 'add' : $action;
|
||||
$action = (isset($_POST['save'])) ? 'save' : $action;
|
||||
@@ -250,7 +292,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
|
||||
|
||||
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&mode=config&module_id=' . $module_id);
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\modules\portal&mode=config&module_id=' . $module_id);
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
@@ -258,7 +300,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
case 'save':
|
||||
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));
|
||||
@@ -273,12 +315,12 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
$result = $this->db->sql_query($sql);
|
||||
while($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$groups_ary[] = $row['group_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$link_permissions = array_intersect($link_permission, $groups_ary);
|
||||
$link_permissions = implode(',', $link_permissions);
|
||||
@@ -286,18 +328,18 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
// Check for errors
|
||||
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_is_cat && !$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
|
||||
if (isset($link_id) && $link_id < sizeof($links))
|
||||
{
|
||||
$message = $user->lang['LINK_UPDATED'];
|
||||
$message = $this->user->lang['LINK_UPDATED'];
|
||||
|
||||
$links[$link_id] = array(
|
||||
'title' => $link_title,
|
||||
@@ -310,11 +352,11 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $user->lang['LINK_ADDED'];
|
||||
$message = $this->user->lang['LINK_ADDED'];
|
||||
|
||||
if($link_type != self::LINK_CAT && sizeof($links) < 1)
|
||||
{
|
||||
trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
|
||||
trigger_error($this->user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
$links[] = array(
|
||||
'title' => $link_title,
|
||||
@@ -337,7 +379,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
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))
|
||||
@@ -354,7 +396,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
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,
|
||||
'action' => 'delete',
|
||||
)));
|
||||
@@ -368,7 +410,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
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
|
||||
@@ -411,7 +453,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
// Edit or add menu item
|
||||
case 'edit':
|
||||
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_URL' => (isset($links[$link_id]['url']) && $links[$link_id]['type'] != self::LINK_CAT && $action != 'add') ? str_replace('&', '&', $links[$link_id]['url']) : '',
|
||||
|
||||
@@ -429,16 +471,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
$sql = 'SELECT group_id, group_name
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC';
|
||||
$result = $db->sql_query($sql);
|
||||
while($row = $db->sql_fetchrow($result))
|
||||
$result = $this->db->sql_query($sql);
|
||||
while($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('permission_setting_menu', array(
|
||||
$this->template->assign_block_vars('permission_setting_menu', array(
|
||||
'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'],
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return;
|
||||
|
||||
@@ -447,8 +489,8 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
|
||||
|
||||
for ($i = 0; $i < sizeof($links); $i++)
|
||||
{
|
||||
$template->assign_block_vars('links', array(
|
||||
'LINK_TITLE' => ($action != 'add') ? ((isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
|
||||
$this->template->assign_block_vars('links', array(
|
||||
'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('&', '&', $links[$i]['url']) : '',
|
||||
|
||||
'U_EDIT' => $u_action . '&action=edit&id=' . $i,
|
||||
@@ -461,12 +503,26 @@ class portal_main_menu_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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - News
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package News
|
||||
*/
|
||||
class portal_news_module extends \board3\portal\modules\module_base
|
||||
class news extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -47,25 +41,74 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $language = 'portal_news_module';
|
||||
|
||||
/** @var \phpbb\auth\auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var \phpbb\cache */
|
||||
protected $cache;
|
||||
|
||||
/** @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 news object
|
||||
*
|
||||
* @param \phpbb\auth\auth $auth phpBB auth
|
||||
* @param \phpbb\cache $cache phpBB cache system
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
*/
|
||||
public function __construct($auth, $cache, $config, $db, $template, $phpbb_root_path, $phpEx, $user)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->cache = $cache;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_center($module_id)
|
||||
{
|
||||
global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
|
||||
|
||||
$news = request_var('news', -1);
|
||||
$news = ($news > $config['board3_number_of_news_' . $module_id] -1) ? -1 : $news;
|
||||
$user->add_lang('viewforum');
|
||||
$news = ($news > $this->config['board3_number_of_news_' . $module_id] -1) ? -1 : $news;
|
||||
$this->user->add_lang('viewforum');
|
||||
$start = request_var('np', 0);
|
||||
$start = ($start < 0) ? 0 : $start;
|
||||
|
||||
// Fetch news from portal/includes/functions.php with check if "read full" is requested.
|
||||
$portal_news_length = ($news < 0) ? $config['board3_news_length_' . $module_id] : 0;
|
||||
$fetch_news = phpbb_fetch_posts($module_id, $config['board3_news_forum_' . $module_id], $config['board3_news_permissions_' . $module_id], $config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $config['board3_news_exclude_' . $module_id]);
|
||||
$portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0;
|
||||
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $this->config['board3_news_exclude_' . $module_id]);
|
||||
|
||||
|
||||
// Any news present? If not terminate it here.
|
||||
if (sizeof($fetch_news) == 0)
|
||||
{
|
||||
$template->assign_block_vars('news_row', array(
|
||||
$this->template->assign_block_vars('news_row', array(
|
||||
'S_NO_TOPICS' => true,
|
||||
'S_NOT_LAST' => false,
|
||||
));
|
||||
@@ -73,10 +116,10 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
else
|
||||
{
|
||||
// Count number of posts for news archive, considering if permission check is dis- or enabled.
|
||||
if ($config['board3_news_archive_' . $module_id])
|
||||
if ($this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$permissions = $config['board3_news_permissions_' . $module_id];
|
||||
$forum_from = $config['board3_news_forum_' . $module_id];
|
||||
$permissions = $this->config['board3_news_permissions_' . $module_id];
|
||||
$forum_from = $this->config['board3_news_forum_' . $module_id];
|
||||
|
||||
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
|
||||
|
||||
@@ -84,14 +127,14 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
|
||||
if($permissions == true)
|
||||
{
|
||||
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
||||
$disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$disallow_access = array();
|
||||
}
|
||||
|
||||
if($config['board3_news_exclude_' . $module_id] == true)
|
||||
if($this->config['board3_news_exclude_' . $module_id] == true)
|
||||
{
|
||||
$disallow_access = array_merge($disallow_access, $forum_from);
|
||||
$forum_from = array();
|
||||
@@ -122,7 +165,7 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
|
||||
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
|
||||
$topic_type = ($config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
|
||||
$topic_type = ($this->config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
|
||||
|
||||
$sql = 'SELECT COUNT(topic_id) AS num_topics
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
@@ -130,9 +173,9 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
AND topic_visibility = ' . ITEM_APPROVED . '
|
||||
AND topic_moved_id = 0
|
||||
' . $str_where;
|
||||
$result = $db->sql_query($sql);
|
||||
$total_news = (int) $db->sql_fetchfield('num_topics');
|
||||
$db->sql_freeresult($result);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$total_news = (int) $this->db->sql_fetchfield('num_topics');
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
$topic_tracking_info = get_portal_tracking_info($fetch_news);
|
||||
@@ -147,7 +190,7 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
{
|
||||
$open_bracket = '[ ';
|
||||
$close_bracket = ' ]';
|
||||
$read_full = $user->lang['READ_FULL'];
|
||||
$read_full = $this->user->lang['READ_FULL'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -161,13 +204,13 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||
|
||||
$read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i;
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ($config['board3_news_archive_' . $module_id])
|
||||
$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) . '&t=' . $topic_id);
|
||||
if ($this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
|
||||
$pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
|
||||
}
|
||||
|
||||
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
|
||||
$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'])
|
||||
{
|
||||
@@ -182,7 +225,7 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
default:
|
||||
$folder = 'topic_read';
|
||||
$folder_new = 'topic_unread';
|
||||
if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
|
||||
if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
|
||||
{
|
||||
$folder .= '_hot';
|
||||
$folder_new .= '_hot';
|
||||
@@ -205,38 +248,38 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
|
||||
|
||||
// Grab icons
|
||||
$icons = $cache->obtain_icons();
|
||||
$icons = $this->cache->obtain_icons();
|
||||
|
||||
phpbb_generate_template_pagination($template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $config['board3_number_of_news_' . $module_id], $start);
|
||||
phpbb_generate_template_pagination($this->template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $this->config['board3_number_of_news_' . $module_id], $start);
|
||||
|
||||
$template->assign_block_vars('news_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
$this->template->assign_block_vars('news_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("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
|
||||
'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&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']),
|
||||
'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'],
|
||||
'N_ID' => $i,
|
||||
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
||||
'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt),
|
||||
'TOPIC_IMG_STYLE' => $folder_img,
|
||||
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
||||
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
|
||||
'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'),
|
||||
'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt],
|
||||
'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'] : '',
|
||||
'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
|
||||
'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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
|
||||
'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'),
|
||||
'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}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&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}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'),
|
||||
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['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,
|
||||
@@ -250,18 +293,18 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
{
|
||||
foreach ($fetch_news[$i]['attachments'] as $attachment)
|
||||
{
|
||||
$template->assign_block_vars('news_row.attachment', array(
|
||||
$this->template->assign_block_vars('news_row.attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
|
||||
if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'NP_PAGINATION' => $pagination,
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? sprintf($user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
|
||||
'NP_PAGE_NUMBER' => phpbb_on_page($template, $user, $view_topic_url, $total_news, $config['board3_number_of_news_' . $module_id], $start))
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? sprintf($this->user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($this->user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
|
||||
'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, $view_topic_url, $total_news, $this->config['board3_number_of_news_' . $module_id], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -275,17 +318,17 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
$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'];
|
||||
$read_full = $this->user->lang['BACK'];
|
||||
|
||||
$read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i");
|
||||
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
if ($config['board3_news_archive_' . $module_id])
|
||||
$read_full_url = (isset($_GET['np'])) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "np=$start#n$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#n$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) . '&t=' . $topic_id);
|
||||
if ($this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
|
||||
$pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
|
||||
}
|
||||
|
||||
$template->assign_block_vars('news_row', array(
|
||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
$this->template->assign_block_vars('news_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'],
|
||||
@@ -295,36 +338,37 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
'REPLIES' => $fetch_news[$i]['topic_replies'],
|
||||
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
|
||||
'N_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", '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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'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}", '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}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['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,
|
||||
));
|
||||
|
||||
phpbb_generate_template_pagination($this->template, $view_topic_url, 'news_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)
|
||||
{
|
||||
$template->assign_block_vars('news_row.attachment', array(
|
||||
$this->template->assign_block_vars('news_row.attachment', array(
|
||||
'DISPLAY_ATTACHMENT' => $attachment)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
|
||||
if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'NP_PAGINATION' => $pagination,
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
|
||||
'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news_' . $module_id], $start))
|
||||
'TOTAL_NEWS' => ($total_news == 1) ? $this->user->lang['VIEW_FORUM_TOPIC'] : $this->user->lang('VIEW_FORUM_TOPICS', $total_news),
|
||||
'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_news, $this->config['board3_number_of_news_' . $module_id], $start))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -336,17 +380,17 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
$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_NEWEST_OR_FIRST' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'],
|
||||
'POSTED_BY_TEXT' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['LAST_POST'] : $user->lang['POSTED'],
|
||||
'S_DISPLAY_NEWS_RVS' => ($config['board3_show_news_replies_views_' . $module_id]) ? true : false,
|
||||
$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_NEWEST_OR_FIRST' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['JUMP_NEWEST'] : $this->user->lang['JUMP_FIRST'],
|
||||
'POSTED_BY_TEXT' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['LAST_POST'] : $this->user->lang['POSTED'],
|
||||
'S_DISPLAY_NEWS_RVS' => ($this->config['board3_show_news_replies_views_' . $module_id]) ? true : false,
|
||||
'S_TOPIC_ICONS' => $topic_icons,
|
||||
));
|
||||
|
||||
if($config['board3_news_style_' . $module_id])
|
||||
if($this->config['board3_news_style_' . $module_id])
|
||||
{
|
||||
return 'news_compact_center.html';
|
||||
}
|
||||
@@ -356,6 +400,9 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -377,7 +424,7 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -394,6 +441,9 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
@@ -413,17 +463,23 @@ class portal_news_module extends \board3\portal\modules\module_base
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
|
||||
// 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 null
|
||||
*/
|
||||
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)
|
||||
if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
|
||||
{
|
||||
$selected = explode(',', $config[$key]);
|
||||
$selected = explode(',', $this->config[$key]);
|
||||
}
|
||||
// Build forum options
|
||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
||||
@@ -437,11 +493,16 @@ class portal_news_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, $module_id)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
// Get selected extensions
|
||||
$values = request_var($key, array(0 => ''));
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Poll
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Poll
|
||||
*/
|
||||
class portal_poll_module extends \board3\portal\modules\module_base
|
||||
class poll extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -53,16 +47,68 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
/** @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 a poll 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, $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_center($module_id)
|
||||
{
|
||||
return $this->parse_template($module_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
return $this->parse_template($module_id, 'side');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -79,7 +125,7 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -91,6 +137,9 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
@@ -105,17 +154,23 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
|
||||
// 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 null
|
||||
*/
|
||||
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)
|
||||
if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
|
||||
{
|
||||
$selected = explode(',', $config[$key]);
|
||||
$selected = explode(',', $this->config[$key]);
|
||||
}
|
||||
// Build forum options
|
||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
||||
@@ -128,11 +183,16 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
return $s_forum_options;
|
||||
}
|
||||
|
||||
// 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, $module_id)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
// Get selected forums
|
||||
$values = request_var($key, array(0 => ''));
|
||||
|
||||
@@ -147,17 +207,17 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
*
|
||||
* @param int $module_id Module ID
|
||||
* @param string $type Module type (center or side)
|
||||
*
|
||||
* @return string HTML filename
|
||||
*/
|
||||
protected function parse_template($module_id, $type = '')
|
||||
{
|
||||
global $config, $template, $db, $user, $auth, $phpbb_root_path, $phpEx;
|
||||
|
||||
$user->add_lang('viewtopic');
|
||||
$this->user->add_lang('viewtopic');
|
||||
|
||||
// check if we need to include the bbcode class
|
||||
if(!class_exists('bbcode'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||
include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext);
|
||||
}
|
||||
|
||||
$view = request_var('view', '');
|
||||
@@ -166,35 +226,35 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
|
||||
$poll_view_ar = (strpos($poll_view, ',') !== FALSE) ? explode(',', $poll_view) : (($poll_view != '') ? array($poll_view) : array());
|
||||
|
||||
if ($update && $config['board3_poll_allow_vote_' . $module_id])
|
||||
if ($update && $this->config['board3_poll_allow_vote_' . $module_id])
|
||||
{
|
||||
$up_topic_id = request_var('t', 0);
|
||||
$up_forum_id = request_var('f', 0);
|
||||
$voted_id = request_var('vote_id', array('' => 0));
|
||||
|
||||
$cur_voted_id = array();
|
||||
if ($user->data['is_registered'])
|
||||
if ($this->user->data['is_registered'])
|
||||
{
|
||||
$sql = 'SELECT poll_option_id
|
||||
FROM ' . POLL_VOTES_TABLE . '
|
||||
WHERE topic_id = ' . $up_topic_id . '
|
||||
AND vote_user_id = ' . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
AND vote_user_id = ' . $this->user->data['user_id'];
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$cur_voted_id[] = $row['poll_option_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cookie based guest tracking ... I don't like this but hum ho
|
||||
// it's oft requested. This relies on "nice" users who don't feel
|
||||
// the need to delete cookies to mess with results.
|
||||
if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $up_topic_id]))
|
||||
if (isset($_COOKIE[$this->config['cookie_name'] . '_poll_' . $up_topic_id]))
|
||||
{
|
||||
$cur_voted_id = explode(',', request_var($config['cookie_name'] . '_poll_' . $up_topic_id, 0, false, true));
|
||||
$cur_voted_id = explode(',', request_var($this->config['cookie_name'] . '_poll_' . $up_topic_id, 0, false, true));
|
||||
$cur_voted_id = array_map('intval', $cur_voted_id);
|
||||
}
|
||||
}
|
||||
@@ -202,19 +262,19 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
$sql = 'SELECT t.poll_length, t.poll_start, t.poll_vote_change, t.topic_status, f.forum_status, t.poll_max_options
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
||||
WHERE t.forum_id = f.forum_id AND t.topic_id = " . (int) $up_topic_id . " AND t.forum_id = " . (int) $up_forum_id;
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$topic_data = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$topic_data = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$s_can_up_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $up_forum_id)) ||
|
||||
($auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change'])) &&
|
||||
$s_can_up_vote = (((!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $up_forum_id)) ||
|
||||
($this->auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change'])) &&
|
||||
(($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
|
||||
$topic_data['topic_status'] != ITEM_LOCKED &&
|
||||
$topic_data['forum_status'] != ITEM_LOCKED) ? true : false;
|
||||
|
||||
if($s_can_up_vote)
|
||||
{
|
||||
$redirect_url = append_sid("{$phpbb_root_path}app.$phpEx/portal");
|
||||
$redirect_url = append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal");
|
||||
|
||||
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
|
||||
{
|
||||
@@ -232,7 +292,7 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
$message = 'VOTE_CONVERTED';
|
||||
}
|
||||
|
||||
$message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>');
|
||||
$message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
|
||||
@@ -247,19 +307,19 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
SET poll_option_total = poll_option_total + 1
|
||||
WHERE poll_option_id = ' . (int) $option . '
|
||||
AND topic_id = ' . (int) $up_topic_id;
|
||||
$db->sql_query($sql);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
if ($this->user->data['is_registered'])
|
||||
{
|
||||
$sql_ary = array(
|
||||
'topic_id' => (int) $up_topic_id,
|
||||
'poll_option_id' => (int) $option,
|
||||
'vote_user_id' => (int) $user->data['user_id'],
|
||||
'vote_user_ip' => (string) $user->ip,
|
||||
'vote_user_id' => (int) $this->user->data['user_id'],
|
||||
'vote_user_ip' => (string) $this->user->ip,
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
|
||||
$db->sql_query($sql);
|
||||
$sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,32 +331,32 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
SET poll_option_total = poll_option_total - 1
|
||||
WHERE poll_option_id = ' . (int) $option . '
|
||||
AND topic_id = ' . (int) $up_topic_id;
|
||||
$db->sql_query($sql);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
if ($this->user->data['is_registered'])
|
||||
{
|
||||
$sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
|
||||
WHERE topic_id = ' . (int) $up_topic_id . '
|
||||
AND poll_option_id = ' . (int) $option . '
|
||||
AND vote_user_id = ' . (int) $user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
AND vote_user_id = ' . (int) $this->user->data['user_id'];
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
|
||||
if ($this->user->data['user_id'] == ANONYMOUS && !$this->user->data['is_bot'])
|
||||
{
|
||||
$user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000);
|
||||
$this->user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . '
|
||||
SET poll_last_vote = ' . time() . "
|
||||
WHERE topic_id = $up_topic_id";
|
||||
//, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
|
||||
$db->sql_query($sql);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
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($this->user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,13 +366,13 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
// Get readable forums
|
||||
$forum_list = array();
|
||||
|
||||
$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_poll_topic_id_' . $module_id] !== '')
|
||||
if($this->config['board3_poll_topic_id_' . $module_id] !== '')
|
||||
{
|
||||
$poll_forums_config = explode(',' ,$config['board3_poll_topic_id_' . $module_id]);
|
||||
$poll_forums_config = explode(',' ,$this->config['board3_poll_topic_id_' . $module_id]);
|
||||
|
||||
if($config['board3_poll_exclude_id_' . $module_id])
|
||||
if($this->config['board3_poll_exclude_id_' . $module_id])
|
||||
{
|
||||
$forum_list = array_unique(array_diff($forum_list, $poll_forums_config));
|
||||
}
|
||||
@@ -327,10 +387,10 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
if(sizeof($forum_list))
|
||||
{
|
||||
$poll_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 ($config['board3_poll_hide_' . $module_id])
|
||||
if ($this->config['board3_poll_hide_' . $module_id])
|
||||
{
|
||||
$portal_poll_hide = "AND (t.poll_start + t.poll_length > ". time() ." OR t.poll_length = 0)";
|
||||
}
|
||||
@@ -350,13 +410,13 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
AND p.post_id = t.topic_first_post_id
|
||||
{$portal_poll_hide}
|
||||
ORDER BY t.poll_start DESC";
|
||||
$limit = (isset($config['board3_poll_limit_' . $module_id])) ? $config['board3_poll_limit_' . $module_id] : 3;
|
||||
$result = $db->sql_query_limit($sql, $limit);
|
||||
$limit = (isset($this->config['board3_poll_limit_' . $module_id])) ? $this->config['board3_poll_limit_' . $module_id] : 3;
|
||||
$result = $this->db->sql_query_limit($sql, $limit);
|
||||
$has_poll = false;
|
||||
|
||||
if ($result)
|
||||
{
|
||||
while($data = $db->sql_fetchrow($result))
|
||||
while($data = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$has_poll = true;
|
||||
$poll_has_options = false;
|
||||
@@ -365,36 +425,36 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
$forum_id = (int) $data['forum_id'];
|
||||
|
||||
$cur_voted_id = array();
|
||||
if($config['board3_poll_allow_vote_' . $module_id])
|
||||
if($this->config['board3_poll_allow_vote_' . $module_id])
|
||||
{
|
||||
if ($user->data['is_registered'])
|
||||
if ($this->user->data['is_registered'])
|
||||
{
|
||||
$vote_sql = 'SELECT poll_option_id
|
||||
FROM ' . POLL_VOTES_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id . '
|
||||
AND vote_user_id = ' . $user->data['user_id'];
|
||||
$vote_result = $db->sql_query($vote_sql);
|
||||
AND vote_user_id = ' . $this->user->data['user_id'];
|
||||
$vote_result = $this->db->sql_query($vote_sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($vote_result))
|
||||
while ($row = $this->db->sql_fetchrow($vote_result))
|
||||
{
|
||||
$cur_voted_id[] = $row['poll_option_id'];
|
||||
}
|
||||
$db->sql_freeresult($vote_result);
|
||||
$this->db->sql_freeresult($vote_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cookie based guest tracking ... I don't like this but hum ho
|
||||
// it's oft requested. This relies on "nice" users who don't feel
|
||||
// the need to delete cookies to mess with results.
|
||||
if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
|
||||
if (isset($_COOKIE[$this->config['cookie_name'] . '_poll_' . $topic_id]))
|
||||
{
|
||||
$cur_voted_id = explode(',', request_var($config['cookie_name'] . '_poll_' . $topic_id, 0, false, true));
|
||||
$cur_voted_id = explode(',', request_var($this->config['cookie_name'] . '_poll_' . $topic_id, 0, false, true));
|
||||
$cur_voted_id = array_map('intval', $cur_voted_id);
|
||||
}
|
||||
}
|
||||
|
||||
$s_can_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $forum_id)) ||
|
||||
($auth->acl_get('f_votechg', $forum_id) && $data['poll_vote_change'])) &&
|
||||
$s_can_vote = (((!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $forum_id)) ||
|
||||
($this->auth->acl_get('f_votechg', $forum_id) && $data['poll_vote_change'])) &&
|
||||
(($data['poll_length'] != 0 && $data['poll_start'] + $data['poll_length'] > time()) || $data['poll_length'] == 0) &&
|
||||
$data['topic_status'] != ITEM_LOCKED &&
|
||||
$data['forum_status'] != ITEM_LOCKED) ? true : false;
|
||||
@@ -411,20 +471,20 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
WHERE po.topic_id = {$topic_id}
|
||||
ORDER BY po.poll_option_id";
|
||||
|
||||
$poll_result = $db->sql_query($poll_sql);
|
||||
$poll_result = $this->db->sql_query($poll_sql);
|
||||
$poll_total_votes = 0;
|
||||
$poll_data = array();
|
||||
|
||||
if ($poll_result)
|
||||
{
|
||||
while($polls_data = $db->sql_fetchrow($poll_result))
|
||||
while($polls_data = $this->db->sql_fetchrow($poll_result))
|
||||
{
|
||||
$poll_has_options = true;
|
||||
$poll_data[] = $polls_data;
|
||||
$poll_total_votes += $polls_data['poll_option_total'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($poll_result);
|
||||
$this->db->sql_freeresult($poll_result);
|
||||
|
||||
$make_poll_view = array();
|
||||
|
||||
@@ -435,9 +495,9 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
$poll_view_str = urlencode(implode(',', $make_poll_view));
|
||||
$portalpoll_url= append_sid("{$phpbb_root_path}app.$phpEx/portal", "polls=$poll_view_str");
|
||||
$portalvote_url= append_sid("{$phpbb_root_path}app.$phpEx/portal", "f=$forum_id&t=$topic_id");
|
||||
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
|
||||
$portalpoll_url= append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "polls=$poll_view_str");
|
||||
$portalvote_url= append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "f=$forum_id&t=$topic_id");
|
||||
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f=$forum_id&t=$topic_id");
|
||||
$poll_end = $data['poll_length'] + $data['poll_start'];
|
||||
|
||||
// Parse BBCode title
|
||||
@@ -461,15 +521,15 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
$data['poll_title'] = smiley_text($data['poll_title']);
|
||||
unset($poll_bbcode);
|
||||
|
||||
$template->assign_block_vars(($type !== '') ? 'poll_' . $type : 'poll', array(
|
||||
$this->template->assign_block_vars(($type !== '') ? 'poll_' . $type : 'poll', array(
|
||||
'S_POLL_HAS_OPTIONS' => $poll_has_options,
|
||||
'POLL_QUESTION' => $data['poll_title'],
|
||||
'U_POLL_TOPIC' => append_sid($phpbb_root_path . 'viewtopic.' . $phpEx . '?t=' . $topic_id . '&f=' . $forum_id),
|
||||
'U_POLL_TOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext . '?t=' . $topic_id . '&f=' . $forum_id),
|
||||
'POLL_LENGTH' => $data['poll_length'],
|
||||
'TOPIC_ID' => $topic_id,
|
||||
'TOTAL_VOTES' => $poll_total_votes,
|
||||
'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_MAX_VOTES' => $this->user->lang('MAX_OPTIONS_SELECT', $data['poll_max_options']),
|
||||
'L_POLL_LENGTH' => ($data['poll_length']) ? sprintf($this->user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $this->user->format_date($poll_end)) : '',
|
||||
'S_CAN_VOTE' => $s_can_vote,
|
||||
'S_DISPLAY_RESULTS' => $s_display_results,
|
||||
'S_IS_MULTI_CHOICE' => ($data['poll_max_options'] > 1) ? true : false,
|
||||
@@ -504,24 +564,24 @@ class portal_poll_module extends \board3\portal\modules\module_base
|
||||
$pd['poll_option_text'] = smiley_text($pd['poll_option_text']);
|
||||
unset($poll_bbcode);
|
||||
|
||||
$template->assign_block_vars((($type !== '') ? 'poll_' . $type : 'poll') . '.poll_option', array(
|
||||
$this->template->assign_block_vars((($type !== '') ? 'poll_' . $type : 'poll') . '.poll_option', array(
|
||||
'POLL_OPTION_ID' => $pd['poll_option_id'],
|
||||
'POLL_OPTION_CAPTION' => $pd['poll_option_text'],
|
||||
'POLL_OPTION_RESULT' => $pd['poll_option_total'],
|
||||
'POLL_OPTION_PERCENT' => $option_pct_txt,
|
||||
'POLL_OPTION_PCT' => round($option_pct * 100),
|
||||
'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 35) . 'px'),
|
||||
'POLL_OPTION_IMG' => $this->user->img('poll_center', $option_pct_txt, round($option_pct * 35) . 'px'),
|
||||
'POLL_OPTION_VOTED' => (in_array($pd['poll_option_id'], $cur_voted_id)) ? true : false
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'S_HAS_POLL' => $has_poll,
|
||||
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
|
||||
'POLL_RIGHT_CAP_IMG' => $user->img('poll_right'),
|
||||
'POLL_LEFT_CAP_IMG' => $this->user->img('poll_left'),
|
||||
'POLL_RIGHT_CAP_IMG' => $this->user->img('poll_right'),
|
||||
));
|
||||
}
|
||||
return (($type !== '') ? 'poll_' . $type : 'poll_center') . '.html';
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Random Member
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Random Member
|
||||
*/
|
||||
class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
class random_member extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -53,11 +47,35 @@ class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Construct a random member object
|
||||
*
|
||||
* @param \phpbb\db\driver $db phpBB database system
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
*/
|
||||
public function __construct($db, $template, $user)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $db, $user;
|
||||
|
||||
switch ($db->sql_layer)
|
||||
switch ($this->db->sql_layer)
|
||||
{
|
||||
case 'postgres':
|
||||
$sql = 'SELECT *
|
||||
@@ -85,8 +103,8 @@ class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$row = $this->db->sql_fetchrow($result);
|
||||
|
||||
$avatar_img = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']);
|
||||
|
||||
@@ -97,7 +115,7 @@ class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
$user_id = (int) $row['user_id'];
|
||||
$colour = $row['user_colour'];
|
||||
|
||||
$template->assign_block_vars('random_member', array(
|
||||
$this->template->assign_block_vars('random_member', array(
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $colour),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour),
|
||||
@@ -109,16 +127,19 @@ class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
|
||||
'USER_POSTS' => (int) $row['user_posts'],
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'JOINED' => $user->format_date($row['user_regdate'], 'd.M.Y'),
|
||||
'JOINED' => $this->user->format_date($row['user_regdate'], 'd.M.Y'),
|
||||
'USER_OCC' => censor_text($row['user_occ']),
|
||||
'USER_FROM' => censor_text($row['user_from']),
|
||||
'U_WWW' => censor_text($row['user_website']),
|
||||
));
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return 'random_member_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -126,17 +147,4 @@ class portal_random_member_module extends \board3\portal\modules\module_base
|
||||
'vars' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Recent
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Recent
|
||||
*/
|
||||
class portal_recent_module extends \board3\portal\modules\module_base
|
||||
class recent extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -53,23 +47,62 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
/** @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;
|
||||
|
||||
/**
|
||||
* Construct a recent object
|
||||
*
|
||||
* @param \phpbb\auth\auth $auth phpBB auth
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($auth, $config, $db, $template, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_center($module_id)
|
||||
{
|
||||
global $config, $template, $db, $auth, $phpbb_root_path, $phpEx;
|
||||
|
||||
//
|
||||
// Exclude forums
|
||||
//
|
||||
$sql_where = '';
|
||||
if ($config['board3_recent_forum_' . $module_id] > 0)
|
||||
if ($this->config['board3_recent_forum_' . $module_id] > 0)
|
||||
{
|
||||
$exclude_forums = explode(',', $config['board3_recent_forum_' . $module_id]);
|
||||
$exclude_forums = explode(',', $this->config['board3_recent_forum_' . $module_id]);
|
||||
|
||||
$sql_where = ' AND ' . $db->sql_in_set('forum_id', array_map('intval', $exclude_forums), ($config['board3_recent_exclude_forums_' . $module_id]) ? true : false);
|
||||
$sql_where = ' AND ' . $this->db->sql_in_set('forum_id', array_map('intval', $exclude_forums), ($this->config['board3_recent_exclude_forums_' . $module_id]) ? true : false);
|
||||
}
|
||||
|
||||
// Get a list of forums the user cannot read
|
||||
$forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
||||
$forum_ary = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
|
||||
|
||||
// Determine first forum the user is able to read (must not be a category)
|
||||
$sql = 'SELECT forum_id
|
||||
@@ -79,13 +112,13 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
$forum_sql = '';
|
||||
if (sizeof($forum_ary))
|
||||
{
|
||||
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
|
||||
$forum_sql = ' AND ' . $db->sql_in_set('t.forum_id', $forum_ary, true);
|
||||
$sql .= ' AND ' . $this->db->sql_in_set('forum_id', $forum_ary, true);
|
||||
$forum_sql = ' AND ' . $this->db->sql_in_set('t.forum_id', $forum_ary, true);
|
||||
}
|
||||
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
|
||||
$db->sql_freeresult($result);
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$g_forum_id = (int) $this->db->sql_fetchfield('forum_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Recent announcements
|
||||
@@ -98,21 +131,21 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
AND topic_moved_id = 0
|
||||
' . $sql_where . '' . $forum_sql . '
|
||||
ORDER BY topic_time DESC';
|
||||
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]);
|
||||
|
||||
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
{
|
||||
// auto auth
|
||||
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
{
|
||||
$template->assign_block_vars('latest_announcements', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
|
||||
$this->template->assign_block_vars('latest_announcements', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]),
|
||||
'FULL_TITLE' => censor_text($row['topic_title']),
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&t=' . $row['topic_id'])
|
||||
'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&t=' . $row['topic_id'])
|
||||
));
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Recent hot topics
|
||||
@@ -120,25 +153,25 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
$sql = 'SELECT topic_title, forum_id, topic_id
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE topic_visibility = ' . ITEM_APPROVED . '
|
||||
AND topic_posts_approved >' . $config['hot_threshold'] . '
|
||||
AND topic_posts_approved >' . $this->config['hot_threshold'] . '
|
||||
AND topic_moved_id = 0
|
||||
' . $sql_where . '' . $forum_sql . '
|
||||
ORDER BY topic_time DESC';
|
||||
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]);
|
||||
|
||||
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
{
|
||||
// auto auth
|
||||
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
{
|
||||
$template->assign_block_vars('latest_hot_topics', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
|
||||
$this->template->assign_block_vars('latest_hot_topics', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]),
|
||||
'FULL_TITLE' => censor_text($row['topic_title']),
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&t=' . $row['topic_id'])
|
||||
'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($row['forum_id'] == 0) ? $g_forum_id : $row['forum_id']) . '&t=' . $row['topic_id'])
|
||||
));
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Recent topic (only show normal topic)
|
||||
@@ -151,25 +184,28 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
AND topic_moved_id = 0
|
||||
' . $sql_where . '' . $forum_sql . '
|
||||
ORDER BY topic_time DESC';
|
||||
$result = $db->sql_query_limit($sql, $config['board3_max_topics_' . $module_id]);
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['board3_max_topics_' . $module_id]);
|
||||
|
||||
while(($row = $db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
while(($row = $this->db->sql_fetchrow($result)) && ($row['topic_title']))
|
||||
{
|
||||
// auto auth
|
||||
if (($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
if (($this->auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0'))
|
||||
{
|
||||
$template->assign_block_vars('latest_topics', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $config['board3_recent_title_limit_' . $module_id]),
|
||||
$this->template->assign_block_vars('latest_topics', array(
|
||||
'TITLE' => character_limit($row['topic_title'], $this->config['board3_recent_title_limit_' . $module_id]),
|
||||
'FULL_TITLE' => censor_text($row['topic_title']),
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'])
|
||||
'U_VIEW_TOPIC' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'])
|
||||
));
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return 'recent_center.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -185,7 +221,7 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -196,6 +232,9 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
@@ -209,17 +248,23 @@ class portal_recent_module extends \board3\portal\modules\module_base
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
|
||||
// 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 null
|
||||
*/
|
||||
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)
|
||||
if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
|
||||
{
|
||||
$selected = explode(',', $config[$key]);
|
||||
$selected = explode(',', $this->config[$key]);
|
||||
}
|
||||
// Build forum options
|
||||
$s_forum_options = '<select id="' . $key . '" name="' . $key . '[]" multiple="multiple">';
|
||||
@@ -233,11 +278,16 @@ class portal_recent_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, $module_id)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
// Get selected extensions
|
||||
$values = request_var($key, array(0 => ''));
|
||||
|
||||
224
modules/statistics.php
Normal file
224
modules/statistics.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?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 Statistics
|
||||
*/
|
||||
class statistics 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 = 10;
|
||||
|
||||
/**
|
||||
* Default modulename
|
||||
*/
|
||||
public $name = 'STATISTICS';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
public $image_src = 'portal_statistics.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
public $language = 'portal_statistics_module';
|
||||
|
||||
/**
|
||||
* custom acp template
|
||||
* file must be in "adm/style/portal/"
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
/** @var \phpbb\cache */
|
||||
protected $cache;
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Construct a search object
|
||||
*
|
||||
* @param \phpbb\cache $cache phpBB cache system
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB database system
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
*/
|
||||
public function __construct($cache, $config, $db, $template, $user)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
|
||||
$total_posts = $this->config['num_posts'];
|
||||
$total_topics = $this->config['num_topics'];
|
||||
$total_users = $this->config['num_users'];
|
||||
$total_files = $this->config['num_files'];
|
||||
|
||||
$l_total_user_s = ($total_users == 0) ? sprintf($this->user->lang['TOTAL_USERS_ZERO'], $total_users) : sprintf($this->user->lang['TOTAL_USERS'][2], $total_users);
|
||||
$l_total_post_s = ($total_posts == 0) ? sprintf($this->user->lang['TOTAL_POSTS_ZERO'], $total_posts) : sprintf($this->user->lang['TOTAL_POSTS_COUNT'][2], $total_posts);
|
||||
$l_total_topic_s = ($total_topics == 0) ? sprintf($this->user->lang['TOTAL_TOPICS_ZERO'], $total_topics) : sprintf($this->user->lang['TOTAL_TOPICS'][2], $total_topics);
|
||||
|
||||
// avarage stat
|
||||
$board_days = (time() - $this->config['board_startdate']) / 86400;
|
||||
|
||||
$topics_per_day = ($total_topics) ? round($total_topics / $board_days, 0) : 0;
|
||||
$posts_per_day = ($total_posts) ? round($total_posts / $board_days, 0) : 0;
|
||||
$users_per_day = round($total_users / $board_days, 0);
|
||||
$topics_per_user = ($total_topics) ? round($total_topics / $total_users, 0) : 0;
|
||||
$posts_per_user = ($total_posts) ? round($total_posts / $total_users, 0) : 0;
|
||||
$posts_per_topic = ($total_topics) ? round($total_posts / $total_topics, 0) : 0;
|
||||
|
||||
if ($topics_per_day > $total_topics)
|
||||
{
|
||||
$topics_per_day = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_day > $total_posts)
|
||||
{
|
||||
$posts_per_day = $total_posts;
|
||||
}
|
||||
|
||||
if ($users_per_day > $total_users)
|
||||
{
|
||||
$users_per_day = $total_users;
|
||||
}
|
||||
|
||||
if ($topics_per_user > $total_topics)
|
||||
{
|
||||
$topics_per_user = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_user > $total_posts)
|
||||
{
|
||||
$posts_per_user = $total_posts;
|
||||
}
|
||||
|
||||
if ($posts_per_topic > $total_posts)
|
||||
{
|
||||
$posts_per_topic = $total_posts;
|
||||
}
|
||||
|
||||
$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
|
||||
$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
|
||||
$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
|
||||
$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
|
||||
$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
|
||||
$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
|
||||
|
||||
$topics_count = $this->get_topics_count();
|
||||
|
||||
// Assign specific vars
|
||||
$this->template->assign_vars(array(
|
||||
'B3_TOTAL_POSTS' => $l_total_post_s,
|
||||
'B3_TOTAL_TOPICS' => $l_total_topic_s,
|
||||
'B3_TOTAL_USERS' => $l_total_user_s,
|
||||
'B3_NEWEST_USER' => sprintf($this->user->lang['NEWEST_USER'], get_username_string('full', $this->config['newest_user_id'], $this->config['newest_username'], $this->config['newest_user_colour'])),
|
||||
'B3_ANNOUNCE_COUNT' => $topics_count[POST_ANNOUNCE],
|
||||
'B3_STICKY_COUNT' => $topics_count[POST_STICKY],
|
||||
'B3_TOTAL_ATTACH' => ($this->config['allow_attachments']) ? $total_files : 0,
|
||||
|
||||
// average stat
|
||||
'B3_TOPICS_PER_DAY' => sprintf($this->user->lang[$l_topics_per_day_s], $topics_per_day),
|
||||
'B3_POSTS_PER_DAY' => sprintf($this->user->lang[$l_posts_per_day_s], $posts_per_day),
|
||||
'B3_USERS_PER_DAY' => sprintf($this->user->lang[$l_users_per_day_s], $users_per_day),
|
||||
'B3_TOPICS_PER_USER' => sprintf($this->user->lang[$l_topics_per_user_s], $topics_per_user),
|
||||
'B3_POSTS_PER_USER' => sprintf($this->user->lang[$l_posts_per_user_s], $posts_per_user),
|
||||
'B3_POSTS_PER_TOPIC' => sprintf($this->user->lang[$l_posts_per_topic_s], $posts_per_topic),
|
||||
));
|
||||
return 'statistics_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'STATISTICS',
|
||||
'vars' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get topics count by type
|
||||
*
|
||||
* @return array Topics count array with type in array keys and count
|
||||
* in array values
|
||||
*/
|
||||
public function get_topics_count()
|
||||
{
|
||||
if (($return_ary = $this->cache->get('_b3p_topics_type_count')) === false)
|
||||
{
|
||||
$return_ary = array(
|
||||
POST_ANNOUNCE => 0,
|
||||
POST_STICKY => 0,
|
||||
);
|
||||
|
||||
$sql_in = array(
|
||||
POST_ANNOUNCE,
|
||||
POST_STICKY,
|
||||
);
|
||||
|
||||
$sql = 'SELECT DISTINCT(topic_id) AS topic_id, topic_type AS type
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('topic_type', $sql_in, false);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
switch ($row['type'])
|
||||
{
|
||||
case POST_ANNOUNCE:
|
||||
++$return_ary[POST_ANNOUNCE];
|
||||
break;
|
||||
|
||||
case POST_STICKY:
|
||||
++$return_ary[POST_STICKY];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// cache topics type count for 1 hour
|
||||
$this->cache->put('_b3p_topics_type_count', $return_ary, 3600);
|
||||
}
|
||||
|
||||
return $return_ary;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Topposters
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Topposters
|
||||
*/
|
||||
class portal_topposters_module extends \board3\portal\modules\module_base
|
||||
class topposters extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -47,37 +41,68 @@ class portal_topposters_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $language = 'portal_topposters_module';
|
||||
|
||||
public function get_template_center($module_id)
|
||||
/** @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;
|
||||
|
||||
/**
|
||||
* Construct a topposers object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($config, $db, $template, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
return false;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $db, $template;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$sql = 'SELECT user_id, username, user_posts, user_colour
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . "
|
||||
AND user_posts <> 0
|
||||
AND username <> ''
|
||||
ORDER BY user_posts DESC";
|
||||
$result = $db->sql_query_limit($sql, $config['board3_topposters_' . $module_id]);
|
||||
$result = $this->db->sql_query_limit($sql, $this->config['board3_topposters_' . $module_id]);
|
||||
|
||||
while (($row = $db->sql_fetchrow($result)))
|
||||
while (($row = $this->db->sql_fetchrow($result)))
|
||||
{
|
||||
$template->assign_block_vars('topposters', array(
|
||||
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&sr=posts'),
|
||||
$this->template->assign_block_vars('topposters', array(
|
||||
'S_SEARCH_ACTION' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'author_id=' . $row['user_id'] . '&sr=posts'),
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'POSTER_POSTS' => $row['user_posts'],
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return 'topposters_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -90,7 +115,7 @@ class portal_topposters_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -98,6 +123,9 @@ class portal_topposters_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
223
modules/user_menu.php
Normal file
223
modules/user_menu.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?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 User menu
|
||||
*/
|
||||
class user_menu 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 = 10;
|
||||
|
||||
/**
|
||||
* Default modulename
|
||||
*/
|
||||
public $name = 'USER_MENU';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
public $image_src = 'portal_user.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
public $language = 'portal_user_menu_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;
|
||||
|
||||
/** @var php file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/** @var phpbb root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Construct a user menu object
|
||||
*
|
||||
* @param \phpbb\auth\auth $auth phpBB auth
|
||||
* @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
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($auth, $config, $db, $template, $user, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
if (!function_exists('get_user_avatar'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
|
||||
}
|
||||
|
||||
if ($this->user->data['is_registered'])
|
||||
{
|
||||
//
|
||||
// + new posts since last visit & you post number
|
||||
//
|
||||
$ex_fid_ary = array_unique(array_merge(array_keys($this->auth->acl_getf('!f_read', true)), array_keys($this->auth->acl_getf('!f_search', true))));
|
||||
|
||||
if ($this->auth->acl_get('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array(-1);
|
||||
$m_approve_fid_sql = '';
|
||||
}
|
||||
else if ($this->auth->acl_getf_global('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array_diff(array_keys($this->auth->acl_getf('!m_approve', true)), $ex_fid_ary);
|
||||
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$m_approve_fid_ary = array();
|
||||
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(distinct t.topic_id) as total
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE t.topic_last_post_time > ' . $this->user->data['user_lastvisit'] . '
|
||||
AND t.topic_moved_id = 0
|
||||
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||
$result = $this->db->sql_query($sql);
|
||||
$new_posts_count = (int) $this->db->sql_fetchfield('total');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// unread posts
|
||||
$sql_where = 'AND t.topic_moved_id = 0
|
||||
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $this->db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||
$unread_list = array();
|
||||
$unread_list = get_unread_topics($this->user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
|
||||
$unread_posts_count = sizeof($unread_list);
|
||||
|
||||
|
||||
// Get user avatar and rank
|
||||
$user_id = $this->user->data['user_id'];
|
||||
$username = $this->user->data['username'];
|
||||
$colour = $this->user->data['user_colour'];
|
||||
$avatar_img = get_user_avatar($this->user->data['user_avatar'], $this->user->data['user_avatar_type'], $this->user->data['user_avatar_width'], $this->user->data['user_avatar_height']);
|
||||
$rank_title = $rank_img = '';
|
||||
get_user_rank($this->user->data['user_rank'], $this->user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
// Assign specific vars
|
||||
$this->template->assign_vars(array(
|
||||
'L_NEW_POSTS' => $this->user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')',
|
||||
'L_SELF_POSTS' => $this->user->lang['SEARCH_SELF'] . ' (' . $this->user->data['user_posts'] . ')',
|
||||
'L_UNREAD_POSTS'=> $this->user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')',
|
||||
|
||||
'B3P_AVATAR_IMG' => $avatar_img,
|
||||
'B3P_RANK_TITLE' => $rank_title,
|
||||
'B3P_RANK_IMG' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
|
||||
|
||||
'U_NEW_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=newposts'),
|
||||
'U_SELF_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=egosearch'),
|
||||
'U_UNREAD_POSTS' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'search_id=unreadposts'),
|
||||
'U_UM_BOOKMARKS' => ($this->config['allow_bookmarks']) ? append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=bookmarks') : '',
|
||||
'U_UM_MAIN_SUBSCRIBED' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=main&mode=subscribed'),
|
||||
'U_UM_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=main&mode=front', true, $this->user->session_id) : '',
|
||||
'S_DISPLAY_SUBSCRIPTIONS' => ($this->config['allow_topic_notify'] || $this->config['allow_forum_notify']) ? true : false,
|
||||
));
|
||||
|
||||
return 'user_menu_side.html';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assign specific vars
|
||||
$this->template->assign_vars(array(
|
||||
'U_PORTAL' => append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"),
|
||||
'S_DISPLAY_FULL_LOGIN' => true,
|
||||
'S_AUTOLOGIN_ENABLED' => ($this->config['allow_autologin']) ? true : false,
|
||||
'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'mode=login'),
|
||||
'S_SHOW_REGISTER' => ($this->config['board3_user_menu_register_' . $module_id]) ? true : false,
|
||||
));
|
||||
|
||||
return 'login_box_side.html';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'USER_MENU',
|
||||
'vars' => array(
|
||||
'legend1' => 'USER_MENU_SETTINGS',
|
||||
'board3_user_menu_register_' . $module_id => array('lang' => 'USER_MENU_REGISTER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
set_config('board3_user_menu_register_' . $module_id, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
'board3_user_menu_register_' . $module_id,
|
||||
);
|
||||
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Welcome
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Welcome
|
||||
*/
|
||||
class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
class welcome extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -53,23 +47,62 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $custom_acp_tpl = 'acp_portal_welcome';
|
||||
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var php file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/** @var phpbb root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* Construct a welcome object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\user $user phpBB user
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($config, $template, $user, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_center($module_id)
|
||||
{
|
||||
global $config, $template, $portal_config, $phpEx;
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
// Generate text for display and assign template vars
|
||||
$uid = $config['board3_welcome_message_uid_' . $module_id];
|
||||
$bitfield = $config['board3_welcome_message_bitfield_' . $module_id];
|
||||
$uid = $this->config['board3_welcome_message_uid_' . $module_id];
|
||||
$bitfield = $this->config['board3_welcome_message_bitfield_' . $module_id];
|
||||
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
|
||||
$text = generate_text_for_display($portal_config['board3_welcome_message_' . $module_id], $uid, $bitfield, $bbcode_options);
|
||||
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'PORTAL_WELCOME_MSG' => $text,
|
||||
));
|
||||
|
||||
return 'welcome_center.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -82,7 +115,7 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
@@ -93,6 +126,9 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
@@ -113,17 +149,24 @@ class portal_welcome_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
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage welcome message
|
||||
*
|
||||
* @param mixed $value Value of input
|
||||
* @param string $key Key name
|
||||
* @param int $module_id Module ID
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function manage_welcome($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['submit'])) ? 'save' : $action;
|
||||
$action = (isset($_POST['preview'])) ? 'preview' : $action;
|
||||
|
||||
$portal_config = obtain_portal_config();
|
||||
|
||||
$u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&mode=config&module_id=' . $module_id);
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id);
|
||||
|
||||
switch($action)
|
||||
{
|
||||
@@ -131,7 +174,7 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
case 'save':
|
||||
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);
|
||||
}
|
||||
|
||||
$welcome_message = utf8_normalize_nfc(request_var('welcome_message', '', true));
|
||||
@@ -142,10 +185,10 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
// first check for obvious errors, we don't want to waste server resources
|
||||
if(empty($welcome_message))
|
||||
{
|
||||
trigger_error($user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
|
||||
trigger_error($this->user->lang['ACP_PORTAL_WELCOME_MESSAGE_SHORT']. adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
|
||||
add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['PORTAL_WELCOME']);
|
||||
add_log('admin', 'LOG_PORTAL_CONFIG', $this->user->lang['PORTAL_WELCOME']);
|
||||
|
||||
// set_portal_config will take care of escaping the welcome message
|
||||
set_portal_config('board3_welcome_message_' . $module_id, $welcome_message);
|
||||
@@ -156,20 +199,15 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
case 'preview':
|
||||
$welcome_message = $text = utf8_normalize_nfc(request_var('welcome_message', '', true));
|
||||
|
||||
if (!class_exists('parse_message'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
||||
}
|
||||
|
||||
$bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
|
||||
$uid = (isset($config['board3_welcome_message_uid_' . $module_id])) ? $config['board3_welcome_message_uid_' . $module_id] : '';
|
||||
$bitfield = (isset($config['board3_welcome_message_bitfield_' . $module_id])) ? $config['board3_welcome_message_bitfield_' . $module_id] : '';
|
||||
$uid = (isset($this->config['board3_welcome_message_uid_' . $module_id])) ? $this->config['board3_welcome_message_uid_' . $module_id] : '';
|
||||
$bitfield = (isset($this->config['board3_welcome_message_bitfield_' . $module_id])) ? $this->config['board3_welcome_message_bitfield_' . $module_id] : '';
|
||||
$options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
|
||||
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
|
||||
|
||||
$text = generate_text_for_display($text, $uid, $bitfield, $options);
|
||||
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'PREVIEW_TEXT' => $text,
|
||||
'S_PREVIEW' => true,
|
||||
));
|
||||
@@ -179,10 +217,10 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
default:
|
||||
if(!isset($welcome_message))
|
||||
{
|
||||
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $config['board3_welcome_message_uid_' . $module_id], '');
|
||||
$welcome_message = generate_text_for_edit($portal_config['board3_welcome_message_' . $module_id], $this->config['board3_welcome_message_uid_' . $module_id], '');
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
$this->template->assign_vars(array(
|
||||
'WELCOME_MESSAGE' => (is_array($welcome_message)) ? $welcome_message['text'] : $welcome_message,
|
||||
//'U_BACK' => $u_action,
|
||||
'U_ACTION' => $u_action,
|
||||
@@ -192,22 +230,30 @@ class portal_welcome_module extends \board3\portal\modules\module_base
|
||||
'S_BBCODE_FLASH' => true,
|
||||
'S_BBCODE_QUOTE' => true,
|
||||
'S_BBCODE_ALLOWED' => true,
|
||||
'MAX_FONT_SIZE' => (int) $config['max_post_font_size'],
|
||||
'MAX_FONT_SIZE' => (int) $this->config['max_post_font_size'],
|
||||
));
|
||||
|
||||
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
|
||||
display_custom_bbcodes();
|
||||
$user->add_lang('posting');
|
||||
$this->user->add_lang('posting');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update welcome message
|
||||
*
|
||||
* @param string $key Key name
|
||||
* @param int $module_id Module ID
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function update_welcome($key, $module_id)
|
||||
{
|
||||
$this->manage_welcome('', $key, $module_id);
|
||||
@@ -1,24 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Who is online
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
namespace board3\portal\modules;
|
||||
|
||||
/**
|
||||
* @package Who is online
|
||||
*/
|
||||
class portal_whois_online_module extends \board3\portal\modules\module_base
|
||||
class whois_online extends module_base
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
@@ -53,12 +47,51 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
/** @var \phpbb\auth\auth */
|
||||
protected $auth;
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var phpbb root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var php file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Construct a user menu object
|
||||
*
|
||||
* @param \phpbb\auth\auth $auth phpBB auth
|
||||
* @param \phpbb\db\driver $db phpBB db driver
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\user $user phpBB user
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $phpEx php file extension
|
||||
*/
|
||||
public function __construct($auth, $db, $template, $user, $phpbb_root_path, $phpEx)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->db = $db;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $phpEx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_center($module_id)
|
||||
{
|
||||
global $config, $template, $user, $auth, $db, $phpbb_root_path, $phpEx;
|
||||
|
||||
// Grab group details for legend display
|
||||
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
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
@@ -72,48 +105,50 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
|
||||
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
|
||||
ON (
|
||||
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
|
||||
)
|
||||
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';
|
||||
}
|
||||
$result = $db->sql_query($sql);
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$legend = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
|
||||
$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'];
|
||||
|
||||
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
|
||||
if ($row['group_name'] == 'BOTS' || ($this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')))
|
||||
{
|
||||
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
|
||||
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$legend = implode(', ', $legend);
|
||||
|
||||
$template->assign_var('PORTAL_LEGEND', $legend);
|
||||
$this->template->assign_var('PORTAL_LEGEND', $legend);
|
||||
|
||||
return 'whois_online_center.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $user, $auth, $db, $phpbb_root_path, $phpEx;
|
||||
|
||||
// No legend on the side so just return the template file
|
||||
|
||||
return 'whois_online_side.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
@@ -121,17 +156,4 @@ class portal_whois_online_module extends \board3\portal\modules\module_base
|
||||
'vars' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - Statistics
|
||||
* @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 Statistics
|
||||
*/
|
||||
class portal_statistics_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 = 'STATISTICS';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
public $image_src = 'portal_statistics.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
public $language = 'portal_statistics_module';
|
||||
|
||||
/**
|
||||
* custom acp template
|
||||
* file must be in "adm/style/portal/"
|
||||
*/
|
||||
public $custom_acp_tpl = '';
|
||||
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $user;
|
||||
|
||||
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
|
||||
$total_posts = $config['num_posts'];
|
||||
$total_topics = $config['num_topics'];
|
||||
$total_users = $config['num_users'];
|
||||
$total_files = $config['num_files'];
|
||||
|
||||
$l_total_user_s = ($total_users == 0) ? sprintf($user->lang['TOTAL_USERS_ZERO'], $total_users) : sprintf($user->lang['TOTAL_USERS'][2], $total_users);
|
||||
$l_total_post_s = ($total_posts == 0) ? sprintf($user->lang['TOTAL_POSTS_ZERO'], $total_posts) : sprintf($user->lang['TOTAL_POSTS_COUNT'][2], $total_posts);
|
||||
$l_total_topic_s = ($total_topics == 0) ? sprintf($user->lang['TOTAL_TOPICS_ZERO'], $total_topics) : sprintf($user->lang['TOTAL_TOPICS'][2], $total_topics);
|
||||
|
||||
// avarage stat
|
||||
$board_days = (time() - $config['board_startdate']) / 86400;
|
||||
|
||||
$topics_per_day = ($total_topics) ? round($total_topics / $board_days, 0) : 0;
|
||||
$posts_per_day = ($total_posts) ? round($total_posts / $board_days, 0) : 0;
|
||||
$users_per_day = round($total_users / $board_days, 0);
|
||||
$topics_per_user = ($total_topics) ? round($total_topics / $total_users, 0) : 0;
|
||||
$posts_per_user = ($total_posts) ? round($total_posts / $total_users, 0) : 0;
|
||||
$posts_per_topic = ($total_topics) ? round($total_posts / $total_topics, 0) : 0;
|
||||
|
||||
if ($topics_per_day > $total_topics)
|
||||
{
|
||||
$topics_per_day = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_day > $total_posts)
|
||||
{
|
||||
$posts_per_day = $total_posts;
|
||||
}
|
||||
|
||||
if ($users_per_day > $total_users)
|
||||
{
|
||||
$users_per_day = $total_users;
|
||||
}
|
||||
|
||||
if ($topics_per_user > $total_topics)
|
||||
{
|
||||
$topics_per_user = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_user > $total_posts)
|
||||
{
|
||||
$posts_per_user = $total_posts;
|
||||
}
|
||||
|
||||
if ($posts_per_topic > $total_posts)
|
||||
{
|
||||
$posts_per_topic = $total_posts;
|
||||
}
|
||||
|
||||
$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
|
||||
$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
|
||||
$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
|
||||
$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
|
||||
$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
|
||||
$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
|
||||
|
||||
$topics_count = $this->get_topics_count();
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'B3_TOTAL_POSTS' => $l_total_post_s,
|
||||
'B3_TOTAL_TOPICS' => $l_total_topic_s,
|
||||
'B3_TOTAL_USERS' => $l_total_user_s,
|
||||
'B3_NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
|
||||
'B3_ANNOUNCE_COUNT' => $topics_count[POST_ANNOUNCE],
|
||||
'B3_STICKY_COUNT' => $topics_count[POST_STICKY],
|
||||
'B3_TOTAL_ATTACH' => ($config['allow_attachments']) ? $total_files : 0,
|
||||
|
||||
// average stat
|
||||
'B3_TOPICS_PER_DAY' => sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
|
||||
'B3_POSTS_PER_DAY' => sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
|
||||
'B3_USERS_PER_DAY' => sprintf($user->lang[$l_users_per_day_s], $users_per_day),
|
||||
'B3_TOPICS_PER_USER' => sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
|
||||
'B3_POSTS_PER_USER' => sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
|
||||
'B3_POSTS_PER_TOPIC' => sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
|
||||
));
|
||||
return 'statistics_side.html';
|
||||
}
|
||||
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'STATISTICS',
|
||||
'vars' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Better function with only one query
|
||||
public function get_topics_count()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$return_ary = array(
|
||||
POST_ANNOUNCE => 0,
|
||||
POST_STICKY => 0,
|
||||
);
|
||||
|
||||
$sql_in = array(
|
||||
POST_ANNOUNCE,
|
||||
POST_STICKY,
|
||||
);
|
||||
|
||||
$sql = 'SELECT DISTINCT(topic_id) AS topic_id, topic_type AS type
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_type', $sql_in, false);
|
||||
$result = $db->sql_query($sql);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
switch($row['type'])
|
||||
{
|
||||
case POST_ANNOUNCE:
|
||||
++$return_ary[POST_ANNOUNCE];
|
||||
break;
|
||||
|
||||
case POST_STICKY:
|
||||
++$return_ary[POST_STICKY];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $return_ary;
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2 - User Menu
|
||||
* @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_user_menu_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 = 'USER_MENU';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
public $image_src = 'portal_user.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
public $language = 'portal_user_menu_module';
|
||||
|
||||
public function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;
|
||||
|
||||
if (!function_exists('get_user_avatar'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
||||
}
|
||||
|
||||
if ($user->data['is_registered'])
|
||||
{
|
||||
//
|
||||
// + new posts since last visit & you post number
|
||||
//
|
||||
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
|
||||
|
||||
if ($auth->acl_get('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array(-1);
|
||||
$m_approve_fid_sql = '';
|
||||
}
|
||||
else if ($auth->acl_getf_global('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
|
||||
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$m_approve_fid_ary = array();
|
||||
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(distinct t.topic_id) as total
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
|
||||
AND t.topic_moved_id = 0
|
||||
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||
$result = $db->sql_query($sql);
|
||||
$new_posts_count = (int) $db->sql_fetchfield('total');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// unread posts
|
||||
$sql_where = 'AND t.topic_moved_id = 0
|
||||
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||
$unread_list = array();
|
||||
$unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
|
||||
$unread_posts_count = sizeof($unread_list);
|
||||
|
||||
|
||||
// Get user avatar and rank
|
||||
$user_id = $user->data['user_id'];
|
||||
$username = $user->data['username'];
|
||||
$colour = $user->data['user_colour'];
|
||||
$avatar_img = get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height']);
|
||||
$rank_title = $rank_img = '';
|
||||
get_user_rank($user->data['user_rank'], $user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'L_NEW_POSTS' => $user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')',
|
||||
'L_SELF_POSTS' => $user->lang['SEARCH_SELF'] . ' (' . $user->data['user_posts'] . ')',
|
||||
'L_UNREAD_POSTS'=> $user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')',
|
||||
|
||||
'B3P_AVATAR_IMG' => $avatar_img,
|
||||
'B3P_RANK_TITLE' => $rank_title,
|
||||
'B3P_RANK_IMG' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
|
||||
|
||||
'U_NEW_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
|
||||
'U_SELF_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
|
||||
'U_UNREAD_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'),
|
||||
'U_UM_BOOKMARKS' => ($config['allow_bookmarks']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=bookmarks') : '',
|
||||
'U_UM_MAIN_SUBSCRIBED' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=subscribed'),
|
||||
'U_UM_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '',
|
||||
'S_DISPLAY_SUBSCRIPTIONS' => ($config['allow_topic_notify'] || $config['allow_forum_notify']) ? true : false,
|
||||
));
|
||||
|
||||
return 'user_menu_side.html';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'U_PORTAL' => append_sid("{$phpbb_root_path}app.$phpEx/portal"),
|
||||
'S_DISPLAY_FULL_LOGIN' => true,
|
||||
'S_AUTOLOGIN_ENABLED' => ($config['allow_autologin']) ? true : false,
|
||||
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
|
||||
'S_SHOW_REGISTER' => ($config['board3_user_menu_register_' . $module_id]) ? true : false,
|
||||
));
|
||||
|
||||
return 'login_box_side.html';
|
||||
}
|
||||
}
|
||||
|
||||
public function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'USER_MENU',
|
||||
'vars' => array(
|
||||
'legend1' => 'USER_MENU_SETTINGS',
|
||||
'board3_user_menu_register_' . $module_id => array('lang' => 'USER_MENU_REGISTER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
public function install($module_id)
|
||||
{
|
||||
set_config('board3_user_menu_register_' . $module_id, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall($module_id, $db)
|
||||
{
|
||||
$del_config = array(
|
||||
'board3_user_menu_register_' . $module_id,
|
||||
);
|
||||
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user