##############################################################
## MOD Title: Current Local Weather part 2 for PCP
## MOD Author: Handyman < Francis@michaellewismusic.com > (Francis Lewis) http://michaellewismusic.com/forum
## MOD Description: This mod allows registered users to pick a city from
## within their profile and have the current and 5 day forecast displayed
## on the main phpbb page. If no city is selected or an invalid code is entered,
## then no weather is displayed. Guests see nothing. This mod also allows
## the admin to view what code a user has chosen through user management in the admin page.
## This mod is based on the weather_usa and real name mods.
## MOD Version: 1.3.2
##
## Installation Level: Intermediate
## Installation Time: 5 Minutes
## Files To Edit:
## language/lang_english/lang_extend_profile_control_panel.php
## profilecp/profilecp_register.php
## profilcp/def/def_userfields.php
## profilcp/def/def_usermaps.php
## templates/subSilver/profilecp/register_body.tpl
## Included Files:
## popup.php
## popup_ab.php
## popup_cd.php
## popup_eg.php
## popup_hj.php
## popup_km.php
## popup_np.php
## popup_qs.php
## popup_tz.php
## popup.tpl
## popup_ab.tpl
## popup_cd.tpl
## popup_eg.tpl
## popup_hj.tpl
## popup_km.tpl
## popup_np.tpl
## popup_qs.tpl
## popup_tz.tpl
## includes/weather.php
## templates/subSilver/weather.css
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Copyright 2005  Handyman.
##
## Thanks to Matt (http://thehottub.net)
## and ozzie for some of the PCP integration.
## and Scanman20 for creating the original version of this mod.
##
## This mod will create a new field in your users table, Registering table
## (for PCP only) and in the profile section (PCP only).
## Registered members will see one of two things. Either "No City Selected"
## or their weather. Users can modify their city code via their profile and admins
## can edit them in the User Admin Management page. I have made the city codes hidden
## to everyone (except the admin) when you look at another user's profile.
## I don't think that should be public. As I designed this mod, only the main index.php
## page shows the weather. This can be altered, however, I don't think users would want
## to see their weather on every page.
## I decided to go with the CNN weather feed which uses city codes or zipcodes.
##
## I will not be able to offer support on any forum except for mine:
## "http://michaellewismusic.com/forum" as I don't have time to check the other forums.
##
## Thanks. Have fun and God Bless.
## http://michaellewismusic.com/pope (tribute to the great Pope John Paul II)
##############################################################
## MOD History:
##
## 2005-04-30 - Version 1.0.0
## - Original release
##
## 2005-05-25 - Version 1.1
## - Fixed the code to be compatible with heavily modded boards
##
## 2005-6-28 - Version 1.2
## - Fixed code to be compatible with different languages
##
## 2005-7-11 - Version 1.3
## - Fixed some Coding errors.
##
## 2005-7-23   - Version 1.3.1
## - Fixed some not critical code in the install file.
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
profilecp/profilecp_register.php

#
#-----[ FIND ]------------------------------------------
#
$view_userdata['user_email'] = '';

#
#-----[ AFTER, ADD ]------------------------------------------
#
$view_userdata['user_zipcode'] = '';

#
#-----[ FIND ]------------------------------------------
#
$user_email_confirm = trim(htmlspecialchars($HTTP_POST_VARS['user_email_confirm']));

#
#-----[ AFTER, ADD ]------------------------------------------
#
$zipcode = trim(htmlspecialchars($HTTP_POST_VARS['zipcode']));

#
#-----[ FIND ]------------------------------------------
#
$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Robot_flood_control'];
	}

#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start Zipcode Check by Francis Lewis 
	// zipcode
	$zipcode_changed = false;
	$zipcode_error = false;

	// create : zipcode should be set
	if ( $create_user && empty($zipcode) )
	{
		$zipcode_error = true;
		$error = true;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty'];
	}

	// edit : check if a zipcode has been set
	if ( !empty($zipcode) )
	{
		if (!$zipcode_error)
		{
			$zipcode_changed = true;
		}
	}
// End Address Check by Francis Lewis

#
#-----[ FIND ]------------------------------------------
#
// prepare values
$values = array();
if ( $username_changed ) $values['username'] = $username;
if ( $email_changed ) $values['user_email'] = $user_email;
if ( $password_changed ) $values['user_password'] = $new_password;
if ( $active_changed ) $values['user_active'] = $user_active;
if ( $active_changed ) $values['user_actkey'] = $user_actkey;

#
#-----[ AFTER, ADD ]------------------------------------------
#
$values['user_zipcode'] = $zipcode;

#
#-----[ FIND ]------------------------------------------
#
'L_SUBMIT' => $lang['Submit'],
'L_RESET' => $lang['Reset'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
'L_ZIPCODE' => $lang['Zipcode'],
'L_ZIPCODE_VIEWABLE' => $lang['Zipcode_Viewable'],

#
#-----[ FIND ]------------------------------------------
#
'EMAIL_CONFIRM'		=> $view_userdata['user_email'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
'ZIPCODE'			=> $view_userdata['user_zipcode'],

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profilecp/register_body.tpl

#
#-----[ FIND ]------------------------------------------
#
<table cellpadding="0" cellspacing="10" border="0" width="100%">

#
#-----[ AFTER, ADD ]------------------------------------------
#
<SCRIPT>
function spawn() {
x=(screen.width/2)-225;
y=(screen.height/2)-200;
window.open('popup.php','test','left=' + x + ',top=' + y +',screenX=x,screenY=y,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=400')
}
</script>

#
#-----[ FIND ]------------------------------------------
#
<form name="post" action="{S_PROFILCP_ACTION}" method="post">

#
#-----[ REPLACE WITH ]------------------------------------------
#
<form name="myform" action="{S_PROFILCP_ACTION}" method="post">

#
#-----[ FIND ]------------------------------------------
#
<tr>
<td class="row1">
<span class="gen">{L_CONFIRM_PASSWORD}:</span>
<span class="gensmall"><br />{L_PASSWORD_CONFIRM_IF_CHANGED}</span>
</td>
<td class="row2">
<input type="password" class="post" style="width: 200px" name="password_confirm" size="25" maxlength="100" value="{PASSWORD_CONFIRM}" />
</td>
</tr>

#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
<td class="row1"><span class="gen">{L_ZIPCODE}:</span><br /><span class="gensmall">{L_ZIPCODE_VIEWABLE}</span></td>
<td class="row2"><input type="text" class="post" style="width:200px" name="zipcode" size="25" maxlength="10" value="{ZIPCODE}" /> <span class="gensmall"><a href="javascript:void(0);" onclick="spawn();">{L_SELECT_CITY}</a></span></td>
</tr>

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_extend_profile_control_panel.php

#
#-----[ FIND ]------------------------------------------
#
$lang['Disagree_rules'] = 'You have declared you disagree with the rules used on this board, so you won\'t be able to register.';

#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Zipcode'] = 'Zipcode/Weather City Code';
$lang['Zipcode_Viewable'] = 'Type in your zipcode or click "select your city" to have your Local Forecast appear at the bottom of the forum index [This is not Publicly Viewable]';

#
#-----[ OPEN ]------------------------------------------
# 
# This step is Optional.
# This section places a zipcode box in the profile, since
# there is already a zipcode box in the registering section
# with a select city button, this is not a necessary step.
profilcp/def/def_userfields.php

#
#-----[ FIND ]------------------------------------------
#
'USERS' => array(
'sql_id' => 'u',
'sql_join' => '[cst.USERS_TABLE] AS [USERS]',
),

#
#-----[ AFTER, ADD ]------------------------------------------
#
'WEATHER' => array(
'sql_id' => 'we',
'sql_join' => 'LEFT JOIN [cst.WEATHER_TABLE] AS [WEATHER].zip_code = [USERS].user_zipcode',
'sql_where' => '[USERS].user_id <> ANONYMOUS',
'sql_order' => '',
),

#
#-----[ FIND ]------------------------------------------
#
'user_work_phone' => array(
'lang_key' => 'Work_phone',
'class' => 'real',
'type' => 'VARCHAR',
),

#
#-----[ AFTER, ADD ]------------------------------------------
#
'user_zipcode' => array(
'lang_key' => 'zip_code',
'explain' => 'zip_code',
'class' => 'real',
'type' => 'VARCHAR',
'dsp_func' => 'pcp_output_zip_code',
'leg' => true,
'txt' => true,
'auth' => USER,
),

#
#-----[ OPEN ]------------------------------------------
#
# If you skipped the last section, (profilecp/def/def_usermaps.php)
#skip this section as well.
profilcp/def/def_usermaps.php

#
#-----[ FIND ]------------------------------------------
#
'user_birthday' => array(
'input_id' => 'birthday',
'user_only' => true,
),

#
#-----[ AFTER, ADD ]------------------------------------------
#
'user_zipcode' => array(
'lang_key' => 'zip_code',
'explain' => 'zip_code',
'class' => 'real',
'type' => 'VARCHAR',
'dsp_func' => 'pcp_output_zip_code',
'leg' => true,
'txt' => true,
'auth' => USER,
),

#
#-----[ FIND ]------------------------------------------
#
'user_work_phone' => array(
'ind' => '23',
),

#
#-----[ AFTER, ADD ]------------------------------------------
#
'user_zipcode' => array(
'lang_key' => 'zip_code',
'explain' => 'zip_code',
'class' => 'real',
'type' => 'VARCHAR',
'dsp_func' => 'pcp_output_zip_code',
'leg' => true,
'txt' => true,
'auth' => USER,
),

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM