Add SMF 2 exporter barebone
authorTim Düsterhus <timwolla@bastelstu.be>
Tue, 3 Sep 2013 15:37:46 +0000 (17:37 +0200)
committerTim Düsterhus <timwolla@bastelstu.be>
Tue, 3 Sep 2013 15:37:46 +0000 (17:37 +0200)
files/lib/system/exporter/SMF2xExporter.class.php [new file with mode: 0644]
language/de.xml
language/en.xml
objectType.xml

diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php
new file mode 100644 (file)
index 0000000..bd11f18
--- /dev/null
@@ -0,0 +1,192 @@
+<?php
+namespace wcf\system\exporter;
+use wbb\data\board\Board;
+use wbb\data\board\BoardCache;
+use wcf\data\like\Like;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\group\UserGroup;
+use wcf\data\user\option\UserOption;
+use wcf\data\user\rank\UserRank;
+use wcf\data\user\UserProfile;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\database\DatabaseException;
+use wcf\system\exception\SystemException;
+use wcf\system\importer\ImportHandler;
+use wcf\system\request\LinkHandler;
+use wcf\system\Callback;
+use wcf\system\Regex;
+use wcf\system\WCF;
+use wcf\util\ArrayUtil;
+use wcf\util\FileUtil;
+use wcf\util\StringUtil;
+use wcf\util\UserRegistrationUtil;
+use wcf\util\UserUtil;
+
+/**
+ * Exporter for SMF 2.x
+ *
+ * @author     Tim Duesterhus
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    WoltLab Burning Board License <http://www.woltlab.com/products/burning_board/license.php>
+ * @package    com.woltlab.wcf.exporter
+ * @subpackage system.exporter
+ * @category   Community Framework (commercial)
+ */
+class SMF2xExporter extends AbstractExporter {
+       /**
+        * board cache
+        * @var array
+        */
+       protected $boardCache = array();
+       
+       /**
+        * @see wcf\system\exporter\AbstractExporter::$methods
+        */
+       protected $methods = array(
+               'com.woltlab.wcf.user' => 'Users',
+               'com.woltlab.wcf.user.group' => 'UserGroups',
+               'com.woltlab.wcf.user.rank' => 'UserRanks',
+               'com.woltlab.wcf.user.follower' => 'Followers',
+               'com.woltlab.wcf.user.avatar' => 'UserAvatars',
+               'com.woltlab.wcf.user.option' => 'UserOptions',
+               'com.woltlab.wcf.conversation.label' => 'ConversationFolders',
+               'com.woltlab.wcf.conversation' => 'Conversations',
+               'com.woltlab.wcf.conversation.message' => 'ConversationMessages',
+               'com.woltlab.wcf.conversation.user' => 'ConversationUsers',
+               'com.woltlab.wcf.conversation.attachment' => 'ConversationAttachments',
+               'com.woltlab.wbb.board' => 'Boards',
+               'com.woltlab.wbb.thread' => 'Threads',
+               'com.woltlab.wbb.post' => 'Posts',
+               'com.woltlab.wbb.attachment' => 'PostAttachments',
+               'com.woltlab.wbb.watchedThread' => 'WatchedThreads',
+               'com.woltlab.wbb.poll' => 'Polls',
+               'com.woltlab.wbb.poll.option' => 'PollOptions',
+               'com.woltlab.wbb.poll.option.vote' => 'PollOptionVotes',
+               'com.woltlab.wbb.like' => 'Likes',
+               'com.woltlab.wcf.label' => 'Labels',
+               'com.woltlab.wbb.acl' => 'ACLs',
+               'com.woltlab.wcf.smiley' => 'Smilies'
+       );
+       
+       /**
+        * @see wcf\system\exporter\AbstractExporter::$limits
+        */
+       protected $limits = array(
+               'com.woltlab.wcf.user' => 200,
+               'com.woltlab.wcf.user.avatar' => 100,
+               'com.woltlab.wcf.user.follower' => 100
+       );
+       
+       /**
+        * @see wcf\system\exporter\IExporter::getSupportedData()
+        */
+       public function getSupportedData() {
+               return array(
+                       /*'com.woltlab.wcf.user' => array(
+                               'com.woltlab.wcf.user.group',
+                               'com.woltlab.wcf.user.avatar',
+                               'com.woltlab.wcf.user.option',
+                               'com.woltlab.wcf.user.follower',
+                               'com.woltlab.wcf.user.rank'
+                       ),
+                       'com.woltlab.wbb.board' => array(
+                               'com.woltlab.wbb.acl',
+                               'com.woltlab.wbb.attachment',
+                               'com.woltlab.wbb.poll',
+                               'com.woltlab.wbb.watchedThread',
+                               'com.woltlab.wbb.like',
+                               'com.woltlab.wcf.label'
+                       ),
+                       'com.woltlab.wcf.conversation' => array(
+                               'com.woltlab.wcf.conversation.label'
+                       ),
+                       'com.woltlab.wcf.smiley' => array()*/
+               );
+       }
+       
+       /**
+        * @see wcf\system\exporter\IExporter::validateDatabaseAccess()
+        */
+       public function validateDatabaseAccess() {
+               parent::validateDatabaseAccess();
+               
+               $sql = "SELECT  value
+                       FROM    ".$this->databasePrefix."settings
+                       WHERE   Variable = ?";
+               $statement = $this->database->prepareStatement($sql);
+               $statement->execute(array('smfVersion'));
+               $row = $statement->fetchArray();
+               
+               if (version_compare('2.0.0', $row['value'], '<=')) throw new DatabaseException('Cannot import less than SMF 2.x', $this->database);
+       }
+       
+       /**
+        * @see wcf\system\exporter\IExporter::validateFileAccess()
+        */
+       public function validateFileAccess() {
+               if (in_array('com.woltlab.wcf.user.avatar', $this->selectedData) || in_array('com.woltlab.wbb.attachment', $this->selectedData) || in_array('com.woltlab.wcf.smiley', $this->selectedData)) {
+                       if (empty($this->fileSystemPath) || !@file_exists($this->fileSystemPath . 'SSI.php')) return false;
+               }
+               
+               return true;
+       }
+       
+       /**
+        * @see wcf\system\exporter\IExporter::getQueue()
+        */
+       public function getQueue() {
+               $queue = array();
+               /*
+               // user
+               if (in_array('com.woltlab.wcf.user', $this->selectedData)) {
+                       if (in_array('com.woltlab.wcf.user.group', $this->selectedData)) {
+                               $queue[] = 'com.woltlab.wcf.user.group';
+                               if (in_array('com.woltlab.wcf.user.rank', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.rank';
+                       }
+                       
+                       if (in_array('com.woltlab.wcf.user.option', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.option';
+                       $queue[] = 'com.woltlab.wcf.user';
+                       if (in_array('com.woltlab.wcf.user.avatar', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.avatar';
+                       
+                       if (in_array('com.woltlab.wcf.user.follower', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.follower';
+                       
+                       // conversation
+                       if (in_array('com.woltlab.wcf.conversation', $this->selectedData)) {
+                               if (in_array('com.woltlab.wcf.conversation.label', $this->selectedData)) $queue[] = 'com.woltlab.wcf.conversation.label';
+                               
+                               $queue[] = 'com.woltlab.wcf.conversation';
+                               $queue[] = 'com.woltlab.wcf.conversation.user';
+                       }
+               }
+               
+               // board
+               if (in_array('com.woltlab.wbb.board', $this->selectedData)) {
+                       $queue[] = 'com.woltlab.wbb.board';
+                       if (in_array('com.woltlab.wcf.label', $this->selectedData)) $queue[] = 'com.woltlab.wcf.label';
+                       $queue[] = 'com.woltlab.wbb.thread';
+                       $queue[] = 'com.woltlab.wbb.post';
+                       
+                       if (in_array('com.woltlab.wbb.acl', $this->selectedData)) $queue[] = 'com.woltlab.wbb.acl';
+                       if (in_array('com.woltlab.wbb.attachment', $this->selectedData)) $queue[] = 'com.woltlab.wbb.attachment';
+                       if (in_array('com.woltlab.wbb.watchedThread', $this->selectedData)) $queue[] = 'com.woltlab.wbb.watchedThread';
+                       if (in_array('com.woltlab.wbb.poll', $this->selectedData)) {
+                               $queue[] = 'com.woltlab.wbb.poll';
+                               $queue[] = 'com.woltlab.wbb.poll.option';
+                               $queue[] = 'com.woltlab.wbb.poll.option.vote';
+                       }
+                       if (in_array('com.woltlab.wbb.like', $this->selectedData)) $queue[] = 'com.woltlab.wbb.like';
+               }
+               
+               // smiley
+               if (in_array('com.woltlab.wcf.smiley', $this->selectedData)) $queue[] = 'com.woltlab.wcf.smiley';
+               */
+               return $queue;
+       }
+       
+       /**
+        * @see wcf\system\exporter\IExporter::getDefaultDatabasePrefix()
+        */
+       public function getDefaultDatabasePrefix() {
+               return 'smf_';
+       }
+}
index 1486f8478b71718aaa3a2660663990c455ed52af..fa38495d5366a857dd323122b535f144a972db17 100644 (file)
@@ -4,5 +4,6 @@
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb2x"><![CDATA[Burning Board 2.3.x]]></item>
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb3x"><![CDATA[Burning Board 3.0.x, 3.1.x, Lite 2.1.x]]></item>
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.mybb16x"><![CDATA[MyBB 1.6.x]]></item>
+               <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.smf2x"><![CDATA[Simple Machines Forum 2.x]]></item>
        </category>
 </language>
index bbd560a90b0c3833569edcd4cea92fb4887128e8..4c2784ef0849b357a721bdb0075f6b9d95d2b9e1 100644 (file)
@@ -4,5 +4,6 @@
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb2x"><![CDATA[Burning Board 2.3.x]]></item>
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb3x"><![CDATA[Burning Board 3.0.x, 3.1.x, Lite 2.1.x]]></item>
                <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.mybb16x"><![CDATA[MyBB 1.6.x]]></item>
+               <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.smf2x"><![CDATA[Simple Machines Forum 2.x]]></item>
        </category>
 </language>
index 89be81b67c3b45d2234c7d64346967997441a285..d9e9d0204905c9ccb47c9778e675c350991d2cfa 100644 (file)
                        <definitionname>com.woltlab.wcf.exporter</definitionname>
                        <classname>wcf\system\exporter\MyBB16xExporter</classname>
                </type>
+               
+               <type>
+                       <name>com.woltlab.wcf.exporter.smf2x</name>
+                       <definitionname>com.woltlab.wcf.exporter</definitionname>
+                       <classname>wcf\system\exporter\SMF2xExporter</classname>
+               </type>
        </import>
 </data>
\ No newline at end of file