[RC] Country Flag User Edition

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!
Get Involved
User avatar
oddfish
Registered User
Posts: 839
Joined: Mon Mar 19, 2007 8:45 pm
Location: Testing 3.1
Contact:

Re: [RC] Country Flag User Edition

Post by oddfish » Sat Nov 07, 2009 10:52 pm

looks like an edit or 2 was missed.

check /includes/ucp/ucp_profile.php again for all edits -- the empty box in particular might point to the last edit placed before ICQ.

If not, pm me and we'll get you sorted.

cheers,
oddfish.
Country Flag User Edition Clickable Post Count Link

... another record broken without breaking any records ...
Testing phpBB3.1 dark style based on prosilver ... http://www.oddmods.net

Br33zer
Registered User
Posts: 76
Joined: Fri Sep 19, 2008 7:07 pm
Contact:

Re: [RC] Country Flag User Edition

Post by Br33zer » Sat Nov 07, 2009 11:09 pm

You were right. I had to do some edits in /includes/ucp/ucp_profile.php

Got it now. Working like a charm :D

Thanks.
Visit: http://www.gossipall.com/ For the latest news, images and other stuff of entertainment.
Visit: http://www.easyrecipesmenu.com/ For Easy Recipes.

User avatar
Gremlinn
Registered User
Posts: 2133
Joined: Mon Aug 04, 2003 12:13 am
Location: Rochester, NY
Name: Nathan

Re: [RC] Country Flag User Edition

Post by Gremlinn » Thu Nov 19, 2009 2:12 pm

RC UPDATE: oddfish and I have tested the RC version with 3.0.6. It looks good. I have a little more validation to go, but it looks to be a go for release tomorrow.

skool!
Registered User
Posts: 4
Joined: Fri Nov 20, 2009 7:27 pm

Re: [RC] Country Flag User Edition

Post by skool! » Sun Nov 22, 2009 8:04 pm

Purged my site after installing a few other MODS and now I notice two flags. This only appears when checking PM's. Any idea where the problem is?

Image

ucp_pm_viewmessage.php

Code: Select all

<?php
/**
*
* @package ucp
* @version $Id: ucp_pm_viewmessage.php 10126 2009-09-09 21:41:51Z bantu $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* View private message
*/
function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{
	global $user, $template, $auth, $db, $cache;
	global $phpbb_root_path, $phpEx, $config;

	$user->add_lang(array('viewtopic', 'memberlist'));

	$msg_id		= (int) $msg_id;
	$folder_id	= (int) $folder_id;
	$author_id	= (int) $message_row['author_id'];
	$view		= request_var('view', '');

	// Not able to view message, it was deleted by the sender
	if ($message_row['pm_deleted'])
	{
		$meta_info = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&folder=$folder_id");
		$message = $user->lang['NO_AUTH_READ_REMOVED_MESSAGE'];

		$message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>');
		trigger_error($message);
	}

	// Do not allow hold messages to be seen
	if ($folder_id == PRIVMSGS_HOLD_BOX)
	{
		trigger_error('NO_AUTH_READ_HOLD_MESSAGE');
	}

	// Grab icons
	$icons = $cache->obtain_icons();

	$bbcode = false;

	// Instantiate BBCode if need be
	if ($message_row['bbcode_bitfield'])
	{
		include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
		$bbcode = new bbcode($message_row['bbcode_bitfield']);
	}

	// Assign TO/BCC Addresses to template
	write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id);

	$user_info = get_user_information($author_id, $message_row);

	// Parse the message and subject
	$message = censor_text($message_row['message_text']);

	// Second parse bbcode here
	if ($message_row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']);
	}

	// Always process smilies after parsing bbcodes
	$message = bbcode_nl2br($message);
	$message = smiley_text($message);

	// Replace naughty words such as farty pants
	$message_row['message_subject'] = censor_text($message_row['message_subject']);

	// Editing information
	if ($message_row['message_edit_count'] && $config['display_last_edited'])
	{
		$l_edit_time_total = ($message_row['message_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
		$l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, (!$message_row['message_edit_user']) ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time'], false, true), $message_row['message_edit_count']);
	}
	else
	{
		$l_edited_by = '';
	}

	// Pull attachment data
	$display_notice = false;
	$attachments = array();

	if ($message_row['message_attachment'] && $config['allow_pm_attach'])
	{
		if ($auth->acl_get('u_pm_download'))
		{
			$sql = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . "
				WHERE post_msg_id = $msg_id
					AND in_message = 1
				ORDER BY filetime DESC, post_msg_id ASC";
			$result = $db->sql_query($sql);

			while ($row = $db->sql_fetchrow($result))
			{
				$attachments[] = $row;
			}
			$db->sql_freeresult($result);

			// No attachments exist, but message table thinks they do so go ahead and reset attach flags
			if (!sizeof($attachments))
			{
				$sql = 'UPDATE ' . PRIVMSGS_TABLE . "
					SET message_attachment = 0
					WHERE msg_id = $msg_id";
				$db->sql_query($sql);
			}
		}
		else
		{
			$display_notice = true;
		}
	}

	// Assign inline attachments
	if (!empty($attachments))
	{
		$update_count = array();
		parse_attachments(false, $message, $attachments, $update_count);

		// Update the attachment download counts
		if (sizeof($update_count))
		{
			$sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
				SET download_count = download_count + 1
				WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
			$db->sql_query($sql);
		}
	}

	$user_info['sig'] = '';

	$signature = ($message_row['enable_sig'] && $config['allow_sig'] && $auth->acl_get('u_sig') && $user->optionget('viewsigs')) ? $user_info['user_sig'] : '';

	// End signature parsing, only if needed
	if ($signature)
	{
		$signature = censor_text($signature);

		if ($user_info['user_sig_bbcode_bitfield'])
		{
			if ($bbcode === false)
			{
				include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
				$bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']);
			}

			$bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']);
		}

		$signature = bbcode_nl2br($signature);
		$signature = smiley_text($signature);
	}

	$url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm');

	// Number of "to" recipients
	$num_recipients = (int) preg_match_all('/:?(u|g)_([0-9]+):?/', $message_row['to_address'], $match);

	$template->assign_vars(array(
		'MESSAGE_AUTHOR_FULL'		=> get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
		'MESSAGE_AUTHOR_COLOUR'		=> get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
		'MESSAGE_AUTHOR'			=> get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
		'U_MESSAGE_AUTHOR'			=> get_username_string('profile', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),

		'FLAG_COUNTRY'		=> $user_info['flag_country'],
		'FLAG_CODE'			=> $user_info['flag_code'],
		'FLAG_IMG'			=> $user_info['flag_img'],

		'RANK_TITLE'		=> $user_info['rank_title'],
		'RANK_IMG'			=> $user_info['rank_image'],
		'AUTHOR_AVATAR'		=> (isset($user_info['avatar'])) ? $user_info['avatar'] : '',
		'AUTHOR_JOINED'		=> $user->format_date($user_info['user_regdate']),
		'AUTHOR_POSTS'		=> (int) $user_info['user_posts'],
		'AUTHOR_FROM'		=> (!empty($user_info['user_from'])) ? $user_info['user_from'] : '',

		'ONLINE_IMG'		=> (!$config['load_onlinetrack']) ? '' : ((isset($user_info['online']) && $user_info['online']) ? $user->img('icon_user_online', $user->lang['ONLINE']) : $user->img('icon_user_offline', $user->lang['OFFLINE'])),
		'S_ONLINE'			=> (!$config['load_onlinetrack']) ? false : ((isset($user_info['online']) && $user_info['online']) ? true : false),
		'DELETE_IMG'		=> $user->img('icon_post_delete', $user->lang['DELETE_MESSAGE']),
		'INFO_IMG'			=> $user->img('icon_post_info', $user->lang['VIEW_PM_INFO']),
		'PROFILE_IMG'		=> $user->img('icon_user_profile', $user->lang['READ_PROFILE']),
		'EMAIL_IMG'			=> $user->img('icon_contact_email', $user->lang['SEND_EMAIL']),
		'QUOTE_IMG'			=> $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']),
		'REPLY_IMG'			=> $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']),
		'REPORT_IMG'		=> $user->img('icon_post_report', 'REPORT_PM'),
		'EDIT_IMG'			=> $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']),
		'MINI_POST_IMG'		=> $user->img('icon_post_target', $user->lang['PM']),

		'SENT_DATE'			=> ($view == 'print') ? $user->format_date($message_row['message_time'], false, true) : $user->format_date($message_row['message_time']),
		'SUBJECT'			=> $message_row['message_subject'],
		'MESSAGE'			=> $message,
		'SIGNATURE'			=> ($message_row['enable_sig']) ? $signature : '',
		'EDITED_MESSAGE'	=> $l_edited_by,
		'MESSAGE_ID'		=> $message_row['msg_id'],

		'U_PM'			=> ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $author_id) : '',
		'U_WWW'			=> (!empty($user_info['user_website'])) ? $user_info['user_website'] : '',
		'U_ICQ'			=> ($user_info['user_icq']) ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '',
		'U_AIM'			=> ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=aim&u=' . $author_id) : '',
		'U_YIM'			=> ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '',
		'U_MSN'			=> ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=msnm&u=' . $author_id) : '',
		'U_JABBER'		=> ($user_info['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $author_id) : '',

		'U_DELETE'			=> ($auth->acl_get('u_pm_delete')) ? "$url&mode=compose&action=delete&f=$folder_id&p=" . $message_row['msg_id'] : '',
		'U_EMAIL'			=> $user_info['email'],
		'U_REPORT'			=> ($config['allow_pm_report']) ? append_sid("{$phpbb_root_path}report.$phpEx", "pm=" . $message_row['msg_id']) : '',
		'U_QUOTE'			=> ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=quote&f=$folder_id&p=" . $message_row['msg_id'] : '',
		'U_EDIT'			=> (($message_row['message_time'] > time() - ($config['pm_edit_time'] * 60) || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit')) ? "$url&mode=compose&action=edit&f=$folder_id&p=" . $message_row['msg_id'] : '',
		'U_POST_REPLY_PM'	=> ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $message_row['msg_id'] : '',
		'U_POST_REPLY_ALL'	=> ($auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&mode=compose&action=reply&f=$folder_id&reply_to_all=1&p=" . $message_row['msg_id'] : '',
		'U_PREVIOUS_PM'		=> "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=previous",
		'U_NEXT_PM'			=> "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=next",

		'U_PM_ACTION'		=> $url . '&mode=compose&f=' . $folder_id . '&p=' . $message_row['msg_id'],

		'S_HAS_ATTACHMENTS'	=> (sizeof($attachments)) ? true : false,
		'S_DISPLAY_NOTICE'	=> $display_notice && $message_row['message_attachment'],
		'S_AUTHOR_DELETED'	=> ($author_id == ANONYMOUS) ? true : false,
		'S_SPECIAL_FOLDER'	=> in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)),
		'S_PM_RECIPIENTS'	=> $num_recipients,

		'U_PRINT_PM'		=> ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&f=$folder_id&p=" . $message_row['msg_id'] . "&view=print" : '',
		'U_FORWARD_PM'		=> ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&mode=compose&action=forward&f=$folder_id&p=" . $message_row['msg_id'] : '')
	);

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if (isset($attachments) && sizeof($attachments))
	{
		foreach ($attachments as $attachment)
		{
			$template->assign_block_vars('attachment', array(
				'DISPLAY_ATTACHMENT'	=> $attachment)
			);
		}
	}

	if (!isset($_REQUEST['view']) || $_REQUEST['view'] != 'print')
	{
		// Message History
		if (message_history($msg_id, $user->data['user_id'], $message_row, $folder))
		{
			$template->assign_var('S_DISPLAY_HISTORY', true);
		}
	}
}

/**
* Get user information (only for message display)
*/
function get_user_information($user_id, $user_row)
{
	global $db, $auth, $user, $cache;
	global $phpbb_root_path, $phpEx, $config;

	if (!$user_id)
	{
		return array();
	}

	if (empty($user_row))
	{
		$sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $user_id;
		$result = $db->sql_query($sql);
		$user_row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
	}

	// Some standard values
	$user_row['online'] = false;
	$user_row['flag_country'] = $user_row['flag_code'] = $user_row['flag_img'] = $user_row['flag_img_src'] = 
$user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';

	// Generate online information for user
	if ($config['load_onlinetrack'])
	{
		$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
			FROM ' . SESSIONS_TABLE . "
			WHERE session_user_id = $user_id
			GROUP BY session_user_id";
		$result = $db->sql_query_limit($sql, 1);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);

		$update_time = $config['load_online_time'] * 60;
		if ($row)
		{
			$user_row['online'] = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? true : false;
		}
	}

	if (!function_exists('get_user_avatar'))
	{
		include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
	}

	$user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : '';

	get_user_flag($user_row['user_flag'], $user_row['flag_country'], $user_row['flag_code'], $user_row['flag_img'], $user_row['flag_img_src']);


	get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);

	if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email'))
	{
		$user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$user_id") : ((($config['board_hide_emails'] && !$auth->acl_get('a_email')) || empty($user_row['user_email'])) ? '' : 'mailto:' . $user_row['user_email']);
	}

	return $user_row;
}

?>
I have checked and re-checked the code but can't seem to find where I went wrong.

Thanks,

User avatar
oddfish
Registered User
Posts: 839
Joined: Mon Mar 19, 2007 8:45 pm
Location: Testing 3.1
Contact:

Re: [RC] Country Flag User Edition

Post by oddfish » Mon Nov 23, 2009 3:35 am

have a look in yur template/ucp_pm_viewmessage.html for a duplicate entry.

also to tidy up the code you have posted above, find:

Code: Select all

$user_row['flag_country'] = $user_row['flag_code'] = $user_row['flag_img'] = $user_row['flag_img_src'] =
$user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';
and replace with:

Code: Select all

$user_row['flag_country'] = $user_row['flag_code'] = $user_row['flag_img'] = $user_row['flag_img_src'] = $user_row['rank_title'] = $user_row['rank_image'] = $user_row['rank_image_src'] = $user_row['email'] = '';
it is an inline add, not on a new line.

cheers,
oddfish.
Country Flag User Edition Clickable Post Count Link

... another record broken without breaking any records ...
Testing phpBB3.1 dark style based on prosilver ... http://www.oddmods.net

User avatar
TheSnake
Registered User
Posts: 483
Joined: Wed Aug 09, 2006 10:36 pm
Location: Staffordshire, England, UK
Contact:

Re: [RC] Country Flag User Edition

Post by TheSnake » Mon Nov 23, 2009 9:30 am

Hi Gremlinn, I had a look in the Mod Database but couldn't find anything about it's release. What is the status on this, has it been submitted, or is it still going through Validation?

I've updated to 3.0.6 yesterday, & found some of my previously installed mods don't want to work now :cry: , so since you have recently said yours is almost ready for release, I will be eagerly waiting for the official release. :)
Gremlinn wrote:RC UPDATE: oddfish and I have tested the RC version with 3.0.6. It looks good. I have a little more validation to go, but it looks to be a go for release tomorrow.

User avatar
Gremlinn
Registered User
Posts: 2133
Joined: Mon Aug 04, 2003 12:13 am
Location: Rochester, NY
Name: Nathan

Re: [RC] Country Flag User Edition

Post by Gremlinn » Mon Nov 23, 2009 1:09 pm

My apologies. I was unable to find the time over the weekend to post it's release. Unless I hear from oddfish, I will be posting the latest tonight and submitting it to the database tomorrow.

User avatar
TheSnake
Registered User
Posts: 483
Joined: Wed Aug 09, 2006 10:36 pm
Location: Staffordshire, England, UK
Contact:

Re: [RC] Country Flag User Edition

Post by TheSnake » Mon Nov 23, 2009 2:37 pm

OK, thanks for the update.

Once you submit it to the database, does that mean it's available straight away, or is there some procedure they go through before it's listed as valid & ready for use?

User avatar
Gremlinn
Registered User
Posts: 2133
Joined: Mon Aug 04, 2003 12:13 am
Location: Rochester, NY
Name: Nathan

Re: [RC] Country Flag User Edition

Post by Gremlinn » Mon Nov 23, 2009 5:10 pm

The RC will be made available here. The database submission will go through validation by phpbb mod testers. Once it is validated, this topic will be closed and a new release topic will be created. I'll update this topic with all important information.

skool!
Registered User
Posts: 4
Joined: Fri Nov 20, 2009 7:27 pm

Re: [RC] Country Flag User Edition

Post by skool! » Mon Nov 23, 2009 5:37 pm

Thank you Oddfish for the speedy reply. That worked perfectly.
And thank you and Gremlinn for your hard work and dedication to this great MOD.

User avatar
TheSnake
Registered User
Posts: 483
Joined: Wed Aug 09, 2006 10:36 pm
Location: Staffordshire, England, UK
Contact:

Re: [RC] Country Flag User Edition

Post by TheSnake » Mon Nov 23, 2009 6:42 pm

OK, thanks for the info Gremlinn, will keep popping back to check on it's status. :D

User avatar
Gremlinn
Registered User
Posts: 2133
Joined: Mon Aug 04, 2003 12:13 am
Location: Rochester, NY
Name: Nathan

Re: [RC] Country Flag User Edition

Post by Gremlinn » Tue Nov 24, 2009 1:56 pm

UPDATE: I have submitted the latest version of this mod to the release database. It will not be reviewed by the phpbb team. Upon approval, I will post here the released mod topic.

I apologize, for at the moment, I do not have the latest and greatest posted yet. I will put the release candidate up as soon as possible.

User avatar
TheSnake
Registered User
Posts: 483
Joined: Wed Aug 09, 2006 10:36 pm
Location: Staffordshire, England, UK
Contact:

Re: [RC] Country Flag User Edition

Post by TheSnake » Wed Nov 25, 2009 8:55 am

No worries, thanks for keeping us appraised of the situation :-D

neonshares
Registered User
Posts: 138
Joined: Thu May 21, 2009 1:31 am

Re: [RC] Country Flag User Edition

Post by neonshares » Thu Nov 26, 2009 6:56 am

Can we make auto country detection by using the user IP and adding the flag automatically to registration page?

Seen some websites where they display our country, location, what browser we use like that. So by using that feature can we make it possible for auto addition of flag to the registration page. This also reduces spammer as some will keep fake country.

User avatar
oddfish
Registered User
Posts: 839
Joined: Mon Mar 19, 2007 8:45 pm
Location: Testing 3.1
Contact:

Re: [RC] Country Flag User Edition

Post by oddfish » Thu Nov 26, 2009 8:06 am

neonshares wrote:Can we make auto country detection by using the user IP and adding the flag automatically to registration page?

Seen some websites where they display our country, location, what browser we use like that. So by using that feature can we make it possible for auto addition of flag to the registration page. This also reduces spammer as some will keep fake country.
this MOD will not go with reg by ip. there are 2 other such MODs here that will.

how would that reduce spammers?
Country Flag User Edition Clickable Post Count Link

... another record broken without breaking any records ...
Testing phpBB3.1 dark style based on prosilver ... http://www.oddmods.net

Locked

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