MyBB Community Forums

Full Version: Quick Reply Ajax
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
		// This was a post made via the ajax quick reply - we need to do some special things here
		if($mybb->input['ajax'])
		{
			// Visible post
			if($visible == 1)
			{
				// Set post counter
				$postcounter = $thread['replies'] + 1;

				// Was there a new post since we hit the quick reply button?
				if($mybb->input['lastpid'])
				{
					$query = $db->simple_select("posts", "pid", "tid = '{$tid}' AND pid != '{$pid}'", array("order_by" => "pid", "order_dir" => "desc"));
					$new_post = $db->fetch_array($query);
					if($new_post['pid'] != $mybb->input['lastpid'])
					{
						redirect(get_thread_link($tid, 0, "lastpost"));
					}
				}

				// Lets see if this post is on the same page as the one we're viewing or not
				// if it isn't, redirect us
				if($perpage > 0 && (($postcounter) % $perpage) == 0)
				{
					$post_page = ($postcounter) / $mybb->settings['postsperpage'];
				}
				else
				{
					$post_page = intval(($postcounter) / $mybb->settings['postsperpage']) + 1;
				}

				if($mybb->input['from_page'] && $post_page > $mybb->input['from_page'])
				{
					redirect(get_thread_link($tid, 0, "lastpost"));
					exit;
				}

				// Return the post HTML and display it inline   <-- What is this below
				$query = $db->query("
					SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
					FROM ".TABLE_PREFIX."posts p
					LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
					LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
					LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
					WHERE p.pid='{$pid}'
				");
				$post = $db->fetch_array($query);

				// Now lets fetch all of the attachments for this post
				$query = $db->simple_select("attachments", "*", "pid='{$pid}'");
				while($attachment = $db->fetch_array($query))
				{
					$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
				}

				// Is the currently logged in user a moderator of this forum?
				if(is_moderator($fid))
				{
					$ismod = true;
				}
				else
				{
					$ismod = false;
				}

				// Establish altbg - may seem like this is backwards, but build_postbit reverses it
				if(($postcounter - $mybb->settings['postsperpage']) % 2 != 0)
				{
					$altbg = "trow1";
				}
				else
				{
					$altbg = "trow2";
				}

				require_once MYBB_ROOT."inc/functions_post.php";
				$pid = $post['pid'];
				$post = build_postbit($post);
				echo $post;

				// Build a new posthash incase the user wishes to quick reply again
				mt_srand((double) microtime() * 1000000);
			    $new_posthash = md5($mybb->user['uid'].mt_rand());
				echo "<script type=\"text/javascript\">\n"; 
				echo "var hash = document.getElementById('posthash'); if(hash) { hash.value = '{$new_posthash}'; }\n";
				echo "if(typeof(inlineModeration) != 'undefined') { Event.observe($('inlinemod_{$pid}'), 'click', inlineModeration.checkItem); }\n";
				echo "</script>\n"; 
				exit;				
			}
			// Post is in the moderation queue
			else
			{
				redirect(get_thread_link($tid, 0, "lastpost"), $lang->redirect_newreply_moderation);
				exit;
			}
		}
		else // I get all below here
		{
			$lang->redirect_newreply .= $lang->sprintf($lang->redirect_return_forum, get_forum_link($fid)); 
			redirect($url, $lang->redirect_newreply); 
			exit;
		}



could someone please explain (hopefully as thoroughly as possible) how that extract (that i got from newreply.php) makes a ajax quick reply that requires no reload, ideally i could get a response from the Dev team or support team but they hardly visit here ..heres hoping someone who does get this answers my queries
Umm..Quick reply is ajax? I have no re-load on my forum when i post a quick reply? Thus you might have a issue with yours and so you may wanna post this in the support forum as seing how it is a part of the board software.
did you enabled the ajax funktion in the board settings ?
acp settings server&optimizing options
no you misunderstand ..my quick reply is working but for a plugin im making i anna understand HOW this code does it