}
 foreach (NarroSuggestion::LoadArrayByTextId($objDuplicateText->TextId) as $objSuggestion) {
     error_log('Moving text from suggestion');
     $arrDuplicateSuggestions = NarroSuggestion::QueryArray(QQ::AndCondition(QQ::NotEqual(QQN::NarroSuggestion()->SuggestionId, $objSuggestion->SuggestionId), QQ::Equal(QQN::NarroSuggestion()->SuggestionValue, $objSuggestion->SuggestionValue), QQ::Equal(QQN::NarroSuggestion()->TextId, $objText->TextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, $objSuggestion->LanguageId)));
     if (count($arrDuplicateSuggestions)) {
         error_log(sprintf('Found duplicates for "%s": %d', $objSuggestion->SuggestionValue, count($arrDuplicateSuggestions)));
         foreach ($arrDuplicateSuggestions as $objDuplicateSuggestion) {
             if ($objSuggestion->SuggestionValue !== $objDuplicateSuggestion->SuggestionValue) {
                 continue;
             }
             foreach (NarroSuggestionComment::LoadArrayBySuggestionId($objDuplicateSuggestion->SuggestionId) as $objSuggestionComment) {
                 error_log('Moving suggestion comment');
                 $objSuggestionComment->SuggestionId = $objSuggestion->SuggestionId;
                 $objSuggestionComment->Save();
             }
             foreach (NarroSuggestionVote::LoadArrayBySuggestionId($objDuplicateSuggestion->SuggestionId) as $objSuggestionVote) {
                 error_log('Moving suggestion vote');
                 $objSuggestionVote->SuggestionId = $objSuggestion->SuggestionId;
                 $objSuggestionVote->Save();
             }
             foreach (NarroContextInfo::LoadArrayByValidSuggestionId($objDuplicateSuggestion->SuggestionId) as $objApprovedSuggestion) {
                 error_log('Moving approved suggestion');
                 $objApprovedSuggestion->ValidSuggestionId = $objSuggestion->SuggestionId;
                 $objApprovedSuggestion->Save();
             }
             error_log(sprintf('Deleting suggestion %d %d "%s"', $objDuplicateSuggestion->SuggestionId, $objDuplicateSuggestion->LanguageId, $objDuplicateSuggestion->SuggestionValue));
             $objDuplicateSuggestion->Delete();
             $intDuplicateSuggestionsDeleted++;
         }
     }
     $objSuggestion->TextId = $objText->TextId;
Пример #2
0
 /**
  * Gets all associated NarroSuggestionVotesAsSuggestion as an array of NarroSuggestionVote objects
  * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  * @return NarroSuggestionVote[]
  */
 public function GetNarroSuggestionVoteAsSuggestionArray($objOptionalClauses = null)
 {
     if (is_null($this->intSuggestionId)) {
         return array();
     }
     try {
         return NarroSuggestionVote::LoadArrayBySuggestionId($this->intSuggestionId, $objOptionalClauses);
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }