Start working on the future
This commit is contained in:
69
root/portal/includes/functions_modules.php
Normal file
69
root/portal/includes/functions_modules.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Portal
|
||||
* @version $Id$
|
||||
* @copyright (c) 2009, 2010 Board3 Portal Team
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
function column_num_string($column)
|
||||
{
|
||||
switch ($column)
|
||||
{
|
||||
case 1:
|
||||
return 'left';
|
||||
case 2:
|
||||
return 'center';
|
||||
case 3:
|
||||
return 'right';
|
||||
case 4:
|
||||
return 'top';
|
||||
case 5:
|
||||
return 'bottom';
|
||||
}
|
||||
}
|
||||
|
||||
function column_string_num($column)
|
||||
{
|
||||
switch ($column)
|
||||
{
|
||||
case 'left':
|
||||
return 1;
|
||||
case 'center':
|
||||
return 2;
|
||||
case 'right':
|
||||
return 3;
|
||||
case 'top':
|
||||
return 4;
|
||||
case 'bottom':
|
||||
return 5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function column_string_const($column)
|
||||
{
|
||||
switch ($column)
|
||||
{
|
||||
case 'top':
|
||||
return 1;
|
||||
case 'left':
|
||||
return 2;
|
||||
case 'center':
|
||||
return 4;
|
||||
case 'right':
|
||||
return 8;
|
||||
case 'bottom':
|
||||
return 16;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
107
root/portal/modules/portal_default.php
Normal file
107
root/portal/modules/portal_default.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Portal - Modulname
|
||||
* @version $Id$
|
||||
* @copyright (c) 2009, 2010 Board3 Portal Team
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package Modulname
|
||||
*/
|
||||
class portal_modulename_module
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
* top 1
|
||||
* left 2
|
||||
* center 4
|
||||
* right 8
|
||||
* bottom 16
|
||||
*/
|
||||
var $columns = 0;
|
||||
|
||||
/**
|
||||
* Default modulename
|
||||
*/
|
||||
var $name = 'MODULENAME';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
var $image_src = 'modulename.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
var $language = '';
|
||||
|
||||
function get_template_center($module_id)
|
||||
{
|
||||
global $config, $template;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'EXAMPLE' => $config['portal_' . $module_id . '_configname'],
|
||||
));
|
||||
|
||||
return 'modulename_center.html';
|
||||
}
|
||||
|
||||
function get_template_side($module_id)
|
||||
{
|
||||
global $config, $template;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'EXAMPLE' => $config['portal_' . $module_id . '_configname2'],
|
||||
));
|
||||
|
||||
return 'modulename_side.html';
|
||||
}
|
||||
|
||||
function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'ACP_CONFIG_MODULENAME',
|
||||
'vars' => array(
|
||||
'legend1' => 'ACP_MODULENAME_CONFIGLEGEND',
|
||||
'portal_' . $module_id . '_configname' => array('lang' => 'MODULENAME_CONFIGNAME', 'validate' => 'string', 'type' => 'text:10:200', 'explain' => false),
|
||||
'portal_' . $module_id . '_configname2' => array('lang' => 'MODULENAME_CONFIGNAME2', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
function install($module_id)
|
||||
{
|
||||
set_config('portal_' . $module_id . '_configname', 'Hello World!');
|
||||
set_config('portal_' . $module_id . '_configname2', 1337);
|
||||
return true;
|
||||
}
|
||||
|
||||
function uninstall($module_id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$del_config = array(
|
||||
'portal_' . $module_id . '_configname',
|
||||
'portal_' . $module_id . '_configname2',
|
||||
);
|
||||
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('config_name', $del_config);
|
||||
return $db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
113
root/portal/modules/portal_topposters.php
Normal file
113
root/portal/modules/portal_topposters.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Portal - Topposters
|
||||
* @version $Id$
|
||||
* @copyright (c) 2009, 2010 Board3 Portal Team
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package Topposters
|
||||
*/
|
||||
class portal_topposters_module
|
||||
{
|
||||
/**
|
||||
* Allowed columns: Just sum up your options (Exp: left + right = 10)
|
||||
* top 1
|
||||
* left 2
|
||||
* center 4
|
||||
* right 8
|
||||
* bottom 16
|
||||
*/
|
||||
var $columns = 10;
|
||||
|
||||
/**
|
||||
* Default modulename
|
||||
*/
|
||||
var $name = 'TOPPOSTERS';
|
||||
|
||||
/**
|
||||
* Default module-image:
|
||||
* file must be in "{T_THEME_PATH}/images/portal/"
|
||||
*/
|
||||
var $image_src = 'topposters.png';
|
||||
|
||||
/**
|
||||
* module-language file
|
||||
* file must be in "language/{$user->lang}/mods/portal/"
|
||||
*/
|
||||
var $language = 'portal_topposters_module';
|
||||
|
||||
function get_template_center($module_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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['portal_topposters']);
|
||||
|
||||
while (($row = $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'),
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'POSTER_POSTS' => $row['user_posts'],
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return 'topposters_side.html';
|
||||
}
|
||||
|
||||
function get_template_acp($module_id)
|
||||
{
|
||||
return array(
|
||||
'title' => 'TOPPOSTERS_CONFIG',
|
||||
'vars' => array(
|
||||
'legend1' => 'TOPPOSTERS',
|
||||
'portal_topposters' => array('lang' => 'NUM_TOPPOSTERS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* API functions
|
||||
*/
|
||||
function install($module_id)
|
||||
{
|
||||
set_config('portal_topposters', 5);
|
||||
return true;
|
||||
}
|
||||
|
||||
function uninstall($module_id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$del_config = array(
|
||||
'portal_topposters',
|
||||
);
|
||||
$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