News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Change All Subjects

Started by live627, April 16, 2008, 11:31:17 PM

Previous topic - Next topic

Joker002

Thank you Bugo, but

Quote
8: Undefined variable: id_member_poster
File: /home/***/public_html/forum/Sources/Post.php
Line: 233

232: $context['can_modify_any'] = allowedTo('modify_any');
==>233: $context['can_changeallsubjects'] = ($id_member_poster == $user_info['id']) ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
234: $context['can_changeallsubjects'] = ($context['can_changeallsubjects'] && $context['can_modify_any'] && isset($_REQUEST['msg']) && $context['is_first_post']);
235: $context['can_quote'] = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
236:


Joker002


Bugo


Joker002

Error occurs when creating a new topic.

Bugo

@Joker222
Try replace
$context['can_changeallsubjects'] = ($id_member_poster == $user_info['id']) ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
with
$context['can_changeallsubjects'] = $context['can_lock'] ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
P. S. Не забудь, что это всё надо в Notepad++ делать ;)

@live627
Look at my fixed install20.xml:
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>[SiNaN]:Change_All_Subjects</id>
<version>1.1.1</version>

<file name="$sourcedir/Post.php">
<operation>
<search position="before"><![CDATA[$context['locked'] = !empty($locked) || !empty($_REQUEST['lock']);]]></search>
<add><![CDATA[

$context['is_new_topic'] = empty($topic);
$context['is_new_post'] = !isset($_REQUEST['msg']);
$context['is_first_post'] = $context['is_new_topic'] || (isset($_REQUEST['msg']) && $_REQUEST['msg'] == $id_first_msg);

$context['can_modify_any'] = allowedTo('modify_any');
$context['can_changeallsubjects'] = $context['can_lock'] ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
$context['can_changeallsubjects'] = ($context['can_changeallsubjects'] && $context['can_modify_any'] && isset($_REQUEST['msg']) && $context['is_first_post']);]]></add>
</operation>
</file>

<file name="$sourcedir/Subs-Post.php">
<operation>
<search position="after"><![CDATA[// Change the post.
$smcFunc['db_query']('', ']]></search>
<add><![CDATA[ //Change all subjects if wanted and subject set.
if (!empty($_POST['changeallsubject']) && isset($msgOptions['subject']))
{
// 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);
}

//Add the prefix and do it.
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET subject = {text:new_subject}
WHERE id_topic = {int:topicOptions}',
array(
'topicOptions' => $topicOptions['id'],
'new_subject' => $context['response_prefix'] . $msgOptions['subject'],
)
);
}

]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
function modifyPost(&$msgOptions, &$topicOptions, &$posterOptions)
{
global $user_info, $modSettings, $smcFunc, $context]]></search>
<add><![CDATA[, $txt, $language]]></add>
</operation>
</file>
<file name="$sourcedir/ManagePermissions.php">
<operation>
<search position="before"><![CDATA['modify_replies' => array(false, 'topic', 'moderate'),]]></search>
<add><![CDATA[//
'change_all_subjects' => array(true, 'topic', 'moderate'),
]]></add>
</operation>
</file>

</modification>

and fixed install11.xml:
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>[SiNaN]:Change_All_Subjects</id>
<version>1.1.1</version>
<file name="$sourcedir/Post.php">
<operation>
<search position="before"><![CDATA[ $context['locked'] = !empty($locked) || !empty($_REQUEST['lock']);]]></search>
<add><![CDATA[
$context['can_modify_any'] = allowedTo('modify_any');
$context['can_changeallsubjects'] = ($ID_MEMBER_POSTER = $ID_MEMBER) ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
$context['can_changeallsubjects'] = ($context['can_changeallsubjects'] && $context['can_modify_any'] && isset($_REQUEST['msg']) && $ID_FIRST_MSG);]]></add>
</operation>
</file>
<file name="$sourcedir/Subs-Post.php">
<operation>
<search position="after"><![CDATA[ // Change the post.
db_query("
UPDATE {$db_prefix}messages]]></search>
<add><![CDATA[ //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__);
}

]]></add>
</operation>
<operation>
<search position="before"><![CDATA[global $db_prefix, $user_info, $ID_MEMBER, $modSettings]]></search>
<add><![CDATA[, $txt]]></add>
</operation>
</file>
<file name="$sourcedir/ManagePermissions.php">
<operation>
<search position="before"><![CDATA['modify_replies' => false,]]></search>
<add><![CDATA[//
'change_all_subjects' => true,
]]></add>
</operation>
</file>
<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA['
</table>
</div>
</td>
</tr>';]]></search>
<add><![CDATA[$context['can_changeallsubjects'] ? '
<tr>
<td class="smalltext"><label for="check_changeallsubject"><input type="checkbox" name="changeallsubject" id="changeallsubject" value="1" class="check" /> ' . $txt['changeallsubject'] . '</label></td>
<td class="smalltext"></td>
</tr>' : '', ]]></add>
</operation>
</file>
</modification>



Neo_TE

update for smf 2.0 rc4. :(

@ bugo - could you take over this mod if the original author is not interested in updating this anymore :)

Bugo


FragaCampos


HunterP

Quote from: Bugo on November 14, 2010, 08:52:09 AMLook at my fixed install20.xml:
and fixed install11.xml:

Thanks for the fix ;)

Neo_TE

update for SMF 2.0 RC5. :(

@ bugo/other mod authors - could you take over this mod if the original author is not interested in updating this anymore :)

live627

New version is on the mod site that seems to have no errors.

HunterP

Quote from: live627 on February 22, 2011, 01:31:09 PM
New version is on the mod site that seems to have no errors.

When posting, I get:

Parse error: syntax error, unexpected T_VARIABLE in Post.php on line 199

But line 199 seems to be the comment line below, which doesn't make any sense :

   // An array to hold all the attachments for this topic.
   $context['current_attachments'] = array();

live627

Post three lines above that.

HunterP

Quote from: live627 on February 22, 2011, 06:30:01 PM
Post three lines above that.

A few more, to be sure :

// !!! These won't work if you're posting an event!
$context['can_notify'] = allowedTo('mark_any_notify');
$context['can_move'] = allowedTo('move_any');
$context['can_announce'] = allowedTo('announce_topic');
$context['locked'] = !empty($locked) || !empty($_REQUEST['lock']);
$context['can_modify_any'] = allowedTo('modify_any');
$context['can_changeallsubjects'] = ($ID_MEMBER_POSTER = $user_info['id']) ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');
$context['can_changeallsubjects'] = ($context['can_changeallsubjects'] && $context['can_modify_any'] && isset($_REQUEST['msg']) && $context['is_first_post'])

// An array to hold all the attachments for this topic.
$context['current_attachments'] = array();

live627

There's no semicolon after line 197

HunterP

Quote from: live627 on February 23, 2011, 07:24:35 PM
There's no semicolon after line 197

Thanks! Did you correct it in the mod as well?  ::)

live627

No, because I double-checked and it was there

HunterP

#78
Quote from: live627 on February 23, 2011, 10:23:24 PM
No, because I double-checked and it was there

Weird, I can't recall making any manual changes....

Anyway, I'm getting a new error :

8: Undefined index: id
File: Post.php
Line: 195

$context['can_changeallsubjects'] = ($ID_MEMBER_POSTER = $user_info['id']) ? allowedTo(array('change_all_subjects_own', 'change_all_subjects_any')) : allowedTo('change_all_subjects_any');

HunterP


Sorry, and another one :

8: Undefined index: is_first_post
File: Post.php
Line: 196

$context['can_changeallsubjects'] = ($context['can_changeallsubjects'] && $context['can_modify_any'] && isset($_REQUEST['msg']) && $context['is_first_post']);

Advertisement: