Page 1 of 2

[BETA] ADD DST in phpBB

Posted: Fri Apr 14, 2006 7:04 pm
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 :)

Posted: Fri Apr 14, 2006 7:35 pm
by Elias
Sorry but what is DST?

Posted: Fri Apr 14, 2006 7:54 pm
by micaribe
EY wrote: Sorry but what is DST?
Description above wrote: ## MOD Title: Add DST (Daylight Saving Time)

Posted: Fri Apr 14, 2006 7:59 pm
by Elias
Sorry didn't see. I only looked at the Description.

Posted: Fri Apr 14, 2006 8:33 pm
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. :)

Posted: Sat Apr 15, 2006 10:38 am
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)

Posted: Sun Apr 16, 2006 4:09 pm
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

Posted: Sun Apr 16, 2006 5:25 pm
by Damic
Ok I've worked hard 8) :lol: and this is currently the working result

Look my first post for the link :)

Posted: Sun Apr 16, 2006 6:21 pm
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

:)

Posted: Sun Apr 16, 2006 7:05 pm
by Damic
THX mate, I missed somethings when I was copy pasting from phpbb :(

ps. ive updated the file (just some syntax :))

Posted: Mon Apr 17, 2006 5:10 pm
by Damic
Ok just uploaded the new beta version 0.0.3 :)

See first post for the url :)

Posted: Tue May 02, 2006 2:45 pm
by ewelin
Is this a forum wide setting or a per user setting?

Posted: Wed May 03, 2006 2:16 pm
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

Posted: Sat May 13, 2006 11:21 pm
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

Posted: Fri May 19, 2006 5:00 am
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