[BETA] ADD DST in phpBB

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! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Damic
Registered User
Posts: 11
Joined: Mon Mar 17, 2003 6:25 pm
Location: Belgium
Contact:

[BETA] ADD DST in phpBB

Post by Damic »

Yes I know another DST mod, but this 1 is working work with the DATE() function :)
add_DST.txt wrote: ##############################################################
## MOD Title: Add DST (Daylight Saving Time)
## MOD Author: Damic
## MOD Description: This mod will add the DST feature to your forum.
## MOD Version: BETA 0.0.3
## MOD Download: http://home.scarlet.be/~guido456/andere/add_DST.txt
##
## Installation Level: easy/medium
## Installation Time: 10 Minutes
## Files To Edit: (7)
## usercp_register.php
## lang_main.php
## profile_add_body.tpl
## functions.php
## admin_board.php
## lang_admin.php
## board_config_body.tpl
##
## Included Files: (0)
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## 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/
##############################################################
## MOD History:
## BETA 0.0.3: Admin Config Board (ACP) Changed + Mod History
## BETA 0.0.2: Saves user DST info now + corrects the hours + Some syntax changed
## ALPHA 0.0.1: First release, nothing to fancy
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################


Normaly everything is working, if you find a bug please post it here :)
Last edited by Damic on Mon Apr 17, 2006 5:14 pm, edited 5 times in total.
User avatar
Elias
Registered User
Posts: 5136
Joined: Sat Feb 25, 2006 4:31 pm
Location: In the Water!
Name: Elias

Post by Elias »

Sorry but what is DST?
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|
Offering private web hosting. Contact me for details.
micaribe
Registered User
Posts: 264
Joined: Wed Aug 24, 2005 7:00 pm
Location: 42° 3' N 83° 22' W

Post by micaribe »

EY wrote: Sorry but what is DST?
Description above wrote: ## MOD Title: Add DST (Daylight Saving Time)
- Matt

Did you know... "mi caribe" is Spanish for "my Caribbean"

www.micaribe.net || community.micaribe.net || About Me!
No support via PM
User avatar
Elias
Registered User
Posts: 5136
Joined: Sat Feb 25, 2006 4:31 pm
Location: In the Water!
Name: Elias

Post by Elias »

Sorry didn't see. I only looked at the Description.
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|
Offering private web hosting. Contact me for details.
User avatar
-ds-
Registered User
Posts: 554
Joined: Wed Sep 14, 2005 7:12 pm

Post by -ds- »

I tried this on a test board and it didn't work.

The ticked value in the profile never stuck, and the board time didn't change.

Couldn't you use the standard 2 boxes (yes/no) instead of the 1?
Also, could you incorporate being able to switch the defaults 'Enable DST' (yes/no) in the ACP Board Config to show or hide the options in the profile?


I would love this to work. :)
Damic
Registered User
Posts: 11
Joined: Mon Mar 17, 2003 6:25 pm
Location: Belgium
Contact:

Post by Damic »

@-ds-: First READ THE DAMN TITLE: it says ALPHA but for the rest:
Couldn't you use the standard 2 boxes (yes/no) instead of the 1?
I will try
you incorporate being able to switch the defaults 'Enable DST' (yes/no)
Yes i will

Sorry for shouting but sometimes people need it, just to see what they have missed

For the rest:
Progress information:
* More files are changed :)
* Currently I'm changing the create_date() function in functions.php (tricky part)
User avatar
-ds-
Registered User
Posts: 554
Joined: Wed Sep 14, 2005 7:12 pm

Post by -ds- »

Damic wrote: Sorry for shouting but sometimes people need it, just to see what they have missed


Well I though since you ARE providing a code that it would work :lol:

And since its alpha i merely provided you with testing feedback which was that it didn't work :wink:

It looks like a good mod and I look forward to seeing it in Beta or released :P
Damic
Registered User
Posts: 11
Joined: Mon Mar 17, 2003 6:25 pm
Location: Belgium
Contact:

Post by Damic »

Ok I've worked hard 8) :lol: and this is currently the working result

Look my first post for the link :)
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26854
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Post by Paul »

Code: Select all

$user_dst=( isset($HTTP_POST_VARS['dst']) ) ? doubleval($HTTP_POST_VARS['dst']) : $board_config['board_dst'];
I think you can better use intval(), because it is a int, not a double.

Code: Select all

        'DST_SELECT_NO'=>!($user_dst)? 'checked="checked"' : '',
        'DST_SELECT_YES'=>($user_dst)? 'checked="checked"' : '',
Can be better this:

Code: Select all

        'DST_SELECT_NO'=>(!$user_dst)? 'checked="checked"' : '',
        'DST_SELECT_YES'=>($user_dst)? 'checked="checked"' : '',

Code: Select all

user_dst=$user_dst,
Add some space before and after the = :)

Code: Select all

# 
#-----[ FIND ]------------------------------------------ 
#

	global $board_config, $lang;

replace in

	; => ,$userdata;

## it must look like this: global $board_config, $lang, $userdata;
Isn't a valid action:

Code: Select all

# 
#-----[ FIND ]------------------------------------------ 
#

	global $board_config, $lang;

# 
#-----[ INLINE, FIND ]------------------------------------------ 
#

	;
# 
#-----[ INLINE, BEFORE ADD ]------------------------------------------ 
#

,$userdata

## it must look like this: global $board_config, $lang, $userdata;

Code: Select all

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

# 
#-----[ SQL ]------------------------------------------ 
# 

insert into `phpbb_config` set `config_name`='BOARD_DST',`config_value`='0';
ALTER TABLE `phpbb_users` ADD `user_dst` TINYINT( 1 ) NOT NULL DEFAULT '0';
The sql command cannot be after the end of the mod.
You use some action that not exists. See also this kb articel:
http://www.phpbb.com/kb/article.php?article_id=38
http://www.phpbb.com/kb/article.php?article_id=39
http://www.phpbb.com/kb/article.php?article_id=200

:)
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development
Damic
Registered User
Posts: 11
Joined: Mon Mar 17, 2003 6:25 pm
Location: Belgium
Contact:

Post by Damic »

THX mate, I missed somethings when I was copy pasting from phpbb :(

ps. ive updated the file (just some syntax :))
Damic
Registered User
Posts: 11
Joined: Mon Mar 17, 2003 6:25 pm
Location: Belgium
Contact:

Post by Damic »

Ok just uploaded the new beta version 0.0.3 :)

See first post for the url :)
User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Post by ewelin »

Is this a forum wide setting or a per user setting?
User avatar
vrflyer
Registered User
Posts: 503
Joined: Mon Feb 17, 2003 8:27 pm

Post by vrflyer »

The code below makes almost no sense or lacks logical editing.

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#

	includes/functions.php

#
#-----[ FIND ]------------------------------------------
#

	return ( !empty($translate) ) ?


#
#-----[ FIND IN ]------------------------------------------
#

	$tz

#
#-----[ REPLACE BY ]------------------------------------------
#

	$tz + $dst
#
#-----[ BEFORE, ADD ]------------------------------------------
#

	$dst=date("I", $gmepoch +(3600 * $tz));
	if(!$userdata['user_dst']==1 || !$dst==1)$dst=0;
This is part of the code to be edited, however see above instructions...

Code: Select all

//
// Create date/time from format and timezone
//
function create_date($format, $gmepoch, $tz)
{
	global $board_config, $lang, $userdata;
	static $translate;

	if ( empty($translate) && $board_config['default_lang'] != 'english' )
	{
		@reset($lang['datetime']);
		while ( list($match, $replace) = @each($lang['datetime']) )
		{
			$translate[$match] = $replace;
		}
	}

	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
}
Please clarify. :P
Always Under Construction !
Stevish
Registered User
Posts: 12
Joined: Thu May 11, 2006 4:23 am

Post by Stevish »

I just want to offer a note of encouragement. I am very much looking forward to the final release of this MOD. The only other DST mod that was released was locked back in April of 2003 (and had several problems), and apparently you are the only one who is even working on this kind of MOD right now.

So keep up the good work... if I knew enough about php, I'd try to help... but alas... I know nothing :?

-Steve
mtcrowe
Registered User
Posts: 3
Joined: Wed Nov 16, 2005 2:15 am

Post by mtcrowe »

I tried this mod and couldn't get it to work. I did some patching using some other information I found on DST and removed the (ACP) section and got it working nicely on a user by user basis. Here is the code I used based on your mod.

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
# 

	includes/usercp_register.php

# 
#-----[ FIND ]------------------------------------------ 
#

	$user_timezone = ( isset($HTTP_POST_VARS['timezone']) ) ? doubleval($HTTP_POST_VARS['timezone']) : $board_config['board_timezone'];

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

    	$user_dst=( isset($HTTP_POST_VARS['dst']) ) ? intval($HTTP_POST_VARS['dst']) : $board_config['board_dst'];


# 
#-----[ FIND ]------------------------------------------ 
#
	$user_dateformat = $userdata['user_dateformat'];

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	$user_dst = $userdata['user_dst'];

# 
#-----[ FIND ]------------------------------------------ 
#
	'SMILIES_STATUS' => $smilies_status, 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

        'DST_SELECT_NO'=>(!$user_dst)? 'checked="checked"' : '',
        'DST_SELECT_YES'=>($user_dst)? 'checked="checked"' : '',

# 
#-----[ FIND ]------------------------------------------ 
#

	'L_EMAIL_ADDRESS' => $lang['Email_address'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

        'L_DST'=> $lang['DST'],

# 
#-----[ FIND ]------------------------------------------ 
#

	$sql = "UPDATE " . USERS_TABLE . "

# 
#-----[ FIND IN ]------------------------------------------ 
#

	user_timezone = $user_timezone,   

# 
#-----[ ADD IN ]------------------------------------------ 
#

	user_dst = $user_dst,  

## must look like this:  $user_timezone, user_dst=$user_dst,

# 
#-----[ OPEN ]------------------------------------------ 
#

	templates/subsilver/profile_add_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
	<tr> 
	  <td class="row1"><span class="gen">{L_TIMEZONE}:</span></td>
	  <td class="row2"><span class="gensmall">{TIMEZONE_SELECT}</span></td>
	</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	<tr> 
	  <td class="row1"><span class="gen">{L_DST}:</span></td>
	  <td class="row2">
		<input type="radio" name="dst" value="1" {DST_SELECT_YES} />
		<span class="gen">{L_YES}</span>&nbsp;&nbsp; 
		<input type="radio" name="dst" value="0" {DST_SELECT_NO} />
		<span class="gen">{L_NO}</span>
	  </td>
	</tr>

# 
#-----[ OPEN ]------------------------------------------ 
#

	languages/english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
#

	$lang['Timezone'] = 'Timezone';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

	$lang['DST']='Daylight Saving Time';

# 
#-----[ OPEN ]------------------------------------------ 
#

	includes/functions.php

# 
#-----[ FIND ]------------------------------------------ 
#

	global $board_config, $lang;

#
#-----[ INLINE, FIND ]------------------------------------------
# 

	; 

#
#-----[ INLINE, BEFORE ADD ]------------------------------------------
#

	, $userdata

## it must look like this: global $board_config, $lang, $userdata;

# 
#-----[ FIND ]------------------------------------------ 
# 
return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz)); 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
if(!$userdata['user_dst']==0)
    {
	    return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz) + (date('I') * 3600)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz) + (date('I') * 3600));
    }
    else
	{
	     return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
    }

# 
#-----[ SQL ]------------------------------------------ 
# 

ALTER TABLE `phpbb_users` ADD `user_dst` TINYINT( 1 ) NOT NULL DEFAULT '0';

# 
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM
Michael
"Without hope (we) would drown in our sorrow" -Lady Yunalesca FFX

Crow's Nest Online Support Group
Post Reply

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