Esempio n. 1
0
 public static function assignees()
 {
     $session_logic = Session_Logic::getInstance();
     $database_users = Database_Users::getInstance();
     $database_bibles = Database_Bibles::getInstance();
     $myuser = $session_logic->currentUser();
     $mylevel = $session_logic->currentLevel();
     // Bibles the user has write access to.
     $mybibles = array();
     $bibles = $database_bibles->getBibles();
     foreach ($bibles as $bible) {
         if (Access_Bible::write($bible, $myuser)) {
             $mybibles[] = $bible;
         }
     }
     // This holds the assignees.
     $assignees = array();
     // Process all users.
     $users = $database_users->getUsers();
     sort($users);
     foreach ($users as $user) {
         // Assignees should have a level less than or equal to $mylevel.
         $level = $database_users->getUserLevel($user);
         if ($level <= $mylevel) {
             // Assignees should have access to $mybibles or no access to any Bible.
             // The admin has all users assigned.
             $userBibles = $database_users->getBibles4User($user);
             $biblesInCommon = array_intersect($userBibles, $mybibles);
             if (!empty($biblesInCommon) || empty($userBibles) || $mylevel >= Filter_Roles::ADMIN_LEVEL) {
                 $assignees[] = $user;
             }
         }
     }
     return $assignees;
 }
Esempio n. 2
0
 public static function getNames()
 {
     $names = array();
     // Take Bibles the user has read access to.
     $bibles = Access_Bible::bibles();
     $names = array_merge($names, $bibles);
     // Take USFM Resources.
     $database_usfmresources = Database_UsfmResources::getInstance();
     $usfm_resources = $database_usfmresources->getResources();
     $names = array_merge($names, $usfm_resources);
     // Take external Resources.
     $database_resources = Database_Resources::getInstance();
     $resources = $database_resources->getNames();
     $names = array_merge($names, $resources);
     $names = array_unique($names);
     sort($names);
     return $names;
 }
Esempio n. 3
0
                $book = $books[0];
            } else {
                $book = 0;
            }
            $ipc_focus->set($book, 1, 1);
        }
    }
}
$view = new Assets_View(__FILE__);
// Active Bible, and check access.
$bible = Access_Bible::clamp($database_config_user->getBible());
$view->view->bible = $bible;
// Store the active Bible in the page's javascript.
$view->view->navigationCode = Navigation_Passage::code($bible);
// Write access?
$write_access = Access_Bible::write($bible);
$view->view->write_access = $write_access;
$chapterLoaded = Locale_Translate::_("Loaded");
$chapterSaving = Locale_Translate::_("Saving...");
$chapterRetrying = Locale_Translate::_("Retrying...");
$write_access = $write_access ? "true" : "false";
$script = <<<EOD
var editorChapterLoaded = '{$chapterLoaded}';
var editorChapterSaving = '{$chapterSaving}';
var editorChapterRetrying = '{$chapterRetrying}';
var editorWriteAccess = {$write_access};
EOD;
$view->view->script = $script;
$class = Filter_CustomCSS::getClass($bible);
$font = $database_config_bible->getTextFont($bible);
$direction = $database_config_bible->getTextDirection($bible);
Esempio n. 4
0
        if (in_array($destination, $bibles)) {
            $error_message = Locale_Translate::_("Cannot copy Bible because the destination Bible already exists.");
        } else {
            ignore_user_abort(true);
            set_time_limit(0);
            // User needs read access to the original.
            if (Access_Bible::read($origin)) {
                $database_bibles->createBible($destination);
                $books = $database_bibles->getBooks($origin);
                foreach ($books as $book) {
                    $chapters = $database_bibles->getChapters($origin, $book);
                    foreach ($chapters as $chapter) {
                        $data = $database_bibles->getChapter($origin, $book, $chapter);
                        Bible_Logic::storeChapter($destination, $book, $chapter, $data);
                    }
                }
                $success_message = Locale_Translate::_("The Bible was copied.");
                // Check / grant access to destination Bible.
                if (!Access_Bible::write($destination)) {
                    $database_users->grantAccess2Bible($session_logic->currentUser(), $destination);
                }
            }
        }
    }
}
@($view->view->success_message = $success_message);
@($view->view->error_message = $error_message);
$bibles = Access_Bible::bibles();
$view->view->bibles = $bibles;
$view->render("manage.php");
Assets_Page::footer();
Esempio n. 5
0
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.
*/
require_once "../bootstrap/bootstrap.php";
page_access_level(Filter_Roles::MANAGER_LEVEL);
Assets_Page::header(Locale_Translate::_("Sentence Structure"));
$view = new Assets_View(__FILE__);
$database_config_user = Database_Config_User::getInstance();
$database_config_bible = Database_Config_Bible::getInstance();
$bible = Access_Bible::clamp($database_config_user->getBible());
if (isset($_POST['capitals'])) {
    $database_config_bible->setSentenceStructureCapitals($bible, $_POST['capitals']);
    $view->view->success = Locale_Translate::_("The capitals were stored");
}
if (isset($_POST['smallletters'])) {
    $database_config_bible->setSentenceStructureSmallLetters($bible, $_POST['smallletters']);
    $view->view->success = Locale_Translate::_("The small letters were stored");
}
if (isset($_POST['endpunctuationmarks'])) {
    $database_config_bible->setSentenceStructureEndPunctuation($bible, $_POST['endpunctuationmarks']);
    $view->view->success = Locale_Translate::_("The punctuation marks at the ends of sentences were stored");
}
if (isset($_POST['middlepunctuationmarks'])) {
    $database_config_bible->setSentenceStructureMiddlePunctuation($bible, $_POST['middlepunctuationmarks']);
    $view->view->success = Locale_Translate::_("The punctuation marks within the sentences were stored");
Esempio n. 6
0
            if (Access_Bible::write($bible)) {
                $dialog_list->add_row($bible, "&target={$bible}");
            }
        }
        $dialog_list->run();
    } else {
        $database_config_user->setTargetXrefBible($target);
    }
}
$source = $database_config_user->getSourceXrefBible();
if (!Access_Bible::read($source)) {
    $source = "";
    $database_config_user->setSourceXrefBible($source);
}
$target = $database_config_user->getTargetXrefBible();
if (!Access_Bible::write($target)) {
    $target = "";
    $database_config_user->setTargetXrefBible($target);
}
if ($source == "") {
    $source = "--";
}
if ($target == "") {
    $target = "--";
}
$view->view->source = $source;
$view->view->target = $target;
$view->view->success = $success;
$view->view->error = $error;
$view->render("index.php");
Assets_Page::footer();
Esempio n. 7
0
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once "../bootstrap/bootstrap.php";
page_access_level(Filter_Roles::MANAGER_LEVEL);
$database_usfmresources = Database_UsfmResources::getInstance();
@($delete = $_GET['delete']);
if (isset($delete)) {
    if (Access_Bible::write($delete)) {
        $database_usfmresources->deleteResource($delete);
    } else {
        Assets_Page::error(Locale_Translate::_("You do not have write access to this resource"));
    }
}
@($convert = $_GET['convert']);
if (isset($convert)) {
    if (Access_Bible::write($convert)) {
        Tasks_Logic::queue(Tasks_Logic::PHP, array(__DIR__ . "/convert2bible.php", $convert));
        Filter_Url::redirect("../journal/index.php");
        die;
    } else {
        Assets_Page::error(Locale_Translate::_("Insufficient privileges"));
    }
}
$header = new Assets_Header(Locale_Translate::_("USFM Resources"));
$header->jQueryUIOn("dialog");
$header->run();
$view = new Assets_View(__FILE__);
$resources = $database_usfmresources->getResources();
$view->view->resources = $resources;
$view->render("manage.php");
Assets_Page::footer();
Esempio n. 8
0
    $database_logs->log("Non existing user {$username}", Filter_Roles::MANAGER_LEVEL);
}
$pass_ok = $password == $database_users->getmd5($username);
if (!$pass_ok) {
    $database_logs->log("Incorrect password {$password} for user {$username}", Filter_Roles::MANAGER_LEVEL);
}
if (!$user_ok || !$pass_ok) {
    // Unauthorized.
    http_response_code(401);
    die;
}
$session_logic->setUsername($username);
$bookname = $database_books->getEnglishFromId($book);
$database_logs->log("Client sent Bible data: {$bible} {$bookname} {$chapter}", Filter_Roles::MANAGER_LEVEL);
// Check whether the user has write-access to the Bible.
if (!Access_Bible::write($bible, $username)) {
    $message = "User {$username} does not have write access to Bible {$bible}";
    $database_logs->log($message, Filter_Roles::MANAGER_LEVEL);
    echo $message;
    die;
}
// Check checksum.
if ($checksum != Checksum_Logic::get($oldusfm . $newusfm)) {
    $message = "The received data is corrupted";
    $database_logs->log($message, Filter_Roles::MANAGER_LEVEL);
    echo $message;
    die;
}
$serverusfm = $database_bibles->getChapter($bible, $book, $chapter);
// Gather data for recording the changes made by the user, for the change notifications.
$old_id = $database_bibles->getChapterId($bible, $book, $chapter);
Esempio n. 9
0
$verse = $ipc_focus->getVerse();
$passage_selector = $database_config_user->getConsultationNotesPassageSelector();
$edit_selector = $database_config_user->getConsultationNotesEditSelector();
$non_edit_selector = $database_config_user->getConsultationNotesNonEditSelector();
$status_selector = $database_config_user->getConsultationNotesStatusSelector();
$bible_selector = $database_config_user->getConsultationNotesBibleSelector();
$assignment_selector = $database_config_user->getConsultationNotesAssignmentSelector();
$subscription_selector = $database_config_user->getConsultationNotesSubscriptionSelector();
$severity_selector = $database_config_user->getConsultationNotesSeveritySelector();
$text_selector = $database_config_user->getConsultationNotesTextSelector();
$search_text = $database_config_user->getConsultationNotesSearchText();
$passage_inclusion_selector = $database_config_user->getConsultationNotesPassageInclusionSelector();
$text_inclusion_selector = $database_config_user->getConsultationNotesTextInclusionSelector();
$view = new Assets_View(__FILE__);
// The Bibles the current user has access to.
$bibles = Access_Bible::bibles($session_logic->currentUser());
// The admin disables notes selection on Bibles, so the admin sees all notes, even notes referring to non-existing Bibles.
if ($session_logic->currentLevel() == Filter_Roles::ADMIN_LEVEL) {
    $bibles = NULL;
}
$identifiers = $database_notes->selectNotes($bibles, $book, $chapter, $verse, $passage_selector, $edit_selector, $non_edit_selector, $status_selector, $bible_selector, $assignment_selector, $subscription_selector, $severity_selector, $text_selector, $search_text, NULL);
$view->view->identifiers = $identifiers;
$count = count($identifiers);
$view->view->count = $count;
$summaries = array();
$verse_texts = array();
$contents = array();
foreach ($identifiers as $identifier) {
    $summary = $database_notes->getSummary($identifier);
    $passages = $database_notes->getPassages($identifier);
    $verses = Filter_Books::passagesDisplayInline($passages);
Esempio n. 10
0
    }
}
// Identifier for this $bible.
$bibleID = $database_bibles->getID($bible);
// Create an email with the checking results for this $bible.
$emailBody = array();
$hits = $database_check->getHits();
foreach ($hits as $hit) {
    if ($hit['bible'] == $bibleID) {
        $passage = Filter_Books::passagesDisplayInline(array(array($hit['book'], $hit['chapter'], $hit['verse'])));
        $data = Filter_Html::sanitize($hit['data']);
        $result = "<p>{$passage} {$data}</p>";
        $emailBody[] = $result;
    }
}
// Send email to users with write access to the Bible and a subscription to the notification.
if (count($emailBody) > 0) {
    $subject = Locale_Translate::_("Bible Checks") . " " . $bible;
    $emailBody = implode("\n", $emailBody);
    $users = $database_users->getUsers();
    foreach ($users as $user) {
        if ($database_config_user->getUserBibleChecksNotification($user)) {
            if (Access_Bible::write($bible, $user)) {
                if (!Filter_Client::enabled()) {
                    $database_mail->send($user, $subject, $emailBody);
                }
            }
        }
    }
}
$database_logs->log("Check {$bible}: Complete", Filter_Roles::TRANSLATOR_LEVEL);
Esempio n. 11
0
 public function response()
 {
     // The databases to access.
     $database_config_user = Database_Config_User::getInstance();
     $database_volatile = Database_Volatile::getInstance();
     $database_bibles = Database_Bibles::getInstance();
     // The resources to display in the Consistency tool.
     $resources = array();
     $resources[] = Access_Bible::clamp($database_config_user->getBible());
     $resources = array_merge($resources, $database_config_user->getConsistencyResources());
     // The passages entered in the Consistency tool.
     $passages = $database_volatile->getValue($this->id, "passages");
     $passages = trim($passages);
     $passages = Filter_String::string2array($passages);
     // The translations from the Consistency tool.
     $translations = $database_volatile->getValue($this->id, "translations");
     $translations = trim($translations);
     $translations = Filter_String::string2array($translations);
     // Contains the response to display.
     $response = array();
     // Go through the passages interpreting them.
     $previousPassage = array(1, 1, 1);
     foreach ($passages as $line) {
         $line = trim($line);
         if ($line == "") {
             continue;
         }
         $range_sequence = Filter_Books::handleSequencesRanges($line);
         foreach ($range_sequence as $line) {
             $passage = Filter_Books::interpretPassage($previousPassage, $line);
             if ($passage[0] != 0) {
                 $book = $passage[0];
                 $chapter = $passage[1];
                 $verse = $passage[2];
                 $line = Filter_Books::linkForOpeningEditorAt($book, $chapter, $verse);
                 $line .= " ";
                 // Check whether the chapter identifier has changed for this reference.
                 // If so, set a flag so the data can be re-assembled for this verse.
                 // If there was no change, then the data can be fetched from the volatile database.
                 $redoPassage = false;
                 $passageKey = "{$book}.{$chapter}.{$verse}";
                 $currentChapterId = $database_bibles->getChapterId($resources[0], $book, $chapter);
                 $storedChapterId = $database_volatile->getValue($this->id, "{$passageKey}.id");
                 if ($currentChapterId != $storedChapterId) {
                     $database_volatile->setValue($this->id, "{$passageKey}.id", $currentChapterId);
                     $redoPassage = true;
                 }
                 // Go through each resource.
                 foreach ($resources as $resource) {
                     // Produce new verse text if the passage is to be redone, or else fetch the existing text.
                     if ($redoPassage) {
                         $text = $this->verseText($resource, $book, $chapter, $verse);
                         if ($translations != "") {
                             $text = Filter_Markup::words($translations, $text);
                         }
                         $database_volatile->setValue($this->id, "{$passageKey}.{$resource}", $text);
                     } else {
                         $text = $database_volatile->getValue($this->id, "{$passageKey}.{$resource}");
                     }
                     // Formatting.
                     if (count($resources) > 1) {
                         $line .= "<br>";
                     }
                     $line .= $text;
                 }
                 $response[] = $line;
                 $previousPassage = $passage;
             } else {
                 $response[] = '<span class="error">' . Locale_Translate::_("Unknown passage") . " " . $line . '</span>';
             }
         }
     }
     $output = "";
     foreach ($response as $line) {
         $output .= "<div>{$line}</div>\n";
     }
     return $output;
 }
Esempio n. 12
0
 // The files get stored at http://site.org/bibledit-web/changes/<Bible>/<date>
 $basePath = "revisions/" . $bible . "/" . strftime("%Y-%m-%d_%H:%M:%S");
 $directory = realpath("..") . "/{$basePath}";
 mkdir($directory, 0777, true);
 // Produce the USFM and html files.
 Filter_Diff::produceVerseLevel($bible, $directory);
 // Create online page with changed verses.
 $versesoutputfile = "{$directory}/changed_verses.html";
 Filter_Diff::runDiffFile("{$directory}/verses_old.txt", "{$directory}/verses_new.txt", $versesoutputfile);
 // Email users.
 $subject = Locale_Translate::_("Recent changes") . " " . $bible;
 $emailBody = file_get_contents($versesoutputfile);
 $users = $database_users->getUsers();
 foreach ($users as $user) {
     if ($database_config_user->getUserBibleChangesNotification($user)) {
         if (Access_Bible::read($bible, $user)) {
             if (!Filter_Client::enabled()) {
                 $database_mail->send($user, $subject, $emailBody);
             }
         }
     }
 }
 // Generate the online change notifications.
 $books = $database_modifications->getTeamDiffBooks($bible);
 foreach ($books as $book) {
     $chapters = $database_modifications->getTeamDiffChapters($bible, $book);
     foreach ($chapters as $chapter) {
         $database_logs->log("{$bible} " . Filter_Books::passageDisplay($book, $chapter, "") . " Listing changes", Filter_Roles::TRANSLATOR_LEVEL);
         $old_chapter_usfm = $database_modifications->getTeamDiff($bible, $book, $chapter);
         $new_chapter_usfm = $database_bibles->getChapter($bible, $book, $chapter);
         $old_verse_numbers = Filter_Usfm::getVerseNumbers($old_chapter_usfm);
Esempio n. 13
0
require_once "../bootstrap/bootstrap.php";
page_access_level(Filter_Roles::TRANSLATOR_LEVEL);
$database_check = Database_Check::getInstance();
$database_bibles = Database_Bibles::getInstance();
Assets_Page::header(Locale_Translate::_("Suppressed check results"));
$view = new Assets_View(__FILE__);
@($release = $_GET['release']);
if (isset($release)) {
    $database_check->release($release);
    $view->view->success = Locale_Translate::_("The check result will no longer be suppressed.");
}
// Get the Bibles the user has write-access to.
$bibleIDs = array();
$bibles = $database_bibles->getBibles();
foreach ($bibles as $bible) {
    if (Access_Bible::write($bible)) {
        $id = $database_bibles->getID($bible);
        $bibleIDs[] = $id;
    }
}
$ids = array();
$data = array();
$suppressions = $database_check->getSuppressions();
foreach ($suppressions as $suppression) {
    $bibleID = $suppression['bible'];
    // Only display entries for Bibles the user has write access to.
    if (in_array($bibleID, $bibleIDs)) {
        $ids[] = $suppression['rowid'];
        $bible = Filter_Html::sanitize($database_bibles->getName($bibleID));
        $passage = Filter_Books::passagesDisplayInline(array(array($suppression['book'], $suppression['chapter'], $suppression['verse'])));
        $result = Filter_Html::sanitize($suppression['data']);
Esempio n. 14
0
    $checksum = $database_notes->getMultipleChecksum($identifiers);
    $response['t'] = count($identifiers);
    $response['c'] = $checksum;
    die_if_databases_unhealthy_or_busy();
    echo serialize($response);
} else {
    if ($action == "identifiers") {
        $user = Filter_Hex::hex2bin($_POST['u']);
        if (!$database_users->usernameExists($user)) {
            die;
        }
        $md5 = $_POST['p'];
        if ($md5 != $database_users->getmd5($user)) {
            die;
        }
        $bibles = Access_Bible::bibles($user);
        $lowId = $_POST['l'];
        $highId = $_POST['h'];
        $identifiers = $database_notes->getNotesInRangeForBibles($lowId, $highId, $bibles);
        $checksums = array();
        foreach ($identifiers as $identifier) {
            $checksum = $database_notes->getChecksum($identifier);
            $checksums[] = $checksum;
        }
        $response['i'] = $identifiers;
        $response['c'] = $checksums;
        die_if_databases_unhealthy_or_busy();
        echo serialize($response);
    } else {
        if ($action == "fetch") {
            $identifier = $_POST['i'];
Esempio n. 15
0
        http_response_code(401);
        die;
    }
    $bibles = Access_Bible::bibles($username);
    $server_checksum = Checksum_Logic::getBibles($bibles);
    echo $server_checksum;
} else {
    if ($action == "bibles") {
        // The server reads the credentials from the client's user,
        // and responds with a list of Bibles this user has access to.
        if ($password != $database_users->getmd5($username)) {
            // Unauthorized.
            http_response_code(401);
            die;
        }
        $bibles = Access_Bible::bibles($username);
        $bibles = implode("\n", $bibles);
        $checksum = Checksum_Logic::get($bibles);
        echo "{$checksum}\n{$bibles}";
    } else {
        if ($action == "bible") {
            // The server responds with the checksum for the whole Bible.
            $server_checksum = Checksum_Logic::getBible($bible);
            echo $server_checksum;
        } else {
            if ($action == "books") {
                // The server responds with a checksum and then the list of books in the Bible.
                $server_books = $database_bibles->getBooks($bible);
                $server_books = implode("\n", $server_books);
                $checksum = Checksum_Logic::get($server_books);
                echo "{$checksum}\n{$server_books}";
Esempio n. 16
0
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";
page_access_level(Filter_Roles::TRANSLATOR_LEVEL);
$header = new Assets_Header(Locale_Translate::_("Order"));
$header->jQueryUIOn("sortable");
$header->run();
$view = new Assets_View(__FILE__);
$database_config_bible = Database_Config_Bible::getInstance();
$database_books = Database_Books::getInstance();
$database_bibles = Database_Bibles::getInstance();
$bible = Access_Bible::clamp($_GET['bible']);
$view->view->bible = Filter_Html::sanitize($bible);
@($reset = $_GET["reset"]);
if (isset($reset)) {
    $database_config_bible->setBookOrder($bible, "");
}
@($order = $_POST['order']);
if (isset($order)) {
    $order = explode(",", $order);
    $ids = array();
    foreach ($order as $english) {
        $id = $database_books->getIdFromEnglish($english);
        $ids[] = $id;
    }
    $order = implode(" ", $ids);
    $database_config_bible->setBookOrder($bible, $order);
Esempio n. 17
0
 public function run()
 {
     $this->view->view->include_jquery_ui = $this->includeJQueryUI;
     $this->view->view->include_jquery_ui_subset = $this->JQueryUISubset;
     $this->view->view->head_lines = $this->headLines;
     $this->view->view->display_topbar = $this->displayTopbar();
     if ($this->view->view->display_topbar) {
         $menu_main = new Menu_Main();
         $this->view->view->mainmenu = $menu_main->create();
         $menu_user = new Menu_User();
         $this->view->view->usermenu = $menu_user->create();
     }
     $this->view->view->display_navigator = $this->displayNavigator;
     if ($this->view->view->display_navigator) {
         $database_config_user = Database_Config_User::getInstance();
         $bible = Access_Bible::clamp($database_config_user->getBible());
         $this->view->view->navigationHtml = Navigation_Passage::getContainer();
         $this->view->view->navigationCode = Navigation_Passage::code($bible, true);
     }
     $this->view->view->included_stylesheet = $this->includedStylesheet;
     $this->view->view->included_editor_stylesheet = $this->includedEditorStylesheet;
     $this->view->render("xhtml_start.php");
     $this->view->render("header.php");
 }