/** * unsubscribe topic * * @param $oMbqEtForumTopic */ public function unsubscribeTopic($oMbqEtForumTopic) { //ref wcf\data\user\object\watch\UserObjectWatchAction::unsubscribe() $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->watchID) { $editor = new UserObjectWatchEditor($userObjectWatch); $editor->delete(); // reset user storage $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID)); } return true; }
/** * Validates the subscribe action. */ protected function __validateSubscribe() { $this->readInteger('objectID', false, 'data'); $this->readString('objectType', false, 'data'); // validate object type $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $this->parameters['data']['objectType']); if ($objectType === null) { throw new UserInputException('objectType'); } // validate object id $objectType->getProcessor()->validateObjectID(intval($this->parameters['data']['objectID'])); // get existing subscription $this->userObjectWatch = UserObjectWatch::getUserObjectWatch($objectType->objectTypeID, WCF::getUser()->userID, intval($this->parameters['data']['objectID'])); }
/** * unsubscribe topic * * @param Mixed $var($oMbqEtForumTopic or $objsMbqEtForumTopic) */ public function unsubscribeTopic(&$var) { if (is_array($var)) { MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_NOT_ACHIEVE); } else { //ref wcf\data\user\object\watch\UserObjectWatchAction::unsubscribe() $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->watchID) { $editor = new UserObjectWatchEditor($userObjectWatch); $editor->delete(); // reset user storage $objectType->getProcessor()->resetUserStorage(array(WCF::getUser()->userID)); } } }