Exemplo n.º 1
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['packageID'] = 1;
     // set temporary option name
     $data['optionName'] = StringUtil::getRandomID();
     if ($data['optionType'] == 'boolean' || $data['optionType'] == 'integer') {
         if (isset($data['defaultValue'])) {
             $data['defaultValue'] = intval($data['defaultValue']);
         }
     }
     // create category
     $this->createCategory($data['categoryName']);
     // save option
     $action = new UserOptionAction(array(), 'create', array('data' => $data));
     $returnValues = $action->executeAction();
     $userOption = $returnValues['returnValues'];
     // update generic option name
     $editor = new UserOptionEditor($userOption);
     $editor->update(array('optionName' => 'option' . $userOption->optionID));
     // save name
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(LanguageFactory::getInstance()->getDefaultLanguageID(), 'wcf.user.option.option' . $userOption->optionID, $additionalData['name'], 0, $this->languageCategoryID, 1));
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.option', $oldID, $userOption->optionID);
     return $userOption->optionID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     $comment = CommentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
     ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $comment->commentID);
     return $comment->commentID;
 }
Exemplo n.º 3
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     if (!isset($this->options[$additionalData['optionName']])) {
         return 0;
     }
     $data['optionID'] = $this->options[$additionalData['optionName']];
     $data['objectID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['objectID']);
     if (!$data['objectID']) {
         return 0;
     }
     if (!empty($data['groupID'])) {
         $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']);
         if (!$data['groupID']) {
             return 0;
         }
         $sql = "INSERT INTO\twcf" . WCF_N . "_acl_option_to_group\n\t\t\t\t\t\t(optionID, objectID, groupID, optionValue)\n\t\t\t\tVALUES\t\t(?, ?, ?, ?)";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($data['optionID'], $data['objectID'], $data['groupID'], $data['optionValue']));
         return 1;
     } else {
         if (!empty($data['userID'])) {
             $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
             if (!$data['userID']) {
                 return 0;
             }
             $sql = "INSERT INTO\twcf" . WCF_N . "_acl_option_to_user\n\t\t\t\t\t\t(optionID, objectID, userID, optionValue)\n\t\t\t\tVALUES\t\t(?, ?, ?, ?)";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array($data['optionID'], $data['objectID'], $data['userID'], $data['optionValue']));
             return 1;
         }
     }
 }
Exemplo n.º 4
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['objectID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectID']);
     if (!$data['objectID']) {
         return 0;
     }
     return parent::import($oldID, $data);
 }
Exemplo n.º 5
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // check file location
     if (!@file_exists($additionalData['fileLocation'])) {
         return 0;
     }
     // get image size
     $imageData = @getimagesize($additionalData['fileLocation']);
     if ($imageData === false) {
         return 0;
     }
     $data['width'] = $imageData[0];
     $data['height'] = $imageData[1];
     // check min size
     if ($data['width'] < 48 || $data['height'] < 48) {
         return 0;
     }
     // check image type
     if ($imageData[2] != IMAGETYPE_GIF && $imageData[2] != IMAGETYPE_JPEG && $imageData[2] != IMAGETYPE_PNG) {
         return 0;
     }
     // get file hash
     if (empty($data['fileHash'])) {
         $data['fileHash'] = sha1_file($additionalData['fileLocation']);
     }
     // get user id
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     // save avatar
     $avatar = UserAvatarEditor::create($data);
     // check avatar directory
     // and create subdirectory if necessary
     $dir = dirname($avatar->getLocation());
     if (!@file_exists($dir)) {
         FileUtil::makePath($dir, 0777);
     }
     // copy file
     try {
         if (!copy($additionalData['fileLocation'], $avatar->getLocation())) {
             throw new SystemException();
         }
         // create thumbnails
         $action = new UserAvatarAction(array($avatar), 'generateThumbnails');
         $action->executeAction();
         // update owner
         $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\tSET\tavatarID = ?\n\t\t\t\tWHERE\tuserID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($avatar->avatarID, $data['userID']));
         return $avatar->avatarID;
     } catch (SystemException $e) {
         // copy failed; delete avatar
         $editor = new UserAvatarEditor($avatar);
         $editor->delete();
     }
     return 0;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
     return $watch->watchID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     if (!empty($data['parentCategoryID'])) {
         $data['parentCategoryID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['parentCategoryID']);
     }
     $category = CategoryEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
     ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $category->categoryID);
     return $category->categoryID;
 }
Exemplo n.º 8
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']);
     if (!$data['groupID']) {
         $data['groupID'] = UserGroup::getGroupByType(UserGroup::USERS)->groupID;
     }
     $rank = UserRankEditor::create($data);
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.rank', $oldID, $rank->rankID);
     return $rank->rankID;
 }
Exemplo n.º 9
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.label.group', $data['groupID']);
     if (!$data['groupID']) {
         return 0;
     }
     $label = LabelEditor::create($data);
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.label', $oldID, $label->labelID);
     return $label->labelID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
     if (!$data['pollID']) {
         return 0;
     }
     $option = PollOptionEditor::create($data);
     ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $option->optionID);
     return $option->optionID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // get user id
     $data['newsID'] = ImportHandler::getInstance()->getNewID('de.voolia.news.entry', $data['newsID']);
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     // create news update
     $newsUpdate = NewsUpdateEditor::create($data);
     $newsUpdateEditor = new NewsUpdateEditor($newsUpdate);
     ImportHandler::getInstance()->saveNewID('de.voolia.news.entry.update', $oldID, $newsUpdate->updateID);
     return $newsUpdate->updateID;
 }
Exemplo n.º 12
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     if ($data['groupType'] < 4) {
         $newGroupID = UserGroup::getGroupByType($data['groupType'])->groupID;
     } else {
         $action = new UserGroupAction(array(), 'create', array('data' => $data));
         $returnValues = $action->executeAction();
         $newGroupID = $returnValues['returnValues']->groupID;
     }
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.group', $oldID, $newGroupID);
     return $newGroupID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     $action = new ConversationLabelAction(array(), 'create', array('data' => $data));
     $returnValues = $action->executeAction();
     $newID = $returnValues['returnValues']->labelID;
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.conversation.label', $oldID, $newID);
     return $newID;
 }
Exemplo n.º 14
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     $data['followUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['followUserID']);
     if (!$data['userID'] || !$data['followUserID']) {
         return 0;
     }
     if (!isset($data['time'])) {
         $data['time'] = 0;
     }
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_user_follow\n\t\t\t\t\t\t(userID, followUserID, time)\n\t\t\tVALUES\t\t\t(?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($data['userID'], $data['followUserID'], $data['time']));
     return WCF::getDB()->getInsertID('wcf' . WCF_N . '_user_follow', 'followID');
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // check file location
     if (!@file_exists($additionalData['fileLocation'])) {
         return 0;
     }
     // get file hash
     if (empty($data['fileHash'])) {
         $data['fileHash'] = sha1_file($additionalData['fileLocation']);
     }
     // get image size
     if (!empty($data['isImage'])) {
         $imageData = @getimagesize($additionalData['fileLocation']);
         if ($imageData !== false) {
             $data['width'] = $imageData[0];
             $data['height'] = $imageData[1];
         }
     }
     // get user id
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     // check existing attachment id
     if (is_numeric($oldID)) {
         $attachment = new Attachment($oldID);
         if (!$attachment->attachmentID) {
             $data['attachmentID'] = $oldID;
         }
     }
     // save attachment
     $attachment = AttachmentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
     // check attachment directory
     // and create subdirectory if necessary
     $dir = dirname($attachment->getLocation());
     if (!@file_exists($dir)) {
         @mkdir($dir, 0777);
     }
     // copy file
     try {
         if (!copy($additionalData['fileLocation'], $attachment->getLocation())) {
             throw new SystemException();
         }
         return $attachment->attachmentID;
     } catch (SystemException $e) {
         // copy failed; delete attachment
         $editor = new AttachmentEditor($attachment);
         $editor->delete();
     }
     return 0;
 }
Exemplo n.º 16
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // save label group
     $labelGroup = LabelGroupEditor::create($data);
     // save objects
     if (!empty($additionalData['objects'])) {
         $sql = "INSERT INTO\twcf" . WCF_N . "_label_group_to_object\n\t\t\t\t\t\t(groupID, objectTypeID, objectID)\n\t\t\t\tVALUES\t\t(?, ?, ?)";
         $statement = WCF::getDB()->prepareStatement($sql);
         foreach ($additionalData['objects'] as $objectTypeID => $objectIDs) {
             foreach ($objectIDs as $objectID) {
                 $statement->execute(array($labelGroup->groupID, $objectTypeID, $objectID));
             }
         }
     }
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.label.group', $oldID, $labelGroup->groupID);
     return $labelGroup->groupID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['objectID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation.message', $data['objectID']);
     if (!$data['objectID']) {
         return 0;
     }
     $attachmentID = parent::import($oldID, $data, $additionalData);
     if ($attachmentID && $attachmentID != $oldID) {
         // fix embedded attachments
         $messageObj = new ConversationMessage($data['objectID']);
         if (($newMessage = $this->fixEmbeddedAttachments($messageObj->message, $oldID, $attachmentID)) !== false) {
             $editor = new ConversationMessageEditor($messageObj);
             $editor->update(array('message' => $newMessage));
         }
     }
     return $attachmentID;
 }
Exemplo n.º 18
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     if ($data['objectUserID']) {
         $data['objectUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectUserID']);
     }
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     if (empty($data['time'])) {
         $data['time'] = 1;
     }
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_like\n\t\t\t\t\t\t(objectID, objectTypeID, objectUserID, userID, time, likeValue)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($data['objectID'], $this->objectTypeID, $data['objectUserID'], $data['userID'], $data['time'], $data['likeValue']));
     return 0;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     try {
         $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
         return $watch->watchID;
     } catch (DatabaseException $e) {
         // 23000 = INTEGRITY CONSTRAINT VIOLATION a.k.a. duplicate key
         if ($e->getCode() != 23000) {
             throw $e;
         }
     }
     return 0;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['objectID'] = ImportHandler::getInstance()->getNewID('de.codequake.cms.news', $data['objectID']);
     if (!$data['objectID']) {
         return 0;
     }
     $attachmentID = parent::import($oldID, $data, $additionalData);
     if ($attachmentID && $attachmentID != $oldID) {
         // fix embedded attachments
         $news = new News($data['objectID']);
         if (($newMessage = $this->fixEmbeddedAttachments($news->message, $oldID, $attachmentID)) !== false) {
             $editor = new NewsEditor($news);
             $editor->update(array('message' => $newMessage));
         }
     }
     return $attachmentID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['conversationID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation', $data['conversationID']);
     if (!$data['conversationID']) {
         return 0;
     }
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     // check existing message
     if (is_numeric($oldID)) {
         $existingMessage = new ConversationMessage($oldID);
         if (!$existingMessage->messageID) {
             $data['messageID'] = $oldID;
         }
     }
     $message = ConversationMessageEditor::create($data);
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.conversation.message', $oldID, $message->messageID);
     return $message->messageID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // get user id
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     // get news id
     if (is_numeric($oldID)) {
         $news = new News($oldID);
         if (!$news->newsID) {
             $data['newsID'] = $oldID;
         }
     }
     // get news categories
     $categoryIDs = array();
     if (!empty($additionalData['categories'])) {
         foreach ($additionalData['categories'] as $oldCategoryID) {
             $newCategoryID = ImportHandler::getInstance()->getNewID('de.voolia.news.category', $oldCategoryID);
             if ($newCategoryID) {
                 $categoryIDs[] = $newCategoryID;
             }
         }
     }
     // work-around for unknown username
     if (empty($data['username'])) {
         $user = new User($data['userID']);
         $data['username'] = $user->username;
     }
     // get language by languageCode
     if (!empty($additionalData['languageCode'])) {
         if (($language = LanguageFactory::getInstance()->getLanguageByCode($additionalData['languageCode'])) !== null) {
             $data['languageID'] = $language->languageID;
         }
     }
     // create news
     $news = NewsEditor::create($data);
     $newsEditor = new NewsEditor($news);
     // save the tags from news entry
     if (!empty($additionalData['tags'])) {
         TagEngine::getInstance()->addObjectTags('de.voolia.news.entry', $news->newsID, $additionalData['tags'], $news->languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID());
     }
     // update news categories
     $newsEditor->updateCategoryIDs($categoryIDs);
     ImportHandler::getInstance()->saveNewID('de.voolia.news.entry', $oldID, $news->newsID);
     return $news->newsID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!$data['userID']) {
         return 0;
     }
     $data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
     if (!$data['pollID']) {
         return 0;
     }
     $data['optionID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['optionID']);
     if (!$data['optionID']) {
         return 0;
     }
     $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_poll_option_vote\n\t\t\t\t\t\t(pollID, optionID, userID)\n\t\t\tVALUES\t\t\t(?, ?, ?)";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($data['pollID'], $data['optionID'], $data['userID']));
     return 1;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $oldUserID = $data['userID'];
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     // check existing conversation
     if (is_numeric($oldID)) {
         $existingConversation = new Conversation($oldID);
         if (!$existingConversation->conversationID) {
             $data['conversationID'] = $oldID;
         }
     }
     $conversation = ConversationEditor::create($data);
     ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.conversation', $oldID, $conversation->conversationID);
     // add author
     if (empty($data['isDraft'])) {
         ImportHandler::getInstance()->getImporter('com.woltlab.wcf.conversation.user')->import(0, array('conversationID' => $oldID, 'participantID' => $oldUserID, 'username' => $data['username'], 'hideConversation' => 0, 'isInvisible' => 0, 'lastVisitTime' => $data['time']), array('labelIDs' => array()));
     }
     return $conversation->conversationID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // get news id
     $data['objectID'] = ImportHandler::getInstance()->getNewID('de.voolia.news.entry', $data['objectID']);
     if (!$data['objectID']) {
         return 0;
     }
     $attachmentID = parent::import($oldID, $data, $additionalData);
     if ($attachmentID && $attachmentID != $oldID) {
         // get the news
         $news = new News($data['objectID']);
         // update news text with the new attachment id
         if (($newText = $this->fixEmbeddedAttachments($news->text, $oldID, $attachmentID)) !== false) {
             $newsEditor = new NewsEditor($news);
             $newsEditor->update(array('text' => $newText));
         }
     }
     return $attachmentID;
 }
Exemplo n.º 26
0
 /**
  * @see	\wcf\system\worker\IWorker::validate()
  */
 public function validate()
 {
     WCF::getSession()->checkPermissions(array('admin.system.canImportData'));
     if (!isset($this->parameters['objectType'])) {
         throw new SystemException("parameter 'objectType' missing");
     }
     // get import data
     $this->importData = WCF::getSession()->getVar('importData');
     if ($this->importData === null) {
         throw new SystemException("import data missing");
     }
     // get exporter
     $this->exporter = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.exporter', $this->importData['exporterName'])->getProcessor();
     // set data
     $this->exporter->setData($this->importData['dbHost'], $this->importData['dbUser'], $this->importData['dbPassword'], $this->importData['dbName'], $this->importData['dbPrefix'], $this->importData['fileSystemPath'], $this->importData['additionalData']);
     $this->exporter->init();
     // set user merge mode
     ImportHandler::getInstance()->setUserMergeMode($this->importData['userMergeMode']);
     // set import hash
     ImportHandler::getInstance()->setImportHash(substr(StringUtil::getHash($this->importData['dbHost'] . $this->importData['dbName'] . $this->importData['dbPrefix']), 0, 8));
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     $data['commentID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['commentID']);
     if (!$data['commentID']) {
         return 0;
     }
     $response = CommentResponseEditor::create($data);
     $sql = "SELECT\t\tresponseID\n\t\t\tFROM\t\twcf" . WCF_N . "_comment_response\n\t\t\tWHERE\t\tcommentID = ?\n\t\t\tORDER BY\ttime ASC, responseID ASC";
     $statement = WCF::getDB()->prepareStatement($sql, 5);
     $statement->execute(array($response->commentID));
     $responseIDs = array();
     while ($responseID = $statement->fetchColumn()) {
         $responseIDs[] = $responseID;
     }
     // update parent comment
     $sql = "UPDATE\twcf" . WCF_N . "_comment\n\t\t\tSET\tresponseIDs = ?,\n\t\t\t\tresponses = responses + 1\n\t\t\tWHERE\tcommentID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(serialize($responseIDs), $response->commentID));
     return $response->responseID;
 }
Exemplo n.º 28
0
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     // copy smiley
     $data['smileyPath'] = 'images/smilies/' . basename($additionalData['fileLocation']);
     if (!@copy($additionalData['fileLocation'], WCF_DIR . $data['smileyPath'])) {
         return 0;
     }
     // check smileycode
     if (isset($this->knownCodes[mb_strtolower($data['smileyCode'])])) {
         return $this->knownCodes[mb_strtolower($data['smileyCode'])];
     }
     $data['packageID'] = 1;
     if (!isset($data['aliases'])) {
         $data['aliases'] = '';
     }
     // check aliases
     $aliases = array();
     if (!empty($data['aliases'])) {
         $aliases = explode("\n", StringUtil::unifyNewlines($data['aliases']));
         foreach ($aliases as $key => $alias) {
             if (isset($this->knownCodes[mb_strtolower($alias)])) {
                 unset($aliases[$key]);
             }
         }
         $data['aliases'] = implode("\n", $aliases);
     }
     // get category id
     if (!empty($data['categoryID'])) {
         $data['categoryID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.smiley.category', $data['categoryID']);
     }
     // save smiley
     $smiley = SmileyEditor::create($data);
     // add smileyCode + aliases to knownCodes
     $this->knownCodes[mb_strtolower($data['smileyCode'])] = $smiley->smileyID;
     foreach ($aliases as $alias) {
         $this->knownCodes[mb_strtolower($alias)] = $smiley->smileyID;
     }
     return $smiley->smileyID;
 }
Exemplo n.º 29
0
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
     if (!empty($additionalData['languageCode'])) {
         if (($language = LanguageFactory::getInstance()->getLanguageByCode($additionalData['languageCode'])) !== null) {
             $data['languageID'] = $language->languageID;
         }
     }
     if (is_numeric($oldID)) {
         $news = new News($oldID);
         if (!$news->newsID) {
             $data['newsID'] = $oldID;
         }
     }
     // save categories
     $categoryIDs = array();
     if (!empty($additionalData['categories'])) {
         foreach ($additionalData['categories'] as $oldCategoryID) {
             $newCategoryID = ImportHandler::getInstance()->getNewID('de.codequake.cms.category.news', $oldCategoryID);
             if ($newCategoryID) {
                 $categoryIDs[] = $newCategoryID;
             }
         }
     }
     if (empty($categoryIDs)) {
         $categoryIDs[] = $this->getImportCategoryID();
     }
     $action = new NewsAction(array(), 'create', array('data' => $data, 'categoryIDs' => $categoryIDs));
     $returnValues = $action->executeAction();
     $newID = $returnValues['returnValues']->newsID;
     $news = new News($newID);
     // save tags
     if (!empty($additionalData['tags'])) {
         TagEngine::getInstance()->addObjectTags('de.codequake.cms.news', $news->newsID, $additionalData['tags'], $news->languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID());
     }
     ImportHandler::getInstance()->saveNewID('de.codequake.cms.news', $oldID, $news->newsID);
     return $news->newsID;
 }
 /**
  * @see	\wcf\system\importer\IImporter::import()
  */
 public function import($oldID, array $data, array $additionalData = array())
 {
     $data['conversationID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation', $data['conversationID']);
     if (!$data['conversationID']) {
         return 0;
     }
     $data['participantID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['participantID']);
     $sql = "INSERT INTO\t\t\twcf" . WCF_N . "_conversation_to_user\n\t\t\t\t\t\t\t(conversationID, participantID, username, hideConversation, isInvisible, lastVisitTime)\n\t\t\tVALUES\t\t\t\t(?, ?, ?, ?, ?, ?)\n\t\t\tON DUPLICATE KEY UPDATE\t\thideConversation = IF(hideConversation > 0 AND hideConversation = VALUES(hideConversation),hideConversation,0),\n\t\t\t\t\t\t\tisInvisible = IF(isInvisible AND VALUES(isInvisible),1,0),\n\t\t\t\t\t\t\tlastVisitTime = GREATEST(lastVisitTime,VALUES(lastVisitTime))";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($data['conversationID'], $data['participantID'], $data['username'], $data['hideConversation'], $data['isInvisible'], $data['lastVisitTime']));
     // save labels
     if ($data['participantID'] && !empty($additionalData['labelIDs'])) {
         $sql = "INSERT IGNORE INTO\t\twcf" . WCF_N . "_conversation_label_to_object\n\t\t\t\t\t\t\t\t(labelID, conversationID)\n\t\t\t\tVALUES\t\t\t\t(?, ?)";
         $statement = WCF::getDB()->prepareStatement($sql);
         foreach ($additionalData['labelIDs'] as $labelID) {
             $labelID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.conversation.label', $labelID);
             if ($labelID) {
                 $statement->execute(array($labelID, $data['conversationID']));
             }
         }
     }
     return 1;
 }