/** * Unassociates all PeopleAsRead * @return void */ public function UnassociateAllPeopleAsRead() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllPersonAsReadArray on this unsaved Topic.'); } // Get the Database Object for this Class $objDatabase = Topic::GetDatabase(); // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `read_topic_person_assn` WHERE `topic_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
/** * Given a Topic and the number of items in a "page", this will * return the page number that the topic shows up in * when listing all topics for the Topic's forum, assuming * the list of topics is ordered by reverse last_post_date * @param Topic $objTopic the topic to search for * @param integer $intItemsPerPage * @param Zend_Search_Lucene_Search_QueryHit[] $objQueryHitArray a predefined set of topics to search through * @return unknown_type */ public function GetPageNumber(Topic $objTopic, $intItemsPerPage, $objQueryHitArray = null) { if (is_null($objQueryHitArray)) { $objResult = Topic::GetDatabase()->Query('SELECT id FROM topic WHERE topic_link_id=' . $objTopic->TopicLinkId . ' ORDER BY last_post_date DESC'); $intRecordNumber = 0; while ($objRow = $objResult->GetNextRow()) { $intRecordNumber++; if ($objRow->GetColumn('id') == $objTopic->Id) { break; } } } else { $intRecordNumber = 0; foreach ($objQueryHitArray as $objHit) { $intRecordNumber++; if ($objHit->db_id == $objTopic->Id) { break; } } } $intPageNumber = floor($intRecordNumber / $intItemsPerPage); if ($intRecordNumber % $intItemsPerPage) { $intPageNumber++; } return $intPageNumber; }
/** * Searches using the search index for applicable topics, and returns topics as an array * Note that this will return ALL topics for the search. No limit / pagination can be applied. * @param string $strSearchQuery * @return Topic[] */ public static function LoadArrayBySearch($strSearchQuery) { // open the index $objIndex = new Zend_Search_Lucene(__SEARCH_INDEXES__ . '/topics'); $intIdArray = array(); $objHits = $objIndex->find($strSearchQuery); if (!count($objHits)) { return array(); } foreach ($objHits as $objHit) { $intIdArray[] = $objHit->db_id; // note: do we want to do anything with $objHit->score (?) } $objResult = Topic::GetDatabase()->Query('SELECT * FROM topic WHERE id IN(' . implode(',', $intIdArray) . ');'); while ($objRow = $objResult->GetNextRow()) { $objTopic = Topic::InstantiateDbRow($objRow); $objTopicArrayById[$objTopic->Id] = $objTopic; } $objTopicArray = array(); foreach ($objHits as $objHit) { $objTopicArray[] = $objTopicArrayById[intval($objHit->db_id)]; } return $objTopicArray; }
$objWikiPage->CompileHtml(); $objWikiItem->CreateNewVersion('Downloads from Old Qcodo.com Website', $objWikiPage, 'Save', array(), Person::Load(1), null); print "Done.\r\n"; QDataGen::DisplayForEachTaskStart($strTitle = 'Refreshing Topic Stats', Topic::CountAll()); foreach (Topic::LoadAll() as $objTopic) { QDataGen::DisplayForEachTaskNext($strTitle); $objTopic->RefreshStats(); } QDataGen::DisplayForEachTaskEnd($strTitle); QDataGen::DisplayForEachTaskStart($strTitle = 'Refreshing TopicLink Stats', TopicLink::CountAll()); foreach (TopicLink::LoadAll() as $objTopicLink) { QDataGen::DisplayForEachTaskNext($strTitle); $objTopicLink->RefreshStats(); } QDataGen::DisplayForEachTaskEnd($strTitle); $objResult = $objDb->query('SELECT * FROM email_topic_person_assn'); while (QDataGen::DisplayWhileTask('Migrating email_topic_person_assn', $objResult->num_rows)) { $objRow = $objResult->fetch_array(); try { Topic::GetDatabase()->NonQuery('INSERT INTO email_topic_person_assn(topic_id, person_id) VALUES (' . $objRow['topic_id'] . ',' . $objRow['person_id'] . ');'); } catch (QMySqliDatabaseException $objExc) { } } $objResult = $objDb->query('SELECT * FROM read_topic_person_assn'); while (QDataGen::DisplayWhileTask('Migrating read_topic_person_assn', $objResult->num_rows)) { $objRow = $objResult->fetch_array(); try { Topic::GetDatabase()->NonQuery('INSERT INTO read_topic_person_assn(topic_id, person_id) VALUES (' . $objRow['topic_id'] . ',' . $objRow['person_id'] . ');'); } catch (QMySqliDatabaseException $objExc) { } }
/** * Unassociates all PeopleAsRead * @return void */ public function UnassociateAllPeopleAsRead() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAllPersonAsReadArray on this unsaved Topic.'); } // Get the Database Object for this Class $objDatabase = Topic::GetDatabase(); // Journaling (if applicable) if ($objDatabase->JournalingDatabase) { $objResult = $objDatabase->Query('SELECT `person_id` AS associated_id FROM `read_topic_person_assn` WHERE `topic_id` = ' . $objDatabase->SqlVariable($this->intId)); while ($objRow = $objResult->GetNextRow()) { $this->JournalPersonAsReadAssociation($objRow->GetColumn('associated_id'), 'DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `read_topic_person_assn` WHERE `topic_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }