/** * Removes object $contentObject from the search database. * * @param eZContentObject $contentObject the content object to remove * @param bool $commit Whether to commit after removing the object * @return bool True if the operation succeed. */ function removeObject( $contentObject, $commit = null ) { /* * @since eZFind 2.2: allow delayed commits if explicitely set as configuration setting and * the parameter $commit it is not set * Default behaviour is as before */ if ( !isset( $commit ) && ( $this->FindINI->variable( 'IndexOptions', 'DisableDeleteCommits' ) === 'true' ) ) { $commit = false; } elseif ( !isset( $commit ) ) { $commit = true; } // 1: remove the assciated "elevate" configuration eZFindElevateConfiguration::purge( '', $contentObject->attribute( 'id' ) ); //eZFindElevateConfiguration::synchronizeWithSolr(); $this->pushElevateConfiguration(); // @todo Remove if accepted. Optimize is bad on runtime. $optimize = false; if ( $commit && ( $this->FindINI->variable( 'IndexOptions', 'OptimizeOnCommit' ) === 'enabled' ) ) { $optimize = true; } // 2: create a delete array with all the required infos, groupable by language $languages = eZContentLanguage::fetchList(); foreach ( $languages as $language ) { $languageCode = $language->attribute( 'locale' ); $docs[$languageCode] = $this->guid( $contentObject, $languageCode ); } if ( $this->UseMultiLanguageCores === true ) { foreach ( $docs as $languageCode => $doc ) { $this->SolrLanguageShards[$languageCode]->deleteDocs( array( $doc ), false, $commit, $optimize ); } } else { return $this->Solr->deleteDocs( $docs, false, $commit, $optimize ); } }
// Identify which object is concerned. $object = false; if ($Params['ObjectID'] !== false and is_numeric($Params['ObjectID'])) { $object = eZContentObject::fetch($Params['ObjectID']); } if (!$object) { //error. Redirect to the elevate configuration landing page. $module->redirectTo('/ezfind/elevate'); } elseif ($object and $http->hasPostVariable('ezfind-removeelevation-cancel')) { // Redirect to the detail elevate configuration page for this object : $module->redirectTo('/ezfind/elevation_detail/' . $object->attribute('id')); } elseif ($object and $http->hasPostVariable('ezfind-removeelevation-do')) { $tpl->setVariable('elevatedObject', $object); $searchQuery = htmlspecialchars($http->postVariable("ezfind-removeelevation-searchquery"), ENT_QUOTES); $languageCode = htmlspecialchars($http->postVariable("ezfind-removeelevation-languagecode"), ENT_QUOTES); eZFindElevateConfiguration::purge($searchQuery, $object->attribute('id'), $languageCode); $feedback['removal_back_link'] = '/ezfind/elevate/'; $feedback['confirm_remove'] = array('contentobject_id' => $object->attribute('id'), 'search_query' => $searchQuery, 'language_code' => $languageCode); } else { $thisUrl .= '/' . $object->attribute('id'); $tpl->setVariable('elevatedObject', $object); // check search query $searchQuery = false; if ($Params['SearchQuery'] !== false and $Params['SearchQuery'] != '') { $searchQuery = $Params['SearchQuery']; $thisUrl .= '/' . $searchQuery; } else { // error, redirect to the detail elevate configuration page for this object : $module->redirectTo('/ezfind/elevation_detail/' . $object->attribute('id')); } if ($Params['LanguageCode'] !== false and $Params['LanguageCode'] != '') {