Change all subjects 2.0 RC1-1

Started by Mark S, July 12, 2009, 06:34:53 PM

Previous topic - Next topic

Mark S

Got through the manual installation of this mod, including the first code hack in the ./Sources/Subs-Post.php

The second one has me stumped:

Find:
   global $db_prefix, $user_info, $ID_MEMBER, $modSettings;

Replace with:

   global $db_prefix, $user_info, $ID_MEMBER, $modSettings, $txt;

The problem:  The "Find:" code doesn't exist.

Everything else in the mod is working.  But this I don't know what to do with.

If it's the only thing left and the mod works, then the Mod for 2.0 RC1-1 would be complete as I successfully hacked the first subs routine.

Thanks!





[SiNaN]

If I remember correctly, that edit is just to add the $txt variable to modifyPost() function globals.
Former SMF Core Developer | My Mods | SimplePortal

Mark S

Thanks!  I gave it a try, but it didn't work.  The string to be found isn't even in the file, so I don't know where to look for its eqivalent.

[SiNaN]

See how post action deals with it. Look for $context['response_prefix'] in Post.php file.
Former SMF Core Developer | My Mods | SimplePortal

Mark S

// Get a response prefix (like 'Re:') in the default forum language.
if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
{
if ($language === $user_info['language'])
$context['response_prefix'] = $txt['response_prefix'];
else
{
loadLanguage('index', $language, false);
$context['response_prefix'] = $txt['response_prefix'];
loadLanguage('index');
}
cache_put_data('response_prefix', $context['response_prefix'], 600);


Several instaces of that action.  Not certain where to add the $txt.  Guidance  ???  Thanks!

Arantor

It looks like the $txt entry should be in Themes/yourtheme/languages/index.yourlanguage.php.
Holder of controversial views, all of which my own.


Mark S

Yes, the text itself is in that file.  What I'm asking is, which instance in the above code which SiNan cited above does the $txt go after?

Arantor

For that block of code, find the function ....() line above it, and you should see a list of entries that start with 'global ...' like you posted earlier. Just add $txt to that.
Holder of controversial views, all of which my own.


Mark S

#8
Excellent! That brought the check box and the text on-line.

Un..... fortunately... when I "checkmark" the box and "save" to activate the function....

Fatal error: Call to undefined function db_query() in /home1/classig8/public_html/forum/Sources/Subs-Post.php on line 2436   >:(

Line 2436 = db_query("

//Change all subjects if wanted and subject set.
if (!empty($_POST['changeallsubject']) && isset($msgOptions['subject']))
{
//Add the prefix and do it.
db_query("
UPDATE {$db_prefix}messages
SET subject = '$txt[response_prefix]$msgOptions[subject]'
WHERE ID_TOPIC = $topicOptions[id]", __FILE__, __LINE__);
                               
}


Well, so much for thinking the rest of it was going to work smoothly....

Arantor

That's because in 2.0 we don't use db_query at all.

Where did that code come from?
Holder of controversial views, all of which my own.


Mark S

v 1.1.8 (I'm pretty sure).  This mod was never updated for 2.0, so, at this point, that appears to be what we're doing here. 

If that's the case, I'm not expecting you to continue the support on this.  It's not an "important" mod, as some would rate importance, but out site covers a lot of mechanical topics and we've always been very anal about good topic titles for searching & browsing purposes.  Often, a new topic will be started with a title like, "help!" and it will get several responses before admin sees it.  It would obviously be much more expedient to have the Change All Subjects mod updated in our case and, based on my acquaintance with similar groups, it would be an important tool for any site using SMF and as are particular as we are.

It's totally up to you.  If you don't wish to continue expending any more time on this, I completely understand.     

Arantor

That's the problem - you will completely need to rewrite the query to suit 2.0.

Off the top of my head I think you want...

//Change all subjects if wanted and subject set.
if (!empty($_POST['changeallsubject']) && isset($msgOptions['subject']))
{
//Add the prefix and do it.
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET subject = {string:subject}
WHERE id_topic = {int:topic}',
array(
'subject' => $txt['response_prefix'] . $msgOptions['subject'],
'topic' => $topicOptions['id'];
));                             
}
Holder of controversial views, all of which my own.


[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

Advertisement: