public static function getInstance() { if (empty(self::$instance)) { self::$instance = new Database_BibleActions(); } return self::$instance; }
public static function deleteBible($bible) { $database_bibles = Database_Bibles::getInstance(); $database_modifications = Database_Modifications::getInstance(); $database_bibleactions = Database_BibleActions::getInstance(); // Record data of the Bible to be deleted prior to deletion. if (Filter_Client::enabled()) { // Client stores Bible actions. $books = $database_bibles->getBooks($bible); foreach ($books as $book) { $chapters = $database_bibles->getChapters($bible, $book); foreach ($chapters as $chapter) { $usfm = $database_bibles->getChapter($bible, $book, $chapter); $database_bibleactions->record($bible, $book, $chapter, $usfm); } } } else { // Server stores diff data. $database_modifications->storeTeamDiffBible($bible); } // Delete the Bible from the database. $database_bibles->deleteBible($bible); }
public function testBibleActionsOne() { $database_bibleactions = Database_BibleActions::getInstance(); $database_bibleactions->optimize(); $bibles = $database_bibleactions->getBibles(); $this->assertEquals(array(), $bibles); $database_bibleactions->record("phpunit1", 1, 2, "data112"); $database_bibleactions->record("phpunit1", 1, 3, "data113"); $database_bibleactions->record("phpunit1", 2, 4, "data124"); $database_bibleactions->record("phpunit2", 5, 6, "data256"); $database_bibleactions->record("phpunit2", 5, 6, "data256: Not to be stored"); $bibles = $database_bibleactions->getBibles(); $this->assertEquals(array("phpunit1", "phpunit2"), $bibles); $books = $database_bibleactions->getBooks("phpunit1"); $this->assertEquals(array(1, 2), $books); $chapters = $database_bibleactions->getChapters("phpunit1", 1); $this->assertEquals(array(2, 3), $chapters); $chapters = $database_bibleactions->getChapters("phpunit1", 2); $this->assertEquals(array(4), $chapters); $database_bibleactions->delete("phpunit1", 2, 3); $chapters = $database_bibleactions->getChapters("phpunit1", 2); $this->assertEquals(array(4), $chapters); $database_bibleactions->delete("phpunit1", 2, 4); $chapters = $database_bibleactions->getChapters("phpunit1", 2); $this->assertEquals(array(), $chapters); $usfm = $database_bibleactions->getUsfm("phpunit2", 5, 5); $this->assertFalse($usfm); $usfm = $database_bibleactions->getUsfm("phpunit2", 5, 6); $this->assertEquals("data256", $usfm); }
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. */ require_once "../bootstrap/bootstrap.php"; // Security: The script runs from the cli SAPI only. Filter_Cli::assert(); $database_logs = Database_Logs::getInstance(); $database_config_bible = Database_Config_Bible::getInstance(); $database_config_general = Database_Config_General::getInstance(); $database_bibles = Database_Bibles::getInstance(); $database_bibleactions = Database_BibleActions::getInstance(); $database_users = Database_Users::getInstance(); $database_books = Database_Books::getInstance(); $database_logs->log(Locale_Translate::_("Sending and receiving Bibles"), Filter_Roles::TRANSLATOR_LEVEL); $response = Filter_Client::setup(); if ($response === false || $response < Filter_Roles::GUEST_LEVEL || $response > Filter_Roles::ADMIN_LEVEL) { $database_logs->log(Locale_Translate::_("Failure initializing sending and receiving Bibles"), Filter_Roles::TRANSLATOR_LEVEL); die; } $address = $database_config_general->getServerAddress(); $users = $database_users->getUsers(); $user = $users[0]; $hash = $database_users->getmd5($user); $communication_errors = false; // Go through the Bibles / books / chapters that have actions recorded for them. $bibles = $database_bibleactions->getBibles();
function enable_client($username, $password, $level) { // Enable client mode upon a successful connection. Filter_Client::set(true); // Remove all users from the database, and add the current one. remove_all_users(); $database_users = Database_Users::getInstance(); $database_users->addNewUser($username, $password, $level, ""); // Clear all pending note actions and Bible actions and settings updates. $database_noteactions = Database_NoteActions::getInstance(); $database_bibleactions = Database_BibleActions::getInstance(); $database_config_user = Database_Config_User::getInstance(); $session_logic = Session_Logic::getInstance(); $database_noteactions->clear(); $database_noteactions->create(); $database_bibleactions->clear(); $database_bibleactions->create(); $session_logic->setUsername($username); $database_config_user->setUpdatedSettings(array()); // Set it repeats sync every so often. $database_config_general = Database_Config_General::getInstance(); $database_config_general->setRepeatSendReceive(2); // Schedule a sync operation straight-away. SendReceive_Logic::queuesync(true); }