From: Tim Düsterhus Date: Tue, 10 Sep 2013 18:59:00 +0000 (+0200) Subject: Export followers (SMF) X-Git-Tag: 2.0.0_Beta_6~5^2~22 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8223dc913b325cc43f8a2aa58160782d36a23fde;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Export followers (SMF) --- diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php index c292d12..957d300 100644 --- a/files/lib/system/exporter/SMF2xExporter.class.php +++ b/files/lib/system/exporter/SMF2xExporter.class.php @@ -85,8 +85,8 @@ class SMF2xExporter extends AbstractExporter { '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.option',*/ + 'com.woltlab.wcf.user.follower', 'com.woltlab.wcf.user.rank' ), /*'com.woltlab.wbb.board' => array( @@ -146,10 +146,10 @@ class SMF2xExporter extends AbstractExporter { /*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.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'; @@ -315,4 +315,39 @@ class SMF2xExporter extends AbstractExporter { )); } } + + /** + * Counts followers. + */ + public function countFollowers() { + $sql = "SELECT COUNT(*) AS count + FROM ".$this->databasePrefix."members + WHERE buddy_list <> ?"; + $statement = $this->database->prepareStatement($sql); + $statement->execute(array('')); + $row = $statement->fetchArray(); + return $row['count']; + } + + /** + * Exports followers. + */ + public function exportFollowers($offset, $limit) { + $sql = "SELECT id_member, buddy_list + FROM ".$this->databasePrefix."members + WHERE buddy_list <> ? + ORDER BY id_member"; + $statement = $this->database->prepareStatement($sql, $limit, $offset); + $statement->execute(array('')); + while ($row = $statement->fetchArray()) { + $buddylist = array_unique(ArrayUtil::toIntegerArray(explode(',', $row['buddy_list']))); + + foreach ($buddylist as $buddy) { + ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user.follower')->import(0, array( + 'userID' => $row['id_member'], + 'followUserID' => $buddy + )); + } + } + } }