[MODDB] ACP Announcement Centre 1.2.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Suggested Hosts
Locked
User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

I just tried this ^ and got:

Code: Select all

Parse error: syntax error, unexpected T_VARIABLE in /home/ronnieja/public_html/RJDtesting/includes/functions_announcements.php on line 71

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

what does your code look like around the replaced code?
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

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;
}



?>

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

i just used your pasted code on my testboard and it worked fine. *shrugs*
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

I just added that same file again

Here is the link
http://www.ronnie-james-dio.com/RJDtesting/index.php

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

Could you set me up with a temp FTP account by any chance? No idea why it does not work for you.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

I don’t know how to do a temp F.T.P.

Would an admin board account work ok?

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

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.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

lefty74 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.
I got the host to show me how to do this so I am sending you a PM

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

i just put the code in, works fine to me.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

lefty74 wrote:i just put the code in, works fine to me.
Just looked at it and it kinna looks the same to me

How do I set the individual birthdays to override ALL birthdays?

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

as you can see i set myself to have a birthday today, it shows on the index page but not in the announcements.

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
you will need to change that part and put down the user_id's of the users you want to show the birthday of so if you have users 3, 56, 23 that you want to show you just change above to this

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
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

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

User avatar
lefty74
Registered User
Posts: 3649
Joined: Wed Sep 14, 2005 8:26 pm
Location: NL
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by lefty74 »

DragonMaster1 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
you can find the user_id of a user when you hover over their username, i.e. your user_id here is 135936

http://www.phpbb.com/community/memberli ... =[b]135936[/b]

However, I am not sure you should be using this code if you do not know where to find the user_id especially as this will not be included in any future versions, i.e. it would have to be changed every time there is a change and I was not going to do that.
lefty74
zoocrew.eu - help us save our wildlife
My MODS | Due to lack of time I unfortunately am unable to work on my mods anymore, anyone who has ideas to improve them and would like to take any of them over, please PM me.

User avatar
DragonMaster1
Registered User
Posts: 994
Joined: Tue Aug 17, 2004 11:04 am
Name: Terry
Contact:

Re: [Beta] ACP Announcement Centre 1.1.3

Post by DragonMaster1 »

I know where to find it on the server control panel where I do the SQL

I was just wondering if there was an easier way

If the code goes in generally the same place, I don’t see a problem with adding it to future releases once I see how it is done as I have to change the code already to get it to match the size of the forum

I see where the code was changed in functions_announcements to use the individual I.D.s

If that is the only line that has changed then it will be no problem to revise this in the future

Thanx for showing me how to do this

Just got your test user name and added it and got it to appear easily

Now I know how to do this

THANX AGAIN

Locked

Return to “[3.0.x] MODs in Development”