Added more import features
authorMarcel Werk <burntime@woltlab.com>
Sun, 30 Jun 2013 18:36:37 +0000 (20:36 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 30 Jun 2013 18:36:37 +0000 (20:36 +0200)
files/lib/system/exporter/WBB3xExporter.class.php
language/de.xml [new file with mode: 0644]
language/en.xml [new file with mode: 0644]
package.xml

index f9b29bdde38415e68604962ae2033259416f2f6e..8fdb5a2a518482a75363b699fc0225287c06a5b8 100644 (file)
@@ -39,7 +39,16 @@ class WBB3xExporter extends AbstractExporter {
         */
        protected $methods = array(
                'com.woltlab.wcf.user' => 'Users',
-               'com.woltlab.wcf.user.group' => 'UserGroups'
+               'com.woltlab.wcf.user.group' => 'UserGroups',
+               'com.woltlab.wcf.user.rank' => 'UserRanks',
+               'com.woltlab.wcf.user.follower' => 'Followers'
+       );
+       
+       /**
+        * @see wcf\system\exporter\AbstractExporter::$limits
+        */
+       protected $limits = array(
+               'com.woltlab.wcf.user' => 200
        );
        
        /**
@@ -129,9 +138,11 @@ class WBB3xExporter extends AbstractExporter {
                
                // 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.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';
-                       if (in_array('com.woltlab.wcf.user.rank', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.rank';
                        $queue[] = 'com.woltlab.wcf.user';
                        if (in_array('com.woltlab.wcf.user.avatar', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.avatar';
                        
@@ -219,6 +230,8 @@ class WBB3xExporter extends AbstractExporter {
         * Counts users.
         */
        public function countUsers() {
+               return 2000; // @todo
+               
                $sql = "SELECT  COUNT(*) AS count
                        FROM    wcf".$this->dbNo."_user";
                $statement = $this->database->prepareStatement($sql);
@@ -271,6 +284,8 @@ class WBB3xExporter extends AbstractExporter {
                        ORDER BY        user_table.userID";
                $statement = $this->database->prepareStatement($sql, $limit, $offset);
                $statement->execute();
+               
+               WCF::getDB()->beginTransaction();
                while ($row = $statement->fetchArray()) {
                        $data = array(
                                'username' => $row['username'],
@@ -313,5 +328,69 @@ class WBB3xExporter extends AbstractExporter {
                                $passwordUpdateStatement->execute(array('wcf1:'.$row['salt'].':'.$row['password'], $newUserID));
                        }
                }
+               WCF::getDB()->commitTransaction();
+       }
+       
+       /**
+        * Counts user ranks.
+        */
+       public function countUserRanks() {
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".$this->dbNo."_user_rank";
+               $statement = $this->database->prepareStatement($sql);
+               $statement->execute();
+               $row = $statement->fetchArray();
+               return $row['count'];
+       }
+       
+       /**
+        * Exports user ranks.
+        */
+       public function exportUserRanks($offset, $limit) {
+               $sql = "SELECT          *
+                       FROM            wcf".$this->dbNo."_user_rank
+                       ORDER BY        rankID";
+               $statement = $this->database->prepareStatement($sql, $limit, $offset);
+               $statement->execute();
+               while ($row = $statement->fetchArray()) {
+                       ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user.rank')->import($row['rankID'], array(
+                               'groupID' => $row['groupID'],
+                               'requiredPoints' => $row['neededPoints'],
+                               'rankTitle' => $row['rankTitle'],
+                               'rankImage' => $row['rankImage'],
+                               'repeatImage' => $row['repeatImage'],
+                               'requiredGender' => $row['gender']
+                       ));
+               }
+       }
+       
+       /**
+        * Counts followers.
+        */
+       public function countFollowers() {
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".$this->dbNo."_user_whitelist";
+               $statement = $this->database->prepareStatement($sql);
+               $statement->execute();
+               $row = $statement->fetchArray();
+               return $row['count'];
+       }
+       
+       /**
+        * Exports followers.
+        */
+       public function exportFollowers($offset, $limit) {
+               $sql = "SELECT          *
+                       FROM            wcf".$this->dbNo."_user_whitelist
+                       ORDER BY        userID, whiteUserID";
+               $statement = $this->database->prepareStatement($sql, $limit, $offset);
+               $statement->execute();
+               while ($row = $statement->fetchArray()) {
+                       ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user.follower')->import(0, array(
+                               'userID' => $row['userID'],
+                               'followUserID' => $row['whiteUserID'],
+                               'time' => $row['time']
+                       ));
+               }
        }
 }
diff --git a/language/de.xml b/language/de.xml
new file mode 100644 (file)
index 0000000..b72c23e
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de">
+       <category name="wcf.acp.dataImport">
+               <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb3x"><![CDATA[Burning Board 3.x]]></item>
+       </category>
+</language>
diff --git a/language/en.xml b/language/en.xml
new file mode 100644 (file)
index 0000000..8d18c81
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en">
+       <category name="wcf.acp.dataImport">
+               <item name="wcf.acp.dataImport.exporter.com.woltlab.wcf.exporter.wbb3x"><![CDATA[Burning Board 3.x]]></item>
+       </category>
+</language>
index e7e16edda30541f4a543ed1c944b5a9172943f2f..29edf95472a4a8da620df09f4ad6ba2c4a5b519a 100644 (file)
@@ -19,5 +19,6 @@
        <instructions type="install">
                <instruction type="file">files.tar</instruction>
                <instruction type="objectType">objectType.xml</instruction>
+               <instruction type="language">language/*.xml</instruction>
        </instructions>
 </package>
\ No newline at end of file