/** * @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()) { $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; }
/** * Adds a subscription. */ public function subscribe() { $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $this->parameters['data']['objectType']); UserObjectWatchEditor::create(array('userID' => WCF::getUser()->userID, 'objectID' => intval($this->parameters['data']['objectID']), 'objectTypeID' => $objectType->objectTypeID, 'notification' => !empty($this->parameters['enableNotification']) ? 1 : 0)); // reset user storage $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID)); }
/** * subscribe topic * * @param $oMbqEtForumTopic */ public function subscribeTopic($oMbqEtForumTopic) { //ref wcf\data\user\object\watch\UserObjectWatchAction::subscribe() $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', 'com.woltlab.wbb.thread'); $userObjectWatch = UserObjectWatch::getUserObjectWatch($objectType->objectTypeID, WCF::getUser()->userID, intval($oMbqEtForumTopic->topicId->oriValue)); if (!$userObjectWatch) { //help confirm not subscribed UserObjectWatchEditor::create(array('userID' => WCF::getUser()->userID, 'objectID' => intval($oMbqEtForumTopic->topicId->oriValue), 'objectTypeID' => $objectType->objectTypeID, 'notification' => 0)); // reset user storage $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID)); } return true; }
/** * subscribe topic * * @param Mixed $var($oMbqEtForumTopic or $objsMbqEtForumTopic) */ public function subscribeTopic(&$var) { if (is_array($var)) { MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_NOT_ACHIEVE); } else { //ref wcf\data\user\object\watch\UserObjectWatchAction::subscribe() $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', 'com.woltlab.wbb.thread'); $userObjectWatch = UserObjectWatch::getUserObjectWatch($objectType->objectTypeID, WCF::getUser()->userID, intval($var->topicId->oriValue)); if (!$userObjectWatch) { //help confirm not subscribed UserObjectWatchEditor::create(array('userID' => WCF::getUser()->userID, 'objectID' => intval($var->topicId->oriValue), 'objectTypeID' => $objectType->objectTypeID, 'notification' => 0)); // reset user storage $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID)); } } }