public function testCreateNote() { $data = Filter_Client::createNoteEncode("bible", 1, 2, 3, "summary", "line1\nline2", false); $standard = <<<EOD bible 1 2 3 summary line1 line2 EOD; $this->assertEquals($standard, $data); $data = Filter_Client::createNoteDecode($standard); $this->assertEquals("bible", $data["bible"]); $this->assertEquals(1, $data["book"]); $this->assertEquals(2, $data["chapter"]); $this->assertEquals(3, $data["verse"]); $this->assertEquals("summary", $data["summary"]); $this->assertEquals("", $data["raw"]); $contents = <<<EOD line1 line2 EOD; $this->assertEquals($contents, $data["contents"]); }
if (!$pass_ok) { $database_logs->log("Incorrect password {$password} for user {$username}", Filter_Roles::MANAGER_LEVEL); } $level_ok = $level == $database_users->getUserLevel($username); if (!$level_ok) { $database_logs->log("Incorrect role {$level} for user {$username}", Filter_Roles::MANAGER_LEVEL); } if (!$user_ok || !$pass_ok || !$level_ok) { // Unauthorized. http_response_code(401); die; } $session_logic->setUsername($username); if ($action == Notes_Logic::noteActionCreate) { // Create the note on the server. $data = Filter_Client::createNoteDecode($content); $bible = $data["bible"]; $book = $data["book"]; $chapter = $data["chapter"]; $verse = $data["verse"]; $summary = $data["summary"]; $raw = $data["raw"]; $contents = $data["contents"]; $server_id = $notes_logic->createNote($bible, $book, $chapter, $verse, $summary, $contents, $raw); // Update the note identifier on the server to be same as the client. $database_notes->setIdentifier($server_id, $note); // Update search field. $database_notes->updateSearchFields($note); $database_logs->log("Client created note on server" . ": {$summary}", Filter_Roles::MANAGER_LEVEL); echo "The server created the note"; } else {