Topic locked by

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)
Suggested Hosts
Locked
User avatar
Haldirman
Registered User
Posts: 49
Joined: Tue Apr 14, 2009 1:01 pm
Location: ./adm/index.php
Contact:

Topic locked by

Post by Haldirman »

Recently I put on my board a code that displays on every locked topic a message at the bottom informing that the topic is closed. Can somebody help me insert in that box a message like "Topic locked by Haldirman on 24/08/2010 at 17:51". ?
A image:

Image

User avatar
Haldirman
Registered User
Posts: 49
Joined: Tue Apr 14, 2009 1:01 pm
Location: ./adm/index.php
Contact:

Re: Topic locked by

Post by Haldirman »

Can someone help me?

Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Topic locked by

Post by Drummer »

What have you done exactly? Just a template edit?

User avatar
noth
Registered User
Posts: 2483
Joined: Fri Jan 07, 2005 7:10 pm
Location: North Surrey
Contact:

Re: Topic locked by

Post by noth »

I have no idea what you're doing

but you have raised a very valid issue

too many times (including on this site) topics are locked . . . . with no clue as to who by (or why) :o

User avatar
Haldirman
Registered User
Posts: 49
Joined: Tue Apr 14, 2009 1:01 pm
Location: ./adm/index.php
Contact:

Re: Topic locked by

Post by Haldirman »

Drummer wrote:What have you done exactly? Just a template edit?
Yes, in the picture it's just a template edit , but I want to display the name of the moderator who closed that topic and the time and date.

Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Topic locked by

Post by Drummer »

Try this:
Create a column called "locker" on the _topics table.

Code: Select all

ALTER phpbb_topics ADD COLUMN locker VARCHAR(255)
open includes/mcp/mcp_main.php
Find:

Code: Select all

		$sql = "UPDATE $table
			SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED) . '
			WHERE ' . $db->sql_in_set($sql_id, $ids);
		$db->sql_query($sql);
Replace with:

Code: Select all

		$sql = "UPDATE $table
			SET $set_id = " . (($action == 'lock' || $action == 'lock_post') ? ITEM_LOCKED : ITEM_UNLOCKED);
		$sql .= ($table == TOPICS_TABLE) ? ", locker = '" . serialize(array($user->data['user_id'], $user->data['username'], $user->data['user_colour'])) . "'" : '';
		$sql .=  ' WHERE ' . $db->sql_in_set($sql_id, $ids);
		$db->sql_query($sql);
open viewtopic.php
Find:

Code: Select all

// Does this topic contain a poll?
Add before:

Code: Select all

$topic_data['locker'] = unserialize($topic_data['locker']);
$template->assign_var('S_LOCKER', ($topic_data['topic_status'] == ITEM_LOCKED)? get_username_string('full', $topic_data['locker'][0], $topic_data['locker'][1],$topic_data['locker'][2]) : false);
Then open styles/<style>/template/viewtopic_body.html and insert {S_LOCKER} wherever you want to display the locker.

User avatar
Haldirman
Registered User
Posts: 49
Joined: Tue Apr 14, 2009 1:01 pm
Location: ./adm/index.php
Contact:

Re: Topic locked by

Post by Haldirman »

Now it displays "locked by Guest"

Drummer
Registered User
Posts: 199
Joined: Wed Jul 21, 2010 11:49 am

Re: Topic locked by

Post by Drummer »

Haldirman wrote:Now it displays "locked by Guest"
It's just an idea. There will be other problems, i.e. you wont wanna store that serialized data.
It should "work" anyway.
get_username_string() only returns "Guest" if the third parameter is false, "", 0 ... or if the second one is 1. Remove the unserialize() line and see what it shows.

Mafios_X
Registered User
Posts: 3
Joined: Fri Aug 19, 2011 11:27 pm

Re: Topic locked by

Post by Mafios_X »

Drummer wrote:
Haldirman wrote:Now it displays "locked by Guest"
It's just an idea. There will be other problems, i.e. you wont wanna store that serialized data.
It should "work" anyway.
get_username_string() only returns "Guest" if the third parameter is false, "", 0 ... or if the second one is 1. Remove the unserialize() line and see what it shows.
Doesn't work, show locked by Guest . Any solutions ? :)

Mafios_X
Registered User
Posts: 3
Joined: Fri Aug 19, 2011 11:27 pm

Re: Topic locked by

Post by Mafios_X »

Sorry for x2 post!
If i lock the topic with edit or on reply, is show topick locked by Guest, if i lock with moderator control panel if show correctly.

How i can solve :)?

Locked

Return to “[3.0.x] MOD Requests”