Example #1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database_NoteActions();
     }
     return self::$instance;
 }
Example #2
0
 public function testDelete()
 {
     $database = Database_NoteActions::getInstance();
     $database->record("phpunit1", 2, 3, "content1");
     $database->record("phpunit2", 4, 5, "content2");
     $database->delete(1);
     $notes = $database->getNotes();
     $this->assertEquals(array(4), $notes);
 }
Example #3
0
 public function delete($identifier)
 {
     $database_notes = Database_Notes::getInstance();
     $trash_handler = Trash_Handler::getInstance();
     if (Filter_Client::enabled()) {
         // Client: record the action in the database.
         $database_noteactions = Database_NoteActions::getInstance();
         $session_logic = Session_Logic::getInstance();
         $database_noteactions->record($session_logic->currentUser(), $identifier, self::noteActionDelete, "");
     } else {
         // Server: notification.
         $this->handlerDeleteNote($identifier);
     }
     $trash_handler->consultationNote($identifier);
     $database_notes->delete($identifier);
 }
Example #4
0
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";
// Security: The script runs from the cli SAPI only.
Filter_Cli::assert();
$database_logs = Database_Logs::getInstance();
$database_config_bible = Database_Config_Bible::getInstance();
$database_config_general = Database_Config_General::getInstance();
$database_notes = Database_Notes::getInstance();
$database_noteactions = Database_NoteActions::getInstance();
$database_users = Database_Users::getInstance();
$notes_logic = Notes_Logic::getInstance();
$database_logs->log(Locale_Translate::_("Sending and receiving Consultation Notes"), Filter_Roles::TRANSLATOR_LEVEL);
$response = Filter_Client::setup();
if ($response === false || $response < Filter_Roles::GUEST_LEVEL || $response > Filter_Roles::ADMIN_LEVEL) {
    $database_logs->log(Locale_Translate::_("Failure sending and receiving Consultation Notes"), Filter_Roles::TRANSLATOR_LEVEL);
    die;
}
$address = $database_config_general->getServerAddress();
// Go through all notes which have actions recorded for them.
$notes = $database_noteactions->getNotes();
foreach ($notes as $note) {
    $summary = $database_notes->getSummary($note);
    $database_logs->log(Locale_Translate::_("Sending note to server") . ": {$summary}", Filter_Roles::TRANSLATOR_LEVEL);
    // Go through all the actions for the current note.
Example #5
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);
}