public function rebuildIndex(XenForo_Search_Indexer $indexer, $lastId, $batchSize) { if (!Tinhte_XenTag_Option::xfrmFound()) { // XFRM is not installed/enabled // do not rebuild index return false; } $ids = $this->_getResourceModel()->getResourceIdsInRange($lastId, $batchSize); if (!$ids) { return false; } $this->quickIndex($indexer, $ids); return max($ids); }
protected function _postSaveAfterTransaction() { $response = parent::_postSaveAfterTransaction(); if ($this->get('resource_state') == 'visible' and $this->get('description_update_id') > 0) { $contentData = array_merge(array('content_type' => 'resource_update', 'content_id' => $this->get('description_update_id')), $this->getMergedData(), $this->getDescriptionDw()->getMergedData()); if (Tinhte_XenTag_Option::xfrmFound() >= 1010000) { // XenForo Resource Manager 1.1 introduces category permission $contentPermissionConfig = array('content_type' => 'resource_category', 'content_id' => $this->get('resource_category_id'), 'permissions' => array('view')); } else { $contentPermissionConfig = array(); } Tinhte_XenTag_Integration::sendNotificationToWatchUsersOnTagged(Tinhte_XenTag_Constants::CONTENT_TYPE_RESOURCE, $this->get('resource_id'), $contentData, $this, $contentPermissionConfig); } return $response; }
protected function _deleteTaggedContentsResources(array $tag, array $taggeds) { if (!Tinhte_XenTag_Option::xfrmFound()) { // XFRM is not installed/enabled return false; } $tagModel = $this->getModelFromCache('Tinhte_XenTag_Model_Tag'); $resourceModel = $this->getModelFromCache('XenResource_Model_Resource'); $resourceIds = array(); foreach ($taggeds as $tagged) { if ($tagged['content_type'] == Tinhte_XenTag_Constants::CONTENT_TYPE_RESOURCE) { $resourceIds[] = $tagged['content_id']; } } $resources = $resourceModel->getResourcesByIds($resourceIds); foreach ($resources as $resource) { $tagsOrTexts = Tinhte_XenTag_Helper::unserialize($resource[Tinhte_XenTag_Constants::FIELD_RESOURCE_TAGS]); $tagTexts = Tinhte_XenTag_Helper::getTextsFromTagsOrTexts($tagsOrTexts); $filteredTagTexts = array(); foreach ($tagTexts as $tagText) { if ($tagModel->isTagIdenticalWithText($tag, $tagText)) { // drop this tag } else { $filteredTagTexts[] = $tagText; } } if (count($tagTexts) != count($filteredTagTexts)) { /* @var $dw XenResource_DataWriter_Resource */ $dw = XenForo_DataWriter::create('XenResource_DataWriter_Resource'); $dw->setExistingData($resource, true); // save queries $dw->Tinhte_XenTag_setTags($filteredTagTexts); $dw->setExtraData(Tinhte_XenTag_XenResource_DataWriter_Resource::DATA_SKIP_UPDATE_TAGS_IN_DATABASE, true); $dw->save(); } } }