[REQ] Edit Post and Registration Dates

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

[REQ] Edit Post and Registration Dates

Post by Linda Carter » Tue Jul 15, 2008 5:51 pm

Edit Post Date
This hack allows the Admin(s) of your forum to change the posting date of any post on the forum.

After installing the hack, a new button entitled 'date' will appear next to the normal 'edit' button at the top of each post if you are logged in as an Admin. Pressing the button causes a popup window to appear that allows you to change the post date of the post. When the popup window closes, the page is refreshed and the new post date will appear for the post.

A check is made so that an illegal date, i.e. February 30, 2002, cannot be entered.
These MODs already exists but were developed for phpBB 2, not phpBB 3. :)

I am actually using them and they are working fine, but in the future I will try phpBB 3 but don't want lose these features.

What needs to be corrected (and not only modified to work on phpB 3):

Edit Post Date:

- Only american dates: Month, Day, Year (not a big deal, but could be changed);

- Dates can only be changed from 1995 to 2010 - I don't know what is going to happen when we reach the year 2010;

- When you set a time such as 02:00 PM, you are actually saying the post date was made on 03:00 PM. My english is not that good, but I believe this is called:

http://en.wikipedia.org/wiki/Daylight_saving_time

And when you specify the hour/minutes between November to February/March, 02:00 PM for example, you are in fact saying it was posted on 04:00 PM. This really needs to be fixed! I don't know the logic behind it, if someone could explain.

My board (and all my users) are always using GMT -03:00. And everytime I need to modify one post date to match the original ones, I am having this kind of problem.

- phpBB 2 is preventing us to order all threads on the list by the last post/date. Like the member Carpe Diem said:
I guess there is no further development going on for this otherwise very useful mod, concerning the fix of the replacing of the topic in the viewforum page according to the date change?
I have changed all dates but if this matter can't be solved, we may have threads when the last post date was 2004 being listed first (on the top), and when the last post date was 5 minutes ago being listed on the bottom of the viewforum page.

If wasn't for this, this hack could have been 100% perfect. All my threads being listed chronologicaly, considering the fake dates. The viewforum is disregarding this hack on the thread list.

Edit Registration Date:
Note: Dates can be changed from 1970 to 2030 for example;

- Only american dates: Month, Day, Year (not a big deal, but could be changed - we use Day/Month/Year, that's why I always get confused);

- It would be nice to have one option to change registration dates (if you are the admin) by just looking the profile (not going to the Admin CP everytime).

Downloading the MODS (if you want to know how they work):

Edit Post Date

## Installation Level: Easy
## Installation Time: 2 minutes

## Included Files (7): edit_post_date_install.txt
## edit_post_date.php
## edit_post_date_functions.php
## edit_post_date_body.tpl
## lang_edit_post_date.php
## edit_post_date_icon.gif
## icon_edit_date.gif

http://www.phpbbhacks.com/download/883

Editable Registration Date

## Installation Level: Easy
## Installation Time: 5 minutes
##
## Files To Edit: admin/admin_users.php
## language/lang_english/lang_admin.php
## templates/subSilver/admin/user_edit_body.tpl

http://www.phpbbhacks.com/download/7956

The author of the Post Date hack is not working on his MOD anymore, in the last years he just corrected the code:
http://www.erdrron.com/phpBB2/index.php

If someone knows how to, at least, adapt these MODs to work on phpBB 3, it will be great. :)

For those who are asking what is the purpose of modifying post dates, I have losted my old board and no backups (from the database) were made, but I was able to find threads cached by Google (HTML) and I have created the same scenario today on phpBB 2, so these MODs were somehow, useful to me. ;)
Last edited by Linda Carter on Sun Sep 07, 2008 9:33 pm, edited 1 time in total.
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

letmeinforgodsake
Registered User
Posts: 467
Joined: Thu Mar 21, 2002 12:01 am
Location: England

Re: Edit Post and Registration Dates

Post by letmeinforgodsake » Wed Jul 16, 2008 8:28 am

Is it just me, or is this still taking the time from the server clock, which is no use at all ?

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: Edit Post and Registration Dates

Post by Linda Carter » Thu Jul 17, 2008 7:47 pm

letmeinforgodsake wrote:Is it just me, or is this still taking the time from the server clock, which is no use at all ?
What is the concept of a server clock?

Sorry if I am being too dumb but one thing about this Edit Post Date hack that I never figure out was why the modified post hour/minute time is always changed this way (1 hour after your specified time on 80% of the year/posts, and 2 hours in the start of spring until the end of the autumn - November to March).

I mean, I could understand the second case because many countries have used it, including mine (despite the fact that here on the northeast area, we don't use it because there are no benefits, so in many states it's 02:00 AM and here will be always 01:00 AM).

I always choose "No" for the option "Summer Time/DST is in effect" (my phpBB 2 doesn't have this feature to be selected, however, phpBB 3 does).

When I am saying 04:50 AM to this MOD I might be saying 05:50 AM or 06:50 AM. Even if the board original settings and all users, including the admin, are using GMT -3, it's still doing this. Why? :|
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Sun Sep 07, 2008 9:39 pm

Anyone? :(

I think the idea of registration dates should be less complicated than post dates.

And even the "Edit Post Date hack" should not be that hard, the included files are "templates" in the most part which the original "modified" files will be based.

To answer my previous question:
- Dates can only be changed from 1995 to 2010 - I don't know what is going to happen when we reach the year 2010;
Dates can be changed on phpBB 2 to whatever year you fill on the included file.

This is one of the included files from this hack - edit_post_date.php:

Code: Select all

<?php
/***************************************************************************
 *				edit_post_date.php
 *				-------------------
 *   begin              : Sunday, December 01, 2002
 *   including fixes	: SUnday, February 04, 2007
 *   copyright          : (C) 2002 ErDrRon
 *   email              : ErDrRon@aol.com
 *
 *   $Id: edit_post_date.php,v 1.0.1 02/04/2007, 16:32:00 erdrron Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);

// Set variables for phpBB
//
	$phpbb_root_path = '../';

// Set includes
//
	include($phpbb_root_path . 'extension.inc');
	include($phpbb_root_path . 'common.'.$phpEx);
	include($phpbb_root_path . 'includes/edit_post_date_functions.'.$phpEx);
	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_edit_post_date.' . $phpEx);

	$p = ( isset($HTTP_GET_VARS['p']) ) ? intval($HTTP_GET_VARS['p']) : '';

// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_VIEWMEMBERS);
init_userprefs($userdata);

// Set global variable
//
$p = $_GET['p'];
$edit_month = $_POST['edit_month'];
$edit_day = $_POST['edit_day'];
$edit_year = $_POST['edit_year'];
$edit_hour = $_POST['edit_hour'];
$edit_minute = $_POST['edit_minute'];
$edit_ampm = $_POST['edit_ampm'];
$submit = $_POST['submit'];

// Pull current Post date for the Post in question
//
		$sql = "SELECT post_time" .
 				" FROM ". POSTS_TABLE .
				" WHERE post_id = $p";

		if( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not query Posts table.', '', __LINE__, __FILE__, $sql);
			}

		$row = $db->sql_fetchrow($result);
		$current_post_date = $row['post_time'];
		$new_post_date = "";

// Initialize variables
//
		if( isset($HTTP_POST_VARS['submit']) )
		{ 
			if( checkdate( month_to_int($edit_month), $edit_day, $edit_year))
			{
				$valid_date = "";
								
				if( $edit_ampm == 'pm' && $edit_hour < '12') $edit_hour += 12;
				if( $edit_ampm == 'am' && $edit_hour == '12') $edit_hour = '00';
			
				$enter_new_post_date = strtotime($edit_day . " " . $edit_month . " " . $edit_year . " " . $edit_hour . ":" . $edit_minute);

				$sql = "UPDATE " . POSTS_TABLE . " SET
					post_time = " . $enter_new_post_date . "
					WHERE post_id =" . $p;

				if( !$db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Failed to update Post Date for Post \# $p", "", __LINE__, __FILE__, $sql);
				}

				echo "<script language=\"JavaScript\">";
				echo "window.close()";
				echo "</script>";
			}
		else
			{
				$valid_date = $lang['Edit_post_invalid_date'];
			}
		}

	// Determine current day field
		if(isset($HTTP_GET_VARS['day']) || isset($HTTP_POST_VARS['day']))
			{
				$day_field = (isset($HTTP_POST_VARS['day'])) ? $HTTP_POST_VARS['day'] : $HTTP_GET_VARS['day'];
			}
		else
			{
				$day_field = date("d", $row['post_time']);
			}

		// Determine current month field
		if(isset($HTTP_GET_VARS['month']) || isset($HTTP_POST_VARS['month']))
			{
				$month_field = (isset($HTTP_POST_VARS['month'])) ? $HTTP_POST_VARS['month'] : $HTTP_GET_VARS['month'];
			}
		else
			{
				$month_field = date("F", $row['post_time']);
			}

// Determine current year field
		if(isset($HTTP_GET_VARS['year']) || isset($HTTP_POST_VARS['year']))
			{
				$year_field = (isset($HTTP_POST_VARS['year'])) ? $HTTP_POST_VARS['year'] : $HTTP_GET_VARS['year'];
			}
		else
			{
				$year_field = date("Y", $row['post_time']);
			}

// Determine current hour field
		if(isset($HTTP_GET_VARS['hour']) || isset($HTTP_POST_VARS['hour']))
			{
				$hour_field = (isset($HTTP_POST_VARS['hour'])) ? $HTTP_POST_VARS['hour'] : $HTTP_GET_VARS['hour'];
			}
		else
			{
				$hour_field = date("h", $row['post_time']);
			}

// Determine current minute field
		if(isset($HTTP_GET_VARS['minute']) || isset($HTTP_POST_VARS['minute']))
			{
				$minute_field = (isset($HTTP_POST_VARS['minute'])) ? $HTTP_POST_VARS['minute'] : $HTTP_GET_VARS['minute'];
			}
		else
			{
				$minute_field = date("i", $row['post_time']);
			}

// Determine current ampm field
		if(isset($HTTP_GET_VARS['ampm']) || isset($HTTP_POST_VARS['ampm']))
			{
				$ampm_field = (isset($HTTP_POST_VARS['ampm'])) ? $HTTP_POST_VARS['ampm'] : $HTTP_GET_VARS['ampm'];
			}
		else
			{
				$ampm_field = date("a", $row['post_time']);
			}

// Assign month fields
		$month_fields_text = array(
						$lang['datetime']['January'], $lang['datetime']['February'], $lang['datetime']['March'], $lang['datetime']['April'],
						$lang['datetime']['May'], $lang['datetime']['June'], $lang['datetime']['July'], $lang['datetime']['August'],
						$lang['datetime']['September'], $lang['datetime']['October'], $lang['datetime']['November'],
						$lang['datetime']['December']
						);

		$month_fields = array(
						'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
						);

// Assign day fields
		$day_fields_text = array(
						$lang['datetime']['01'], $lang['datetime']['02'], $lang['datetime']['03'], $lang['datetime']['04'], $lang['datetime']['05'],
						$lang['datetime']['06'], $lang['datetime']['07'], $lang['datetime']['08'], $lang['datetime']['09'], $lang['datetime']['10'],
						$lang['datetime']['11'], $lang['datetime']['12'], $lang['datetime']['13'], $lang['datetime']['14'], $lang['datetime']['15'],
						$lang['datetime']['16'], $lang['datetime']['17'], $lang['datetime']['18'], $lang['datetime']['19'], $lang['datetime']['20'],
						$lang['datetime']['21'], $lang['datetime']['22'], $lang['datetime']['23'], $lang['datetime']['24'], $lang['datetime']['25'],
						$lang['datetime']['26'], $lang['datetime']['27'], $lang['datetime']['28'], $lang['datetime']['29'], $lang['datetime']['30'],
						$lang['datetime']['31']
						);

		$day_fields = array(
						'01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
						'21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'
						);

// Assign year fields
		$year_fields_text = array(
						$lang['datetime']['1995'], $lang['datetime']['1996'], $lang['datetime']['1997'], $lang['datetime']['1998'], $lang['datetime']['1999'],
						$lang['datetime']['2000'], $lang['datetime']['2001'], $lang['datetime']['2002'], $lang['datetime']['2003'], $lang['datetime']['2004'],
						$lang['datetime']['2005'], $lang['datetime']['2006'], $lang['datetime']['2007'], $lang['datetime']['2008'], $lang['datetime']['2009'],
						$lang['datetime']['2010']
						);

		$year_fields = array(
						'1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'
						);

// Assign hour fields
		$hour_fields_text = array(
						$lang['datetime']['01'], $lang['datetime']['02'], $lang['datetime']['03'], $lang['datetime']['04'], $lang['datetime']['05'],
						$lang['datetime']['06'], $lang['datetime']['07'], $lang['datetime']['08'], $lang['datetime']['09'], $lang['datetime']['10'],
						$lang['datetime']['11'], $lang['datetime']['12']
						);

		$hour_fields = array(
						'01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'
						);

// Assign minute fields
		$minute_fields_text = array(
						$lang['datetime']['00'], $lang['datetime']['01'], $lang['datetime']['02'], $lang['datetime']['03'], $lang['datetime']['04'],
						$lang['datetime']['05'], $lang['datetime']['06'], $lang['datetime']['07'], $lang['datetime']['08'], $lang['datetime']['09'],
						$lang['datetime']['10'], $lang['datetime']['11'], $lang['datetime']['12'], $lang['datetime']['13'], $lang['datetime']['14'],
						$lang['datetime']['15'], $lang['datetime']['16'], $lang['datetime']['17'], $lang['datetime']['18'], $lang['datetime']['19'],
						$lang['datetime']['20'], $lang['datetime']['21'], $lang['datetime']['22'], $lang['datetime']['23'], $lang['datetime']['24'],
						$lang['datetime']['25'], $lang['datetime']['26'], $lang['datetime']['27'], $lang['datetime']['28'], $lang['datetime']['29'],
						$lang['datetime']['30'], $lang['datetime']['31'], $lang['datetime']['32'], $lang['datetime']['33'], $lang['datetime']['34'],
						$lang['datetime']['35'], $lang['datetime']['36'], $lang['datetime']['37'], $lang['datetime']['38'], $lang['datetime']['39'],
						$lang['datetime']['40'], $lang['datetime']['41'], $lang['datetime']['42'], $lang['datetime']['43'], $lang['datetime']['44'],
						$lang['datetime']['45'], $lang['datetime']['46'], $lang['datetime']['47'], $lang['datetime']['48'], $lang['datetime']['49'],
						$lang['datetime']['50'], $lang['datetime']['51'], $lang['datetime']['52'], $lang['datetime']['53'], $lang['datetime']['54'],
						$lang['datetime']['55'], $lang['datetime']['56'], $lang['datetime']['57'], $lang['datetime']['58'], $lang['datetime']['59']
						);

		$minute_fields = array(
						'00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
						'20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39',
						'40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'
						);

// Assign ampm fields
		$ampm_fields_text = array(
						$lang['datetime']['am'], $lang['datetime']['pm']
						);

		$ampm_fields = array(
						'am', 'pm'
						);

	// Set month field
		if (count($month_fields_text) > 0)
			{
				$select_month_field = '<select name="edit_month">';

				for($i = 0; $i < count($month_fields_text); $i++)
					{
						$selected = ($month_field == $month_fields[$i]) ? ' selected="selected"' : '';
						$select_month_field .= '<option value="' . $month_fields[$i] . '"' . $selected . '>' . $month_fields_text[$i] . '</option>';
					}
						$select_month_field .= '</select>';
			}

	// Set day field
		if (count($day_fields_text) > 0)
			{
				$select_day_field = '<select name="edit_day">';

				for($i = 0; $i < count($day_fields_text); $i++)
					{
						$selected = ($day_field == $day_fields[$i]) ? ' selected="selected"' : '';
						$select_day_field .= '<option value="' . $day_fields[$i] . '"' . $selected . '>' . $day_fields_text[$i] . '</option>';
					}
						$select_day_field .= '</select>';
			}

	// Set year field
		if (count($year_fields_text) > 0)
			{
				$select_year_field = '<select name="edit_year">';

				for($i = 0; $i < count($year_fields_text); $i++)
					{
						$selected = ($year_field == $year_fields[$i]) ? ' selected="selected"' : '';
						$select_year_field .= '<option value="' . $year_fields[$i] . '"' . $selected . '>' . $year_fields_text[$i] . '</option>';
					}
						$select_year_field .= '</select>';
			}

	// Set hour field
		if (count($hour_fields_text) > 0)
			{
				$select_hour_field = '<select name="edit_hour">';

				for($i = 0; $i < count($hour_fields_text); $i++)
					{
						$selected = ($hour_field == $hour_fields[$i]) ? ' selected="selected"' : '';
						$select_hour_field .= '<option value="' . $hour_fields[$i] . '"' . $selected . '>' . $hour_fields_text[$i] . '</option>';
					}
						$select_hour_field .= '</select>';
			}

	// Set minute field
		if (count($minute_fields_text) > 0)
			{
				$select_minute_field = '<select name="edit_minute">';

				for($i = 0; $i < count($minute_fields_text); $i++)
					{
						$selected = ($minute_field == $minute_fields[$i]) ? ' selected="selected"' : '';
						$select_minute_field .= '<option value="' . $minute_fields[$i] . '"' . $selected . '>' . $minute_fields_text[$i] . '</option>';
					}
						$select_minute_field .= '</select>';
			}

	// Set ampm field
		if (count($ampm_fields_text) > 0)
			{
				$select_ampm_field = '<select name="edit_ampm">';

				for($i = 0; $i < count($ampm_fields_text); $i++)
					{
						$selected = ($ampm_field == $ampm_fields[$i]) ? ' selected="selected"' : '';
						$select_ampm_field .= '<option value="' . $ampm_fields[$i] . '"' . $selected . '>' . $ampm_fields_text[$i] . '</option>';
					}
						$select_ampm_field .= '</select>';
			}

// Build arrays
//
	// Assign page template
		$template->set_filenames(array(
			'body' => 'edit_post_date_body.tpl')
);

// Assign labels
//
	$template->assign_vars(array(
		'L_EDIT_POST_DATE_TITLE' => $lang['Edit_post_date_title'],
		'L_EDIT_POST_DATE_EXPLAIN' => $lang['Edit_post_date_explain'],
		'L_EDIT_POST_ID' => $lang['Edit_post_id'],
		'L_CURRENT_POST_DATE' => $lang['Current_post_date'],
		'L_NEW_POST_DATE' => $lang['New_post_date'],
		'L_CHANGE_POST_DATE' => $lang['Change_post_date'],
		'L_SUBMIT' => $lang['Submit'], 
		'L_RESET' => $lang['Reset'],
		'L_CLOSE_WINDOW' => $lang['Close_window'],

		'S_MONTH_SELECT' => $select_month_field,
		'S_DAY_SELECT' => $select_day_field,
		'S_YEAR_SELECT' => $select_year_field,
		'S_HOUR_SELECT' => $select_hour_field,
		'S_MINUTE_SELECT' => $select_minute_field,
		'S_AMPM_SELECT' => $select_ampm_field,
			
		'EDIT_POST_DATE_ICON' => '<img src="' . $phpbb_root_path . 'templates/subSilver/images/edit_post_date_icon.gif" />',
		'POST_ID' => $p,
		'CURRENT_POST_DATE' => create_date($board_config['default_dateformat'], $current_post_date, $board_config['board_timezone']),
		'EDIT_POST_VALID_DATE' => $valid_date,
		));

// The following assigns all _template_ variables that may be used at any point in a template.
//
	$template->assign_vars(array(
		'T_HEAD_STYLESHEET' => $theme['head_stylesheet'], 'T_BODY_BACKGROUND' => $theme['body_background'],
		'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'], 'T_BODY_TEXT' => '#'.$theme['body_text'],
		'T_BODY_LINK' => '#'.$theme['body_link'], 'T_BODY_VLINK' => '#'.$theme['body_vlink'],
		'T_BODY_ALINK' => '#'.$theme['body_alink'], 'T_BODY_HLINK' => '#'.$theme['body_hlink'],
		'T_TR_COLOR1' => '#'.$theme['tr_color1'], 'T_TR_COLOR2' => '#'.$theme['tr_color2'],
		'T_TR_COLOR3' => '#'.$theme['tr_color3'], 'T_TR_CLASS1' => $theme['tr_class1'],
		'T_TR_CLASS2' => $theme['tr_class2'], 'T_TR_CLASS3' => $theme['tr_class3'],
		'T_TH_COLOR1' => '#'.$theme['th_color1'], 'T_TH_COLOR2' => '#'.$theme['th_color2'],
		'T_TH_COLOR3' => '#'.$theme['th_color3'], 'T_TH_CLASS1' => $theme['th_class1'],
		'T_TH_CLASS2' => $theme['th_class2'], 'T_TH_CLASS3' => $theme['th_class3'],
		'T_TD_COLOR1' => '#'.$theme['td_color1'], 'T_TD_COLOR2' => '#'.$theme['td_color2'],
		'T_TD_COLOR3' => '#'.$theme['td_color3'], 'T_TD_CLASS1' => $theme['td_class1'],
		'T_TD_CLASS2' => $theme['td_class2'], 'T_TD_CLASS3' => $theme['td_class3'],
		'T_FONTFACE1' => $theme['fontface1'], 'T_FONTFACE2' => $theme['fontface2'],
		'T_FONTFACE3' => $theme['fontface3'], 'T_FONTSIZE1' => $theme['fontsize1'],
		'T_FONTSIZE2' => $theme['fontsize2'], 'T_FONTSIZE3' => $theme['fontsize3'],
		'T_FONTCOLOR1' => '#'.$theme['fontcolor1'], 'T_FONTCOLOR2' => '#'.$theme['fontcolor2'],
		'T_FONTCOLOR3' => '#'.$theme['fontcolor3'], 'T_SPAN_CLASS1' => $theme['span_class1'],
		'T_SPAN_CLASS2' => $theme['span_class2'], 'T_SPAN_CLASS3' => $theme['span_class3'],

		'NAV_LINKS' => $nav_links_html)
);

//		echo $new_post_date; exit;

// I'm the boss...need the info...
//
	$template->pparse('body');
	include($phpbb_root_path .'includes/page_tail.'.$phpEx);

?>
As you can see, the years 1995 to 2010 are covered on this file, so it's only a matter of adding more numbers/years.

Look, this is the entire "Registration date" hack (from phpBB 2):

Code: Select all

#################################################################
## MOD Title: Editable RegistrationDate
## MOD Author: Wicher < N/A > (N/A) http://www.detecties.com/modforum
## MOD Description: This mod makes it possible to edit the users registrationdate.
##  
## MOD Version: 1.0.0
## 
## Installation Level:  easy 
## Installation Time:  5 minutes 
## 
## Files To Edit:  admin/admin_users.php
##                 language/lang_english/lang_admin.php
##                 templates/subSilver/admin/user_edit_body.tpl  
##
## 
## Included Files: N/A
## 
## 
################################################# Author Notes:   
##		   This mod has been tested on phpbb 2.0.22 
## 
############################################################## 
## MOD History: 
##
##   2007-06-09 - Version 1.0.0
##    started this thing 
##   
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ OPEN ]------------------------------------------ 
# 
admin/admin_users.php
# 
#-----[ FIND ]------------------------------------------ 
# 
		$user_status = ( !empty($HTTP_POST_VARS['user_status']) ) ? intval( $HTTP_POST_VARS['user_status'] ) : 0;
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
		// Begin EditableJoinDate
		$user_regdate = ( !empty($HTTP_POST_VARS['user_regdate']) ) ? htmlspecialchars( $HTTP_POST_VARS['user_regdate'] ) : 0;
		// END EditableJoinDate
# 
#-----[ FIND ]------------------------------------------ 
# 
		//
		// Update entry in DB
		//
		if( !$error )
		{
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
			// Begin EditableJoinDate
			if ($user_regdate)
			{
				$regdate_sql = ", user_regdate = ".strtotime($user_regdate);
			}
			// Added "$regdate_sql . " below
			// End EditableJoinDate
# 
#-----[ FIND ]------------------------------------------ 
# 
				SET " . $username_sql . $passwd_sql
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 
$avatar_sql .
# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
# 
 $regdate_sql .
# 
#-----[ FIND ]------------------------------------------ 
# 
		$user_status = $this_userdata['user_active'];
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
		// Begin EditableJoinDate
		$user_regdate = create_date($board_config['default_dateformat'], $this_userdata['user_regdate'], $board_config['board_timezone']);
		// Begin EditableJoinDate
# 
#-----[ FIND ]------------------------------------------ 
# 
			'USER_ACTIVE_NO' => (!$user_status) ? 'checked="checked"' : '', 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
			// Begin EditableJoinDate
			'USER_REGDATE' => $user_regdate,
			// End EditableJoinDate
# 
#-----[ FIND ]------------------------------------------ 
# 
			'L_USER_ACTIVE' => $lang['User_status'],
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
			// Begin EditableJoinDate
			'L_USER_REGDATE' => $lang['user_regdate'],
			'L_USER_REGDATE_EXPLAIN' => $lang['user_regdate_explain'],
			'L_USER_REGDATE_EXAMPLE' => create_date($board_config['default_dateformat'], 25200, $board_config['board_timezone']),
			'L_USER_REGDATE_EXPLAIN2' => $lang['user_regdate_explain2'],
			// End EditableJoinDate
# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_admin.php
# 
#-----[ FIND ]------------------------------------------ 
# 
$lang['User_status'] =
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// Begin EditableJoinDate
$lang['user_regdate'] = 'Registrationdate/time';
$lang['user_regdate_explain'] = 'Here you can adjust the time this user has registered.<br />Use the same format as this';
$lang['user_regdate_explain2'] = '<br />If you leave the field empty, nothing will change.';
// End EditableJoinDate
# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/admin/user_edit_body.tpl
# 
#-----[ FIND ]------------------------------------------ 
# 
		<input type="radio" name="user_status" value="0" {USER_ACTIVE_NO} />
		<span class="gen">{L_NO}</span></td>
	</tr>
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	<!--// editable joindate -->
	<tr> 
	  <td class="row1"><span class="gen">{L_USER_REGDATE}</span>
	  </td>
	  <td class="row2"> 
	    <span class="gensmall">{L_USER_REGDATE_EXPLAIN}: <b>{L_USER_REGDATE_EXAMPLE}</b> {L_USER_REGDATE_EXPLAIN2}</span><br />
		<b>{USER_REGDATE}</b>&nbsp;<input class="post" type="text" name="user_regdate" size="35" style="width: 180px"  />
	  </td>
	</tr>
	<!--// editable joindate -->
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: [REQ] Edit Post and Registration Dates

Post by mtrs » Sun Sep 07, 2008 10:01 pm

After one minute search, I found these mods below. They can help. :)
[BETA] Change Registration Date 1.0.1
[BETA] Change Post Time 0.0.2
I abandoned all of my mods.

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Sun Sep 07, 2008 10:30 pm

mtrs wrote:After one minute search, I found these mods below. They can help. :)
[BETA] Change Registration Date 1.0.1
[BETA] Change Post Time 0.0.2
Thank you for the input, but this "Change Post Time" is bugged, and doesn't work. :(

The idea is very nice, but when you enter a date like:

January 1st, 2007, 10:00:00

You will get this kind of result:

January 12th, 2008, 01:04 PM

Any date will result in something completely different and unpredictable, there is no pattern to be followed.

To avoid losing too much attention from this thread, I will paste the code from this BETA hack below. It's a great concept, but to be honest, I thought the "Edit Post Date" button was more helpful, because if you need to edit many post dates, you will need to gain more time.

In my tests, after you edit each date (clicking on the "Edit Date" button (on phpBB 2), the page refreshes everytime, ONLY IF you are using the Firefox browser. This is very annoying if you need to quickly edit several dates on the same thread page.

Only the Opera browser was capable to edit each post date without loading/refreshing the thread page again.

Not to mention the fact that both MODs are using this time format:

MM-DD-YYYY HH:MM:SS

I would like to change that to:

DD-MM-YYYY HH:MM

The first date is only used by americans, which are also using Ante meridiem and Post meridiem (AM/PM).

This is the PHP date I am using:

­D, d/m/Y, H:i

Sun, 07/09/2008, 19:38

Instead of:

Sun, 09/07/2008, 07:38 PM

Code: Select all

##############################################################
## MOD Title: Change Post Time
## MOD Author: A_Jelly_Doughnut < support@jd1.clawz.com > (Josh W) 
## MOD Description: Gives moderators the power to change the date a post was posted.
## MOD Version: 0.0.2
##
## Installation Level: Beginner
## Installation Time: 5 Minutes
## Files To Edit: includes/mcp/mcp_post.php
##		language/en/mcp.php
##      styles/subsilver2/template/mcp_post.html
##      styles/prosilver/template/mcp_post.html
## Included Files: N/A
##############################################################
##############################################################
## Author Notes:
##	Haven't tested prosilver template at all. 
##
##############################################################
## MOD History:
##
##	 2007-04-16 - Version 0.0.2
##		- Fix install file
##   2007-04-15 - Version 0.0.1
##      - Initial Release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
############################################################## 

#
#----[ OPEN ]---------------------
#
includes/mcp/mcp_post.php

#
#----[ FIND ]---------------------
#
		case 'chgposter':

#
#----[ BEFORE, ADD ]----------
#
		// MOD: change post time
		case 'chgposttime':

			if (!$auth->acl_get('m_chgposter', $post_info['forum_id']))
			{
				trigger_error('NOT_AUTHORISED');
			}
             $day = request_var('day', '');
             $month = request_var('month', '');
             $year = request_var('year', '');
             $hour = request_var('hour', '');
             $minute = request_var('minute', '');
             $second = '0';
			// Time is given in moderator's local time.  We must have GMT.
			// we *subtract* the timezone offsets given by the $user object

			$update_time = mktime($hour, $minute, $second, $month, $day, $year);

			// this could be a complicated dance.  Yay for the sync function !
			$sql = 'UPDATE ' . POSTS_TABLE . ' SET post_time = ' . (int) $update_time . 
				' WHERE post_id = ' . (int) $post_id;
			$db->sql_query($sql);

			sync('topic', 'topic_id', $post_info['topic_id'], true);
			sync('forum', 'forum_id', $post_info['forum_id'], true);
		break;
		// END MOD

#
#----[ OPEN ]---------------------
#
language/en/mcp.php

#
#----[ FIND ]---------------------
#
));

?>

#
#----[ BEFORE, ADD ]--------------
#
	'CHANGE_POST_TIME'			=> 'Change Post Time',
        'CHANGE_POST_TIME_FORMAT'   => 'DD-MM-YYYY HH:MM',

#
#----[ OPEN ]---------------------
#
styles/subsilver2/template/mcp_post.html

#
#----[ FIND ]---------------------
#
		<!-- IF S_CAN_CHGPOSTER -->

#
#----[ AFTER, ADD ]---------------
#
			<tr>
				<form method="post" name="mcp_chgposttime" action="{U_POST_ACTION}">
					<td class="row1" valign="top"><b class="gen">{L_CHANGE_POST_TIME}</b><br /><span class="gensmall">{L_CHANGE_POST_TIME_FORMAT}</span></td>
					<td class="row2"><input class="post" type="text" name="new_time" value="" /> <input class="btnmain" type="submit" value="{L_SUBMIT}" name="action[chgposttime]" /></td>
				</form>
			</tr>

#
#----[ OPEN ]---------------------
#
styles/prosilver/template/mcp_post.html

#
#----[ FIND ]---------------------
#
			<form method="post" id="mcp_chgposter" action="{U_POST_ACTION}">

#
#----[ AFTER, ADD ]---------------
#
			<fieldset>
			<dl>
				<dt><label>{L_CHANGE_POST_TIME}:</label></dt>
				<dd style="margin-top:3px;">
                   <input type="text" size="2" maxlength="2" name="day" value="" />
                   <input type="text" size="2" maxlength="2" name="month" value="" />
                   <input type="text" size="4" maxlength="4" name="year" value="" />
                   <input type="text" size="2" maxlength="2" name="hour" value="" />
                   <input type="text" size="2" maxlength="2" name="minute" value="" />
					<input type="submit" class="button2" name="action[chgposttime]" value="{L_SUBMIT}" />
					<br />
					<span>{L_CHANGE_POST_TIME_FORMAT}</span>
				</dd>
			</dl>
			</fieldset>

#
#----[ SAVE/CLOSE ALL FILES ]-----
#
# EoM
Note: The code above was edited and is already containing the fix required for this MOD. Now the MOD is working!!!!!!!!

Also corrected the american dates thing, now I can change posts by using the format: DD-MM-YYYY!!!! :)

:arrow: Not corrected: :(
- phpBB 2 is preventing us to order all threads on the list by the last post/date. Like the member Carpe Diem said:
I guess there is no further development going on for this otherwise very useful mod, concerning the fix of the replacing of the topic in the viewforum page according to the date change?
I have changed all dates but if this matter can't be solved, we may have threads when the last post date was 2004 being listed first (on the top), and when the last post date was 5 minutes ago being listed on the bottom of the viewforum page.
Last edited by Linda Carter on Mon Sep 08, 2008 2:15 am, edited 5 times in total.
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: [REQ] Edit Post and Registration Dates

Post by mtrs » Sun Sep 07, 2008 10:56 pm

There is a fix at this adres . Did you try it?
I abandoned all of my mods.

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: Edit Post and Registration Dates

Post by Linda Carter » Sun Sep 07, 2008 11:25 pm

That's it!!!!!!!

That MOD is finally working!!!!! :) :) :)

Sadly is not possible to edit those dates using the subSilver template, only if you use proSilver. But now, I was able to set correct dates!!!! Do you know if there is a way to fix the one hour issue?

I mean, that one from the quote below: :)
Linda Carter wrote:What is the concept of a server clock?

Sorry if I am being too dumb but one thing about this Edit Post Date hack that I never figure out was why the modified post hour/minute time is always changed this way (1 hour after your specified time on 80% of the year/posts, and 2 hours in the start of spring until the end of the autumn - November to March).

I mean, I could understand the second case because many countries have used it, including mine (despite the fact that here on the northeast area, we don't use it because there are no benefits, so in many states it's 02:00 AM and here will be always 01:00 AM).

I always choose "No" for the option "Summer Time/DST is in effect" (my phpBB 2 doesn't have this feature to be selected, however, phpBB 3 does).

When I am saying 04:50 AM to this MOD I might be saying 05:50 AM or 06:50 AM. Even if the board original settings and all users, including the admin, are using GMT -3, it's still doing this. Why? :|
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Mon Sep 08, 2008 4:26 am

This is the old code:

Code: Select all

#
#----[ OPEN ]---------------------
#
styles/subsilver2/template/mcp_post.html

#
#----[ FIND ]---------------------
#
      <!-- IF S_CAN_CHGPOSTER -->

#
#----[ AFTER, ADD ]---------------
#
         <tr>
            <form method="post" name="mcp_chgposttime" action="{U_POST_ACTION}">
               <td class="row1" valign="top"><b class="gen">{L_CHANGE_POST_TIME}</b><br /><span class="gensmall">{L_CHANGE_POST_TIME_FORMAT}</span></td>
               <td class="row2"><input class="post" type="text" name="new_time" value="" /> <input class="btnmain" type="submit" value="{L_SUBMIT}" name="action[chgposttime]" /></td>
            </form>
         </tr>

#
I changed a little bit trying to match the proSilver one and now, at least it's working on subSilver:

Code: Select all

#
#----[ OPEN ]---------------------
#
styles/subsilver2/template/mcp_post.html

#
#----[ FIND ]---------------------
#
      <!-- IF S_CAN_CHGPOSTER -->

#
#----[ AFTER, ADD ]---------------
#
         <tr>
            <form method="post" name="mcp_chgposttime" action="{U_POST_ACTION}">
               <td class="row1" valign="top"><b class="gen">{L_CHANGE_POST_TIME}</b><br /><span class="gensmall">{L_CHANGE_POST_TIME_FORMAT}</span></td>
                   <input type="text" size="2" maxlength="2" name="day" value="" />
                   <input type="text" size="2" maxlength="2" name="month" value="" />
                   <input type="text" size="4" maxlength="4" name="year" value="" />
                   <input type="text" size="2" maxlength="2" name="hour" value="" />
                   <input type="text" size="2" maxlength="2" name="minute" value="" />
               <td class="row2"><input class="button2" type="submit" name="action[chgposttime]" value="{L_SUBMIT}" /></td>
            </form>
         </tr>
Well, this is it. The MOD is working exactly like the Edit Post Date hack, unfortunatelly the "one/two-hour issue" still remains to be corrected.

:arrow: THE FINAL SUBSILVER2 CORRECTED CODE:
Thanks to: oddfish/Star Trek Guide

Code: Select all

#
#----[ OPEN ]---------------------
#
styles/subsilver2/template/mcp_post.html

#
#----[ FIND ]---------------------
#
      <!-- IF S_CAN_CHGPOSTER -->

#
#----[ AFTER, ADD ]---------------
#
            <tr>
                    <td class="row1" valign="top"><b class="gen">{L_CHANGE_POST_TIME}</b><br /><span class="gensmall">{L_CHANGE_POST_TIME_FORMAT}</span></td>
                    <td class="row2"><form method="post" name="mcp_chgposttime" action="{U_POST_ACTION}">
                    <input type="text" size="2" maxlength="2" name="month" value="" />
                    <input type="text" size="2" maxlength="2" name="day" value="" />
                    <input type="text" size="4" maxlength="4" name="year" value="" />
                    <input type="text" size="2" maxlength="2" name="hour" value="" />
                    <input type="text" size="2" maxlength="2" name="minute" value="" />
                    <input class="btnmain" type="submit" name="action[chgposttime]" value="{L_CONFIRM}" /></form></td>
            </tr> 
Last edited by Linda Carter on Fri Sep 12, 2008 5:07 am, edited 3 times in total.
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

User avatar
fazaljatoi
I've Been Banned!
Posts: 503
Joined: Wed Aug 31, 2005 8:02 pm

Re: [REQ] Edit Post and Registration Dates

Post by fazaljatoi » Tue Sep 09, 2008 3:12 pm

i need EDIT POST DATE mod for phpBB3

User avatar
fazaljatoi
I've Been Banned!
Posts: 503
Joined: Wed Aug 31, 2005 8:02 pm

Re: [REQ] Edit Post and Registration Dates

Post by fazaljatoi » Wed Sep 10, 2008 4:44 pm

fazaljatoi wrote:i need EDIT POST DATE mod for phpBB3

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Sat Sep 13, 2008 8:05 am

I have made some tests regarding this issue, described below:
1) phpBB 2 (and 3) are preventing us to order all threads on the list by the last post/date. Like someone said to me once:
I guess there is no further development going on for this otherwise very useful mod, concerning the fix of the replacing of the topic in the viewforum page according to the date change?
If this matter can't be solved, we may have threads when the last post date was 2004 being listed first (on the top), and when the last post date was 5 minutes ago being listed on the bottom of the viewforum page.
And I reached the following conclusions: this MOD is not having that issue from the Edit Post Date hack, it's only partially wrong.

In my test, two threads were created. Let's assume those two threads already have replies.

Thread A - last response was given on 04:45, today.
Thread B - last response was given on 04:40, today.


They are listed that way on the viewforum.

If you change the post date from the thread B to the year 2010, for example, the viewforum will list those threads that way:

Thread B - last response was given on the year 2010.
Thread A - last response was given on 04:45, today.


The same goes for viewtopic.

The only problem with this thing is if you need to assign a new date to any post, other than the last one.

Example:
Thread A
- First reply was given on 2005. Second and last reply on 2006.

Thread B
- First reply was given on 2004. Second and last reply on 2005.
If you change the post date from B-1 (2004) to 2010, the viewforum will not list the thread B on the top and thread A on the bottom. Instead, you will get this:
Thread A
- Last reply on 2006.

Thread B
- Last reply on 2005.
Because each time a new post is added into the database, they have different IDs (post number 1, 2, 3, etc.).

The Edit Post Date hack wasn't considering the last post to correct the viewforum. At least this was corrected on the Change Post Time. :)
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

mtrs
Registered User
Posts: 2049
Joined: Sat Sep 22, 2007 2:39 pm

Re: [REQ] Edit Post and Registration Dates

Post by mtrs » Sat Sep 13, 2008 8:49 am

Linda Carter wrote:The Edit Post Date hack wasn't considering the last post to correct the viewforum. At least this was corrected on the Change Post Time. :)
It's seen, that mod only change posts_table but, viewforum shows the topic time from topics_table, so it was not intended to change topic time the mod.
I abandoned all of my mods.

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Sat Sep 13, 2008 1:47 pm

mtrs wrote:
Linda Carter wrote:The Edit Post Date hack wasn't considering the last post to correct the viewforum. At least this was corrected on the Change Post Time. :)
It's seen, that mod only change posts_table but, viewforum shows the topic time from topics_table, so it was not intended to change topic time the mod.
I see. :(

If you change any post, other than the last one from each thread, the MOD will not force viewforum to reorder the list to match viewtopic.

Due to the fact the last post of each thread (by ID) is the only one who is considered from viewforum.

viewtopic is always working along with this MOD. That means, if Linda Carter is the author of this thread, created on 2008, and someone changed mtrs post to the year 2002, mtrs (who posted on 2009) will become the author of this thread.

But if you try to change Linda Carter's initial post to the year 2010, viewforum will disregard your command, because it will know her post was not the last one.
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

User avatar
Linda Carter
Registered User
Posts: 514
Joined: Fri Feb 15, 2008 6:45 am

Re: [REQ] Edit Post and Registration Dates

Post by Linda Carter » Sun Jan 25, 2009 2:24 pm

Sadly, I was looking today my board and some posts from the StarTrekGuide and I discover something... :cry:

The [BETA] Change Post Time 0.0.2 is not working as it should. Not working like the old "Edit Post Date" from phpBB 2 at all. See the post below:
Has anyone cracked this problem yet?

I've been using this MOD for a few months now, and it's working perfectly... except for the fact that it always adds 4 hours to the time I enter. For example, if I try to change a post's time to "1 January 2007, 12:00pm", it will change the time to "1 January 2007, 4:00pm".

I can easily work around it by subtracting 4 hours when I enter the time (and this MOD, for whatever strange reason, reliably adds the 4 hours back on), but it's still rather irritating.

Other than that, it's a great MOD.
I tried to insert the same date (January 1st, 2007, but instead of 12:00 PM, I have choosen 14:00 (02:00 PM). The board is changing to 17:00, adding +3 hours.

I tested another date, where the Daylight saving time effect can't affect any results (the middle of year):
May 25th, 2007, 14:00

And the board is adding +2 hours (16:00). My board is using GMT -3, but that doesn't mean anything, it should not affect the MOD. :|

I hope someone can fix those issues and the ones I explained about before. :(
"Whoever has not known himself has known nothing. But whoever has known himself has simultaneously achieved knowledge about the depth of all things."

Locked

Return to “[3.0.x] MOD Requests”