public function testAll() { $database_history = Database_History::getInstance(); $author = "test"; $bible = "phpunit"; $book = 1; $chapter = 2; $verse = 3; $start = 0; // Start with an empty history. $count = $database_history->count($author, array($bible), $book, $chapter, $verse); $this->assertEquals(0, $count); $count = $database_history->count(NULL, array(), NULL, NULL, NULL); $this->assertEquals(0, $count); $data = $database_history->get($author, array($bible), $book, $chapter, $verse, $start); $this->assertEmpty($data); $authors = $database_history->authors(array($bible)); $this->assertEmpty($authors); // Record some data. $database_history->record(time(), $author, $bible, $book, $chapter, $verse, "old1", "mod1", "new1"); $database_history->record(time(), $author, $bible, $book, $chapter, $verse, "old2", "mod2", "new2"); // Check the data. $count = $database_history->count($author, array($bible), $book, $chapter, $verse); $this->assertEquals(2, $count); $count = $database_history->count(NULL, array(), NULL, NULL, NULL); $this->assertEquals(2, $count); $data = $database_history->get($author, array($bible), $book, $chapter, $verse, $start); $this->assertEquals(2, count($data)); $this->assertEquals("test", $data[0]['author']); $this->assertEquals("new2", $data[1]['newtext']); }
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ include "utils.php"; ob_start(); require_once "../database/sqlite.php"; require_once "../database/history.php"; $database_history = Database_History::getInstance(); $database_history->create(); $okay = !ob_get_flush(); display_header($okay); if ($okay) { display_okay(); display_paragraph("History database okay."); } else { display_paragraph("Errors creating or upgrading the history database"); open_paragraph(); display_link("history1.php", "Retry"); close_paragraph(); } display_footer();
function processIdentifiers($user, $bible, $book, $chapter, $oldId, $newId, &$email) { if ($oldId != 0) { $database_modifications = Database_Modifications::getInstance(); $database_config_user = Database_Config_User::getInstance(); $database_config_bible = Database_Config_Bible::getInstance(); $database_bibles = Database_Bibles::getInstance(); $database_history = Database_History::getInstance(); $stylesheet = $database_config_bible->getExportStylesheet($bible); $old_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $oldId); $old_chapter_usfm = $old_chapter_usfm['oldtext']; $new_chapter_usfm = $database_modifications->getUserChapter($user, $bible, $book, $chapter, $newId); $new_chapter_usfm = $new_chapter_usfm['newtext']; $timestamp = $database_modifications->getUserTimestamp($user, $bible, $book, $chapter, $newId); $old_verse_numbers = Filter_Usfm::getVerseNumbers($old_chapter_usfm); $new_verse_numbers = Filter_Usfm::getVerseNumbers($new_chapter_usfm); $verses = array_merge($old_verse_numbers, $new_verse_numbers); $verses = array_unique($verses); sort($verses, SORT_NUMERIC); foreach ($verses as $verse) { $old_verse_usfm = Filter_Usfm::getVerseText($old_chapter_usfm, $verse); $new_verse_usfm = Filter_Usfm::getVerseText($new_chapter_usfm, $verse); if ($old_verse_usfm != $new_verse_usfm) { $filter_text_old = new Filter_Text($bible); $filter_text_new = new Filter_Text($bible); $filter_text_old->html_text_standard = new Html_Text(Locale_Translate::_("Bible")); $filter_text_new->html_text_standard = new Html_Text(Locale_Translate::_("Bible")); $filter_text_old->text_text = new Text_Text(); $filter_text_new->text_text = new Text_Text(); $filter_text_old->addUsfmCode($old_verse_usfm); $filter_text_new->addUsfmCode($new_verse_usfm); $filter_text_old->run($stylesheet); $filter_text_new->run($stylesheet); $old_html = $filter_text_old->html_text_standard->getInnerHtml(); $new_html = $filter_text_new->html_text_standard->getInnerHtml(); $old_text = $filter_text_old->text_text->get(); $new_text = $filter_text_new->text_text->get(); if ($old_text != $new_text) { $modification = Filter_Diff::diff($old_text, $new_text); $email .= "<div>"; $email .= Filter_Books::passageDisplay($book, $chapter, $verse); $email .= " "; $email .= $modification; $email .= "</div>"; if ($database_config_user->getUserUserChangesNotificationsOnline($user)) { $changeNotificationUsers = array($user); $database_modifications->recordNotification($changeNotificationUsers, "☺", $bible, $book, $chapter, $verse, $old_html, $modification, $new_html); } $database_history->record($timestamp, $user, $bible, $book, $chapter, $verse, $old_html, $modification, $new_html); } } } } }