From 2fd418fc2141aa3d5a38b47fc129f8cbb2e9d770 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Dec 2005 20:25:51 +0000 Subject: [PATCH] - some bugfixes - checking if page_header has been called already - call correct page footer function - rewrote avatar gallery - seperated compilation of template and template functions (new file: functions_template.php) - added assign_display function to template - added group management (acp) - removed admin_groups git-svn-id: file:///svn/phpbb/trunk@5319 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_groups.php | 956 ------------------ phpBB/includes/acm/acm_db.php | 2 +- phpBB/includes/acm/acm_file.php | 24 +- phpBB/includes/acp/acp_groups.php | 700 +++++++++++++ phpBB/includes/functions.php | 29 +- phpBB/includes/functions_module.php | 20 +- phpBB/includes/functions_template.php | 668 ++++++++++++ phpBB/includes/functions_user.php | 120 ++- phpBB/includes/template.php | 679 ++----------- phpBB/includes/ucp/ucp_profile.php | 82 +- phpBB/language/en/acp/common.php | 20 + phpBB/language/en/acp/groups.php | 111 ++ phpBB/language/en/acp/posting.php | 2 +- .../template/ucp_profile_avatar.html | 10 +- 14 files changed, 1725 insertions(+), 1698 deletions(-) delete mode 100644 phpBB/adm/admin_groups.php create mode 100644 phpBB/includes/acp/acp_groups.php create mode 100644 phpBB/includes/functions_template.php create mode 100644 phpBB/language/en/acp/groups.php diff --git a/phpBB/adm/admin_groups.php b/phpBB/adm/admin_groups.php deleted file mode 100644 index 22dd3a725e..0000000000 --- a/phpBB/adm/admin_groups.php +++ /dev/null @@ -1,956 +0,0 @@ -acl_get('a_group')) - { - return; - } - - $module['USER']['GROUP_MANAGE'] = basename(__FILE__) . "$SID&mode=manage"; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); -include($phpbb_root_path . 'includes/functions_user.'.$phpEx); - -// Do we have general permissions? -if (!$auth->acl_get('a_group')) -{ - trigger_error($user->lang['NO_ADMIN']); -} - -// Check and set some common vars -$mode = request_var('mode', ''); -$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', '')); -$group_id = request_var('g', 0); -$mark_ary = request_var('mark', array(0)); -$name_ary = request_var('usernames', ''); -$leader = request_var('leader', 0); -$default = request_var('default', 0); -$start = request_var('start', 0); -$update = (isset($_POST['update'])) ? true : false; -$confirm = (isset($_POST['confirm'])) ? true : false; -$cancel = (isset($_POST['cancel'])) ? true : false; - -// Clear some vars -$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; -$group_row = array(); - -// Grab basic data for group, if group_id is set and exists -if ($group_id) -{ - $sql = 'SELECT * - FROM ' . GROUPS_TABLE . " - WHERE group_id = $group_id"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - trigger_error($user->lang['NO_GROUP']); - } -} - -switch ($mode) -{ - case 'manage': - // Page header - adm_page_header($user->lang['MANAGE']); - - // Common javascript -?> - - - -lang['NO_GROUP']); - } - - group_user_attributes($action, $group_id, $mark_ary, false, ($group_id) ? $group_row['group_name'] : false); - - switch ($action) - { - case 'demote': - $message = 'GROUP_MODS_DEMOTED'; - break; - - case 'promote': - $message = 'GROUP_MODS_PROMOTED'; - break; - - case 'approve': - $message = 'USERS_APPROVED'; - break; - } - - trigger_error($user->lang[$message]); - break; - - case 'default': - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP']); - } - - if (!$mark_ary) - { - $start = 0; - do - { - $sql = 'SELECT user_id - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - ORDER BY user_id"; - $result = $db->sql_query_limit($sql, 200, $start); - - $mark_ary = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $mark_ary[] = $row['user_id']; - } - while ($row = $db->sql_fetchrow($result)); - - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - - $start = (sizeof($user_id_ary) < 200) ? 0 : $start + 200; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - } - else - { - group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); - } - - trigger_error($user->lang['GROUP_DEFS_UPDATED']); - break; - - case 'deleteusers': - case 'delete': - if (!$cancel && !$confirm) - { - adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']); - } - else - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP']); - } - - switch ($action) - { - case 'delete': - $error = group_delete($group_id, $group_row['group_name']); - break; - - case 'deleteusers': - $error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']); - break; - } - - if ($error) - { - trigger_error($user->lang[$error]); - } - - $message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE'; - trigger_error($user->lang[$message]); - } - break; - - case 'addusers': - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP']); - } - - if (!$name_ary) - { - trigger_error($user->lang['NO_USERS']); - } - - $name_ary = array_unique(explode("\n", $name_ary)); - - // Add user/s to group - if ($error = group_user_add($group_id, false, $name_ary, $group_row['group_name'], $default, $leader, $group_row)) - { - trigger_error($user->lang[$error]); - } - - $message = ($action == 'addleaders') ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED'; - trigger_error($user->lang[$message]); - break; - - case 'edit': - case 'add': - - $data = $submit_ary = array(); - - if ($action == 'edit' && !$group_id) - { - trigger_error($user->lang['NO_GROUP']); - } - - $error = array(); - $user->add_lang('ucp'); - - // Did we submit? - if ($update) - { - $group_name = request_var('group_name', ''); - $group_desc = request_var('group_description', ''); - $group_type = request_var('group_type', GROUP_FREE); - - $data['uploadurl'] = request_var('uploadurl', ''); - $data['remotelink'] = request_var('remotelink', ''); - $delete = request_var('delete', ''); - - $submit_ary = array( - 'colour' => request_var('group_colour', ''), - 'rank' => request_var('group_rank', 0), - 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, - 'message_limit' => request_var('group_message_limit', 0) - ); - - $avatar = ''; - - if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) - { - $data['width'] = request_var('width', ''); - $data['height'] = request_var('height', ''); - - // Avatar stuff - $var_ary = array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - ); - - if (!($error = validate_data($data, $var_ary))) - { - $data['user_id'] = "g$group_id"; - - if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); - } - else if ($data['remotelink']) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error); - } - } - } - else if ($delete) - { - $submit_ary['avatar'] = ''; - $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; - } - - if (($submit_ary['avatar'] && (!isset($group_row['group_avatar']) || $group_row['group_avatar'] != $submit_ary['avatar'])) || $delete) - { - if (isset($group_row['group_avatar']) && $group_row['group_avatar']) - { - avatar_delete($group_row['group_avatar']); - } - } - - // Only set the rank, colour, etc. if it's changed or if we're adding a new - // group. This prevents existing group members being updated if no changes - // were made. - - $group_attributes = array(); - foreach (array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'message_limit') as $test) - { - if ($action == 'add' || (isset($group_row['group_' . $test]) && $group_row['group_' . $test] != $submit_ary[$test])) - { - $group_attributes[$test] = $group_row['group_' . $test] = $submit_ary[$test]; - } - } - - if (!($error = group_create($group_id, $group_type, $group_name, $group_description, $group_attributes))) - { - $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; - trigger_error($message); - } - } - else if (!$group_id) - { - $group_name = request_var('group_name', ''); - $group_description = ''; - $group_type = GROUP_OPEN; - } - else - { - $group_name = $group_row['group_name']; - $group_description = $group_row['group_description']; - $group_type = $group_row['group_type']; - } - -?> - -

lang['MANAGE']; ?>

- -

lang['GROUP_EDIT_EXPLAIN']; ?>

- -sql_query($sql); - - $rank_options = ''; - if ($row = $db->sql_fetchrow($result)) - { - do - { - $selected = (!empty($group_rank) && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; - $rank_options .= ''; - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; - $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; - $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; - $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - - if (isset($group_row['group_avatar']) && $group_row['group_avatar']) - { - switch ($group_row['group_avatar_type']) - { - case AVATAR_UPLOAD: - $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; - break; - case AVATAR_GALLERY: - $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; - break; - } - $avatar_img .= $group_row['group_avatar']; - - $avatar_img = ''; - } - else - { - $avatar_img = ''; - } - - $display_gallery = (isset($_POST['displaygallery'])) ? true : false; - -?> - - - -
"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['GROUP_DETAILS']; ?>
', $error); ?>
lang['GROUP_NAME']; ?>:lang['G_' . $group_name] : $group_name; ?>
lang['GROUP_DESC']; ?>:
lang['GROUP_TYPE']; ?>:
lang['GROUP_TYPE_EXPLAIN']; ?>
/> lang['GROUP_OPEN']; ?>   /> lang['GROUP_REQUEST']; ?>   /> lang['GROUP_CLOSED']; ?>   " /> lang['GROUP_HIDDEN']; ?>
lang['GROUP_SETTINGS_SAVE']; ?>
lang['GROUP_RECEIVE_PM']; ?>: />
lang['GROUP_MESSAGE_LIMIT']; ?>:
lang['GROUP_MESSAGE_LIMIT_EXPLAIN']; ?>
lang['GROUP_COLOR']; ?>:
lang['GROUP_COLOR_EXPLAIN']; ?>
  [ " onclick="swatch();return false" target="_swatch">lang['COLOUR_SWATCH']; ?> ]
lang['GROUP_RANK']; ?>:
lang['GROUP_AVATAR']; ?>
lang['CURRENT_IMAGE']; ?>:
lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)); ?>



 lang['DELETE_AVATAR']; ?>
lang['UPLOAD_AVATAR_FILE']; ?>:
lang['UPLOAD_AVATAR_URL']; ?>:
lang['UPLOAD_AVATAR_URL_EXPLAIN']; ?>
lang['LINK_REMOTE_AVATAR']; ?>:
lang['LINK_REMOTE_AVATAR_EXPLAIN']; ?>
lang['LINK_REMOTE_SIZE']; ?>:
lang['LINK_REMOTE_SIZE_EXPLAIN']; ?>
px X px
lang['AVATAR_GALLERY']; ?>:
lang['AVATAR_GALLERY']; ?>
lang['AVATAR_CATEGORY']; ?>:   lang['AVATAR_PAGE']; ?>:  
- - - - - - - - - - - - - - -
{avatar_row.avatar_column.AVATAR_NAME}
- -
 
-
- -lang['NO_GROUP']); - } - -?> - -

lang['GROUP_MEMBERS']; ?>

- -

lang['GROUP_MEMBERS_EXPLAIN']; ?>

- -
"> - - - - - - - - - -sql_query($sql); - - $total_leaders = ($row = $db->sql_fetchrow($result)) ? $row['total_leaders'] : 0; - $db->sql_freeresult($result); - - // Total number of group members (non-leaders) - $sql = 'SELECT COUNT(user_id) AS total_members - FROM ' . USER_GROUP_TABLE . " - WHERE group_id = $group_id - AND group_leader <> 1"; - $result = $db->sql_query($sql); - - $total_members = ($row = $db->sql_fetchrow($result)) ? $row['total_members'] : 0; - $db->sql_freeresult($result); - - // Grab the members - $sql = 'SELECT u.user_id, u.username, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending - FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug - WHERE ug.group_id = $group_id - AND u.user_id = ug.user_id - ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username "; - $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - - $leader = $member = 0; - $group_data = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $type = ($row['group_leader']) ? 'leader' : 'member'; - - $group_data[$type][$$type]['user_id'] = $row['user_id']; - $group_data[$type][$$type]['group_id'] = $row['group_id']; - $group_data[$type][$$type]['username'] = $row['username']; - $group_data[$type][$$type]['user_regdate'] = $row['user_regdate']; - $group_data[$type][$$type]['user_posts'] = $row['user_posts']; - $group_data[$type][$$type]['user_pending'] = ($row['user_pending']) ? 1 : 0; - - $$type++; - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - if ($group_row['group_type'] != GROUP_SPECIAL) - { - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['USERNAME']; ?>lang['GROUP_DEFAULT']; ?>lang['JOINED']; ?>lang['POSTS']; ?>lang['MARK']; ?>
lang['GROUP_LEAD']; ?>
">lang['YES'] : $user->lang['NO']; ?>format_date($row['user_regdate'], $user->lang['DATE_FORMAT']); ?>
lang['GROUPS_NO_MODS']; ?>
lang['GROUP_APPROVED']; ?>
lang['GROUP_PENDING']; ?>
">lang['YES'] : $user->lang['NO']; ?>format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '-'; ?>
lang['GROUPS_NO_MEMBERS']; ?>
-   -
- - - - - - -
- lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?> 
- -
- - -

lang['ADD_USERS']; ?>

- -

lang['ADD_USERS_EXPLAIN']; ?>

- - - - - - - - - - - - - - - - - - - - -
lang['ADD_USERS']; ?>
lang['USER_GROUP_LEADER']; ?>: lang['YES']; ?>   lang['NO']; ?>
lang['USER_GROUP_DEFAULT']; ?>:
lang['USER_GROUP_DEFAULT_EXPLAIN']; ?>
lang['YES']; ?>   lang['NO']; ?>
lang['USERNAME']; ?>:
lang['USERNAMES_EXPLAIN']; ?>
[ " target="usersearch">lang['FIND_USERNAME']; ?> ]
- -
- - - -

lang['GROUP_MANAGE']; ?>

- -

lang['GROUP_MANAGE_EXPLAIN']; ?>

- -

lang['USER_DEF_GROUPS']; ?>

- -

lang['USER_DEF_GROUPS_EXPLAIN']; ?>

- -
"> - - - - - - - -sql_query($sql); - - $special = $normal = 0; - $group_ary = array(); - while ($row = $db->sql_fetchrow($result) ) - { - $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal'; - - $group_ary[$type][$$type]['group_id'] = $row['group_id']; - $group_ary[$type][$$type]['group_name'] = $row['group_name']; - $group_ary[$type][$$type]['group_type'] = $row['group_type']; - $group_ary[$type][$$type]['total_members'] = $row['total_members']; - - $$type++; - } - $db->sql_freeresult($result); - - $special_toggle = false; - foreach ($group_ary as $type => $row_ary) - { - if ($type == 'special') - { - -?> - - - -
lang['MANAGE']; ?>lang['TOTAL_MEMBERS']; ?>lang['OPTIONS']; ?>
lang['CREATE_GROUP']; ?>:
- -

lang['SPECIAL_GROUPS']; ?>

- -

lang['SPECIAL_GROUPS_EXPLAIN']; ?>

- - - - - - - -lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name']; - -?> - - - - - - - - - - - -
lang['MANAGE']; ?>lang['TOTAL_MEMBERS']; ?>lang['OPTIONS']; ?>
">   ">lang['GROUP_DEFAULT']; ?>  ">lang['EDIT']; ?>  " . $user->lang['DELETE'] . '' : $user->lang['DELETE']; - -?> 
 
-
- -lang['GROUP_PREFS']); - - if ($update) - { - $user_lang = request_var('lang', ''); - $user_tz = request_var('tz', 0.0); - $user_dst = request_var('dst', 0); - } - else - { - } - -?> -

lang['GROUP_SETTINGS']; ?>

- -

lang['GROUP_SETTINGS_EXPLAIN']; ?>

- -
"> - - - - - - - - - - - - - - - - - - -
lang['GROUP_SETTINGS']; ?>
lang['GROUP_LANG']; ?>:
lang['GROUP_TIMEZONE']; ?>:
lang['GROUP_DST']; ?>: lang['DISABLED']; ?>   lang['ENABLED']; ?>   lang['USER_DEFAULT']; ?>
 
- -lang['NO_MODE']); -} - -exit; - -?> \ No newline at end of file diff --git a/phpBB/includes/acm/acm_db.php b/phpBB/includes/acm/acm_db.php index ecabae0fd5..a9b75a9a77 100644 --- a/phpBB/includes/acm/acm_db.php +++ b/phpBB/includes/acm/acm_db.php @@ -159,7 +159,7 @@ class acm if (empty($this->var_ready[$var_name])) { $this->vars[$var_name] = unserialize($this->vars[$var_name]); - $this->var_ready[$var_name] = TRUE; + $this->var_ready[$var_name] = true; } return $this->vars[$var_name]; diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 4efc3621e1..8f7e79aad5 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -132,7 +132,7 @@ class acm if ($fp = @fopen($this->cache_dir . 'data' . $var_name . ".$phpEx", 'wb')) { @flock($fp, LOCK_EX); - fwrite($fp, " " . (time() + $ttl) . ") ? TRUE : FALSE;\nif (\$expired) { return; }\n\n\$data = unserialize('" . str_replace("'", "\\'", str_replace('\\', '\\\\', serialize($var))) . "');\n?>"); + fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$data = unserialize('" . str_replace("'", "\\'", str_replace('\\', '\\\\', serialize($var))) . "');\n?>"); @flock($fp, LOCK_UN); fclose($fp); } @@ -141,7 +141,7 @@ class acm { $this->vars[$var_name] = $var; $this->var_expires[$var_name] = time() + $ttl; - $this->is_modified = TRUE; + $this->is_modified = true; } } @@ -172,13 +172,13 @@ class acm } @closedir($dir); } - elseif ($var_name{0} == '_') + else if ($var_name{0} == '_') { @unlink($this->cache_dir . 'data' . $var_name . ".$phpEx"); } - elseif (isset($this->vars[$var_name])) + else if (isset($this->vars[$var_name])) { - $this->is_modified = TRUE; + $this->is_modified = true; unset($this->vars[$var_name]); unset($this->var_expires[$var_name]); } @@ -216,13 +216,13 @@ class acm { $lines[] = "'$k'=>" . $this->format_array($v); } - elseif (is_int($v)) + else if (is_int($v)) { $lines[] = "'$k'=>$v"; } - elseif (is_bool($v)) + else if (is_bool($v)) { - $lines[] = "'$k'=>" . (($v) ? 'TRUE' : 'FALSE'); + $lines[] = "'$k'=>" . (($v) ? 'true' : 'false'); } else { @@ -249,12 +249,12 @@ class acm if (!isset($expired)) { - return FALSE; + return false; } - elseif ($expired) + else if ($expired) { unlink($this->cache_dir . 'sql_' . md5($query) . ".$phpEx"); - return FALSE; + return false; } return $query_id; @@ -283,7 +283,7 @@ class acm } $db->sql_freeresult($query_result); - fwrite($fp, " " . (time() + $ttl) . ") ? TRUE : FALSE;\nif (\$expired) { return; }\n\n\$this->sql_rowset[\$query_id] = array(" . implode(',', $lines) . ') ?>'); + fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$this->sql_rowset[\$query_id] = array(" . implode(',', $lines) . ') ?>'); @flock($fp, LOCK_UN); fclose($fp); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php new file mode 100644 index 0000000000..70715f2e1f --- /dev/null +++ b/phpBB/includes/acp/acp_groups.php @@ -0,0 +1,700 @@ +add_lang('acp/groups'); + $this->tpl_name = 'acp_groups'; + $this->page_title = 'ACP_GROUPS_MANAGE'; + + $u_action = "{$phpbb_admin_path}index.$phpEx$SID&i=$id&mode=$mode"; + + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + + // Check and set some common vars + $action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', '')); + $group_id = request_var('g', 0); + $mark_ary = request_var('mark', array(0)); + $name_ary = request_var('usernames', ''); + $leader = request_var('leader', 0); + $default = request_var('default', 0); + $start = request_var('start', 0); + $update = (isset($_POST['update'])) ? true : false; + + // Clear some vars + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + $group_row = array(); + + // Grab basic data for group, if group_id is set and exists + if ($group_id) + { + $sql = 'SELECT * + FROM ' . GROUPS_TABLE . " + WHERE group_id = $group_id"; + $result = $db->sql_query($sql); + $group_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$group_row) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + } + + // Which page? + switch ($action) + { + case 'approve': + case 'demote': + case 'promote': + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + // Approve, demote or promote + group_user_attributes($action, $group_id, $mark_ary, false, ($group_id) ? $group_row['group_name'] : false); + + switch ($action) + { + case 'demote': + $message = 'GROUP_MODS_DEMOTED'; + break; + + case 'promote': + $message = 'GROUP_MODS_PROMOTED'; + break; + + case 'approve': + $message = 'USERS_APPROVED'; + break; + } + + trigger_error($user->lang[$message] . adm_back_link($u_action)); + break; + + case 'default': + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + if (confirm_box(true)) + { + if (!sizeof($mark_ary)) + { + $start = 0; + + do + { + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + ORDER BY user_id"; + $result = $db->sql_query_limit($sql, 200, $start); + + $mark_ary = array(); + if ($row = $db->sql_fetchrow($result)) + { + do + { + $mark_ary[] = $row['user_id']; + } + while ($row = $db->sql_fetchrow($result)); + + group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); + + $start = (sizeof($mark_ary) < 200) ? 0 : $start + 200; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + } + else + { + group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row); + } + + trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($u_action)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); + } + + break; + + case 'deleteusers': + case 'delete': + if (confirm_box(true)) + { + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + $error = ''; + + switch ($action) + { + case 'delete': + $error = group_delete($group_id, $group_row['group_name']); + break; + + case 'deleteusers': + $error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']); + break; + } + + if ($error) + { + trigger_error($user->lang[$error] . adm_back_link($u_action)); + } + + $message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE'; + trigger_error($user->lang[$message] . adm_back_link($u_action)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'mark' => $mark_ary, + 'g' => $group_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action)) + ); + } + break; + + case 'addusers': + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + if (!$name_ary) + { + trigger_error($user->lang['NO_USERS'] . adm_back_link($u_action)); + } + + $name_ary = array_unique(explode("\n", $name_ary)); + + // Add user/s to group + if ($error = group_user_add($group_id, false, $name_ary, $group_row['group_name'], $default, $leader, 0, $group_row)) + { + trigger_error($user->lang[$error] . adm_back_link($u_action)); + } + + $message = ($action == 'addleaders') ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED'; + trigger_error($user->lang[$message] . adm_back_link($u_action)); + break; + + case 'edit': + case 'add': + + $data = $submit_ary = array(); + + if ($action == 'edit' && !$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + $error = array(); + $user->add_lang('ucp'); + + $avatar_select = basename(request_var('avatar_select', '')); + $category = basename(request_var('category', '')); + + // Did we submit? + if ($update) + { + $group_name = request_var('group_name', ''); + $group_description = request_var('group_description', ''); + $group_type = request_var('group_type', GROUP_FREE); + + $data['uploadurl'] = request_var('uploadurl', ''); + $data['remotelink'] = request_var('remotelink', ''); + $delete = request_var('delete', ''); + + $submit_ary = array( + 'colour' => request_var('group_colour', ''), + 'rank' => request_var('group_rank', 0), + 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, + 'message_limit' => request_var('group_message_limit', 0) + ); + + if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) + { + $data['width'] = request_var('width', ''); + $data['height'] = request_var('height', ''); + + // Avatar stuff + $var_ary = array( + 'uploadurl' => array('string', true, 5, 255), + 'remotelink' => array('string', true, 5, 255), + 'width' => array('string', true, 1, 3), + 'height' => array('string', true, 1, 3), + ); + + if (!($error = validate_data($data, $var_ary))) + { + $data['user_id'] = "g$group_id"; + + if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) + { + list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); + } + else if ($data['remotelink']) + { + list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error); + } + } + } + else if ($avatar_select && $config['allow_avatar_local']) + { + // check avatar gallery + if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) + { + $submit_ary['avatar_type'] = AVATAR_GALLERY; + + list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select); + $submit_ary['avatar'] = $category . '/' . $avatar_select; + } + } + else if ($delete) + { + $submit_ary['avatar'] = ''; + $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; + } + + if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']) || $group_row['group_avatar'] != $submit_ary['avatar'])) || $delete) + { + if (isset($group_row['group_avatar']) && $group_row['group_avatar']) + { + avatar_delete($group_row['group_avatar']); + } + } + + // Only set the rank, colour, etc. if it's changed or if we're adding a new + // group. This prevents existing group members being updated if no changes + // were made. + + $group_attributes = array(); + $test_variables = array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'message_limit'); + foreach ($test_variables as $test) + { + if ($action == 'add' || (isset($submit_ary[$test]) && $group_row['group_' . $test] != $submit_ary[$test])) + { + $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; + } + } + + if (!($error = group_create($group_id, $group_type, $group_name, $group_description, $group_attributes))) + { + $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; + trigger_error($user->lang[$message] . adm_back_link($u_action)); + } + } + else if (!$group_id) + { + $group_name = request_var('group_name', ''); + $group_description = ''; + $group_rank = 0; + $group_type = GROUP_OPEN; + } + else + { + $group_name = $group_row['group_name']; + $group_description = $group_row['group_description']; + $group_type = $group_row['group_type']; + $group_rank = $group_row['group_rank']; + } + + $sql = 'SELECT * + FROM ' . RANKS_TABLE . ' + WHERE rank_special = 1 + ORDER BY rank_title'; + $result = $db->sql_query($sql); + + $rank_options = ''; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; + $rank_options .= ''; + } + while ($row = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + + $type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : ''; + $type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : ''; + $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; + $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; + + if (isset($group_row['group_avatar']) && $group_row['group_avatar']) + { + switch ($group_row['group_avatar_type']) + { + case AVATAR_UPLOAD: + $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; + break; + case AVATAR_GALLERY: + $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; + break; + } + $avatar_img .= $group_row['group_avatar']; + + $avatar_img = ''; + } + else + { + $avatar_img = ''; + } + + $display_gallery = (isset($_POST['display_gallery'])) ? true : false; + + if ($config['allow_avatar_local'] && $display_gallery) + { + avatar_gallery($category, $avatar_select, 4); + } + + $template->assign_vars(array( + 'S_EDIT' => true, + 'S_INCLUDE_SWATCH' => true, + 'S_CAN_UPLOAD' => $can_upload, + 'S_ERROR' => (sizeof($error)) ? true : false, + 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, + 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, + 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, + + 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', + 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, + 'GROUP_DESCRIPTION' => $group_description, + 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', + 'GROUP_MESSAGE_LIMIT' => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0, + 'GROUP_COLOUR' => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '', + + 'S_RANK_OPTIONS' => $rank_options, + 'AVATAR_IMAGE' => $avatar_img, + 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], + 'GROUP_AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', + 'GROUP_AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', + + 'GROUP_TYPE_FREE' => GROUP_FREE, + 'GROUP_TYPE_OPEN' => GROUP_OPEN, + 'GROUP_TYPE_CLOSED' => GROUP_CLOSED, + 'GROUP_TYPE_HIDDEN' => GROUP_HIDDEN, + 'GROUP_FREE' => $type_free, + 'GROUP_OPEN' => $type_open, + 'GROUP_CLOSED' => $type_closed, + 'GROUP_HIDDEN' => $type_hidden, + + 'U_BACK' => $u_action, + 'U_SWATCH' => "{$phpbb_admin_path}swatch.$phpEx$SID&form=settings&name=group_colour", + 'U_ACTION' => "{$u_action}&action=$action&g=$group_id", + 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)), + ) + ); + + return; + break; + + case 'list': + + if (!$group_id) + { + trigger_error($user->lang['NO_GROUP'] . adm_back_link($u_action)); + } + + $this->page_title = 'GROUP_MEMBERS'; + + // Total number of group leaders + $sql = 'SELECT COUNT(user_id) AS total_leaders + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + AND group_leader = 1"; + $result = $db->sql_query($sql); + + $total_leaders = (int) $db->sql_fetchfield('total_leaders', 0, $result); + $db->sql_freeresult($result); + + // Total number of group members (non-leaders) + $sql = 'SELECT COUNT(user_id) AS total_members + FROM ' . USER_GROUP_TABLE . " + WHERE group_id = $group_id + AND group_leader <> 1"; + $result = $db->sql_query($sql); + + $total_members = (int) $db->sql_fetchfield('total_members', 0, $result); + $db->sql_freeresult($result); + + // Grab the members + $sql = 'SELECT u.user_id, u.username, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending + FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug + WHERE ug.group_id = $group_id + AND u.user_id = ug.user_id + ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username"; + $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); + + $leader = $member = 0; + $group_data = array(); + + while ($row = $db->sql_fetchrow($result)) + { + $type = ($row['group_leader']) ? 'leader' : 'member'; + + $group_data[$type][$$type]['user_id'] = $row['user_id']; + $group_data[$type][$$type]['group_id'] = $row['group_id']; + $group_data[$type][$$type]['username'] = $row['username']; + $group_data[$type][$$type]['user_regdate'] = $row['user_regdate']; + $group_data[$type][$$type]['user_posts'] = $row['user_posts']; + $group_data[$type][$$type]['user_pending'] = ($row['user_pending']) ? 1 : 0; + + $$type++; + } + $db->sql_freeresult($result); + + $s_action_options = ''; + $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE'); + + foreach ($options as $option => $lang) + { + $s_action_options .= ''; + } + + $template->assign_vars(array( + 'S_LIST' => true, + 'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false, + 'S_ACTION_OPTIONS' => $s_action_options, + + 'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start), + 'PAGINATION' => generate_pagination($u_action . "&action=$action&g=$group_id", $total_members, $config['topics_per_page'], $start, true), + + 'U_ACTION' => $u_action . "&g=$group_id", + 'U_BACK' => $u_action, + 'U_FIND_USERNAME' => $phpbb_root_path . "memberlist.$phpEx$SID&mode=searchuser&form=list&field=usernames") + ); + + if ($group_row['group_type'] != GROUP_SPECIAL) + { + foreach ($group_data['leader'] as $row) + { + $template->assign_block_vars('leader', array( + 'U_USER_EDIT' => $phpbb_admin_path . "index.$phpEx$SID&i=users&action=edit&u={$row['user_id']}", + + 'USERNAME' => $row['username'], + 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, + 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '-', + 'USER_POSTS' => $row['user_posts'], + 'USER_ID' => $row['user_id']) + ); + } + } + + $pending = false; + + foreach ($group_data['member'] as $row) + { + if ($row['user_pending'] && !$pending) + { + $template->assign_block_vars('member', array( + 'S_PENDING' => true) + ); + + $pending = true; + } + + $template->assign_block_vars('member', array( + 'U_USER_EDIT' => $phpbb_admin_path . "index.$phpEx$SID&i=users&action=edit&u={$row['user_id']}", + + 'USERNAME' => $row['username'], + 'S_GROUP_DEFAULT' => ($row['group_id'] == $group_id) ? true : false, + 'JOINED' => ($row['user_regdate']) ? $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '-', + 'USER_POSTS' => $row['user_posts'], + 'USER_ID' => $row['user_id']) + ); + } + + return; + break; + } + + $template->assign_vars(array( + 'U_ACTION' => $u_action, + ) + ); + + $sql = 'SELECT g.group_id, g.group_name, g.group_type, COUNT(ug.user_id) AS total_members + FROM ' . GROUPS_TABLE . ' g + LEFT JOIN ' . USER_GROUP_TABLE . ' ug USING (group_id) + GROUP BY g.group_id + ORDER BY g.group_type ASC, g.group_name'; + $result = $db->sql_query($sql); + + $special = $normal = 0; + $group_ary = array(); + + while ($row = $db->sql_fetchrow($result)) + { + $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal'; + + $group_ary[$type][$$type]['group_id'] = $row['group_id']; + $group_ary[$type][$$type]['group_name'] = $row['group_name']; + $group_ary[$type][$$type]['group_type'] = $row['group_type']; + $group_ary[$type][$$type]['total_members'] = $row['total_members']; + + $$type++; + } + $db->sql_freeresult($result); + + $special_toggle = false; + foreach ($group_ary as $type => $row_ary) + { + if ($type == 'special') + { + $template->assign_block_vars('groups', array( + 'S_SPECIAL' => true) + ); + } + + foreach ($row_ary as $row) + { + $group_id = $row['group_id']; + $group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name']; + + $template->assign_block_vars('groups', array( + 'U_LIST' => "{$u_action}&action=list&g=$group_id", + 'U_DEFAULT' => "{$u_action}&action=default&g=$group_id", + 'U_EDIT' => "{$u_action}&action=edit&g=$group_id", + 'U_DELETE' => "{$u_action}&action=delete&g=$group_id", + + 'S_GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL) ? true : false, + + 'GROUP_NAME' => $group_name, + 'TOTAL_MEMBERS' => $row['total_members'], + ) + ); + } + } + } +} + +/** +* @package module_install +*/ +class acp_groups_info +{ + function module() + { + return array( + 'filename' => 'acp_groups', + 'title' => 'ACP_GROUPS_MANAGEMENT', + 'version' => '1.0.0', + 'modes' => array( + 'manage' => array('title' => 'ACP_GROUPS_MANAGE', 'auth' => 'acl_a_group'), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + + + +/* + +   + + + + +lang['GROUP_PREFS']); + + if ($update) + { + $user_lang = request_var('lang', ''); + $user_tz = request_var('tz', 0.0); + $user_dst = request_var('dst', 0); + } + else + { + } + +?> +

lang['GROUP_SETTINGS']; ?>

+ +

lang['GROUP_SETTINGS_EXPLAIN']; ?>

+ +
"> + + + + + + + + + + + + + + + + + + +
lang['GROUP_SETTINGS']; ?>
lang['GROUP_LANG']; ?>:
lang['GROUP_TIMEZONE']; ?>:
lang['GROUP_DST']; ?>: lang['DISABLED']; ?>   lang['ENABLED']; ?>   lang['USER_DEFAULT']; ?>
 
+ +lang['NO_MODE']); +} + +exit; +*/ + + +?> \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index f25e41443e..6e40431f62 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1476,7 +1476,7 @@ function build_hidden_fields($field_ary) function msg_handler($errno, $msg_text, $errfile, $errline) { global $cache, $db, $auth, $template, $config, $user; - global $phpEx, $phpbb_root_path, $starttime, $display_header, $msg_title; + global $phpEx, $phpbb_root_path, $starttime, $msg_title; switch ($errno) { @@ -1528,23 +1528,21 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $user->setup(); } + $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; + $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); + if (!defined('HEADER_INC')) { if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) { - // adm_page_header('', '', false); - adm_page_header(''); + adm_page_header($msg_title); } else { - page_header(''); + page_header($msg_title); } } - $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; - $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); - $display_header = (!isset($display_header)) ? false : (bool) $display_header; - $template->set_filenames(array( 'body' => 'message_body.html') ); @@ -1556,7 +1554,15 @@ function msg_handler($errno, $msg_text, $errfile, $errline) // We do not want the cron script to be called on error messages define('IN_CRON', true); - page_footer(); + + if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) + { + adm_page_footer(); + } + else + { + page_footer(); + } exit; break; @@ -1570,6 +1576,11 @@ function page_header($page_title = '') { global $db, $config, $template, $SID, $user, $auth, $phpEx, $phpbb_root_path; + if (defined('HEADER_INC')) + { + return; + } + define('HEADER_INC', true); // gzip_compression diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index ba43943406..5c5f7e30e2 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -382,16 +382,30 @@ class p_master */ function display($page_title) { - global $template; + global $template, $user; // Generate the page - page_header($page_title); + if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) + { + adm_page_header($page_title); + } + else + { + page_header($page_title); + } $template->set_filenames(array( 'body' => $this->get_tpl_name()) ); - page_footer(); + if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) + { + adm_page_footer(); + } + else + { + page_footer(); + } } /** diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php new file mode 100644 index 0000000000..01ed80f61d --- /dev/null +++ b/phpBB/includes/functions_template.php @@ -0,0 +1,668 @@ +template = &$template; + } + + /** + * Load template source from file + * @private + */ + function _tpl_load_file($handle) + { + // Try and open template for read + if (!($fp = @fopen($this->template->files[$handle], 'r'))) + { + trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); + } + + $this->template->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->template->files[$handle])))); + @fclose($fp); + + // Actually compile the code now. + $this->compile_write($handle, $this->template->compiled_code[$handle]); + } + + /** + * The all seeing all doing compile method. Parts are inspired by or directly + * from Smarty + * @private + */ + function compile($code, $no_echo = false, $echo_var = '') + { + global $config; + + if ($echo_var) + { + global $$echo_var; + } + + // Remove any "loose" php ... we want to give admins the ability + // to switch on/off PHP for a given template. Allowing unchecked + // php is a no-no. There is a potential issue here in that non-php + // content may be removed ... however designers should use entities + // if they wish to display < and > + $match_php_tags = array('#\<\?php .*?\?\>#is', '#\<\script language="php"\>.*?\<\/script\>#is', '#\<\?.*?\?\>#s', '#\<%.*?%\>#s'); + $code = preg_replace($match_php_tags, '', $code); + + // Pull out all block/statement level elements and seperate plain text + preg_match_all('#(.*?)#s', $code, $matches); + $php_blocks = $matches[1]; + $code = preg_replace('#(.*?)#s', '', $code); + + preg_match_all('##', $code, $matches); + $include_blocks = $matches[1]; + $code = preg_replace('##', '', $code); + + preg_match_all('##', $code, $matches); + $includephp_blocks = $matches[1]; + $code = preg_replace('##', '', $code); + + preg_match_all('##', $code, $blocks); + $text_blocks = preg_split('##', $code); + + for ($i = 0, $j = sizeof($text_blocks); $i < $j; $i++) + { + $this->compile_var_tags($text_blocks[$i]); + } + $compile_blocks = array(); + + for ($curr_tb = 0, $tb_size = sizeof($text_blocks); $curr_tb < $tb_size; $curr_tb++) + { + if (!isset($blocks[1][$curr_tb])) + { + $blocks[1][$curr_tb] = ''; + } + + switch ($blocks[1][$curr_tb]) + { + case 'BEGIN': + $this->template->block_else_level[] = false; + $compile_blocks[] = 'compile_tag_block($blocks[2][$curr_tb]) . ' ?>'; + break; + + case 'BEGINELSE': + $this->template->block_else_level[sizeof($this->template->block_else_level) - 1] = true; + $compile_blocks[] = ''; + break; + + case 'END': + array_pop($this->template->block_names); + $compile_blocks[] = 'template->block_else_level)) ? '}' : '}}') . ' ?>'; + break; + + case 'IF': + $compile_blocks[] = 'compile_tag_if($blocks[2][$curr_tb], false) . ' ?>'; + break; + + case 'ELSE': + $compile_blocks[] = ''; + break; + + case 'ELSEIF': + $compile_blocks[] = 'compile_tag_if($blocks[2][$curr_tb], true) . ' ?>'; + break; + + case 'ENDIF': + $compile_blocks[] = ''; + break; + + case 'DEFINE': + $compile_blocks[] = 'compile_tag_define($blocks[2][$curr_tb], true) . ' ?>'; + break; + + case 'UNDEFINE': + $compile_blocks[] = 'compile_tag_define($blocks[2][$curr_tb], false) . ' ?>'; + break; + + case 'INCLUDE': + $temp = ''; + list(, $temp) = each($include_blocks); + $compile_blocks[] = 'compile_tag_include($temp) . ' ?>'; + $this->template->_tpl_include($temp, false); + break; + + case 'INCLUDEPHP': + if ($config['tpl_php']) + { + $temp = ''; + list(, $temp) = each($includephp_blocks); + $compile_blocks[] = 'compile_tag_include_php($temp) . ' ?>'; + } + else + { + $compile_blocks[] = ''; + } + break; + + case 'PHP': + if ($config['tpl_php']) + { + $temp = ''; + list(, $temp) = each($php_blocks); + $compile_blocks[] = ''; + } + else + { + $compile_blocks[] = ''; + } + break; + + default: + $this->compile_var_tags($blocks[0][$curr_tb]); + $trim_check = trim($blocks[0][$curr_tb]); + $compile_blocks[] = (!$no_echo) ? ((!empty($trim_check)) ? $blocks[0][$curr_tb] : '') : ((!empty($trim_check)) ? $blocks[0][$curr_tb] : ''); + break; + } + } + + $template_php = ''; + for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++) + { + $trim_check_text = trim($text_blocks[$i]); + $trim_check_block = trim($compile_blocks[$i]); + $template_php .= (!$no_echo) ? ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '') : ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : ''); + } + + // There will be a number of occassions where we switch into and out of + // PHP mode instantaneously. Rather than "burden" the parser with this + // we'll strip out such occurences, minimising such switching + $template_php = str_replace(' ?>generate_block_varref($namespace, $varname, true, $varrefs[3][$j]); + + $text_blocks = str_replace($varrefs[0][$j], $new, $text_blocks); + } + + // This will handle the remaining root-level varrefs + if (!$this->template->static_lang) + { + $text_blocks = preg_replace('#\{L_([a-z0-9\-_]*?)\}#is', "_tpldata['.'][0]['L_\\1'])) ? \$this->_tpldata['.'][0]['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ ' . ucfirst(strtolower(str_replace('_', ' ', '\\1'))) . ' }')); ?>", $text_blocks); + } + else + { + global $user; + + $text_blocks = preg_replace('#\{L_([A-Z0-9\-_]*?)\}#e', "'_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks); + } + + $text_blocks = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "_tpldata['.'][0]['\\1'])) ? \$this->_tpldata['.'][0]['\\1'] : ''; ?>", $text_blocks); + $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*?)\}#is', "_tpldata['DEFINE']['.']['\\1'])) ? \$this->_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks); + + return; + } + + /** + * Compile blocks + * @private + */ + function compile_tag_block($tag_args) + { + // Allow for control of looping (indexes start from zero): + // foo(2) : Will start the loop on the 3rd entry + // foo(-2) : Will start the loop two entries from the end + // foo(3,4) : Will start the loop on the fourth entry and end it on the fifth + // foo(3,-4) : Will start the loop on the fourth entry and end it four from last + if (preg_match('#^(.*?)\(([\-0-9]+)(,([\-0-9]+))?\)$#', $tag_args, $match)) + { + $tag_args = $match[1]; + + if ($match[2] < 0) + { + $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; + } + else + { + $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; + } + + if (strlen($match[4]) < 1 || $match[4] == -1) + { + $loop_end = '$_' . $tag_args . '_count'; + } + else if ($match[4] >= 0) + { + $loop_end = '(' . ($match[4] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[4] + 1) . ')'; + } + else //if ($match[4] < -1) + { + $loop_end = '$_' . $tag_args . '_count' . ($match[4] + 1); + } + } + else + { + $loop_start = 0; + $loop_end = '$_' . $tag_args . '_count'; + } + + $tag_template_php = ''; + array_push($this->template->block_names, $tag_args); + + if (sizeof($this->template->block_names) < 2) + { + // Block is not nested. + $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; + } + else + { + // This block is nested. + + // Generate a namespace string for this block. + $namespace = implode('.', $this->template->block_names); + + // Get a reference to the data array for this block that depends on the + // current indices of all parent blocks. + $varref = $this->generate_block_data_ref($namespace, false); + + // Create the for loop code to iterate over this block. + $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;'; + } + + $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; + $tag_template_php .= 'for ($this->_' . $tag_args . '_i = ' . $loop_start . '; $this->_' . $tag_args . '_i < ' . $loop_end . '; $this->_' . $tag_args . '_i++){'; + + return $tag_template_php; + } + + /** + * Compile IF tags - much of this is from Smarty with + * some adaptions for our block level methods + * @private + */ + function compile_tag_if($tag_args, $elseif) + { + // Tokenize args for 'if' tag. + preg_match_all('/(?: + "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | + \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | + [(),] | + [^\s(),]+)/x', $tag_args, $match); + + $tokens = $match[0]; + $is_arg_stack = array(); + + for ($i = 0, $size = sizeof($tokens); $i < $size; $i++) + { + $token = &$tokens[$i]; + + switch ($token) + { + case '!': + case '%': + case '!==': + case '==': + case '===': + case '>': + case '<': + case '!=': + case '<>': + case '<<': + case '>>': + case '<=': + case '>=': + case '&&': + case '||': + case '|': + case '^': + case '&': + case '~': + case ')': + case ',': + case '+': + case '-': + case '*': + case '/': + case '@': + break; + + case 'eq': + $token = '=='; + break; + + case 'ne': + case 'neq': + $token = '!='; + break; + + case 'lt': + $token = '<'; + break; + + case 'le': + case 'lte': + $token = '<='; + break; + + case 'gt': + $token = '>'; + break; + + case 'ge': + case 'gte': + $token = '>='; + break; + + case 'and': + $token = '&&'; + break; + + case 'or': + $token = '||'; + break; + + case 'not': + $token = '!'; + break; + + case 'mod': + $token = '%'; + break; + + case '(': + array_push($is_arg_stack, $i); + break; + + case 'is': + $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; + $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); + + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); + + array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); + + $i = $is_arg_start; + + default: + if (preg_match('#^(([a-z0-9\-_]+?\.)+?)?(\$)?([A-Z]+[A-Z0-9\-_]+)$#s', $token, $varrefs)) + { + $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[3]) . '[\'' . $varrefs[4] . '\']' : (($varrefs[3]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[4] . '\']' : '$this->_tpldata[\'.\'][0][\'' . $varrefs[4] . '\']'); + } + else if (preg_match('#^\.((([a-z0-9\-_]+)?\.?)+?)$#s', $token, $varrefs)) + { + $_tok = $this->generate_block_data_ref($varrefs[1], false); + $token = "(isset($_tok) && sizeof($_tok))"; + } + + break; + } + } + + return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); + } + + /** + * Compile DEFINE tags + * @private + */ + function compile_tag_define($tag_args, $op) + { + preg_match('#^(([a-z0-9\-_]+?\.)+?)?\$([A-Z][A-Z0-9_\-]*?)( = (\'?)(.*?)(\'?))?$#', $tag_args, $match); + + if (empty($match[3]) || (empty($match[6]) && $op)) + { + return; + } + + if (!$op) + { + return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[3] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[3] . '\']') . ');'; + } + + // Are we a string? + if ($match[5] && $match[7]) + { + $match[6] = addslashes(str_replace(array('\\\'', '\\\\'), array('\'', '\\'), $match[6])); + + // Compile reference, we allow template variables in defines... + $match[6] = $this->compile($match[6]); + + // Now replace the php code + $match[6] = "'" . str_replace(array(''), array("' . ", " . '"), $match[6]) . "'"; + } + else + { + preg_match('#(true|false|\.)#i', $match[6], $type); + + switch (strtolower($type[1])) + { + case 'true': + case 'false': + $match[6] = strtoupper($match[6]); + break; + case '.'; + $match[6] = doubleval($match[6]); + break; + default: + $match[6] = intval($match[6]); + break; + } + } + + return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[3] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[3] . '\']') . ' = ' . $match[6] . ';'; + } + + /** + * Compile INCLUDE tag + * @private + */ + function compile_tag_include($tag_args) + { + return "\$this->_tpl_include('$tag_args');"; + } + + /** + * Compile INCLUDE_PHP tag + * @private + */ + function compile_tag_include_php($tag_args) + { + return "include('" . $this->template->root . '/' . $tag_args . "');"; + } + + /** + * parse expression + * This is from Smarty + * @private + */ + function _parse_is_expr($is_arg, $tokens) + { + $expr_end = 0; + $negate_expr = false; + + if (($first_token = array_shift($tokens)) == 'not') + { + $negate_expr = true; + $expr_type = array_shift($tokens); + } + else + { + $expr_type = $first_token; + } + + switch ($expr_type) + { + case 'even': + if (@$tokens[$expr_end] == 'by') + { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; + } + else + { + $expr = "!($is_arg % 2)"; + } + break; + + case 'odd': + if (@$tokens[$expr_end] == 'by') + { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "(($is_arg / $expr_arg) % $expr_arg)"; + } + else + { + $expr = "($is_arg % 2)"; + } + break; + + case 'div': + if (@$tokens[$expr_end] == 'by') + { + $expr_end++; + $expr_arg = $tokens[$expr_end++]; + $expr = "!($is_arg % $expr_arg)"; + } + break; + + default: + break; + } + + if ($negate_expr) + { + $expr = "!($expr)"; + } + + array_splice($tokens, 0, $expr_end, $expr); + + return $tokens; + } + + /** + * Generates a reference to the given variable inside the given (possibly nested) + * block namespace. This is a string of the form: + * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' + * It's ready to be inserted into an "echo" line in one of the templates. + * NOTE: expects a trailing "." on the namespace. + * @private + */ + function generate_block_varref($namespace, $varname, $echo = true, $defop = false) + { + // Strip the trailing period. + $namespace = substr($namespace, 0, -1); + + // Get a reference to the data block for this namespace. + $varref = $this->generate_block_data_ref($namespace, true, $defop); + // Prepend the necessary code to stick this in an echo line. + + // Append the variable reference. + $varref .= "['$varname']"; + $varref = ($echo) ? "" : ((isset($varref)) ? $varref : ''); + + return $varref; + } + + /** + * Generates a reference to the array of data values for the given + * (possibly nested) block namespace. This is a string of the form: + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] + * + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. + * NOTE: does not expect a trailing "." on the blockname. + * @private + */ + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) + { + // Get an array of the blocks involved. + $blocks = explode('.', $blockname); + $blockcount = sizeof($blocks) - 1; + $varref = '$this->_tpldata' . (($defop) ? '[\'DEFINE\']' : ''); + + // Build up the string with everything but the last child. + for ($i = 0; $i < $blockcount; $i++) + { + $varref .= "['" . $blocks[$i] . "'][\$this->_" . $blocks[$i] . '_i]'; + } + + // Add the block reference for the last child. + $varref .= "['" . $blocks[$blockcount] . "']"; + + // Add the iterator for the last child if requried. + if ($include_last_iterator) + { + $varref .= '[$this->_' . $blocks[$blockcount] . '_i]'; + } + + return $varref; + } + + /** + * Write compiled file to cache directory + * @private + */ + function compile_write(&$handle, $data) + { + global $phpEx, $user; + + $filename = $this->template->cachepath . $this->template->filename[$handle] . '.' . (($this->template->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx; + + if ($fp = @fopen($filename, 'wb')) + { + @flock($fp, LOCK_EX); + @fwrite ($fp, $data); + @flock($fp, LOCK_UN); + @fclose($fp); + + @umask(0); + @chmod($filename, 0644); + } + + return; + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c5593c5ba3..f308f4805f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -49,7 +49,7 @@ function user_get_id_name(&$user_id_ary, &$username_ary) return 'NO_USERS'; } - $id_ary = $username_ary = array(); + $user_id_ary = $username_ary = array(); do { $username_ary[$row['user_id']] = $row['username']; @@ -1061,57 +1061,98 @@ function avatar_upload($data, &$error) /** * Avatar Gallery */ -function avatar_gallery($category, &$error) +function avatar_gallery($category, $avatar_select, $items_per_column, $block_var = 'avatar_row') { - global $user, $cache; + global $user, $cache, $template; global $config, $phpbb_root_path; + $avatar_list = array(); + $path = $phpbb_root_path . $config['avatar_gallery_path']; if (!file_exists($path) || !is_dir($path)) { - return array($user->lang['NONE'] => array()); + $avatar_list = array($user->lang['NONE'] => array()); } - - // To be replaced with SQL ... before M3 completion - $dp = @opendir($path); - - $data = array(); - $avatar_row_count = $avatar_col_count = 0; - while ($file = readdir($dp)) + else { - if ($file{0} != '.' && is_dir("$path/$file")) + // Collect images + $dp = @opendir($path); + + while ($file = readdir($dp)) { - $dp2 = @opendir("$path/$file"); - - while ($sub_file = readdir($dp2)) + if ($file{0} != '.' && is_dir("$path/$file")) { - if (preg_match('#\.(gif$|png$|jpg|jpeg)$#i', $sub_file)) + $avatar_row_count = $avatar_col_count = 0; + + $dp2 = @opendir("$path/$file"); + while ($sub_file = readdir($dp2)) { - $data[$file][$avatar_row_count][$avatar_col_count]['file'] = "$file/$sub_file"; - $data[$file][$avatar_row_count][$avatar_col_count]['name'] = ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))); - - $avatar_col_count++; - if ($avatar_col_count == 4) + if (preg_match('#\.(gif$|png$|jpg|jpeg)$#i', $sub_file)) { - $avatar_row_count++; - $avatar_col_count = 0; + $avatar_list[$file][$avatar_row_count][$avatar_col_count] = array( + 'file' => "$file/$sub_file", + 'filename' => $sub_file, + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))), + ); + + $avatar_col_count++; + if ($avatar_col_count == $items_per_column) + { + $avatar_row_count++; + $avatar_col_count = 0; + } } } + closedir($dp2); } - closedir($dp2); + } + closedir($dp); + } + + if (!sizeof($avatar_list)) + { + $avatar_list = array($user->lang['NONE'] => array()); + } + + @ksort($avatar_list); + + $category = (!$category) ? key($avatar_list) : $category; + $avatar_categories = array_keys($avatar_list); + + $s_category_options = ''; + foreach ($avatar_categories as $cat) + { + $s_category_options .= ''; + } + + $template->assign_vars(array( + 'S_IN_AVATAR_GALLERY' => true, + 'S_CAT_OPTIONS' => $s_category_options) + ); + + $avatar_list = $avatar_list[$category]; + + foreach ($avatar_list as $avatar_row_ary) + { + $template->assign_block_vars($block_var, array()); + + foreach ($avatar_row_ary as $avatar_col_ary) + { + $template->assign_block_vars($block_var . '.avatar_column', array( + 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], + 'AVATAR_NAME' => $avatar_col_ary['name'], + 'AVATAR_FILE' => $avatar_col_ary['filename']) + ); + + $template->assign_block_vars($block_var . '.avatar_option_column', array( + 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], + 'S_OPTIONS_AVATAR' => $avatar_col_ary['filename']) + ); } } - closedir($dp); - if (!sizeof($data)) - { - return array($user->lang['NONE'] => array()); - } - - @ksort($data); - - return $data; + return $avatar_list; } // @@ -1350,7 +1391,6 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, } } - $usernames = array(); if (sizeof($update_id_ary)) { $sql = 'UPDATE ' . USER_GROUP_TABLE . ' @@ -1358,18 +1398,6 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, WHERE user_id IN (' . implode(', ', $update_id_ary) . ") AND group_id = $group_id"; $db->sql_query($sql); - - foreach ($update_id_ary as $id) - { - $usernames[] = $username_ary[$id]; - } - } - else - { - foreach ($add_id_ary as $id) - { - $usernames[] = $username_ary[$id]; - } } if ($default) diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 791cbb069e..5d051debab 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -53,6 +53,10 @@ class template var $static_lang; + /** + * Set template location + * @public + */ function set_template($static_lang = false) { global $phpbb_root_path, $config, $user; @@ -75,6 +79,10 @@ class template return true; } + /** + * Set custom template location (able to use directory outside of phpBB) + * @public + */ function set_custom_template($template_path, $template_name, $static_lang = false) { global $phpbb_root_path; @@ -88,8 +96,11 @@ class template return true; } - // Sets the template filenames for handles. $filename_array - // should be a hash of handle => filename pairs. + /** + * Sets the template filenames for handles. $filename_array + * should be a hash of handle => filename pairs. + * @public + */ function set_filenames($filename_array) { if (!is_array($filename_array)) @@ -112,15 +123,19 @@ class template return true; } - - // Destroy template data set + /** + * Destroy template data set + * @public + */ function destroy() { $this->_tpldata = array(); } - - // Methods for loading and evaluating the templates + /** + * Display handle + * @public + */ function display($handle, $include_once = true) { global $user; @@ -137,10 +152,34 @@ class template return true; } - // Load a compiled template if possible, if not, recompile it + /** + * Display the handle and assign the output to a template variable + * @public + */ + function assign_display($handle, $template_var, $return_content = false, $include_once = true) + { + ob_start(); + $this->display($handle, $include_once); + $contents = ob_get_contents(); + ob_end_clean(); + + if ($return_content) + { + return $contents; + } + + $this->assign_var($template_var, $contents); + + return true; + } + + /** + * Load a compiled template if possible, if not, recompile it + * @private + */ function _tpl_load(&$handle) { - global $config, $user, $db, $phpEx; + global $user, $phpEx, $config; $filename = $this->cachepath . $this->filename[$handle] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx; @@ -152,6 +191,10 @@ class template return $filename; } + global $db, $phpbb_root_path; + + include_once($phpbb_root_path . 'includes/functions_template.' . $phpEx); + $compile = new template_compile($this); // If the file for this handle is already loaded and compiled, do nothing. if (!empty($this->uncompiled_code[$handle])) @@ -220,27 +263,14 @@ class template return false; } - $this->_tpl_load_file($handle); + $compile->_tpl_load_file($handle); return false; } - // Load template source from file - function _tpl_load_file($handle) - { - // Try and open template for read - if (!($fp = @fopen($this->files[$handle], 'r'))) - { - trigger_error("template->_tpl_load_file(): File {$this->files[$handle]} does not exist or is empty", E_USER_ERROR); - } - - $this->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->files[$handle])))); - @fclose($fp); - - // Actually compile the code now. - $this->compile_write($handle, $this->compiled_code[$handle]); - } - - // Assign key variable pairs from an array + /** + * Assign key variable pairs from an array + * @public + */ function assign_vars($vararray) { foreach ($vararray as $key => $val) @@ -251,7 +281,10 @@ class template return true; } - // Assign a single variable to a single key + /** + * Assign a single variable to a single key + * @public + */ function assign_var($varname, $varval) { $this->_tpldata['.'][0][$varname] = $varval; @@ -259,7 +292,10 @@ class template return true; } - // Assign key variable pairs from an array to a specified block + /** + * Assign key variable pairs from an array to a specified block + * @public + */ function assign_block_vars($blockname, $vararray) { if (strpos($blockname, '.') !== false) @@ -362,6 +398,7 @@ class template * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) * + * @public */ function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') { @@ -431,7 +468,10 @@ class template } } - // Include a seperate template + /** + * Include a seperate template + * @private + */ function _tpl_include($filename, $include = true) { $handle = $filename; @@ -452,587 +492,6 @@ class template eval(' ?>' . $this->compiled_code[$handle] . ' - $match_php_tags = array('#\<\?php .*?\?\>#is', '#\<\script language="php"\>.*?\<\/script\>#is', '#\<\?.*?\?\>#s', '#\<%.*?%\>#s'); - $code = preg_replace($match_php_tags, '', $code); - - // Pull out all block/statement level elements and seperate plain text - preg_match_all('#(.*?)#s', $code, $matches); - $php_blocks = $matches[1]; - $code = preg_replace('#(.*?)#s', '', $code); - - preg_match_all('##', $code, $matches); - $include_blocks = $matches[1]; - $code = preg_replace('##', '', $code); - - preg_match_all('##', $code, $matches); - $includephp_blocks = $matches[1]; - $code = preg_replace('##', '', $code); - - preg_match_all('##', $code, $blocks); - $text_blocks = preg_split('##', $code); - - for ($i = 0, $j = sizeof($text_blocks); $i < $j; $i++) - { - $this->compile_var_tags($text_blocks[$i]); - } - $compile_blocks = array(); - - for ($curr_tb = 0, $tb_size = sizeof($text_blocks); $curr_tb < $tb_size; $curr_tb++) - { - if (!isset($blocks[1][$curr_tb])) - { - $blocks[1][$curr_tb] = ''; - } - - switch ($blocks[1][$curr_tb]) - { - case 'BEGIN': - $this->block_else_level[] = false; - $compile_blocks[] = 'compile_tag_block($blocks[2][$curr_tb]) . ' ?>'; - break; - - case 'BEGINELSE': - $this->block_else_level[sizeof($this->block_else_level) - 1] = true; - $compile_blocks[] = ''; - break; - - case 'END': - array_pop($this->block_names); - $compile_blocks[] = 'block_else_level)) ? '}' : '}}') . ' ?>'; - break; - - case 'IF': - $compile_blocks[] = 'compile_tag_if($blocks[2][$curr_tb], false) . ' ?>'; - break; - - case 'ELSE': - $compile_blocks[] = ''; - break; - - case 'ELSEIF': - $compile_blocks[] = 'compile_tag_if($blocks[2][$curr_tb], true) . ' ?>'; - break; - - case 'ENDIF': - $compile_blocks[] = ''; - break; - - case 'DEFINE': - $compile_blocks[] = 'compile_tag_define($blocks[2][$curr_tb], true) . ' ?>'; - break; - - case 'UNDEFINE': - $compile_blocks[] = 'compile_tag_define($blocks[2][$curr_tb], false) . ' ?>'; - break; - - case 'INCLUDE': - $temp = ''; - list(, $temp) = each($include_blocks); - $compile_blocks[] = 'compile_tag_include($temp) . ' ?>'; - $this->_tpl_include($temp, false); - break; - - case 'INCLUDEPHP': - if ($config['tpl_php']) - { - $temp = ''; - list(, $temp) = each($includephp_blocks); - $compile_blocks[] = 'compile_tag_include_php($temp) . ' ?>'; - } - else - { - $compile_blocks[] = ''; - } - break; - - case 'PHP': - if ($config['tpl_php']) - { - $temp = ''; - list(, $temp) = each($php_blocks); - $compile_blocks[] = ''; - } - else - { - $compile_blocks[] = ''; - } - break; - - default: - $this->compile_var_tags($blocks[0][$curr_tb]); - $trim_check = trim($blocks[0][$curr_tb]); - $compile_blocks[] = (!$no_echo) ? ((!empty($trim_check)) ? $blocks[0][$curr_tb] : '') : ((!empty($trim_check)) ? $blocks[0][$curr_tb] : ''); - break; - } - } - - $template_php = ''; - for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++) - { - $trim_check_text = trim($text_blocks[$i]); - $trim_check_block = trim($compile_blocks[$i]); - $template_php .= (!$no_echo) ? ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '') : ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : ''); - } - - // There will be a number of occassions where we switch into and out of - // PHP mode instantaneously. Rather than "burden" the parser with this - // we'll strip out such occurences, minimising such switching - $template_php = str_replace(' ?>generate_block_varref($namespace, $varname, true, $varrefs[3][$j]); - - $text_blocks = str_replace($varrefs[0][$j], $new, $text_blocks); - } - - // This will handle the remaining root-level varrefs - if (!$this->static_lang) - { - $text_blocks = preg_replace('#\{L_([a-z0-9\-_]*?)\}#is', "_tpldata['.'][0]['L_\\1'])) ? \$this->_tpldata['.'][0]['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ ' . ucfirst(strtolower(str_replace('_', ' ', '\\1'))) . ' }')); ?>", $text_blocks); - } - else - { - global $user; - - $text_blocks = preg_replace('#\{L_([A-Z0-9\-_]*?)\}#e', "'_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks); - } - - $text_blocks = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "_tpldata['.'][0]['\\1'])) ? \$this->_tpldata['.'][0]['\\1'] : ''; ?>", $text_blocks); - $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*?)\}#is', "_tpldata['DEFINE']['.']['\\1'])) ? \$this->_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks); - - return; - } - - function compile_tag_block($tag_args) - { - // Allow for control of looping (indexes start from zero): - // foo(2) : Will start the loop on the 3rd entry - // foo(-2) : Will start the loop two entries from the end - // foo(3,4) : Will start the loop on the fourth entry and end it on the fifth - // foo(3,-4) : Will start the loop on the fourth entry and end it four from last - if (preg_match('#^(.*?)\(([\-0-9]+)(,([\-0-9]+))?\)$#', $tag_args, $match)) - { - $tag_args = $match[1]; - - if ($match[2] < 0) - { - $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; - } - else - { - $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; - } - - if (strlen($match[4]) < 1 || $match[4] == -1) - { - $loop_end = '$_' . $tag_args . '_count'; - } - else if ($match[4] >= 0) - { - $loop_end = '(' . ($match[4] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[4] + 1) . ')'; - } - else //if ($match[4] < -1) - { - $loop_end = '$_' . $tag_args . '_count' . ($match[4] + 1); - } - } - else - { - $loop_start = 0; - $loop_end = '$_' . $tag_args . '_count'; - } - - $tag_template_php = ''; - array_push($this->block_names, $tag_args); - - if (sizeof($this->block_names) < 2) - { - // Block is not nested. - $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; - } - else - { - // This block is nested. - - // Generate a namespace string for this block. - $namespace = implode('.', $this->block_names); - - // Get a reference to the data array for this block that depends on the - // current indices of all parent blocks. - $varref = $this->generate_block_data_ref($namespace, false); - - // Create the for loop code to iterate over this block. - $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;'; - } - - $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; - $tag_template_php .= 'for ($this->_' . $tag_args . '_i = ' . $loop_start . '; $this->_' . $tag_args . '_i < ' . $loop_end . '; $this->_' . $tag_args . '_i++){'; - - return $tag_template_php; - } - - /** - * Compile IF tags - much of this is from Smarty with - * some adaptions for our block level methods - */ - function compile_tag_if($tag_args, $elseif) - { - // Tokenize args for 'if' tag. - preg_match_all('/(?: - "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | - \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | - [(),] | - [^\s(),]+)/x', $tag_args, $match); - - $tokens = $match[0]; - $is_arg_stack = array(); - - for ($i = 0, $size = sizeof($tokens); $i < $size; $i++) - { - $token = &$tokens[$i]; - - switch ($token) - { - case '!': - case '%': - case '!==': - case '==': - case '===': - case '>': - case '<': - case '!=': - case '<>': - case '<<': - case '>>': - case '<=': - case '>=': - case '&&': - case '||': - case '|': - case '^': - case '&': - case '~': - case ')': - case ',': - case '+': - case '-': - case '*': - case '/': - case '@': - break; - - case 'eq': - $token = '=='; - break; - - case 'ne': - case 'neq': - $token = '!='; - break; - - case 'lt': - $token = '<'; - break; - - case 'le': - case 'lte': - $token = '<='; - break; - - case 'gt': - $token = '>'; - break; - - case 'ge': - case 'gte': - $token = '>='; - break; - - case 'and': - $token = '&&'; - break; - - case 'or': - $token = '||'; - break; - - case 'not': - $token = '!'; - break; - - case 'mod': - $token = '%'; - break; - - case '(': - array_push($is_arg_stack, $i); - break; - - case 'is': - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; - $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); - - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); - - array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); - - $i = $is_arg_start; - - default: - if (preg_match('#^(([a-z0-9\-_]+?\.)+?)?(\$)?([A-Z]+[A-Z0-9\-_]+)$#s', $token, $varrefs)) - { - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[3]) . '[\'' . $varrefs[4] . '\']' : (($varrefs[3]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[4] . '\']' : '$this->_tpldata[\'.\'][0][\'' . $varrefs[4] . '\']'); - } - else if (preg_match('#^\.((([a-z0-9\-_]+)?\.?)+?)$#s', $token, $varrefs)) - { - $_tok = $this->generate_block_data_ref($varrefs[1], false); - $token = "(isset($_tok) && sizeof($_tok))"; - } - - break; - } - } - - return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); - } - - function compile_tag_define($tag_args, $op) - { - preg_match('#^(([a-z0-9\-_]+?\.)+?)?\$([A-Z][A-Z0-9_\-]*?)( = (\'?)(.*?)(\'?))?$#', $tag_args, $match); - - if (empty($match[3]) || (empty($match[6]) && $op)) - { - return; - } - - if (!$op) - { - return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[3] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[3] . '\']') . ');'; - } - - // Are we a string? - if ($match[5] && $match[7]) - { - $match[6] = addslashes(str_replace(array('\\\'', '\\\\'), array('\'', '\\'), $match[6])); - - // Compile reference, we allow template variables in defines... - $match[6] = $this->compile($match[6]); - - // Now replace the php code - $match[6] = "'" . str_replace(array(''), array("' . ", " . '"), $match[6]) . "'"; - } - else - { - preg_match('#(true|false|\.)#i', $match[6], $type); - - switch (strtolower($type[1])) - { - case 'true': - case 'false': - $match[6] = strtoupper($match[6]); - break; - case '.'; - $match[6] = doubleval($match[6]); - break; - default: - $match[6] = intval($match[6]); - break; - } - } - - return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[3] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[3] . '\']') . ' = ' . $match[6] . ';'; - } - - function compile_tag_include($tag_args) - { - return "\$this->_tpl_include('$tag_args');"; - } - - function compile_tag_include_php($tag_args) - { - return "include('" . $this->root . '/' . $tag_args . "');"; - } - - // This is from Smarty - function _parse_is_expr($is_arg, $tokens) - { - $expr_end = 0; - $negate_expr = false; - - if (($first_token = array_shift($tokens)) == 'not') - { - $negate_expr = true; - $expr_type = array_shift($tokens); - } - else - { - $expr_type = $first_token; - } - - switch ($expr_type) - { - case 'even': - if (@$tokens[$expr_end] == 'by') - { - $expr_end++; - $expr_arg = $tokens[$expr_end++]; - $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; - } - else - { - $expr = "!($is_arg % 2)"; - } - break; - - case 'odd': - if (@$tokens[$expr_end] == 'by') - { - $expr_end++; - $expr_arg = $tokens[$expr_end++]; - $expr = "(($is_arg / $expr_arg) % $expr_arg)"; - } - else - { - $expr = "($is_arg % 2)"; - } - break; - - case 'div': - if (@$tokens[$expr_end] == 'by') - { - $expr_end++; - $expr_arg = $tokens[$expr_end++]; - $expr = "!($is_arg % $expr_arg)"; - } - break; - - default: - break; - } - - if ($negate_expr) - { - $expr = "!($expr)"; - } - - array_splice($tokens, 0, $expr_end, $expr); - - return $tokens; - } - - /** - * Generates a reference to the given variable inside the given (possibly nested) - * block namespace. This is a string of the form: - * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' - * It's ready to be inserted into an "echo" line in one of the templates. - * NOTE: expects a trailing "." on the namespace. - */ - function generate_block_varref($namespace, $varname, $echo = true, $defop = false) - { - // Strip the trailing period. - $namespace = substr($namespace, 0, -1); - - // Get a reference to the data block for this namespace. - $varref = $this->generate_block_data_ref($namespace, true, $defop); - // Prepend the necessary code to stick this in an echo line. - - // Append the variable reference. - $varref .= "['$varname']"; - $varref = ($echo) ? "" : ((isset($varref)) ? $varref : ''); - - return $varref; - } - - /** - * Generates a reference to the array of data values for the given - * (possibly nested) block namespace. This is a string of the form: - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] - * - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. - * NOTE: does not expect a trailing "." on the blockname. - */ - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) - { - // Get an array of the blocks involved. - $blocks = explode('.', $blockname); - $blockcount = sizeof($blocks) - 1; - $varref = '$this->_tpldata' . (($defop) ? '[\'DEFINE\']' : ''); - - // Build up the string with everything but the last child. - for ($i = 0; $i < $blockcount; $i++) - { - $varref .= "['" . $blocks[$i] . "'][\$this->_" . $blocks[$i] . '_i]'; - } - - // Add the block reference for the last child. - $varref .= "['" . $blocks[$blockcount] . "']"; - - // Add the iterator for the last child if requried. - if ($include_last_iterator) - { - $varref .= '[$this->_' . $blocks[$blockcount] . '_i]'; - } - - return $varref; - } - - function compile_write(&$handle, $data) - { - global $phpEx, $user; - - $filename = $this->cachepath . $this->filename[$handle] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx; - - if ($fp = @fopen($filename, 'wb')) - { - @flock($fp, LOCK_EX); - @fwrite ($fp, $data); - @flock($fp, LOCK_UN); - @fclose($fp); - - @umask(0); - @chmod($filename, 0644); - } - - return; - } } ?> \ No newline at end of file diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index f6edac0d7e..5881f15bf7 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -460,15 +460,11 @@ class ucp_profile case 'avatar': - $display_gallery = (isset($_POST['displaygallery'])) ? true : false; - $category = request_var('category', ''); + $display_gallery = (isset($_POST['display_gallery'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; - $avatarselect = request_var('avatarselect', ''); - $avatarselect = str_replace(array('../', '..\\', './', '.\\'), '', $avatarselect); - if ($avatarselect && ($avatarselect{0} == '/' || $avatarselect{0} == "\\")) - { - $avatarselect = ''; - } + + $avatar_select = basename(request_var('avatar_select', '')); + $category = basename(request_var('category', '')); // Can we upload? $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; @@ -499,6 +495,7 @@ class ucp_profile if (!sizeof($error)) { $data['user_id'] = $user->data['user_id']; + if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) { list($type, $filename, $width, $height) = avatar_upload($data, $error); @@ -507,11 +504,21 @@ class ucp_profile { list($type, $filename, $width, $height) = avatar_remote($data, $error); } - else if ($avatarselect && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) + else if ($avatar_select && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) { $type = AVATAR_GALLERY; - $filename = $avatarselect; - list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $filename); + $filename = $avatar_select; + + // check avatar gallery + if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) + { + $type = $filename = $width = $height = ''; + } + else + { + list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $filename); + $filename = $category . '/' . $filename; + } } else if ($delete && $auth->acl_get('u_chgavatar')) { @@ -543,8 +550,8 @@ class ucp_profile } } - meta_refresh(3, "ucp.$phpEx$SID&i=$id&mode=$mode"); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], "", ''); + meta_refresh(3, "{$phpbb_root_path}ucp.$phpEx$SID&i=$id&mode=$mode"); + $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], "", ''); trigger_error($message); } @@ -557,20 +564,22 @@ class ucp_profile // Generate users avatar $avatar_img = ''; + if ($user->data['user_avatar']) { switch ($user->data['user_avatar_type']) { case AVATAR_UPLOAD: $avatar_img = $phpbb_root_path . $config['avatar_path'] . '/'; - break; + break; + case AVATAR_GALLERY: $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; - break; + break; } $avatar_img .= $user->data['user_avatar']; - $avatar_img = ''; + $avatar_img = ''; } $template->assign_vars(array( @@ -583,44 +592,9 @@ class ucp_profile 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),) ); - $s_categories = $s_pages = ''; if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) { - $avatar_list = avatar_gallery($category, $error); - $category = (!$category) ? key($avatar_list) : $category; - - $s_category_options = ''; - foreach (array_keys($avatar_list) as $cat) - { - $s_category_options .= ''; - } - - $template->assign_vars(array( - 'S_DISPLAY_GALLERY' => true, - 'S_CAT_OPTIONS' => $s_category_options) - ); - - $avatar_list = $avatar_list[$category]; - - foreach ($avatar_list as $avatar_row_ary) - { - $template->assign_block_vars('avatar_row', array()); - - foreach ($avatar_row_ary as $avatar_col_ary) - { - $template->assign_block_vars('avatar_row.avatar_column', array( - 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], - 'AVATAR_NAME' => $avatar_col_ary['name'], - 'AVATAR_FILE' => $avatar_col_ary['file']) - ); - - $template->assign_block_vars('avatar_row.avatar_option_column', array( - 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], - 'S_OPTIONS_AVATAR' => $avatar_col_ary['file']) - ); - } - } - unset($avatar_list); + avatar_gallery($category, $avatar_select, 4); } else { @@ -633,9 +607,7 @@ class ucp_profile 'S_UPLOAD_AVATAR_FILE' => $can_upload, 'S_UPLOAD_AVATAR_URL' => $can_upload, 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, - 'S_GALLERY_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false, - 'S_AVATAR_CAT_OPTIONS' => $s_categories, - 'S_AVATAR_PAGE_OPTIONS' => $s_pages,) + 'S_GALLERY_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) ); } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 30d1edada4..30ef191be7 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -53,6 +53,9 @@ $lang += array( 'ACP_FORUM_LOGS' => 'Forum Logs', 'ACP_GENERAL_CONFIGURATION' => 'General Configuration', 'ACP_GENERAL_TASKS' => 'General Tasks', + 'ACP_GROUPS' => 'Groups', + 'ACP_GROUPS_MANAGE' => 'Manage Groups', + 'ACP_GROUPS_MANAGEMENT' => 'Group Management', 'ACP_ICONS' => 'Topic Icons', 'ACP_ICONS_SMILIES' => 'Topic Icons/Smilies', 'ACP_INDEX' => 'Admin index', @@ -83,7 +86,9 @@ $lang += array( 'BACK' => 'Back', + 'COLOUR_SWATCH' => 'Web-safe colour swatch', 'CONFIG_UPDATED' => 'Configuration updated successfully', + 'CONFIRM_OPERATION' => 'Are you sure you wish to carry out this operation?', 'DEACTIVATE' => 'Deactivate', 'DIMENSIONS' => 'Dimensions', @@ -109,6 +114,7 @@ $lang += array( 'LOGIN_ADMIN_CONFIRM' => 'To administer the board you must re-authenticate yourself.', 'LOGIN_ADMIN_SUCCESS' => 'You have successfully authenticated and will now be redirected to the Administration Control Panel', + 'MANAGE' => 'Manage', 'MOVE_DOWN' => 'Move Down', 'MOVE_UP' => 'Move Up', @@ -122,7 +128,10 @@ $lang += array( 'REORDER' => 'Reorder', 'RETURN_TO' => 'Return to ...', + 'SELECT_OPTION' => 'Select option', + 'UCP' => 'User Control Panel', + 'USERNAMES_EXPLAIN' => 'Place each username on a seperate line', 'USER_CONTROL_PANEL' => 'User Control Panel', ); @@ -230,6 +239,17 @@ $lang += array( 'LOG_DOWNLOAD_IP' => 'Added ip/hostname to download list
» %s', 'LOG_DOWNLOAD_REMOVE_IP' => 'Removed ip/hostname from download list
» %s', + 'LOG_GROUP_CREATED' => 'New usergroup created
» %s', + 'LOG_GROUP_DEFAULTS' => 'Group made default for members
» %s', + 'LOG_GROUP_DELETE' => 'Usergroup deleted
» %s', + 'LOG_GROUP_DEMOTED' => 'Leaders demoted in usergroup %s
» %s', + 'LOG_GROUP_PROMOTED' => 'Members promoted to leader in usergroup %s
» %s', + 'LOG_GROUP_REMOVE' => 'Members removed from usergroup %s
» %s', + 'LOG_GROUP_UPDATED' => 'Usergroup details updated
» %s', + 'LOG_MODS_ADDED' => 'Added new leaders to usergroup %s
» %s', + 'LOG_USERS_APPROVED' => 'Users approved in usergroup %s
» %s', + 'LOG_USERS_ADDED' => 'Added new members to usergroup %s
» %s', + 'LOG_INDEX_ACTIVATE' => 'Activated inactive users
» %s', 'LOG_INDEX_DELETE' => 'Deleted inactive users
» %s', 'LOG_INDEX_REMIND' => 'Sent reminder emails to inactive users
» %s', diff --git a/phpBB/language/en/acp/groups.php b/phpBB/language/en/acp/groups.php new file mode 100644 index 0000000000..1f0061f092 --- /dev/null +++ b/phpBB/language/en/acp/groups.php @@ -0,0 +1,111 @@ + 'From this panel you can administer all your usergroups, you can delete, create and edit existing groups. You may choose moderators, toggle open/closed group status and set the group name and description.', + 'ADD_USERS' => 'Add Users', + 'ADD_USERS_EXPLAIN' => 'Here you can add new users to the group. You may select whether this group becomes the new default for the selected users. Additionally you can define them as group leaders. Please enter each username on a seperate line.', + + 'CREATE_GROUP' => 'Create new group', + + 'GROUPS_NO_MEMBERS' => 'This group has no members', + 'GROUPS_NO_MODS' => 'No group leaders defined', + 'GROUP_APPROVE' => 'Approve', + 'GROUP_APPROVED' => 'Approved Members', + 'GROUP_AVATAR' => 'Group avatar', + 'GROUP_AVATAR_EXPLAIN' => 'This image will be displayed in the Group Control Panel.', + 'GROUP_CLOSED' => 'Closed', + 'GROUP_COLOR' => 'Group colour', + 'GROUP_COLOR_EXPLAIN' => 'Defines the colour members usernames will appear in, leave blank for user default.', + 'GROUP_CREATED' => 'Group has been created successfully', + 'GROUP_DEFAULT' => 'Default', + 'GROUP_DEFS_UPDATED' => 'Default group set for all members', + 'GROUP_DELETE' => 'Delete', + 'GROUP_DELETED' => 'Group deleted and user default groups set successfully', + 'GROUP_DEMOTE' => 'Demote', + 'GROUP_DESC' => 'Group description', + 'GROUP_DETAILS' => 'Group details', + 'GROUP_DST' => 'Group daylight savings', + 'GROUP_EDIT_EXPLAIN' => 'Here you can edit an existing group. You can change its name, description and type (open, closed, etc.). You can also set certain groupwide options such as colouration, rank, etc. Changes made here override users current settings. Please note that group members can alter their avatar unless you set appropriate user permissions.', + 'GROUP_ERR_DESC_LONG' => 'Group description too long.', + 'GROUP_ERR_TYPE' => 'Inappropriate group type specified.', + 'GROUP_ERR_USERNAME' => 'No group name specified.', + 'GROUP_ERR_USERS_EXIST' => 'The specified users are already members of this group', + 'GROUP_ERR_USER_LONG' => 'Group name too long.', + 'GROUP_HIDDEN' => 'Hidden', + 'GROUP_LANG' => 'Group language', + 'GROUP_LEAD' => 'Group leaders', + 'GROUP_LIST' => 'Current members', + 'GROUP_LIST_EXPLAIN' => 'This is a complete list of all the current users with membership of this group. You can delete members (except in certain special groups) or add new ones as you see fit.', + 'GROUP_MEMBERS' => 'Group members', + 'GROUP_MEMBERS_EXPLAIN' => 'This is a complete listing of all the members of this usergroup. It includes seperate sections for leaders, pending and existing members. From here you can manage all aspects of who has membership of this group and what their role is. To remove a leader but keep them in the group use Demote rather than delete. Similarly use Promote to make an existing member a leader.', + 'GROUP_MESSAGE_LIMIT' => 'Group private message limit per folder', + 'GROUP_MESSAGE_LIMIT_EXPLAIN' => 'This setting overrides the per-user folder message limit. A value of 0 means the user default limit will be used.', + 'GROUP_MODS_ADDED' => 'New group moderators added successfully.', + 'GROUP_MODS_DEMOTED' => 'Group leaders demoted successfully', + 'GROUP_MODS_PROMOTED' => 'Group members promoted successfully', + 'GROUP_NAME' => 'Group name', + 'GROUP_OPEN' => 'Open', + 'GROUP_PENDING' => 'Pending Members', + 'GROUP_PROMOTE' => 'Promote', + 'GROUP_RANK' => 'Group rank', + 'GROUP_RECEIVE_PM' => 'Group able to receive private messages', + 'GROUP_REQUEST' => 'Request', + 'GROUP_SETTINGS' => 'Set user preferences', + 'GROUP_SETTINGS_EXPLAIN' => 'Here you can force changes in users current preferences. Please note these settings are not saved for the group itself. They are intended as a quick method of altering the preferences of all users in this group.', + 'GROUP_SETTINGS_SAVE' => 'Groupwide settings', + 'GROUP_TIMEZONE' => 'Group timezone', + 'GROUP_TYPE' => 'Group type', + 'GROUP_TYPE_EXPLAIN' => 'This determines which users can join or view this group.', + 'GROUP_UPDATED' => 'Group preferences updated successfully.', + 'GROUP_USERS_ADDED' => 'New users added to group successfully.', + 'GROUP_USERS_EXIST' => 'The selected users are already members.', + 'GROUP_USERS_REMOVE' => 'Users removed from group and new defaults set successfully', + + 'NO_GROUP' => 'No group specified', + 'NO_USERS' => 'The requested users do not exist', + + 'SPECIAL_GROUPS' => 'Predefined groups', + 'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings. By clicking "Default" you can set the relevant group to the default for all its members.', + + 'TOTAL_MEMBERS' => 'Members', + + 'USERS_APPROVED' => 'Users approved successfully.', + 'USER_DEFAULT' => 'User default', + 'USER_DEF_GROUPS' => 'User defined groups', + 'USER_DEF_GROUPS_EXPLAIN' => 'These are groups created by you or another admin on this board. You can manage memberships as well as edit group properties or even delete the group. By clicking "Default" you can set the relevant group to the default for all its members.', + 'USER_GROUP_DEFAULT' => 'Set as default group', + 'USER_GROUP_DEFAULT_EXPLAIN' => 'Saying yes here will set this group as the default group for the added users', + 'USER_GROUP_LEADER' => 'Set as group leader', +); + +// 'FORCE_COLOR' => 'Force update', + +?> \ No newline at end of file diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 9e3bcdf92c..a217973511 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -1,7 +1,7 @@ {L_AVATAR_GALLERY}: - + - + {L_AVATAR_GALLERY} - {L_AVATAR_CATEGORY}:   {L_AVATAR_PAGE}:   + {L_AVATAR_CATEGORY}:   @@ -61,7 +61,7 @@ - + @@ -70,7 +70,7 @@ - +
{S_HIDDEN_FIELDS}  {S_HIDDEN_FIELDS}