News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

RenameTopic

Started by JayBachatero, July 12, 2006, 12:32:17 AM

Previous topic - Next topic

JayBachatero

Link to Mod
Review this Mod

This mod will give the option to rename a topic and all of it's posts.  So if you have a 100 page topic and want to change the subject for all of the posts, you can use this.

Features
* Permission to who can rename topic.  Own | Any.

Ver. 1.0.2
! RenameTopic tab was not checking permission correctly (Display.template.php)
! Language string for error was missing (Errors.english.php)
! Permissions were not being picked up correctly for rename_topic_own and rename_topic_any (RenameTopic.php)

Ver. 1.0.1
! I made a mistake with the "Re:" thinking it was going to be dynamic on RC3 but it's not.  Now I added this feature and all posts after the first one will have the "Re:" on it.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

PrizeLive.com

Great mod and thanks a lot!!

I'll install the update you made for "Re:".. thanks again!!
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

JayBachatero

Surf try this package.  It will upgrade the file needed to upgrade and you wont need to uninstall the other one.

EDIT:  Download it from the mod's page.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

littleone

Awesome.  This will be fanastic!

tapirul

#4
that's a great idea for a mod
One question, what should I do to have the "rename" button listed at the top of the page, along with "reply" "notify" "mark unread" etc, instead of bottom? It makes more sense to me to be in that position
I assume I have to edit display.template.php and add something here


// Build the normal button array.
        $normal_buttons = array(
'reply' => array('test' => 'can_reply', 'text' => 146, 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';num_replies=' . $context['num_replies']),
'bookmark' => array('test' => 'can_reply', 'image' => 'print.gif', 'text' => 'bookmark', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.0;do=Bookmark'),
'notify' => array('test' => 'can_mark_notify', 'text' => 125, 'image' => 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']),
'custom' => array(),
'send' => array('test' => 'can_send_topic', 'text' => 707, 'image' => 'sendtopic.gif', 'lang' => true, 'url' => $scripturl . '?action=sendtopic;topic=' . $context['current_topic'] . '.0'),
'print' => array('text' => 465, 'image' => 'print.gif', 'lang' => true, 'custom' => 'target="_blank"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
);
       
// Special case for the custom one.
if ($context['user']['is_logged'] && $settings['show_mark_read'])
$normal_buttons['custom'] = array('text' => 'mark_unread', 'image' => 'markunread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
elseif ($context['can_add_poll'])
$normal_buttons['custom'] = array('text' => 'add_poll', 'image' => 'add_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
else
unset($normal_buttons['custom']);

but i am not sure what
thanks

JayBachatero

Change

$mod_buttons[] = array('text' => 'rename_topic', 'image' => 'edit.gif', 'lang' => true, 'url' => $scripturl . '?action=renameTopic;topic=' . $context['current_topic']);
to this

$normal_buttons[] = array('text' => 'rename_topic', 'image' => 'edit.gif', 'lang' => true, 'url' => $scripturl . '?action=renameTopic;topic=' . $context['current_topic']);
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

tapirul

thanks
I tried, but the button actually disappears...
shouldn't I add something here as well?... Just guessing
// As before, build the custom button right.
if ($context['user']['is_logged'] && $settings['show_mark_read'])
$normal_buttons['custom'] = array('text' => 'mark_unread', 'image' => 'markunread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);
elseif ($context['can_add_poll'])
$normal_buttons['custom'] = array('text' => 'add_poll', 'image' => 'add_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']);

echo '

JayBachatero

Ok add what I gave you right before that.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

tapirul

#8
Thanks!
I actually added it in two places, somewhere under
// Build the normal button array.
(it's line 194 in my case)
and under
// As before, build the custom button right.
line 645 in my case

.. in order to have the button listed BOTH at the top of the topic and the bottom of the topic.

Correction: If I add it under line 645, it will appear twice at the bottom... I left it only in the first area, and now it appears only once in each position.
I left the original "$mod_buttons[] = array(..." under //Rename topic, so now I have the buttom both at the top and the bottom of the topic AND at the bottom in the moderation area (where "move" "remove" "lock" etc buttons are.

Thanks again.
i've now idea of PHP scripting, I am just guessing as I said...

JayBachatero

I guess if it works with no errors that's good.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

tapirul

actually it doesn't work... (if I add under "Build the normal button array")
I have it at the bottom, though, that should do it. I'll try to play around to get the right code to put it at the top, too.
Thanks again

JayBachatero

#11
When I added it there when I told you it added it at the top and bottom.

EDIT:  Add it before this comment.
   // Special case for the custom one.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

tapirul

I uninstalled the mod and reinstalled it fresh...First thing, this time the button didn't show anymore for regular users (which is strange.. )...
I added the code chunk where you said, but it gives an error.. The button shows at the top and the bottom but when I click it as a regular user I get "An error has occurred"
From error logs:
QuoteUndefined index: cannot_rename_topic
File: /....../Sources/Errors.php
Line: 336

::) ::)

JayBachatero

The button is not supposed to show unless you are allowed to rename the topic.  I made it a permission setting.

Which reminds me change

$normal_buttons[] = array('text' => 'rename_topic', 'image' => 'edit.gif', 'lang' => true, 'url' => $scripturl . '?action=renameTopic;topic=' . $context['current_topic']);

to


if (allowedTo('rename_topic'))
$normal_buttons[] = array('text' => 'rename_topic', 'image' => 'edit.gif', 'lang' => true, 'url' => $scripturl . '?action=renameTopic;topic=' . $context['current_topic']);

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

PrizeLive.com

So I need to edit the code since I installed this a few days ago?

Which file is that that you just showed?
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

JayBachatero

You want to change the position of the menu also?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

PrizeLive.com

Oh... no i think it's better on the bottom...
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

tapirul

Quote from: Jay The Code Monkey on July 14, 2006, 01:24:18 PM
The button is not supposed to show unless you are allowed to rename the topic.  I made it a permission setting.
I understand that.. What I did is, I created a normal user, I opened a topic with it and I checked to see if I can rename (the permissions are set to be able to rename own topics).
After the uninstall/reinstall I couldn't see the button anymore, as a regular user (I can see it as admin).
Maybe something left over after uninstall?

So okay, if I start fresh, where do I add the code?

Thanks

tapirul

Quote from: Jay The Code Monkey on July 14, 2006, 01:28:26 PM
You want to change the position of the menu also?
no, just to show the button in "normal buttons" area

JayBachatero

Ok search for

// Build the normal button array.
$normal_buttons = array(
'reply' => array('test' => 'can_reply', 'text' => 146, 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';num_replies=' . $context['num_replies']),
'notify' => array('test' => 'can_mark_notify', 'text' => 125, 'image' => 'notify.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';sesc=' . $context['session_id']),
'custom' => array(),
'send' => array('test' => 'can_send_topic', 'text' => 707, 'image' => 'sendtopic.gif', 'lang' => true, 'url' => $scripturl . '?action=sendtopic;topic=' . $context['current_topic'] . '.0'),
'print' => array('text' => 465, 'image' => 'print.gif', 'lang' => true, 'custom' => 'target="_blank"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
);


Add after

// Show rename topic button.
if (allowedTo('rename_topic'))
$normal_buttons[] = array('text' => 'rename_topic', 'image' => 'edit.gif', 'lang' => true, 'url' => $scripturl . '?action=renameTopic;topic=' . $context['current_topic']);



In Display.php.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Advertisement: