diff options
-rw-r--r-- | phpBB/adm/admin_groups.php | 956 | ||||
-rw-r--r-- | phpBB/includes/acm/acm_db.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 24 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_groups.php | 700 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 29 | ||||
-rw-r--r-- | phpBB/includes/functions_module.php | 20 | ||||
-rw-r--r-- | phpBB/includes/functions_template.php | 668 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 112 | ||||
-rw-r--r-- | phpBB/includes/template.php | 679 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 82 | ||||
-rw-r--r-- | phpBB/language/en/acp/common.php | 20 | ||||
-rw-r--r-- | phpBB/language/en/acp/groups.php | 111 | ||||
-rw-r--r-- | phpBB/language/en/acp/posting.php | 2 | ||||
-rw-r--r-- | phpBB/styles/subSilver/template/ucp_profile_avatar.html | 10 |
14 files changed, 1721 insertions, 1694 deletions
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 @@ -<?php -/** -* -* @package acp -* @version $Id$ -* @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License -* -* @todo Avatar gallery ... -* @todo Mass user pref setting via group membership -*/ - -/** -*/ -if (!empty($setmodules)) -{ - if (!$auth->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 -?> - -<script language="javascript" type="text/javascript"> -<!-- -function marklist(match, status) -{ - len = eval('document.' + match + '.length'); - for (i = 0; i < len; i++) - { - eval('document.' + match + '.elements[i].checked = ' + status); - } -} - -//--> -</script> - -<?php - - // Which page? - switch ($action) - { - case 'approve': - case 'demote': - case 'promote': - if (!$group_id) - { - trigger_error($user->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']; - } - -?> - -<h1><?php echo $user->lang['MANAGE']; ?></h1> - -<p><?php echo $user->lang['GROUP_EDIT_EXPLAIN']; ?></p> - -<?php - $sql = 'SELECT * - FROM ' . RANKS_TABLE . ' - WHERE rank_special = 1 - ORDER BY rank_title'; - $result = $db->sql_query($sql); - - $rank_options = '<option value="-1"' . ((empty($group_rank)) ? 'selected="selected" ' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>'; - if ($row = $db->sql_fetchrow($result)) - { - do - { - $selected = (!empty($group_rank) && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; - $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; - } - 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 = '<img src="' . $avatar_img . '" width="' . $group_row['group_avatar_width'] . '" height="' . $group_row['group_avatar_height'] . '" alt="" />'; - } - else - { - $avatar_img = '<img src="images/no_avatar.gif" alt="" />'; - } - - $display_gallery = (isset($_POST['displaygallery'])) ? true : false; - -?> - -<script language="javascript" type="text/javascript"> -<!-- - -function swatch() -{ - window.open('./swatch.<?php echo $phpEx; ?>?form=settings&name=group_colour', '_swatch', 'HEIGHT=115,resizable=yes,scrollbars=no,WIDTH=636'); - return false; -} - -//--> -</script> - -<form name="settings" method="post" action="<?php echo "admin_groups.$phpEx$SID&mode=$mode&action=$action&g=$group_id"; ?>"<?php echo ($can_upload) ? ' enctype="multipart/form-data"' : ''; ?>> - - <table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th colspan="2"><?php echo $user->lang['GROUP_DETAILS']; ?></th> - </tr> -<?php - - if (sizeof($error)) - { - -?> - <tr> - <td class="row1" colspan="2" align="center"><span style="color:red"><?php echo implode('<br />', $error); ?></span></td> - </tr> -<?php - - } - -?> - <tr> - <td class="row2" width="40%"><b><?php echo $user->lang['GROUP_NAME']; ?>:</b></td> - <td class="row1"><?php - - if ($group_type != GROUP_SPECIAL) - { - -?><input class="post" type="text" name="group_name" value="<?php echo ($group_name) ? $group_name : ''; ?>" size="40" maxlength="40" /><?php - - } - else - { - -?><b><?php echo ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name; ?></b><?php - - } - -?></td> - </tr> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_DESC']; ?>:</b></td> - <td class="row1"><input class="post" type="text" name="group_description" value="<?php echo ($group_description) ? $group_description : ''; ?>" size="40" maxlength="255" /></td> - </tr> -<?php - - if ($group_type != GROUP_SPECIAL) - { - -?> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_TYPE']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_TYPE_EXPLAIN']; ?></span></td> - <td class="row1" nowrap="nowrap"><input type="radio" name="group_type" value="<?php echo GROUP_FREE . '"' . $type_free; ?> /> <?php echo $user->lang['GROUP_OPEN']; ?> <input type="radio" name="group_type" value="<?php echo GROUP_OPEN . '"' . $type_open; ?> /> <?php echo $user->lang['GROUP_REQUEST']; ?> <input type="radio" name="group_type" value="<?php echo GROUP_CLOSED . '"' . $type_closed; ?> /> <?php echo $user->lang['GROUP_CLOSED']; ?> <input type="radio" name="group_type" value="<?php echo GROUP_HIDDEN . '"' . $type_hidden; ?>" /> <?php echo $user->lang['GROUP_HIDDEN']; ?></td> - </tr> -<?php - - } - -?> - <tr> - <th colspan="2"><?php echo $user->lang['GROUP_SETTINGS_SAVE']; ?></th> - </tr> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_RECEIVE_PM']; ?>:</b></td> - <td class="row1" nowrap="nowrap"><input type="checkbox" name="group_receive_pm"<?php echo (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : ''; ?> /></td> - </tr> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_MESSAGE_LIMIT']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_MESSAGE_LIMIT_EXPLAIN']; ?></span></td> - <td class="row1" nowrap="nowrap"><input class="post" type="text" maxlength="4" size="4" name="group_message_limit" value="<?php echo (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0; ?>" /></td> - </tr> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_COLOR']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_COLOR_EXPLAIN']; ?></span></td> - <td class="row1" nowrap="nowrap"><input class="post" type="text" name="group_colour" value="<?php echo (isset($group_row['group_colour'])) ? $group_row['group_colour'] : ''; ?>" size="6" maxlength="6" /> [ <a href="<?php echo "swatch.$phpEx"; ?>" onclick="swatch();return false" target="_swatch"><?php echo $user->lang['COLOUR_SWATCH']; ?></a> ]</td> - </tr> - <tr> - <td class="row2"><b><?php echo $user->lang['GROUP_RANK']; ?>:</b></td> - <td class="row1"><select name="group_rank"><?php echo $rank_options; ?></select></td> - </tr> - <tr> - <th colspan="2"><?php echo $user->lang['GROUP_AVATAR']; ?></th> - </tr> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['CURRENT_IMAGE']; ?>: </b><br /><span class="gensmall"><?php echo sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)); ?></span></td> - <td class="row1" align="center"><br /><?php echo $avatar_img; ?><br /><br /><input type="checkbox" name="delete" /> <span class="gensmall"><?php echo $user->lang['DELETE_AVATAR']; ?></span></td> - </tr> -<?php - - // Can we upload? - if ($can_upload) - { - -?> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['UPLOAD_AVATAR_FILE']; ?>: </b></td> - <td class="row1"><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $config['avatar_max_filesize']; ?>" /><input class="post" type="file" name="uploadfile" /></td> - </tr> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['UPLOAD_AVATAR_URL']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['UPLOAD_AVATAR_URL_EXPLAIN']; ?></span></td> - <td class="row1"><input class="post" type="text" name="uploadurl" size="40" value="" /></td> - </tr> -<?php - - } - -?> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['LINK_REMOTE_AVATAR']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['LINK_REMOTE_AVATAR_EXPLAIN']; ?></span></td> - <td class="row1"><input class="post" type="text" name="remotelink" size="40" value="" /></td> - </tr> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['LINK_REMOTE_SIZE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['LINK_REMOTE_SIZE_EXPLAIN']; ?></span></td> - <td class="row1"><input class="post" type="text" name="width" size="3" value="<?php echo (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : ''; ?>" /> <span class="gen">px X </span> <input class="post" type="text" name="height" size="3" value="<?php echo (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : ''; ?>" /> <span class="gen">px</span></td> - </tr> -<?php - - // Do we have a gallery? - if ($config['allow_avatar_local'] && !$display_gallery) - { - -?> - <tr> - <td class="row2" width="35%"><b><?php echo $user->lang['AVATAR_GALLERY']; ?>: </b></td> - <td class="row1"><input class="btnlite" type="submit" name="displaygallery" value="<?php echo $user->lang['DISPLAY_GALLERY']; ?>" /></td> - </tr> -<?php - } - - // Do we want to display it? - if ($config['allow_avatar_local'] && $display_gallery) - { - -?> - <tr> - <th colspan="2"><?php echo $user->lang['AVATAR_GALLERY']; ?></th> - </tr> - <tr> - <td class="cat" colspan="2" align="center" valign="middle"><span class="genmed"><?php echo $user->lang['AVATAR_CATEGORY']; ?>: </span><select name="avatarcat">{S_CAT_OPTIONS}</select> <span class="genmed"><?php echo $user->lang['AVATAR_PAGE']; ?>: </span><select name="avatarpage">{S_PAGE_OPTIONS}</select> <input class="btnlite" type="submit" value="<?php echo $user->lang['GO']; ?>" name="avatargallery" /></td> - </tr> - <tr> - <td class="row1" colspan="2" align="center"> - - <table cellspacing="1" cellpadding="4" border="0"> - <!-- BEGIN avatar_row --> - <tr> - <!-- BEGIN avatar_column --> - <td class="row1" align="center"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td> - <!-- END avatar_column --> - </tr> - <tr> - <!-- BEGIN avatar_option_column --> - <td class="row2" align="center"><input type="radio" name="avatarselect" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td> - <!-- END avatar_option_column --> - </tr> - <!-- END avatar_row --> - </table> - - </td> - </tr> -<?php - - } - -?> - <tr> - <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> - </tr> - </table> -</form> - -<?php - - adm_page_footer(); - break; - } - - if ($mode == 'list' || $group_id) - { - if (!$group_id) - { - trigger_error($user->lang['NO_GROUP']); - } - -?> - -<h1><?php echo $user->lang['GROUP_MEMBERS']; ?></h1> - -<p><?php echo $user->lang['GROUP_MEMBERS_EXPLAIN']; ?></p> - -<form name="list" method="post" action="<?php echo "admin_groups.$phpEx$SID&mode=$mode&g=$group_id"; ?>"> - - <table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th width="55%"><?php echo $user->lang['USERNAME']; ?></th> - <th width="3%" nowrap="nowrap"><?php echo $user->lang['GROUP_DEFAULT']; ?></th> - <th width="20%"><?php echo $user->lang['JOINED']; ?></th> - <th width="20%"><?php echo $user->lang['POSTS']; ?></th> - <th width="2%"><?php echo $user->lang['MARK']; ?></th> - </tr> -<?php - - // 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 = ($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) - { - -?> - <tr> - <td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_LEAD']; ?></b></td> - </tr> -<?php - - if (sizeof($group_data['leader'])) - { - $row_class = ''; - foreach ($group_data['leader'] as $row) - { - $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; - -?> - <tr> - <td class="<?php echo $row_class; ?>"><a href="<?php echo "admin_users.$phpEx$SID&mode=edit&u=" . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td> - <td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['group_id'] == $group_id) ? $user->lang['YES'] : $user->lang['NO']; ?></td> - <td class="<?php echo $row_class; ?>" align="center"><?php echo $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']); ?></td> - <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['user_posts']; ?></td> - <td class="<?php echo $row_class; ?>" align="center"><input class="checkbox" type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" /></td> - </tr> -<?php - - } - } - else - { - -?> - <tr> - <td class="row1" colspan="5" align="center"><?php echo $user->lang['GROUPS_NO_MODS']; ?></td> - </tr> -<?php - - } - } - -?> - <tr> - <td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_APPROVED']; ?></b></td> - </tr> -<?php - - if (sizeof($group_data['member'])) - { - $row_class = ''; - $pending = false; - - foreach ($group_data['member'] as $row) - { - $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; - - if ($row['user_pending'] && !$pending) - { -?> - <tr> - <td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_PENDING']; ?></b></td> - </tr> -<?php - $pending = true; - } - -?> - <tr class="<?php echo $row_class; ?>"> - <td><a href="<?php echo "admin_users.$phpEx$SID&mode=edit&u=" . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td> - <td align="center"><?php echo ($row['group_id'] == $group_id) ? $user->lang['YES'] : $user->lang['NO']; ?></td> - <td align="center"><?php echo ($row['user_regdate']) ? $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '-'; ?></td> - <td align="center"><?php echo $row['user_posts']; ?></td> - <td align="center"><input class="checkbox" type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" /></td> - </tr> -<?php - - } - } - else - { - -?> - <tr> - <td class="row1" colspan="5" align="center"><?php echo $user->lang['GROUPS_NO_MEMBERS']; ?></td> - </tr> -<?php - - } - -?> - <tr> - <td class="cat" colspan="5" align="right"> - <select name="action"><option class="sep" value=""><?php echo $user->lang['SELECT_OPTION']; ?></option><?php - - foreach (array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE') as $option => $lang) - { - echo '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>'; - } - -?> - </select> <input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> - </td> - </tr> - </table> - - <table width="95%" cellspacing="1" cellpadding="1" border="0" align="center"> - <tr> - <td valign="top"><?php echo on_page($total_members, $config['topics_per_page'], $start); ?></td> - <td align="right"> - <b class="gensmall"><a href="javascript:marklist('list', true);"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist('list', false);"><?php echo $user->lang['UNMARK_ALL']; ?></a></b> <br /> - <span class="nav"><?php echo generate_pagination("admin_groups.$phpEx$SID&action=$action&mode=$mode&g=$group_id", $total_members, $config['topics_per_page'], $start, true); ?></span> - </td> - </tr> - </table> - - -<h1><?php echo $user->lang['ADD_USERS']; ?></h1> - -<p><?php echo $user->lang['ADD_USERS_EXPLAIN']; ?></p> - - <table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th colspan="2"><?php echo $user->lang['ADD_USERS']; ?></th> - </tr> - <tr> - <td class="row1" width="40%"><b><?php echo $user->lang['USER_GROUP_LEADER']; ?>:</b></span></td> - <td class="row2"><input type="radio" name="leader" value="1" /> <?php echo $user->lang['YES']; ?> <input type="radio" name="leader" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td> - </tr> - <tr> - <td class="row1"><b><?php echo $user->lang['USER_GROUP_DEFAULT']; ?>:</b> <br /><span class="gensmall"><?php echo $user->lang['USER_GROUP_DEFAULT_EXPLAIN']; ?></span></td> - <td class="row2"><input type="radio" name="default" value="1" /> <?php echo $user->lang['YES']; ?> <input type="radio" name="default" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td> - </tr> - <tr> - <td class="row1"><b><?php echo $user->lang['USERNAME']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['USERNAMES_EXPLAIN']; ?><br />[ <a href="<?php echo "../memberlist.$phpEx$SID&mode=searchuser&form=list&field=usernames"; ?>" target="usersearch"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td> - <td class="row2"><textarea name="usernames" cols="40" rows="5"></textarea></td> - </tr> - <tr> - <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="addusers" value="<?php echo $user->lang['SUBMIT']; ?>" /></td> - </tr> - </table> - -</form> - -<?php - - adm_page_footer(); - } - - -?> - -<h1><?php echo $user->lang['GROUP_MANAGE']; ?></h1> - -<p><?php echo $user->lang['GROUP_MANAGE_EXPLAIN']; ?></p> - -<h1><?php echo $user->lang['USER_DEF_GROUPS']; ?></h1> - -<p><?php echo $user->lang['USER_DEF_GROUPS_EXPLAIN']; ?></p> - -<form method="post" action="<?php echo "admin_groups.$phpEx$SID&mode=$mode"; ?>"> - - <table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th width="95%"><?php echo $user->lang['MANAGE']; ?></th> - <th nowrap="nowrap"><?php echo $user->lang['TOTAL_MEMBERS']; ?></th> - <th colspan="3"><?php echo $user->lang['OPTIONS']; ?></th> - </tr> -<?php - - $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') - { - -?> - <tr> - <td class="cat" colspan="5" align="right"><?php echo $user->lang['CREATE_GROUP']; ?>: <input class="post" type="text" name="group_name" maxlength="30" /> <input class="btnmain" type="submit" name="add" value="<?php echo $user->lang['SUBMIT']; ?>" /></td> - </tr> - </table> - -<h1><?php echo $user->lang['SPECIAL_GROUPS']; ?></h1> - -<p><?php echo $user->lang['SPECIAL_GROUPS_EXPLAIN']; ?></p> - - <table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th width="95%"><?php echo $user->lang['MANAGE']; ?></th> - <th><?php echo $user->lang['TOTAL_MEMBERS']; ?></th> - <th colspan="3"><?php echo $user->lang['OPTIONS']; ?></th> - </tr> -<?php - - } - - $row_class = ''; - foreach ($row_ary as $row) - { - $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; - - $group_id = $row['group_id']; - $group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name']; - -?> - <tr class="<?php echo $row_class; ?>"> - <td width="95%"><a href="admin_groups.<?php echo "$phpEx$SID&mode=$mode&action=list&g=$group_id"; ?>"><?php echo $group_name; ?></a></td> - <td align="center" nowrap="nowrap"> <?php echo $row['total_members']; ?> </td> - <td align="center" nowrap="nowrap"> <a href="<?php echo "admin_groups.$phpEx$SID&mode=$mode&action=default&g=$group_id"; ?>"><?php echo $user->lang['GROUP_DEFAULT']; ?></a> </td> - <td align="center" nowrap="nowrap"> <a href="<?php echo "admin_groups.$phpEx$SID&mode=$mode&action=edit&g=$group_id"; ?>"><?php echo $user->lang['EDIT']; ?></a> </td> - <td align="center" nowrap="nowrap"> <?php - - echo ($row['group_type'] != GROUP_SPECIAL) ? "<a href=\"admin_groups.$phpEx$SID&mode=$mode&action=delete&g=$group_id\">" . $user->lang['DELETE'] . '</a>' : $user->lang['DELETE']; - -?> </td> - </tr> -<?php - - } - } - -?> - <tr> - <td class="cat" colspan="5"> </td> - </tr> - </table> -</form> - -<?php - - adm_page_footer(); - break; - - // Setting groupwide preferences - case 'prefs': - adm_page_header($user->lang['GROUP_PREFS']); - - if ($update) - { - $user_lang = request_var('lang', ''); - $user_tz = request_var('tz', 0.0); - $user_dst = request_var('dst', 0); - } - else - { - } - -?> -<h1><?php echo $user->lang['GROUP_SETTINGS']; ?></h1> - -<p><?php echo $user->lang['GROUP_SETTINGS_EXPLAIN']; ?></p> - -<form method="post" action="<?php echo "admin_groups.$phpEx$SID&action=edit&g=$group_id"; ?>"><table class="bg" width="90%" cellspacing="1" cellpadding="4" border="0" align="center"> - <tr> - <th colspan="2"><?php echo $user->lang['GROUP_SETTINGS']; ?></th> - </tr> - <tr> - <td class="row2"><?php echo $user->lang['GROUP_LANG']; ?>:</td> - <td class="row1"><select name="user_lang"><?php echo '<option value="-1" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . language_select(); ?></select></td> - </tr> - <tr> - <td class="row2"><?php echo $user->lang['GROUP_TIMEZONE']; ?>:</td> - <td class="row1"><select name="user_tz"><?php echo '<option value="-14" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . tz_select(); ?></select></td> - </tr> - <tr> - <td class="row2"><?php echo $user->lang['GROUP_DST']; ?>:</td> - <td class="row1" nowrap="nowrap"><input type="radio" name="user_dst" value="0" /> <?php echo $user->lang['DISABLED']; ?> <input type="radio" name="user_dst" value="1" /> <?php echo $user->lang['ENABLED']; ?> <input type="radio" name="user_dst" value="-1" checked="checked" /> <?php echo $user->lang['USER_DEFAULT']; ?></td> - </tr> - <tr> - <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="submitprefs" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> - </tr> -</table></form> - -<?php - - adm_page_footer(); - break; - - default: - trigger_error($user->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, "<?php\n\$expired = (time() > " . (time() + $ttl) . ") ? TRUE : FALSE;\nif (\$expired) { return; }\n\n\$data = unserialize('" . str_replace("'", "\\'", str_replace('\\', '\\\\', serialize($var))) . "');\n?>"); + fwrite($fp, "<?php\n\$expired = (time() > " . (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, "<?php\n\n/*\n$query\n*/\n\n\$expired = (time() > " . (time() + $ttl) . ") ? TRUE : FALSE;\nif (\$expired) { return; }\n\n\$this->sql_rowset[\$query_id] = array(" . implode(',', $lines) . ') ?>'); + fwrite($fp, "<?php\n\n/*\n$query\n*/\n\n\$expired = (time() > " . (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 @@ +<?php +/** +* +* @package acp +* @version $Id$ +* @copyright (c) 2005 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @package acp +*/ +class acp_groups +{ + function main($id, $mode) + { + global $config, $db, $user, $auth, $template, $cache; + global $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; + + $user->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 = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>'; + if ($row = $db->sql_fetchrow($result)) + { + do + { + $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : ''; + $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>'; + } + 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 = '<img src="' . $avatar_img . '" width="' . $group_row['group_avatar_width'] . '" height="' . $group_row['group_avatar_height'] . '" alt="" />'; + } + else + { + $avatar_img = '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; + } + + $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('<br />', $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 .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>'; + } + + $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() + { + } +} + + + +/* + <tr> + <td class="cat" colspan="5"> </td> + </tr> + </table> +</form> + +<?php + + adm_page_footer(); + +// prefs + adm_page_header($user->lang['GROUP_PREFS']); + + if ($update) + { + $user_lang = request_var('lang', ''); + $user_tz = request_var('tz', 0.0); + $user_dst = request_var('dst', 0); + } + else + { + } + +?> +<h1><?php echo $user->lang['GROUP_SETTINGS']; ?></h1> + +<p><?php echo $user->lang['GROUP_SETTINGS_EXPLAIN']; ?></p> + +<form method="post" action="<?php echo "admin_groups.$phpEx$SID&action=edit&g=$group_id"; ?>"><table class="bg" width="90%" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th colspan="2"><?php echo $user->lang['GROUP_SETTINGS']; ?></th> + </tr> + <tr> + <td class="row2"><?php echo $user->lang['GROUP_LANG']; ?>:</td> + <td class="row1"><select name="user_lang"><?php echo '<option value="-1" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . language_select(); ?></select></td> + </tr> + <tr> + <td class="row2"><?php echo $user->lang['GROUP_TIMEZONE']; ?>:</td> + <td class="row1"><select name="user_tz"><?php echo '<option value="-14" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . tz_select(); ?></select></td> + </tr> + <tr> + <td class="row2"><?php echo $user->lang['GROUP_DST']; ?>:</td> + <td class="row1" nowrap="nowrap"><input type="radio" name="user_dst" value="0" /> <?php echo $user->lang['DISABLED']; ?> <input type="radio" name="user_dst" value="1" /> <?php echo $user->lang['ENABLED']; ?> <input type="radio" name="user_dst" value="-1" checked="checked" /> <?php echo $user->lang['USER_DEFAULT']; ?></td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="submitprefs" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td> + </tr> +</table></form> + +<?php + + adm_page_footer(); + break; + + default: + trigger_error($user->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 @@ +<?php +/** +* +* @package phpBB3 +* @version $Id$ +* @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @package phpBB3 +* +* Extension of template class - Functions needed for compiling templates only. +* +* psoTFX - Completion of file caching, decompilation routines and implementation of +* conditionals/keywords and associated changes +* +* The interface was inspired by PHPLib templates, and the template file (formats are +* quite similar) +* +* The keyword/conditional implementation is currently based on sections of code from +* the Smarty templating engine (c) 2001 ispi of Lincoln, Inc. which is released +* (on its own and in whole) under the LGPL. Section 3 of the LGPL states that any code +* derived from an LGPL application may be relicenced under the GPL, this applies +* to this source +* +* DEFINE directive inspired by a request by Cyberalien +*/ +class template_compile +{ + /** + * constuctor + */ + function template_compile($template) + { + $this->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('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches); + $php_blocks = $matches[1]; + $code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code); + + preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', $code, $matches); + $include_blocks = $matches[1]; + $code = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDE -->', $code); + + preg_match_all('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.\\\\]+?) -->#', $code, $matches); + $includephp_blocks = $matches[1]; + $code = preg_replace('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDEPHP -->', $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[] = '<?php ' . $this->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[] = '<?php }} else { ?>'; + break; + + case 'END': + array_pop($this->template->block_names); + $compile_blocks[] = '<?php ' . ((array_pop($this->template->block_else_level)) ? '}' : '}}') . ' ?>'; + break; + + case 'IF': + $compile_blocks[] = '<?php ' . $this->compile_tag_if($blocks[2][$curr_tb], false) . ' ?>'; + break; + + case 'ELSE': + $compile_blocks[] = '<?php } else { ?>'; + break; + + case 'ELSEIF': + $compile_blocks[] = '<?php ' . $this->compile_tag_if($blocks[2][$curr_tb], true) . ' ?>'; + break; + + case 'ENDIF': + $compile_blocks[] = '<?php } ?>'; + break; + + case 'DEFINE': + $compile_blocks[] = '<?php ' . $this->compile_tag_define($blocks[2][$curr_tb], true) . ' ?>'; + break; + + case 'UNDEFINE': + $compile_blocks[] = '<?php ' . $this->compile_tag_define($blocks[2][$curr_tb], false) . ' ?>'; + break; + + case 'INCLUDE': + $temp = ''; + list(, $temp) = each($include_blocks); + $compile_blocks[] = '<?php ' . $this->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[] = '<?php ' . $this->compile_tag_include_php($temp) . ' ?>'; + } + else + { + $compile_blocks[] = ''; + } + break; + + case 'PHP': + if ($config['tpl_php']) + { + $temp = ''; + list(, $temp) = each($php_blocks); + $compile_blocks[] = '<?php ' . $temp . ' ?>'; + } + 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(' ?><?php ', '', $template_php); + + return (!$no_echo) ? $template_php : "\$$echo_var .= '" . $template_php . "'"; + } + + /** + * Compile variables + * @private + */ + function compile_var_tags(&$text_blocks) + { + // change template varrefs into PHP varrefs + $varrefs = array(); + + // This one will handle varrefs WITH namespaces + preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)(\$)?([A-Z0-9\-_]+?)\}#', $text_blocks, $varrefs); + + for ($j = 0, $size = sizeof($varrefs[1]); $j < $size; $j++) + { + $namespace = $varrefs[1][$j]; + $varname = $varrefs[4][$j]; + $new = $this->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', "<?php echo ((isset(\$this->_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', "'<?php echo ((isset(\$this->_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', "<?php echo (isset(\$this->_tpldata['.'][0]['\\1'])) ? \$this->_tpldata['.'][0]['\\1'] : ''; ?>", $text_blocks); + $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*?)\}#is', "<?php echo (isset(\$this->_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('<?php echo ', '; ?>'), 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) ? "<?php echo $varref; ?>" : ((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")) - { - $dp2 = @opendir("$path/$file"); + // Collect images + $dp = @opendir($path); - while ($sub_file = readdir($dp2)) + while ($file = readdir($dp)) + { + 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); } - closedir($dp); - if (!sizeof($data)) + if (!sizeof($avatar_list)) { - return array($user->lang['NONE'] => array()); + $avatar_list = array($user->lang['NONE'] => array()); } - @ksort($data); + @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 .= '<option value="' . $cat . '"' . (($cat == $category) ? ' selected="selected"' : '') . '>' . $cat . '</option>'; + } + + $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']) + ); + } + } - 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] . '<?php '); } } - - - - // This next set of methods could be seperated off and included since - // they deal exclusively with compilation ... which is done infrequently - // and would save a fair few kb - - - // The all seeing all doing compile method. Parts are inspired by or directly - // from Smarty - 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('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches); - $php_blocks = $matches[1]; - $code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code); - - preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', $code, $matches); - $include_blocks = $matches[1]; - $code = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDE -->', $code); - - preg_match_all('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.\\\\]+?) -->#', $code, $matches); - $includephp_blocks = $matches[1]; - $code = preg_replace('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDEPHP -->', $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[] = '<?php ' . $this->compile_tag_block($blocks[2][$curr_tb]) . ' ?>'; - break; - - case 'BEGINELSE': - $this->block_else_level[sizeof($this->block_else_level) - 1] = true; - $compile_blocks[] = '<?php }} else { ?>'; - break; - - case 'END': - array_pop($this->block_names); - $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>'; - break; - - case 'IF': - $compile_blocks[] = '<?php ' . $this->compile_tag_if($blocks[2][$curr_tb], false) . ' ?>'; - break; - - case 'ELSE': - $compile_blocks[] = '<?php } else { ?>'; - break; - - case 'ELSEIF': - $compile_blocks[] = '<?php ' . $this->compile_tag_if($blocks[2][$curr_tb], true) . ' ?>'; - break; - - case 'ENDIF': - $compile_blocks[] = '<?php } ?>'; - break; - - case 'DEFINE': - $compile_blocks[] = '<?php ' . $this->compile_tag_define($blocks[2][$curr_tb], true) . ' ?>'; - break; - - case 'UNDEFINE': - $compile_blocks[] = '<?php ' . $this->compile_tag_define($blocks[2][$curr_tb], false) . ' ?>'; - break; - - case 'INCLUDE': - $temp = ''; - list(, $temp) = each($include_blocks); - $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>'; - $this->_tpl_include($temp, false); - break; - - case 'INCLUDEPHP': - if ($config['tpl_php']) - { - $temp = ''; - list(, $temp) = each($includephp_blocks); - $compile_blocks[] = '<?php ' . $this->compile_tag_include_php($temp) . ' ?>'; - } - else - { - $compile_blocks[] = ''; - } - break; - - case 'PHP': - if ($config['tpl_php']) - { - $temp = ''; - list(, $temp) = each($php_blocks); - $compile_blocks[] = '<?php ' . $temp . ' ?>'; - } - 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(' ?><?php ', '', $template_php); - - return (!$no_echo) ? $template_php : "\$$echo_var .= '" . $template_php . "'"; - } - - function compile_var_tags(&$text_blocks) - { - // change template varrefs into PHP varrefs - $varrefs = array(); - - // This one will handle varrefs WITH namespaces - preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)(\$)?([A-Z0-9\-_]+?)\}#', $text_blocks, $varrefs); - - for ($j = 0, $size = sizeof($varrefs[1]); $j < $size; $j++) - { - $namespace = $varrefs[1][$j]; - $varname = $varrefs[4][$j]; - $new = $this->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', "<?php echo ((isset(\$this->_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', "'<?php echo ((isset(\$this->_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', "<?php echo (isset(\$this->_tpldata['.'][0]['\\1'])) ? \$this->_tpldata['.'][0]['\\1'] : ''; ?>", $text_blocks); - $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*?)\}#is', "<?php echo (isset(\$this->_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('<?php echo ', '; ?>'), 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) ? "<?php echo $varref; ?>" : ((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'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&i=$id&mode=$mode\">", '</a>'); + meta_refresh(3, "{$phpbb_root_path}ucp.$phpEx$SID&i=$id&mode=$mode"); + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"{$phpbb_root_path}ucp.$phpEx$SID&i=$id&mode=$mode\">", '</a>'); 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 = '<img src="' . $avatar_img . '" width="' . $user->data['user_avatar_width'] . '" height="' . $user->data['user_avatar_height'] . '" border="0" alt="" />'; + $avatar_img = '<img src="' . $avatar_img . '" width="' . $user->data['user_avatar_width'] . '" height="' . $user->data['user_avatar_height'] . '" alt="" />'; } $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 .= '<option value="' . $cat . '"' . (($cat == $category) ? ' selected="selected"' : '') . '>' . $cat . '</option>'; - } - - $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' => '<b>Added ip/hostname to download list</b><br />» %s', 'LOG_DOWNLOAD_REMOVE_IP' => '<b>Removed ip/hostname from download list</b><br />» %s', + 'LOG_GROUP_CREATED' => '<b>New usergroup created</b><br />» %s', + 'LOG_GROUP_DEFAULTS' => '<b>Group made default for members</b><br />» %s', + 'LOG_GROUP_DELETE' => '<b>Usergroup deleted</b><br />» %s', + 'LOG_GROUP_DEMOTED' => '<b>Leaders demoted in usergroup</b> %s<br />» %s', + 'LOG_GROUP_PROMOTED' => '<b>Members promoted to leader in usergroup</b> %s<br />» %s', + 'LOG_GROUP_REMOVE' => '<b>Members removed from usergroup</b> %s<br />» %s', + 'LOG_GROUP_UPDATED' => '<b>Usergroup details updated</b><br />» %s', + 'LOG_MODS_ADDED' => '<b>Added new leaders to usergroup</b> %s<br />» %s', + 'LOG_USERS_APPROVED' => '<b>Users approved in usergroup</b> %s<br />» %s', + 'LOG_USERS_ADDED' => '<b>Added new members to usergroup</b> %s<br />» %s', + 'LOG_INDEX_ACTIVATE' => '<b>Activated inactive users</b><br />» %s', 'LOG_INDEX_DELETE' => '<b>Deleted inactive users</b><br />» %s', 'LOG_INDEX_REMIND' => '<b>Sent reminder emails to inactive users</b><br />» %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 @@ +<?php +/** +* +* acp_groups [English] +* +* @package language +* @version $Id$ +* @copyright (c) 2005 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* DO NOT CHANGE +*/ +if (empty($lang) || !is_array($lang)) +{ + $lang = array(); +} + +// DEVELOPERS PLEASE NOTE +// +// Placeholders can now contain order information, e.g. instead of +// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows +// translators to re-order the output of data while ensuring it remains correct +// +// You do not need this where single placeholders are used, e.g. 'Message %d' is fine +// equally where a string contains only two placeholders which are used to wrap text +// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine + +$lang += array( + 'ACP_GROUPS_MANAGE_EXPLAIN' => '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 @@ <?php /** * -* acp_modules [English] +* posting [English] * * @package language * @version $Id$ diff --git a/phpBB/styles/subSilver/template/ucp_profile_avatar.html b/phpBB/styles/subSilver/template/ucp_profile_avatar.html index aa8c4f1d06..3456af3192 100644 --- a/phpBB/styles/subSilver/template/ucp_profile_avatar.html +++ b/phpBB/styles/subSilver/template/ucp_profile_avatar.html @@ -40,15 +40,15 @@ <!-- IF S_GALLERY_AVATAR --> <tr> <td class="row1" width="35%"><b class="genmed">{L_AVATAR_GALLERY}: </b></td> - <td class="row2"><input class="btnlite" type="submit" name="displaygallery" value="{L_DISPLAY_GALLERY}" /></td> + <td class="row2"><input class="btnlite" type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" /></td> </tr> <!-- ENDIF --> - <!-- IF S_DISPLAY_GALLERY --> + <!-- IF S_IN_AVATAR_GALLERY --> <tr> <th colspan="2">{L_AVATAR_GALLERY}</th> </tr> <tr> - <td class="cat" colspan="2" align="center" valign="middle"><span class="genmed">{L_AVATAR_CATEGORY}: </span><select name="category">{S_CAT_OPTIONS}</select> <span class="genmed">{L_AVATAR_PAGE}: </span><select name="page">{S_PAGE_OPTIONS}</select> <input class="btnlite" type="submit" value="{L_GO}" name="displaygallery" /></td> + <td class="cat" colspan="2" align="center" valign="middle"><span class="genmed">{L_AVATAR_CATEGORY}: </span><select name="category">{S_CAT_OPTIONS}</select> <input class="btnlite" type="submit" value="{L_GO}" name="display_gallery" /></td> </tr> <tr> <td class="row1" colspan="2" align="center"><table cellspacing="1" cellpadding="4" border="0"> @@ -61,7 +61,7 @@ </tr> <tr> <!-- BEGIN avatar_option_column --> - <td class="row2" align="center"><input type="radio" name="avatarselect" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td> + <td class="row2" align="center"><input type="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td> <!-- END avatar_option_column --> </tr> <!-- END avatar_row --> @@ -70,7 +70,7 @@ </tr> <!-- ENDIF --> <tr> - <td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input class="btnmain" type="submit" name="submit" value="{L_SUBMIT}" /> <!-- IF S_DISPLAY_GALLERY --><input class="btnlite" type="submit" name="cancel" value="{L_CANCEL}" /><!-- ELSE --><input class="btnlite" type="reset" value="{L_RESET}" name="reset" /><!-- ENDIF --></td> + <td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input class="btnmain" type="submit" name="submit" value="{L_SUBMIT}" /> <!-- IF S_IN_AVATAR_GALLERY --><input class="btnlite" type="submit" name="cancel" value="{L_CANCEL}" /><!-- ELSE --><input class="btnlite" type="reset" value="{L_RESET}" name="reset" /><!-- ENDIF --></td> </tr> </table> |