Ejemplo n.º 1
0
 function deleteNote($noteId)
 {
     //If noteId is 0, it will rather elegantly delete EVERYTHING in the note database
     //becasue 0 is used for the parent_id of all new notes
     if ($noteId == 0) {
         return new returnData(0);
     }
     $noteObj = Module::queryObject("SELECT * FROM notes WHERE note_id = '{$noteId}' LIMIT 1");
     Module::query("DELETE FROM note_tags WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM note_likes WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM note_flags WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM note_shares WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM folder_contents WHERE game_id = {$noteObj->game_id} AND content_type = 'PlayerNote' AND content_id = '{$noteId}'");
     Module::query("DELETE FROM note_content WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM note_tags WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM note_likes WHERE note_id = '{$noteId}'");
     Module::query("DELETE FROM notes WHERE note_id = '{$noteId}'");
     Locations::deleteLocationsForObject($noteObj->game_id, "PlayerNote", $noteId);
     $result = Module::query("SELECT note_id FROM notes WHERE parent_note_id = '{$noteId}'");
     while ($commentNote = mysql_fetch_object($result)) {
         Notes::deleteNote($commentNote->note_id);
     }
     return new returnData(0);
 }
 public static function deleteContent($gameId, $intContentID, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     //Lookup the object
     $query = "SELECT content_type,content_id FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}' LIMIT 1";
     $contentQueryResult = Module::query($query);
     $content = @mysql_fetch_object($contentQueryResult);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     Spawnables::deleteSpawnablesOfObject($gameId, $content->content_type, $content->content_id, $editorId, $editorToken);
     //Delete the content record
     $query = "DELETE FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     //Delete the object
     if ($content->content_type == "Node") {
         Nodes::deleteNode($gameId, $content->content_id, $editorId, $editorToken);
     } else {
         if ($content->content_type == "Item") {
             Items::deleteItem($gameId, $content->content_id, $editorId, $editorToken);
         } else {
             if ($content->content_type == "Npc") {
                 Npcs::deleteNpc($gameId, $content->content_id, $editorId, $editorToken);
             } else {
                 if ($content->content_type == "WebPage") {
                     WebPages::deleteWebPage($gameId, $content->content_id, $editorId, $editorToken);
                 } else {
                     if ($content->content_type == "AugBubble") {
                         AugBubbles::deleteAugBubble($gameId, $content->content_id, $editorId, $editorToken);
                     } else {
                         if ($content->content_type == "PlayerNote") {
                             Notes::deleteNote($content->content_id, $editorId, $editorToken);
                         }
                     }
                 }
             }
         }
     }
     if (mysql_affected_rows()) {
         return new returnData(0);
     } else {
         return new returnData(2, 'invalid folder id');
     }
 }
Ejemplo n.º 3
0
 function deleteNote($noteId)
 {
     //If noteId is 0, it will rather elegantly delete EVERYTHING in the note database
     //becasue 0 is used for the parent_id of all new notes
     if ($noteId == 0) {
         return new returnData(0);
     }
     $query = "SELECT * FROM notes WHERE note_id = '{$noteId}' LIMIT 1";
     $result = Module::query($query);
     $noteObj = mysql_fetch_object($result);
     $query = "DELETE FROM note_tags WHERE note_id = '{$noteId}'";
     Module::query($query);
     $query = "DELETE FROM note_likes WHERE note_id = '{$noteId}'";
     Module::query($query);
     $query = "SELECT note_id FROM notes WHERE parent_note_id = '{$noteId}'";
     $result = Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     while ($commentNote = mysql_fetch_object($result)) {
         Notes::deleteNote($commentNote->note_id);
     }
     //Delete Note locations
     Locations::deleteLocationsForObject($noteObj->game_id, "PlayerNote", $noteId);
     //Delete the folder record
     //EditorFolderContents::deleteContent($noteObj->game_id, "PlayerNote", $noteId); //This would cause an infinite loop becasue it deletes the note
     $query = "DELETE FROM folder_contents WHERE game_id = {$noteObj->game_id} AND content_type = 'PlayerNote' AND content_id = '{$noteId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     //Delete the Note's Content
     $query = "DELETE FROM note_content WHERE note_id = '{$noteId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     $query = "DELETE FROM note_tags WHERE note_id = '{$noteId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     $query = "DELETE FROM note_likes WHERE note_id = '{$noteId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     //Delete the Note itself
     $query = "DELETE FROM notes WHERE note_id = '{$noteId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     return new returnData(0);
 }
Ejemplo n.º 4
0
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::getNote($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = Notes::updateNote($id, $data);
    if ($result > 0) {
        $response->json(Result::success('Note Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Note not Updated.'));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::deleteNote($id);
    if ($result > 0) {
        $response->json(Result::success('Note Deleted.'));
    } else {
        $response->json(Result::error('Note not Deleted'));
    }
});