This mod Adds the Ability to Move all posts in board(s) to another board based on How old it is and with special options like only moved topics, locked topics, and/or ignoring stickied topics. This is great for use with Archive boards and mass moving topics of old age at once.Caps
http://custom.simplemachines.org/mods/index.php?action=download;mod=503;id=47250;imageManuel İnstallatinon (2.0 Beta 4)
./Sources/MoveTopic.php
Find (at the end of the file)
?>Add Before
if ( function_exists('MoveTopic3' )
{
// For The Move Old Topics. We Get our Own Function Because the Other was not sufficient enough to do this for us
function MoveTopic3()
{
global $db_prefix, $modSettings, $txt, $smcFunc;
// Can they use the Force?
if( allowedTo('admin_forum' )
redirectexit();
// Make sure they came from our site..
checkSession();
// Don't got the Variables Set? Lets just make them think they can't access it.. ehehe..
if (empty($_POST['toboard']) || isset($_POST['boards']) || isset($_POST['maxdays']))
fatal_error($txt['error_occured'].' ERROR ID: MoveOldPosts-1' ;
// is toboard a Interger. The Variable isset check was done above.
if (is_array($_POST['toboard']))
fatal_error($txt['error_occured'].' ERROR ID: MoveOldPosts-2' ;
else
$_POST['toboard'] = (int) $_POST['toboard'];
// is the boards an array and only have intervals in them?
if ( array_map('intval', array_keys($_POST['boards'])))
fatal_error($txt['error_occured'].' ERROR ID: MoveOldPosts-3' ;
// Are we Going to use Custom Selections of topics?.
$additional = '';
// Just get rid of the moved topic notices...?
if ($_POST['delete_type'] == 'moved'
$additional .= '
AND m.icon = \'moved\'';
// Maybe we just want to get rid of the locked topics?
if ($_POST['delete_type'] == 'locked' || $_POST['delete_type'] == 'moved' $additional .= ' AND t.locked = 1'; // Forget Stickies? if (isset($_POST['delete_old_not_sticky'])) $additional .= ' AND t.is_sticky = 0'; // Now that we made the checks lets get going with this function $request = $smcFunc['db_query']('', " SELECT t.id_topic FROM {db_prefix}topics AS t LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) WHERE m.poster_time < {int:poster_time} AND t.id_board = {int:desination_board} {raw:addition_information} AND t.id_board IN ({array_int:from_boards})", array( 'poster_time' => time() - 3600 * 24 * $_POST['maxdays'], 'desination_board' => $_POST['toboard'], 'addition_information' => $additional, 'from_boards' => array_keys($_POST['boards']), )); $topics = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) $topics[] = $row['id_topic']; $smcFunc['db_free_result']($request); // Do the move. moveTopics($topics, $_POST['toboard']); // Bye Bye.. redirectexit('action=admin;area=maintain;done' ; } } ./Themes/default/ManageMaintenance.template.php
Find
// Move a board?
function template_activity_move_topics_maintenance()Replace With
// Moving Old topics?
function template_activity_move_topics_maintenance()
{
global $scripturl, $txt, $context, $settings;
// Moving any older posts.
echo '
</form>
<script language="JavaScript" type="text/javascript">< -- // -->
< --// Bit of javascript for showing which boards to Moving in an otherwise hidden list. -->
var rotSwap2 = false;
function swapRot2()
{
rotSwap2 = rotSwap2;
document.getElementById("rotIcon2" .src = smf_images_url + (rotSwap2 ? "/collapse.gif" : "/expand.gif" ;
setInnerHTML(document.getElementById("rotText2" , rotSwap2 ? "', $txt['maintain_old_choose'], '" : "', $txt['maintain_old_all'], '" ;
document.getElementById("rotPanel2" .style.display = (rotSwap2 ? "block" : "none" ;
for (var i = 0; i < document.forms.rotForm2.length; i++)
{
if (document.forms.rotForm2.elements[i].type.toLowerCase() == "checkbox" && document.rotForm2.elements[i].id = "delete_old_not_sticky" document.forms.rotForm2.elements[i].checked = rotSwap2; } } // ]]></script> <table> <tr> <td class="windowbg2"> <a name="rotLink"></a>'; // The otherwise hidden "choose which boards to prune". echo ' <form action="', $scripturl, '?action=movetopic3" accept-charset="', $context['character_set'], '" name="rotForm2" id="rotForm2" method="post"> ', $txt['move_maintain_old_since_days1'], ' <input type="text" name="maxdays" value="30" size="3" />', $txt['maintain_old_since_days2'], '<br /> <div style="padding-left: 3ex;"> <label for="delete_type_nothing"><input type="radio" name="delete_type" id="delete_type_nothing" value="nothing" class="check" checked="checked" /> ', $txt['maintain_old_nothing_else'], '</label><br /> <label for="delete_type_moved"><input type="radio" name="delete_type" id="delete_type_moved" value="moved" class="check" /> ', $txt['maintain_old_are_moved'], '</label><br /> <label for="delete_type_locked"><input type="radio" name="delete_type" id="delete_type_locked" value="locked" class="check" /> ', $txt['maintain_old_are_locked'], '</label><br /> </div>'; if ( empty($modSettings['enableStickyTopics'])) echo ' <div style="padding-left: 3ex; padding-top: 1ex;"> <label for="delete_old_not_sticky"><input type="checkbox" name="delete_old_not_sticky" id="delete_old_not_sticky" class="check" checked="checked" /> ', $txt['maintain_old_are_not_stickied'], '</label><br /> </div>'; echo ' <br /> <a href="#rotLink2" onclick="swapRot2();"><img src="', $settings['images_url'], '/expand.gif" alt="+" id="rotIcon2" /></a> <a href="#rotLink2" onclick="swapRot2();"><span id="rotText2" style="font-weight: bold;">', $txt['maintain_old_all'], '</span></a> <div style="display: none;" id="rotPanel2"> <table width="100%" cellpadding="3" cellspacing="0" border="0"> <tr> <td valign="top">'; // This is the "middle" of the list. $middle = count($context['categories']) / 2; $i = 0; foreach ($context['categories'] as $category) { echo ' <span style="text-decoration: underline;">', $category['name'], '</span><br />'; // Display a checkbox with every board. foreach ($category['boards'] as $board) echo ' <label for="boards[', $board['id'], ']"><input type="checkbox" name="boards[', $board['id'], ']" id="boards[', $board['id'], ']" checked="checked" class="check" /> ', str_repeat(' ', $board['child_level']), $board['name'], '</label><br />'; echo ' <br />'; // Increase $i, and check if we're at the middle yet. if (++$i == $middle) echo ' </td> <td valign="top">'; } echo ' </td> </tr> </table> </div><br/> ', $txt['move_Destboard'], '<select name="toboard">'; foreach ($context['categories'] as $category) { echo ' <option disabled="disabled">----------------------------------------------------</option> <option disabled="disabled">', $category['name'], '</option> <option disabled="disabled">----------------------------------------------------</option>'; foreach ($category['boards'] as $board) echo ' <option value="', $board['id'], '">', str_repeat(' ', $board['child_level']), '|--', $board['name'], '</option>'; } echo ' </select> <div align="right" style="margin: 1ex;"><input type="submit" value="', $txt['move_maintain_old_remove'], '" onclick="return confirm(\'', $txt['move_maintain_old_confirm'], '\' ;" /></div> <input type="hidden" name="sc" value="', $context['session_id'], '" /> </form> </td> </tr> </table>'; } // Move a board? function template_activity_move_topics_maintenance_disabled() ./Sources/ManageMaintenance.php
Find
$context['page_title'] = $txt['not_done_title'];Replace With
$context['page_title'] = $txt['move_maintain_old'];Find
$context['page_title'] = isset($txt[$context['maintain_activity']]) ? $txt[$context['maintain_activity']] : $txt['maintain_general'];add after..
if (isset($_REQUEST['activity']) && $_REQUEST['activity'] = 'move_topics_maintenance'
$context['page_title'] = $txt['move_maintain_old'];./Themes/default/languages/Modifications.english.php
Find
?>Add before
// Move Old Posts
$txt['move_maintain_old'] = 'Move Old Posts';
$txt['move_maintain_old_since_days1'] = 'Move all topics not posted in for';
$txt['move_maintain_old_since_days2'] = 'days, which are:';
$txt['move_maintain_old_remove'] = 'Move Old';
$txt['move_Destboard'] = 'Destination Board:';
$txt['move_maintain_old_confirm'] = 'Are you really sure you want to MOVE old posts now?';İndex.php
Find
'movetopic2' => array('MoveTopic.php', 'MoveTopic2' ,Add after.
'movetopic3' => array('MoveTopic.php', 'MoveTopic3' ,