Ejemplo n.º 1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Session_Logic();
     }
     return self::$instance;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 protected function tearDown()
 {
     $database_ipc = Database_Ipc::getInstance();
     $database_ipc->trim();
     $session_logic = Session_Logic::getInstance();
     $session_logic->setUsername("");
 }
Ejemplo n.º 4
0
 public static function check_user_access($url)
 {
     // Get the access level of the user.
     $session_logic = Session_Logic::getInstance();
     $user_level = $session_logic->currentLevel();
     // Check the required access level for the URL.
     // Do not check on e.g. "Filter_Roles::MEMBER_LEVEL" only,
     // but check on the fuller string, as the smaller string may occur
     // elsewhere in a script and so give the wrong access level for the script.
     @($contents = file_get_contents("../{$url}.php"));
     $menu_level = Filter_Roles::MEMBER_LEVEL;
     if (strpos($contents, "page_access_level (Filter_Roles::GUEST_LEVEL)") !== false) {
         $menu_level = Filter_Roles::GUEST_LEVEL;
     }
     if (strpos($contents, "page_access_level (Filter_Roles::MEMBER_LEVEL)") !== false) {
         $menu_level = Filter_Roles::MEMBER_LEVEL;
     }
     if (strpos($contents, "page_access_level (Filter_Roles::CONSULTANT_LEVEL)") !== false) {
         $menu_level = Filter_Roles::CONSULTANT_LEVEL;
     }
     if (strpos($contents, "page_access_level (Filter_Roles::TRANSLATOR_LEVEL)") !== false) {
         $menu_level = Filter_Roles::TRANSLATOR_LEVEL;
     }
     if (strpos($contents, "page_access_level (Filter_Roles::MANAGER_LEVEL)") !== false) {
         $menu_level = Filter_Roles::MANAGER_LEVEL;
     }
     if (strpos($contents, "page_access_level (Filter_Roles::ADMIN_LEVEL)") !== false) {
         $menu_level = Filter_Roles::ADMIN_LEVEL;
     }
     // Result: true: user has access; false: user has no access.
     if ($menu_level > $user_level) {
         return false;
     }
     return true;
 }
Ejemplo n.º 5
0
 public function render($script)
 {
     $session_logic = Session_Logic::getInstance();
     if ($session_logic->loggedIn()) {
         $this->view->user = $session_logic->currentUser();
         $this->view->level = $session_logic->currentLevel(true);
     }
     echo $this->view->render($script);
 }
Ejemplo n.º 6
0
 private function mainmenu()
 {
     // This is the main menu.
     // It will be visible in the top bar.
     // The last element in the array is the submenu to display on expansion.
     $session_logic = Session_Logic::getInstance();
     $username = $session_logic->currentUser();
     $menu = array(array("", $username, $this->usermenu()));
     return $menu;
 }
Ejemplo n.º 7
0
 public function testList()
 {
     $session_logic = Session_Logic::getInstance();
     $session_logic->setUsername("phpunit3");
     $database_config_user = Database_Config_User::getInstance();
     $values = $database_config_user->getList("test2");
     $this->assertEquals(array(), $values);
     $database_config_user->setList("test", array(1, 2, 3, "ah"));
     $values = $database_config_user->getList("test");
     $this->assertEquals(array(1, 2, 3, "ah"), $values);
 }
Ejemplo n.º 8
0
 public function testNormalPostpone()
 {
     $database_mail = Database_Mail::getInstance();
     $session_logic = Session_Logic::getInstance();
     $session_logic->setUsername("phpunit");
     $database_mail->send("phpunit", "subject", "body");
     $mails = $database_mail->getMailsToSend();
     $this->assertEquals(1, count($mails));
     $database_mail->postpone(1);
     $mails = $database_mail->getMailsToSend();
     $this->assertEquals(0, count($mails));
 }
Ejemplo n.º 9
0
 public function alive($alive = false)
 {
     $session_logic = Session_Logic::getInstance();
     $user = $session_logic->currentUser();
     $database_ipc = Database_Ipc::getInstance();
     if (func_num_args() == 0) {
         $alive = $database_ipc->getNotesAlive();
         return $alive;
     } else {
         $alive = Filter_Bool::int($alive);
         $database_ipc->storeMessage($user, "", "notesalive", $alive);
     }
 }
Ejemplo n.º 10
0
function page_access_level($level)
{
    $session_logic = Session_Logic::getInstance();
    if ($level > $session_logic->currentLevel()) {
        $header = new Assets_Header("Privileges");
        $header->setLogin();
        $header->run();
        $view = new Assets_View(__FILE__);
        $view->render("privileges.php");
        Assets_Page::footer();
        die;
    }
}
Ejemplo n.º 11
0
 public function consultationNote($id)
 {
     $database_notes = Database_Notes::getInstance();
     $database_logs = Database_Logs::getInstance();
     $passage = $database_notes->getPassages($id);
     $passageText = Filter_Books::passagesDisplayInline($passage);
     $summary = $database_notes->getSummary($id);
     $contents = $database_notes->getContents($id);
     $contents = Filter_Html::html2text($contents);
     $session_logic = Session_Logic::getInstance();
     $username = $session_logic->currentUser();
     $database_logs->log("{$username} deleted / marked for deletion consultation note {$passageText} | {$summary} | {$contents}");
 }
Ejemplo n.º 12
0
    public function testFilterNotesImportFromBibleditGtkFile()
    {
        $session_logic = Session_Logic::getInstance();
        $session_logic->setUsername("PHPUnit");
        $_SERVER['HTTP_USER_AGENT'] = "PHPUnit";
        $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
        $database_notes = Database_Notes::getInstance();
        $filename = tempnam(sys_get_temp_dir(), '');
        $data = <<<EOD
731157
Note Author
Acts.3.13
No issue
Ndebele
731157
umdumisile: Text was changed from "has given glory" to "has glorified".
Logbook:
EOD;
        file_put_contents($filename, $data);
        $identifier = Filter_Notes::importFromBibleditGtkFile($filename);
        $this->note_identifiers[] = $identifier;
        $bible = $database_notes->getBible($identifier);
        $this->assertEquals("Ndebele", $bible);
        $passages = $database_notes->getPassages($identifier);
        $this->assertEquals(array(array(44, 3, 13)), $passages);
        $summary = $database_notes->getSummary($identifier);
        $this->assertEquals("umdumisile: Text was changed from \"has given glory\" to \"has glorified\".", $summary);
        $status = $database_notes->getStatus($identifier);
        $this->assertEquals("No issue", $status);
        $data = <<<EOD
731157
Note Author
Lev.26.16 Deut.28.22
No issue
Ndebele
731157
umdumisile: Text was changed from "has given glory" to "has glorified".
Logbook:
EOD;
        file_put_contents($filename, $data);
        $identifier = Filter_Notes::importFromBibleditGtkFile($filename);
        $this->note_identifiers[] = $identifier;
        $passages = $database_notes->getPassages($identifier);
        $this->assertEquals(array(array(3, 26, 16), array(5, 28, 22)), $passages);
        $contents = $database_notes->getContents($identifier);
        $this->assertEquals("umdumisile: Text was changed from \"has given glory\" to \"has glorified\".\n\nLogbook:\n", $contents);
        // Tear down.
        unlink($filename);
    }
Ejemplo n.º 13
0
 public static function write($bible, $user = "")
 {
     // Client: User has access to all Bibles.
     if (Filter_Client::enabled()) {
         return true;
     }
     if ($user == "") {
         $session_logic = Session_Logic::getInstance();
         $user = $session_logic->currentUser();
     }
     $database_users = Database_Users::getInstance();
     if (!$database_users->hasAccess2Bible($user, $bible)) {
         return false;
     }
     $readonly = $database_users->hasReadOnlyAccess2Bible($user, $bible);
     return !$readonly;
 }
Ejemplo n.º 14
0
 function set($book, $chapter, $verse)
 {
     $set = false;
     if ($book != $this->getBook()) {
         $set = true;
     }
     if ($chapter != $this->getChapter()) {
         $set = true;
     }
     if ($verse != $this->getVerse()) {
         $set = true;
     }
     if ($set) {
         $database_ipc = Database_Ipc::getInstance();
         $database_config_user = Database_Config_User::getInstance();
         $session_logic = Session_Logic::getInstance();
         $user = $session_logic->currentUser();
         $database_ipc->storeMessage($user, "", "focus", "{$book}.{$chapter}.{$verse}");
         $database_config_user->setFocusedBook($book);
         $database_config_user->setFocusedChapter($chapter);
         $database_config_user->setFocusedVerse($verse);
     }
 }
Ejemplo n.º 15
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::TRANSLATOR_LEVEL);
$database_config_user = Database_Config_User::getInstance();
$database_logs = Database_Logs::getInstance();
$database_bibles = Database_Bibles::getInstance();
$database_modifications = Database_Modifications::getInstance();
$session_logic = Session_Logic::getInstance();
$bible = $_POST['bible'];
$book = $_POST['book'];
$chapter = $_POST['chapter'];
$verse = $_POST['verse'];
$usfm = $_POST['usfm'];
$checksum = $_POST['checksum'];
// Check on information about where to save the verse.
$save = isset($bible) && isset($book) && isset($chapter) && isset($verse) && isset($usfm);
if (!$save) {
    echo Locale_Translate::_("Don't know where to save");
    die;
}
// Checksum.
if (Checksum_Logic::get($usfm) != $checksum) {
    http_response_code(409);
Ejemplo n.º 16
0
 public function unsubscribe($identifier)
 {
     $session_logic = Session_Logic::getInstance();
     $user = $session_logic->currentUser();
     $this->unsubscribeUser($identifier, $user);
 }
Ejemplo n.º 17
0
 public function testBibleAlive()
 {
     $database_ipc = Database_Ipc::getInstance();
     $id = 1;
     $user = "******";
     $session_logic = Session_Logic::getInstance();
     $session_logic->setUsername($user);
     $channel = "channel";
     $command = "biblealive";
     $alive = $database_ipc->getBibleAlive();
     $this->assertFalse($alive);
     $message = "1";
     $database_ipc->storeMessage($user, $channel, $command, $message);
     $alive = $database_ipc->getBibleAlive();
     $this->assertEquals($message, $alive);
     $message = "0";
     $database_ipc->storeMessage($user, $channel, $command, $message);
     $alive = $database_ipc->getBibleAlive();
     $this->assertEquals($message, $alive);
 }
Ejemplo n.º 18
0
 public function setList($key, $values)
 {
     $session_logic = Session_Logic::getInstance();
     $user = $session_logic->currentUser();
     $file = $this->file($user, $key);
     $dir = dirname($file);
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     $value = implode("\n", $values);
     file_put_contents($file, $value);
 }
Ejemplo n.º 19
0
    protected function setUp()
    {
        $this->bible = "PHPUnit";
        $this->repository = uniqid(sys_get_temp_dir() . "/");
        $this->newrepository = uniqid(sys_get_temp_dir() . "/");
        $this->tearDown();
        $database_search = Database_Search::getInstance();
        $database_search->create();
        $database_bibles = Database_Bibles::getInstance();
        $database_bibles->createBible($this->bible);
        mkdir($this->repository);
        mkdir($this->newrepository);
        $command = "cd " . $this->repository . "; git init 2>&1";
        exec($command, $result, $exit_code);
        $command = "cd " . $this->newrepository . "; git init 2>&1";
        exec($command, $result, $exit_code);
        $this->psalms_0_data = <<<EOD
\\id PSA
\\h Izihlabelelo
\\toc2 Izihlabelelo
\\mt2 UGWALO
\\mt LWEZIHLABELELO
EOD;
        $this->psalms_11_data = <<<EOD
\\c 11
\\s IN\\sc KOSI\\sc* iyisiphephelo sabaqotho
\\d Kumqondisi wokuhlabelela. EsikaDavida
\\p
\\v 1 Ngithembela eN\\sc KOSI\\sc*ni\\x + Hlab. 25.2.\\x*. Lingatsho njani emphefumulweni wami: Balekela entabeni yenu \\add njeng\\add*enyoni\\x + 1 Sam. 23.14,19. 26.19,20.\\x*.
\\v 2 Ngoba, khangela, ababi bayagobisa idandili\\x + Hlab. 7.12. Hlab. 64.4.\\x*, balungisa umtshoko wabo entanjeni\\x + Hlab. 7.12. 21.12.\\x*, ukuze batshoke emnyameni abaqotho ngenhliziyo\\x + Hlab. 7.10.\\x*.
\\v 3 Nxa izisekelo zidilizwa\\x + Isa. 19.10. Hlab. 82.5. Hlab. 75.3.\\x*, angenzani olungileyo\\x + Jobe 22.13.\\x*?
\\p
\\v 4 IN\\sc KOSI\\x + Hab. 2.20.\\x*\\sc* isethempelini layo elingcwele\\x + Hlab. 5.7. Hlab. 150.1.\\x*; iN\\sc KOSI\\sc*, isihlalo sayo sobukhosi sisemazulwini\\x + Hlab. 2.4. 103.19. 115.3. 123.1. Isa. 66.1. Mat. 5.34. 23.22. Seb. 7.49. Isam. 4.2.\\x*; amehlo ayo ayakhangela\\x + Jobe 24.23. Hlab. 33.13. 34.15. 66.7. Hlab. 14.2. 102.19. 113.5,6.\\x*, inkophe zayo ziyahlola, abantwana babantu.
\\v 5 IN\\sc KOSI\\sc* iyamhlola olungileyo, kodwa omubi lothanda ubudlwangudlwangu, umphefumulo wayo uyamzonda\\x + Gen. 22.1.\\x*.
\\v 6 Uzanisa phezu kwababi imijibila, umlilo, lesolufa*\\x + Jobe 18.15.\\x*, lomoya otshisayo\\x + Hlab. 119.53. Lilo 5.10.\\x*, kuzakuba yisabelo senkezo yabo\\x + Hlab. 75.8. Jobe 21.20. Hlab. 16.5.\\x*.
\\v 7 Ngoba ilungile iN\\sc KOSI\\sc*, iyathanda ukulunga\\x + Hlab. 33.5. 45.7. Hlab. 37.28. 146.8.\\x*; ubuso bayo buyabona oqotho\\x + Hlab. 33.18. Hlab. 17.2.\\x*.
EOD;
        $this->song_of_solomon_2_data = <<<EOD
\\c 2
\\p
\\v 1 Ngilirozi\\x + Isa. 35.1.\\x* leSharoni\\x + Josh. 12.18.\\x*, umduze wezigodi\\x + 2.16. 4.5. 5.13. 6.2,3. 7.2. 2 Lan. 4.5. Hos. 14.5. Hlab. 45.\\x*.
\\p
\\v 2 Njengomduze phakathi kwameva\\x + 2.16. 4.5. 5.13. 6.2,3. 7.2. 2 Lan. 4.5. Hos. 14.5. Hlab. 45.\\x*, unjalo umngane wami phakathi kwamadodakazi\\x + 1.15.\\x*.
\\p
\\v 3 Njengesihlahla sama-aphula phakathi kwezihlahla zeganga, sinjalo isithandwa sami phakathi kwamadodana\\x + Zaga 25.11.\\x*. Ngahlala emthunzini waso ngathokoza kakhulu\\x + Isa. 25.4. 32.2.\\x*, lesithelo saso simnandi ekunambitheni kwami\\x + Isam. 22.2.\\x*.
\\v 4 Sangisa endlini yewayini, lesiboniso saso phezu kwami siluthando\\x + 1.4.\\x*.
\\v 5 Ngisekelani\\x + Gen. 27.37.\\x* ngeziphiso zewayini\\x + 2 Sam. 6.19. 1 Lan. 16.3. Hos. 3.1.\\x*, lingiqinise ngama-aphula\\x + Zaga 25.11.\\x*, ngoba ngigul\\add isw\\add*a \\add lu\\add*thando\\x + 5.8.\\x*.
\\v 6 Isandla saso sokhohlo singaphansi kwekhanda lami\\x + 8.3. Dute. 33.27.\\x*, lesokunene saso siyangigona\\x + 8.3. Dute. 33.27.\\x*.
\\v 7 Ngiyalifungisa\\x + 3.5. 8.4. 5.8,9.\\x*, madodakazi eJerusalema\\x + 1.5.\\x*, ngemiziki\\x + 2.9,17.\\x*\\x + Zaga 6.5.\\x* kumbe ngezimpala zeganga\\x + 2.9,17.\\x*\\x + Zaga 5.19.\\x*, ukuze lingaphazamisi lingavusi uthando luze luthande.
\\p
\\v 8 Ilizwi lesithandwa sami! Khangela sona siyeza, siseqa phezu kwezintaba, siqolotsha phezu kwamaqaqa\\x + Isa. 52.7.\\x*.
\\v 9 Isithandwa sami sinjengomziki\\x + 2.7,17. 8.14. 2 Sam. 22.34.\\x* kumbe njengethole lendluzele\\x + 2.7,17. 8.14. 2 Sam. 22.34.\\x*\\x + 4.5. 7.3.\\x*. Khangela simi ngemva komduli wethu, silunguza emawindini, sizibonakalisa\\f + \\fk zibonakalisa: \\fl Heb. \\fq hluma.\\f* eminxibeni yewindi\\x + Isa. 14.16.\\x*.
\\v 10 Isithandwa sami saphendula sathi kimi\\x + Hlu. 18.14.\\x*: Vuka wena\\x + 2.13.\\x*, mngane wami, omuhle wami, a\\add si\\add*hambe wena\\x + 1.15.\\x*.
\\v 11 Ngoba khangela, ubusika sebudlulile, izulu seliphelile, lihambile.
\\v 12 Amaluba ayabonakala emhlabeni, isikhathi sokuhlabelela \\add se\\add*sifikile, lelizwi lejuba liyezwakala elizweni lakithi\\x + Hlab. 74.19. Jer. 8.7.\\x*.
\\v 13 Isihlahla somkhiwa sivuthisa imikhiwa yaso eluhlaza, lamavini \\add ale\\add*mpoko\\x + 2.15. 7.12.\\x* aletha iphunga elimnandi\\x + Tshu. 7.1.\\x*. Vuka wena, mngane wami, omuhle wami wena, \\add si\\add*hambe\\x + 2.10.\\x*.
\\p
\\v 14 Juba lami\\x + 5.2. 6.9. 1.15. Mat. 10.16.\\x*, \\add elis\\add*engoxweni yedwala\\x + Jer. 48.28.\\x*\\x + Jer. 49.16. Obad. 3.\\x*, ekusithekeni kweliwa\\x + Hez. 38.20.\\x*, ngitshengisa ubuso bakho, ngizwise ilizwi lakho\\x + 8.13.\\x*, ngoba ilizwi lakho limnandi, lobuso bakho buyabukeka\\x + 1.5.\\x*.
\\v 15 Sibambeleni amakhanka, amakhanka amancinyane, ona izivini\\x + Hez. 13.4. Luka 13.32.\\x*, ngoba izivini zethu \\add zile\\add*zimpoko\\x + 2.15. 7.12.\\x*.
\\v 16 Isithandwa sami ngesami, lami ngingowaso\\x + 6.3. 7.10.\\x*, eselusa phakathi kwemiduze\\x + 2.1. 4.5. 6.3.\\x*.
\\v 17 Kuze kube semadabukakusa, lamathunzi abaleke\\x + 4.6.\\x*, phenduka, sithandwa sami, ube njengomziki kumbe njengethole lendluzele\\x + 8.14. 2.9.\\x* phezu kwezintaba zeBhetheri\\x + 2 Sam. 2.29.\\x*.
EOD;
        mkdir($this->repository . "/Psalms");
        mkdir($this->repository . "/Psalms/0");
        mkdir($this->repository . "/Psalms/11");
        mkdir($this->repository . "/Song of Solomon");
        mkdir($this->repository . "/Song of Solomon/2");
        file_put_contents($this->repository . "/Psalms/0/data", $this->psalms_0_data);
        file_put_contents($this->repository . "/Psalms/11/data", $this->psalms_11_data);
        file_put_contents($this->repository . "/Song of Solomon/2/data", $this->song_of_solomon_2_data);
        $_SERVER['HTTP_USER_AGENT'] = "PHPUnit";
        $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
        $session_logic = Session_Logic::getInstance();
        $session_logic->setUsername("PHPUnit");
    }
Ejemplo n.º 20
0
 /**
  * handleEmailNew - handles an email received from $from with subject $subject and body $body.
  * Returns true if the mail was processed, else false.
  * The email is considered to have been processed if it created a new Consultation Note.
  */
 public function handleEmailNew($from, $subject, $body)
 {
     // Store the original subject.
     $originalSubject = $subject;
     // Check that the subject indicates that a new consultation note is to be created.
     $pos = strpos(strtolower($subject), "new note");
     if ($pos === false) {
         return false;
     }
     // There is a new note. Remove that bit from the $subject.
     $subject = substr($subject, 0, $pos) . substr($subject, $pos + 8);
     // Clean the subject line.
     $subject = trim($subject);
     $subject = str_replace(".", " ", $subject);
     $subject = str_replace(":", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     $subject = str_replace("  ", " ", $subject);
     // Check that the $from address of the email belongs to an existing user.
     $from = Filter_Email::extractEmail($from);
     $database_users = Database_Users::getInstance();
     if (!$database_users->emailExists($from)) {
         return false;
     }
     $username = $database_users->getEmailToUser($from);
     // Extract book, chapter, verse, and note summary from the $subject
     $book = NULL;
     $chapter = NULL;
     $verse = NULL;
     $summary = NULL;
     $subject = explode(" ", $subject);
     if (count($subject) > 0) {
         $book = Filter_Books::interpretBook($subject[0]);
     }
     if (count($subject) > 1) {
         $chapter = Filter_Numeric::integer_in_string($subject[1]);
     }
     if (count($subject) > 2) {
         $verse = Filter_Numeric::integer_in_string($subject[2]);
     }
     unset($subject[0]);
     unset($subject[1]);
     unset($subject[2]);
     $summary = implode(" ", $subject);
     unset($subject);
     // Check book, chapter, verse, and summary. Give feedback if there's anything wrong.
     $noteCheck = "";
     if (!(is_numeric($book) && $book > 0)) {
         $noteCheck .= Locale_Translate::_("Unknown book");
     }
     if (!is_numeric($chapter)) {
         $noteCheck .= " " . Locale_Translate::_("Unknown chapter");
     }
     if (!is_numeric($verse)) {
         $noteCheck .= " " . Locale_Translate::_("Unknown verse");
     }
     if ($summary == NULL || $summary == "") {
         $noteCheck .= " " . Locale_Translate::_("Unknown summary");
     }
     // Mail user if the note could not be posted.
     $database_mail = Database_Mail::getInstance();
     if ($noteCheck != "") {
         $subject = Locale_Translate::_("Your new note could not be posted");
         $database_mail->send($username, $subject . ": " . $originalSubject, $noteCheck);
         return false;
     }
     // Clean the email's body.
     $body = Filter_Email::extractBody($body);
     // Post the note.
     $session_logic = Session_Logic::getInstance();
     $sessionuser = $session_logic->currentUser();
     $session_logic->setUsername($username);
     $database_notes = Database_Notes::getInstance();
     $identifier = $database_notes->storeNewNote("", $book, $chapter, $verse, $summary, $body, false);
     $this->handlerNewNote($identifier);
     $session_logic->setUsername($sessionuser);
     // Mail confirmation to the $username.
     $database_config_user = Database_Config_User::getInstance();
     if ($database_config_user->getUserNotifyMeOfMyPosts($username)) {
         $subject = Locale_Translate::_("Your new note was posted");
         $database_mail->send($username, $subject . ": " . $originalSubject, $body);
     }
     // Log operation.
     $database_logs = Database_Logs::getInstance();
     $database_logs->log("New note posted" . ":" . " " . $body);
     // Job done.
     return true;
 }
Ejemplo n.º 21
0
 public function testSetIdentifier()
 {
     // Create note.
     $session_logic = Session_Logic::getInstance();
     $session_logic->setUsername("phpunit");
     $database_notes = Database_Notes::getInstance();
     $identifier = $database_notes->storeNewNote("", 0, 0, 0, "summary", "contents", false);
     $this->identifiers[] = $identifier;
     // Contents of the note.
     $originalContents = $database_notes->getContents($identifier);
     $this->assertGreaterThan(20, strlen($originalContents));
     // Checksum of the note.
     $originalChecksum = $database_notes->getChecksum($identifier);
     $this->assertEquals(32, strlen($originalChecksum));
     // Change the identifier.
     $newId = 1234567;
     $database_notes->setIdentifier($identifier, $newId);
     $this->identifiers[] = $newId;
     // Check old and new identifier.
     $contents = $database_notes->getContents($identifier);
     $this->assertEmpty($contents);
     $contents = $database_notes->getContents($newId);
     $this->assertEquals($originalContents, $contents);
     $checksum = $database_notes->getChecksum($identifier);
     $this->assertEmpty($checksum);
     $checksum = $database_notes->getChecksum($newId);
     $this->assertEquals($originalChecksum, $checksum);
 }
Ejemplo n.º 22
0
 public function getMails()
 {
     $mails = array();
     $session = Session_Logic::getInstance();
     $user = $session->currentUser();
     $query = "SELECT rowid, timestamp, subject FROM mail WHERE username = '******' ORDER BY timestamp DESC;";
     $result = Database_SQLite::query($this->db, $query);
     foreach ($result as $row) {
         unset($row[0]);
         unset($row[1]);
         unset($row[2]);
         $mails[] = $row;
     }
     return $mails;
 }
Ejemplo n.º 23
0
 public static function goForward()
 {
     $database_navigation = Database_Navigation::getInstance();
     $session_logic = Session_Logic::getInstance();
     $user = $session_logic->currentUser();
     $passage = $database_navigation->getNext($user);
     if ($passage) {
         $ipc_focus = Ipc_Focus::getInstance();
         $ipc_focus->set($passage[0], $passage[1], $passage[2]);
     }
 }
Ejemplo n.º 24
0
 public static function myIdentifier()
 {
     $session_logic = Session_Logic::getInstance();
     $identifier = hexdec(substr(md5($session_logic->currentUser()), 0, 10));
     return $identifier;
 }
Ejemplo n.º 25
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);
}
Ejemplo n.º 26
0
 public function getBibleAlive()
 {
     $session_logic = Session_Logic::getInstance();
     $user = $session_logic->currentUser();
     $highestId = 0;
     $hitMessage = "";
     $data = $this->readData();
     foreach ($data as $record) {
         $recordid = $record['rowid'];
         if ($record['command'] == "biblealive") {
             if ($record['user'] == $user) {
                 if ($recordid > $highestId) {
                     $highestId = $recordid;
                     $hitMessage = file_get_contents($this->file($record['file']));
                 }
             }
         }
     }
     if ($highestId) {
         return $hitMessage;
     }
     return false;
 }