コード例 #1
0
ファイル: note_comments.php プロジェクト: kimblemj/server
 public static function getNoteCommentsForNote($pack)
 {
     $sql_note_comments = dbconnection::queryArray("SELECT note_comments.*, users.user_name, users.display_name FROM note_comments LEFT JOIN users ON note_comments.user_id = users.user_id WHERE game_id = '{$pack->game_id}' AND note_id = '{$pack->note_id}' ORDER BY note_comments.created ASC");
     $note_comments = array();
     for ($i = 0; $i < count($sql_note_comments); $i++) {
         if (!($ob = note_comments::noteCommentObjectFromSQL($sql_note_comments[$i]))) {
             continue;
         }
         $note_comments[] = $ob;
     }
     return new return_package(0, $note_comments);
 }
コード例 #2
0
ファイル: notes.php プロジェクト: kimblemj/server
 public static function deleteNote($pack)
 {
     $note = dbconnection::queryObject("SELECT * FROM notes WHERE note_id = '{$pack->note_id}'");
     $pack->auth->game_id = $note->game_id;
     $pack->auth->permission = "read_write";
     if (($pack->auth->user_id != $note->user_id || !users::authenticateUser($pack->auth)) && !editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     // Cleanup related items.
     $noteComments = dbconnection::queryArray("SELECT * FROM note_comments WHERE note_id = '{$pack->note_id}'");
     for ($i = 0; $i < count($note_comments); $i++) {
         $pack->note_comment_id = $noteComments[$i]->note_comment_id;
         note_comments::deleteNoteComment($pack);
     }
     // NOTE duplicated from tags.php/instances.php/triggers.php due to amf framework public methods being accessible via url.
     $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'NOTE' AND object_id = '{$pack->note_id}'");
     for ($i = 0; $i < count($tags); $i++) {
         $pack->object_tag_id = $tags[$i]->object_tag_id;
         dbconnection::query("DELETE FROM object_tags WHERE object_tag_id = '{$pack->object_tag_id}' LIMIT 1");
     }
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'NOTE' AND object_id = '{$pack->note_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         dbconnection::query("DELETE FROM instances WHERE instance_id = '{$pack->instance_id}' LIMIT 1");
         $triggers = dbconnection::queryArray("SELECT * FROM triggers WHERE instance_id = '{$pack->instance_id}'");
         for ($i = 0; $i < count($triggers); $i++) {
             $pack->trigger_id = $triggers[$i]->trigger_id;
             dbconnection::query("DELETE FROM triggers WHERE trigger_id = '{$pack->trigger_id}' LIMIT 1");
             // TODO fix and clean the rest of the hierarchy (requirement package)
         }
     }
     // After everything is cleaned up.
     dbconnection::query("DELETE FROM notes WHERE note_id = '{$pack->note_id}' LIMIT 1");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }