phpBB

Development Wiki

Olympus for phpBB2 users

From phpBB Development Wiki

Looking for something you know in phpBB2 but can't find in Olympus? See if you can find it here - there's not much yet, but of course you can add things that you stumble about.

phpBB2 Code Olympus Code Description
create_date(
    
$board_config['default_dateformat'],
    
$your_timestamp,
    
$board_config['board_timezone']
);
$user->format_date($your_timestamp);
shorter, more readable and it is set to users date formatting automatically
$userdata['user_id']
$lang['LANG_TEXT']
$user->data['user_id']
$user->lang['LANG_TEXT']
more flexible, $user object contains information which was fomerly stored in global arrays
$userdata['session_logged_in']
$user->data['is_registered']
To check whether a user is logged in or not, you can use this field.
$board_config
$config
Content of phpbb_config table
$page_title $l_title;
page_header($l_title);
The page title in Olympus must given to a function, it isn't enough to declare a variable anymore.
$template->set_filenames(array('foo_body' => 'foo_body.tpl'));

$template->pparse('foo_body');

include_once(
$phpbb_root_path 'includes/page_tail.'.$phpEx);
$template->set_filenames(array('body' => 'foo_body.html'));

page_footer();
Template files use the .html extension (instead of .tpl in phpBB2). The alias for the main template file must be 'body' because phpBB3 handles template parsing in the new page_footer() function.
message_die('foo''foo'__LINE____FILE__)
trigger_error('LANG_VAR');
display message to user or abort on error.

You don't need to pass __LINE__, __FILE__ and $sql anymore, it's all done for you :-)

$result $db->sql_query($sql);
if(!
$result)
{
     
message_die(...);
}
$result $db->sql_query($sql);
no need to check for database errors anymore :-).

If you want the old behaviour (for queries that might fail under normal conditions), use $db->sql_return_on_error(true) before calling $db->sql_query() be sure to use $db->sql_return_on_error(false) immediately following the query function to set it back to default.

if(isset($HTTP_POST_VARS['foo']))
{
     
$foo intval($HTTP_POST_VARS['foo']);
}
elseif(isset(
$HTTP_GET_VARS['foo']))
{
     
$foo intval($HTTP_GET_VARS['foo']);
}
else
{
     
$foo 0;
}
$foo request_var('foo'0truetrue);
get values of GET/POST parameters.

The second parameter of request_var() is the default value; you don't need intval() etc. anymore because the passed in valued is automatically converted to the type of the default value. For strings, htmlspecialchars() and trim() is also applied.

The third parameter $multibyte must be set to true if the parameter can contain UTF-8 characters like German umlauts (i.e. always set it when the user can type in the value).

By default, cookie values are excluded by this function. Set the fourth parameter $cookie to true if the value can also come from $_COOKIE.

redirect(append_sid("login.$phpEx?redirect=foo.$phpEx"true));
login_box("foo.$phpEx"$user->lang['LOGIN_FOO']);
In phpBB3, you don't manually redirect to login.php anymore, instead you call the function login_box(). You can optionally pass a string which explains the user why they need to login
$is_auth = array();
$is_auth auth(AUTH_ALL$forum_id$userdata$forum_topic_data);
if(
$is_auth['auth_reply'])
{
    
//do something
}
if ($auth->acl_get('f_reply'$forum_id))
{
    
//do something
}
In phpBB2, every time you call auth() the sql queries are executed so you need to call auth() once and store the result in a variable.

In phpBB3, you can directly call the $auth->... functions; caching is handled automatically by the functions.

if($userdata['user_level'] == ADMIN)
if ($auth->acl_get('a_foo'))
In phpBB3, you don't care about user levels anymore, you directly check whether the user has a certain permission.


$phpbb_root_path './';
include(
$phpbb_root_path 'extension.inc');
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH './';
$phpEx substr(strrchr(__FILE__'.'), 1);
In phpBB3, there is no extension.inc anymore.