Code: Select all
Parse error: syntax error, unexpected T_VARIABLE in /home/ronnieja/public_html/RJDtesting/includes/functions_announcements.php on line 71
Code: Select all
Parse error: syntax error, unexpected T_VARIABLE in /home/ronnieja/public_html/RJDtesting/includes/functions_announcements.php on line 71
lefty74 wrote:what does your code look like around the replaced code?
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id: functions_announcements.php 143 2008-12-06 20:50:08Z lefty74 $
* @copyright (c) 2008 lefty74
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Generate list of groups (option fields with select)
* note: This is a modified function from functions_admin.php
* @param int $group_ids The groupids to mark as selected
* @param array $exclude_ids The group ids to exclude from the list, false (default) if you whish to exclude no id
* @param int $manage_founder If set to false (default) all groups are returned, if 0 only those groups returned not being managed by founders only, if 1 only those groups returned managed by founders only.
*
* @return string The list of options.
*/
function group_select_options_selected($group_ids, $exclude_ids = false, $manage_founder = false)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
$exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
$sql_and = (!$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
$sql = 'SELECT group_id, group_name, group_type
FROM ' . GROUPS_TABLE . "
$exclude_sql
$sql_and
$sql_founder
ORDER BY group_type DESC, group_name ASC";
$result = $db->sql_query($sql);
$s_group_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = (in_array($row['group_id'], $group_ids, true)) ? ' selected="selected"' : '';
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$db->sql_freeresult($result);
return $s_group_options;
}
/**
* get all the announcement data
*
* @param string $birthday_list, true or false
*/
function get_announcement_data()
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
$user->setup('mods/announcement_centre');
$announcement_bd_user_id_ary = array(2,3); // fill the array with the user_id's of the users whose birthday you would like to show as announcement
$birthday_list = $announcement_text = $announcement_birthday_img = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
// Generate birthday list if required ...
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$sql = 'SELECT user_id, username, user_colour, user_birthday, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height
FROM ' . USERS_TABLE . "
WHERE user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND ' . $db->sql_in_set('user_id', $announcement_bd_user_id_ary);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
//obtain the avatar and username for the birthday announcements
$max_bdavatar_size = $avatar_width = $avatar_height = '';
if ( !empty($row['user_avatar']) )
{
$max_bdavatar_size = $config['announcement_ava_max_size'];
if ( $row['user_avatar_width'] >= $row['user_avatar_height'] )
{
$avatar_width = ( $row['user_avatar_width'] > $max_bdavatar_size ) ? $max_bdavatar_size : $row['user_avatar_width'] ;
$avatar_height = ( $avatar_width == $max_bdavatar_size ) ? round($max_bdavatar_size / $row['user_avatar_width'] * $row['user_avatar_height']) : $row['user_avatar_height'] ;
}
else
{
$avatar_height = ( $row['user_avatar_height'] > $max_bdavatar_size ) ? $max_bdavatar_size : $row['user_avatar_height'] ;
$avatar_width = ( $avatar_height == $max_bdavatar_size ) ? round($max_bdavatar_size / $row['user_avatar_height'] * $row['user_avatar_width']) : $row['user_avatar_width'] ;
}
}
if ( !function_exists('get_user_avatar') ) // only checking for one of the functions as the other is in the same file
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
$template->assign_block_vars('bdannounce', array(
'AVATAR' => ($row['user_avatar']) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $avatar_width, $avatar_height, $row['username']) : '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/theme/images/no_avatar.gif" height="' . $config['announcement_ava_max_size'] . '" width="' . $config['announcement_ava_max_size'] . '" title="" alt="" />',
'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'])));
}
$db->sql_freeresult($result);
}
// Generate the announcement data
$sql = 'SELECT *
FROM ' . ANNOUNCEMENTS_CENTRE_TABLE;
$result = $db->sql_query($sql);
$announcement = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$selected_groups = array();
$selected_groups = explode(",", $config['announcement_show_group']);
$sql = 'SELECT *
FROM ' . USER_GROUP_TABLE . '
WHERE ' . $db->sql_in_set('group_id', $selected_groups) . '
AND user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
$result = $db->sql_query_limit($sql,1,0);
$is_in_group = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
//Announcement Centre by lefty74
if ( ($user->data['user_id']) == ANONYMOUS && $config['announcement_show'] == GUESTS_ONLY ) // Guests only
{
$announcement_show = true;
$announcement_show_everyone_guests = true;
}
else if ( $user->data['user_id'] != ANONYMOUS && ($is_in_group && $config['announcement_show'] == GROUPS_ONLY) ) // Groups only
{
$announcement_show = true;
$announcement_show_everyone_guests = false;
}
else if ( $config['announcement_show'] == EVERYONE ) // Everyone
{
$announcement_show = true;
$announcement_show_everyone_guests = true;
}
else
{
$announcement_show = false;
$announcement_show_everyone_guests = false;
}
$announcement_birthday_img = '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/imageset/birthday.png" title="' . $user->lang['CONGRATULATIONS'] . '" alt="' . $user->lang['CONGRATULATIONS'] . '" />';
$where_sql = $order = '';
if ( $announcement['announcement_forum_id'] || $announcement['announcement_topic_id'] || $announcement['announcement_post_id'])
{
if ($announcement['announcement_forum_id'])
{
$where_sql = 'WHERE forum_id = ' . $announcement['announcement_forum_id'];
}
else if ($announcement['announcement_topic_id'])
{
$where_sql = 'WHERE topic_id = ' . $announcement['announcement_topic_id'];
}
else if ($announcement['announcement_post_id'])
{
$where_sql = 'WHERE post_id = ' . $announcement['announcement_post_id'];
}
$announcement_text = announcement_post($where_sql, $announcement['announcement_first_last_post'], $announcement['announcement_gopost']);
}
else
{
$announcement_text = generate_text_for_display($announcement['announcement_text'],$announcement['announcement_text_bbcode_uid'], $announcement['announcement_text_bbcode_bitfield'], $announcement['announcement_text_bbcode_options']);
}
// Assign index specific vars
$template->assign_vars(array(
'ANNOUNCEMENT_TEXT' => $announcement_text,
'ANNOUNCEMENT_BIRTHDAYS' => $birthday_list,
'BIRTHDAY_IMG' => $announcement_birthday_img,
'ANNOUNCEMENT_TITLE_GUESTS' => $announcement['announcement_title_guests'],
'ANNOUNCEMENT_TEXT_GUESTS' => generate_text_for_display($announcement['announcement_text_guests'],$announcement['announcement_text_guests_bbcode_uid'], $announcement['announcement_text_guests_bbcode_bitfield'], $announcement['announcement_text_guests_bbcode_options']),
'ANNOUNCEMENT_TITLE' => $announcement['announcement_title'],
'ANNOUNCEMENT_TITLE_GUESTS' => $announcement['announcement_title_guests'],
'ANNOUNCEMENT_ENABLE' => $config['announcement_enable'],
'ANNOUNCEMENT_ENABLE_GUESTS' => $config['announcement_enable_guests'],
'ANNOUNCEMENT_ALIGN' => $config['announcement_align'],
'ANNOUNCEMENT_GUESTS_ALIGN' => $config['announcement_guests_align'],
'ANNOUNCEMENT_SHOW_BIRTHDAYS_ALWAYS' => $config['announcement_show_birthdays_always'],
'ANNOUNCEMENT_SHOW_BIRTHDAYS_AND_ANNOUNCE' => ($config['announcement_show_birthdays_and_announce']) ? true : false,
'ANNOUNCEMENT_SHOW' => $announcement_show,
'ANNOUNCEMENT_SHOW_EVERYONE' => $announcement_show_everyone_guests,
'ANNOUNCEMENT_SHOW_BIRTHDAY' => ( $birthday_list != '' && $config['announcement_show_birthdays'] ) ? true : false,
'ANNOUNCEMENT_BIRTHDAY_AVATAR' => ($config['announcement_birthday_avatar']) ? true : false,
));
}
/**
* prepares the preview announcement text
*/
function preview_announcement($text)
{
$uid = $bitfield = $options = '';
$allow_bbcode = $allow_smilies = true;
$allow_urls = false;
//lets (mis)use generate_text_for_storage to create some uid, bitfield... for our preview
generate_text_for_storage($text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
//now we created it, lets show it
$text = generate_text_for_display($text, $uid, $bitfield, $options);
return $text;
}
/**
* prepares the preview announcement text
*/
function announcement_post($where_sql, $order, $gotopost)
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
if (!class_exists('bbcode'))
{
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
}
// $first_last = $where_forum = '';
// $first_last = 'ASC';
// //$first_last = 'last';
// $configforum = 11;
// $configpost = 0;
//
// $where_sql = ($configforum) ? 'WHERE forum_id = ' . $configforum : '';
// //$where_post = ($configpost) ? 'AND topic_id = ' . $configpost : '';
$bbcode_bitfield = '';
$sql = 'SELECT *
FROM ' . POSTS_TABLE . "
$where_sql
ORDER BY post_id $order";
$result = $db->sql_query_limit($sql, 1, 0);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ( $row['post_attachment'] )
{
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('post_msg_id', $row['post_id']) . '
AND in_message = 0
ORDER BY filetime DESC, post_msg_id ASC';
$result = $db->sql_query($sql);
while ($row2 = $db->sql_fetchrow($result))
{
$attachments[$row2['post_msg_id']][] = $row2;
}
$db->sql_freeresult($result);
}
// Parse the message and subject
$message = censor_text($row['post_text']);
// Define the global bbcode bitfield, will be used to load bbcodes
$bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
// Instantiate BBCode if need be
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
// Second parse bbcode here
if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
}
$message = bbcode_nl2br($message);
$message = smiley_text($message);
if (!empty($attachments[$row['post_id']]))
{
parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
}
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (!empty($attachments[$row['post_id']]))
{
foreach ($attachments[$row['post_id']] as $attachment)
{
$template->assign_block_vars('attachments', array(
'DISPLAY_ATTACHMENTS' => $attachment)
);
}
}
// Assign index specific vars
$template->assign_vars(array(
'S_HASATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
'U_ANNOUNCEMENT_GOTOPOST' => ($gotopost) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'] : '',
));
return $message;
}
?>
I got the host to show me how to do this so I am sending you a PMlefty74 wrote:no, i wanted to take a look at the php files on the server while they are on there.
i cant do that via the board.
Just looked at it and it kinna looks the same to melefty74 wrote:i just put the code in, works fine to me.
Code: Select all
$announcement_bd_user_id_ary = array(2,3); // fill the array with the user_id's of the users whose birthday you would like to show as announcement
Code: Select all
$announcement_bd_user_id_ary = array(3,56,23); // fill the array with the user_id's of the users whose birthday you would like to show as announcement
you can find the user_id of a user when you hover over their username, i.e. your user_id here is 135936DragonMaster1 wrote:I don’t see where a user I.D. is supposed to be added
BTW....where do I find the individual I.D. numbers?
....and what files/code do I need to change on my main site to get this working there?
Better if I use the code so any future upgrades don’t break it