<commit_before><?php
require_once("module.php");
require_once("media.php");
require_once("games.php");
require_once("locations.php");
require_once("playerStateChanges.php");
require_once("editorFoldersAndContent.php");

class Notes extends Module
{
    //Returns note_id
	function createNewNote($gameId, $playerId)
    {
        $query = "INSERT INTO notes (game_id, owner_id, title) VALUES ('{$gameId}', '{$playerId}', 'New Note')";
        @mysql_query($query);
		if (mysql_error()) return new returnData(1, NULL, mysql_error());
        
        return new returnData(0, mysql_insert_id());
    }
    
    function updateNote($noteId, $title, $shared)
    {
        $query = "UPDATE notes SET title = '{$title}', shared = '{$shared}' WHERE note_id = '{$noteId}'";
        @mysql_query($query);
		if (mysql_error()) return new returnData(1, NULL, mysql_error());
        
        return new returnData(0);
    }
    
    function addContentToNote($noteId, $gameId, $playerId, $mediaId, $type, $text)
    {
        $query = "INSERT INTO note_content (note_id, game_id, media_id, type, text) VALUES ('{$noteId}', '{$gameId}', '{$mediaId}', '{$type}', '{$text}')";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
        $contentId = mysql_insert_id();
        
        Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM, $contentId);
        if($type == "PHOTO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_IMAGE, $contentId);
        }
        else if($type == "AUDIO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_AUDIO, $contentId);
        }
        else if($type == "VIDEO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_VIDEO, $contentId);
        }

        return new returnData(0, $contentId);
    }
    
    function addContentToNoteFromFileName($gameId, $noteId, $playerId, $filename, $type, $name="playerUploadedContent")
    {
        $newMediaResultData = Media::createMedia($gameId, $name, $filename, 0);
        $newMediaId = $newMediaResultData->data->media_id;
        
        return Notes::addContentToNote($noteId, $gameId, $playerId, $newMediaId, $type, "");
    }
    
    function addCommentToNote($gameId, $playerId, $noteId, $rating)
    {
        $query = "INSERT INTO notes (game_id, owner_id, parent_note_id, parent_rating, title) VALUES ('{game_id}', '{$playerId}', '{$noteId}', '{$rating}', 'New Comment')";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
        $commentId = mysql_insert_id();
        
        $query = "SELECT ave_rating, num_ratings FROM notes WHERE note_id = '{$noteId}'";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());<commit_msg>updateContent function added<commit_after><?php
require_once("module.php");
require_once("media.php");
require_once("games.php");
require_once("locations.php");
require_once("playerStateChanges.php");
require_once("editorFoldersAndContent.php");

class Notes extends Module
{
    //Returns note_id
	function createNewNote($gameId, $playerId)
    {
        $query = "INSERT INTO notes (game_id, owner_id, title) VALUES ('{$gameId}', '{$playerId}', 'New Note')";
        @mysql_query($query);
		if (mysql_error()) return new returnData(1, NULL, mysql_error());
        
        return new returnData(0, mysql_insert_id());
    }
    
    function updateNote($noteId, $title, $shared)
    {
        $query = "UPDATE notes SET title = '{$title}', shared = '{$shared}' WHERE note_id = '{$noteId}'";
        @mysql_query($query);
		if (mysql_error()) return new returnData(1, NULL, mysql_error());
        
        return new returnData(0);
    }
    
    function addContentToNote($noteId, $gameId, $playerId, $mediaId, $type, $text)
    {
        $query = "INSERT INTO note_content (note_id, game_id, media_id, type, text) VALUES ('{$noteId}', '{$gameId}', '{$mediaId}', '{$type}', '{$text}')";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
        $contentId = mysql_insert_id();
        
        Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM, $contentId);
        if($type == "PHOTO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_IMAGE, $contentId);
        }
        else if($type == "AUDIO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_AUDIO, $contentId);
        }
        else if($type == "VIDEO"){
            Module::appendLog($playerId, $gameId, Module::kLOG_UPLOAD_MEDIA_ITEM_VIDEO, $contentId);
        }

        return new returnData(0, $contentId);
    }
    
    function addContentToNoteFromFileName($gameId, $noteId, $playerId, $filename, $type, $name="playerUploadedContent")
    {
        $newMediaResultData = Media::createMedia($gameId, $name, $filename, 0);
        $newMediaId = $newMediaResultData->data->media_id;
        
        return Notes::addContentToNote($noteId, $gameId, $playerId, $newMediaId, $type, "");
    }
    
    function updateContent($contentId, $text)
    {
        $query = "UPDATE note_content SET text='{$text}' WHERE content_id='{$contentId}'";
        @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
        return new returnData(0);
    }
    
    function addCommentToNote($gameId, $playerId, $noteId, $rating)
    {
        $query = "INSERT INTO notes (game_id, owner_id, parent_note_id, parent_rating, title) VALUES ('{game_id}', '{$playerId}', '{$noteId}', '{$rating}', 'New Comment')";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
        $commentId = mysql_insert_id();
        
        $query = "SELECT ave_rating, num_ratings FROM notes WHERE note_id = '{$noteId}'";
        $result = @mysql_query($query);
        if (mysql_error()) return new returnData(1, NULL, mysql_error());
{'fraction_non_alphanumeric': 0.16065894633828087, 'fraction_numerical': 0.00326211058554885, 'mean_word_length': 3.610526315789474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '636296', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1964, 'n_words': 416}