Commit | Line | Data |
---|---|---|
695780d7 MW |
1 | <?php |
2 | namespace wcf\system\importer; | |
c2836ca3 | 3 | use wcf\data\comment\response\CommentResponseEditor; |
9c6a8f95 | 4 | use wcf\system\WCF; |
695780d7 MW |
5 | |
6 | /** | |
7 | * Imports comment responses. | |
e3369fd2 | 8 | * |
1c402870 TD |
9 | * @author Tim Duesterhus, Marcel Werk |
10 | * @copyright 2001-2014 WoltLab GmbH | |
695780d7 MW |
11 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
12 | * @package com.woltlab.wcf | |
13 | * @subpackage system.importer | |
14 | * @category Community Framework | |
15 | */ | |
c2836ca3 MW |
16 | class AbstractCommentResponseImporter extends AbstractImporter { |
17 | /** | |
0ad90fc3 | 18 | * @see \wcf\system\importer\AbstractImporter::$className |
c2836ca3 MW |
19 | */ |
20 | protected $className = 'wcf\data\comment\response\CommentResponse'; | |
21 | ||
695780d7 MW |
22 | /** |
23 | * object type name | |
06355ec3 | 24 | * @var string |
695780d7 MW |
25 | */ |
26 | protected $objectTypeName = ''; | |
27 | ||
28 | /** | |
0ad90fc3 | 29 | * @see \wcf\system\importer\IImporter::import() |
695780d7 | 30 | */ |
6eb1d790 | 31 | public function import($oldID, array $data, array $additionalData = array()) { |
732a49db | 32 | $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']); |
695780d7 MW |
33 | |
34 | $data['commentID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['commentID']); | |
e1ad68de | 35 | if (!$data['commentID']) return 0; |
695780d7 | 36 | |
c2836ca3 | 37 | $response = CommentResponseEditor::create($data); |
695780d7 | 38 | |
1c402870 TD |
39 | $sql = "SELECT responseID |
40 | FROM wcf".WCF_N."_comment_response | |
1a6e8c52 MS |
41 | WHERE commentID = ? |
42 | ORDER BY responseID ASC"; | |
1c402870 TD |
43 | $statement = WCF::getDB()->prepareStatement($sql, 3); |
44 | $statement->execute(array($response->commentID)); | |
45 | $responseIDs = array(); | |
46 | while ($responseID = $statement->fetchColumn()) $responseIDs[] = $responseID; | |
47 | ||
9c6a8f95 AE |
48 | // update parent comment |
49 | $sql = "UPDATE wcf".WCF_N."_comment | |
1c402870 TD |
50 | SET responseIDs = ?, |
51 | responses = responses + 1 | |
9c6a8f95 AE |
52 | WHERE commentID = ?"; |
53 | $statement = WCF::getDB()->prepareStatement($sql); | |
54 | $statement->execute(array( | |
1c402870 | 55 | serialize($responseIDs), |
9c6a8f95 AE |
56 | $response->commentID |
57 | )); | |
58 | ||
c2836ca3 | 59 | return $response->responseID; |
695780d7 MW |
60 | } |
61 | } |