News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1262552186:v:use_geshi-1:v:type-php

Started by akabugeyes, Jan 03, 2010, 08:56 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

akabugeyes

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

require("SSI.php");
require("Sources/Subs-Post.php");
require("Sources/Subs-Boards.php");

$copy = array(
   array('from' => 5, 'to' => 117),
   array('from' => 29, 'child' => 119),
   array('from' => 30, 'child' => 119),
   array('from' => 31, 'child' => 119),
   array('from' => 32, 'child' => 119),
   array('from' => 33, 'child' => 119),
   array('from' => 16, 'child' => 117),
   array('from' => 17, 'child' => 117),
   array('from' => 18, 'child' => 117),
   array('from' => 19, 'child' => 117),
   array('from' => 20, 'child' => 117),
   array('from' => 21, 'child' => 117),
   array('from' => 22, 'child' => 117),
   array('from' => 23, 'child' => 117),
   array('from' => 6, 'to' => 118),
);

$created = array();

foreach($copy as $item)
{
   // 'from' required.
   if(isset($item['from']))
   {
      if (isset($item['child']) && !in_array($item['child'], $created))
      {
         // We need to make this board, baby!
         $request = $smcFunc['db_query']('', '
            SELECT name, description, id_board, id_cat
            FROM {db_prefix}boards
            WHERE id_board = {int:id_board}
            LIMIT 1',
            array(
               'id_board' => $item['from'],
            )
         );
         
         if ($smcFunc['db_num_rows']($request))
         {
            while ($row = $smcFunc['db_fetch_assoc']($request))
            {
               $board = array(
                  'target_board' => $item['child'],
                  'board_name' => $row['name'],
                  'target_category' => $row['id_cat'],
                  'description' => $row['description'],
                  'move_to' => 'child',
               );
            }
            $new_id = createBoard($board);
            $item['to'] = $new_id;
            $created[] = $item['child'];
         }
      }
         
      $topics = ssi_recentTopics(5, null, $item['from'], 'array');
      
      foreach($topics as $topic)
      {
         $msgOptions = array(
            'body' => $topic['preview'],
            'subject' => $topic['subject'],
         );
         
         $topicOptions = array(
            'board' => $item['to'],
            'mark_as_read' => false,
         );
         
         $posterOptions = array(
            'name' => 'SMF Doc Team',
            'email' => 'docs@simplemachines.org',
            'id' => 1,
         );
         createPost($msgOptions, $topicOptions, $posterOptions);
      }
   }
}

?>