Example #1
0
 public static function queuesync($control)
 {
     // Send / receive only works in Client mode.
     if (!Filter_Client::enabled()) {
         return;
     }
     // Deal with a numerical minute to find out whether it's time to automatically sync.
     if (is_numeric($control)) {
         $database_config_general = Database_Config_General::getInstance();
         $repeat = $database_config_general->getRepeatSendReceive();
         // Sync every hour.
         if ($repeat == 1) {
             $control = $control % 60;
             if ($control == 0) {
                 $control = true;
             }
         }
         // Sync every five minutes.
         if ($repeat == 2) {
             $control = $control % 5;
             if ($control == 0) {
                 $control = true;
             }
         }
     }
     // Send and receive: It is time now, or it is manual.
     if ($control === true) {
         // Only queue the sync tasks if none are running at the moment.
         if (SendReceive_Logic::syncqueued()) {
             $database_logs = Database_Logs::getInstance();
             $database_logs->log("Not scheduling sync tasks, because the previous ones have not yet finished");
         } else {
             Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/sendnotes.php"));
             Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/sendbibles.php"));
             Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/sendsettings.php"));
             Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/externalresources.php"));
             Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/usfmresources.php"));
         }
     }
 }
Example #2
0
}
$bible = Access_Bible::clamp($database_config_user->getBible());
$view->view->bible = $bible;
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;
    }