示例#1
0
if (isset($_GET['runbible'])) {
    SendReceive_Logic::queuebible($bible);
    $view->view->successbible = Locale_Translate::_("Will send and receive.");
}
if (isset($_GET['repeatbible'])) {
    $database_config_bible->setRepeatSendReceive($bible, !$database_config_bible->getRepeatSendReceive($bible));
}
$view->view->repeatbible = $database_config_bible->getRepeatSendReceive($bible);
if ($database_config_bible->getRemoteRepositoryUrl($bible) == "") {
    $view->view->errorbible = Locale_Translate::_("Collaboration has not been set up for this Bible");
}
if (isset($_GET['runsync'])) {
    if (SendReceive_Logic::syncqueued()) {
        $view->view->successnotes = Locale_Translate::_("Still sending and receiving from the last time.");
    } else {
        SendReceive_Logic::queuesync(true);
        $view->view->successnotes = Locale_Translate::_("Will send and receive.");
    }
}
$view->view->client = Filter_Client::enabled();
if (isset($_GET['repeatsync'])) {
    $repeatsync = $_GET['repeatsync'];
    if (!is_numeric($repeatsync)) {
        $repeatsync = 0;
    }
    if ($repeatsync < 0) {
        $repeatsync = 0;
    }
    if ($repeatsync > 2) {
        $repeatsync = 2;
    }
示例#2
0
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);
}
示例#3
0
// The order is such that all information generated is as recent as possible.
// More important tasks are done first, and the less important ones at the end.
// This leads to an order as visible in the code below.
// Sending and receiving Bibles to and from the git repository.
// On a production website running on an inexpensive virtual private server
// with 512 Mbyte of memory and a fast network connection,
// sending and receiving two Bibles takes more than 15 minutes when there are many changes.
if (!$client) {
    $sendreceive = $hour == 0 && $minute == 6;
    $repeat = $minute % 5 == 0;
    if ($sendreceive || $repeat) {
        SendReceive_Logic::queueAll($sendreceive);
    }
}
// Client sends/receives Bibles and Consultation.
SendReceive_Logic::queuesync($minute);
// Deal with the changes in the Bible made per user.
// Deal with notifications for the daily changes in the Bibles.
// This takes a few minutes on a production machine with two Bibles and changes in several chapters.
if (!$client) {
    if ($hour == 0 && $minute == 20) {
        Changes_Logic::start();
    }
}
// Comb through the git log and add the changes to the history.
if (!$client) {
    if ($hour == 0 && $minute == 30) {
        $directory = dirname(dirname(__FILE__)) . "/changes";
        Tasks_Logic::queue(Tasks_Logic::PHP, array("{$directory}/git.php"));
        unset($directory);
    }