function _getBlogNumFromNothing($projectUrlName, $blogUrlName, $currentUser) { //NOTE: error messages are put to buffer via the functions called // 1 - get the project number for the blog the user is currently editing $projectNum = _getProjectNum($projectUrlName, $currentUser); if ($projectNum == false) { return false; } // 2 - Get the blog number the user is currently editing $blogNum = _getBlogNum($blogUrlName, $projectNum); if ($blogNum == false) { return false; } return $blogNum; }
function create_new_blog($projectUrlName) { //TODO: include more error checking $currentUser = current_account(); if ($currentUser == -1) { echo '{"result": "not-signed-in"}'; } $projectNum = _getProjectNum($projectUrlName, $currentUser); $time = time(); $blogName = "new blog " . $time; $blogUrl = name_to_url_name($blogName); $createBlog = "INSERT INTO blog_head values(null, {$projectNum}, '{$blogName}', '{$blogUrl}', {$time})"; $result = query($createBlog); $createdBlog = last_insert_id(); $createBlogInfo = "INSERT INTO blog_info values({$createdBlog}, 'http://i.imgur.com/WtDPZp7.png', '', {$time})"; $result2 = query($createBlogInfo); $blogTitle = "<p id='blog-title' contenteditable='true'> BlogTitle </p>"; $createBlogContent = "INSERT INTO blog_contents VALUES({$createdBlog}, \"{$blogTitle}\");"; $result3 = query($createBlogContent); echo '{"result": "create-new-blog-success"}'; }