<?php
	require_once("../system.engine/system.core.php");
	$l->setPrefix("ajax.handle.fetch.mentions");
	
	$mPong = array();
	$a = &$mPong;
	$p = &$_POST;
	
	global $systemHandler;
	$systemExecution = $systemHandler->loadHandler("EXECUTION");
	$systemHash = $systemHandler->loadHandler("HASH");
	/* ### DO YOUR CODES ONLY FROM HERE ### */

	$mContainerId = $p["containerId"];
	$mCount = $systemExecution->runQuery("SELECT COUNT(id) AS containerCount FROM web_timeline WHERE id = '%s'", $mContainerId)->fetch_object()->containerCount;
	
	if($mCount > 0) {
		$mMentionsList = $systemExecution->runQuery("SELECT post_mentions_list FROM web_timeline WHERE id = '%s'", $mContainerId)->fetch_object()->post_mentions_list;
		
		if(strlen($mMentionsList) > 0) {
			$mSplittedMentions = explode(',', $mMentionsList);
			$mMentionsList = null;
			
			$a["htmlContainer"] = "<ul class=\"list-group setScrollbar\">";
			foreach($mSplittedMentions as $mUserId) {
				$mCachedUser = new systemUSER($mUserId);
				$a["htmlContainer"] .= "<li class=\"list-group-item\">
										<div class=\"row\">
											<div class=\"col-md-2\">
												<center>
													<a href=\"page.profile.php?profile-id=".$mCachedUser->mUserId."\">
														<img src=\"".$mCachedUser->mProfilePicture."\" class=\"pull-left likesProfilePicture\" />
													</a>
												</center>
											</div>
											<div class=\"col-md-10\" style=\"font-size: 16px; text-align: left\">
												<strong><a href=\"page.profile.php?profile-id=".$mCachedUser->mUserId."\">".$mCachedUser->mFullname."</a></strong>
											</div>
										</div>
									</li>";
			}
			$a["htmlContainer"] .= "</ul>";
		}
	} else $a["htmlContainer"] = "<center>".$l->getValue("nomentions")."</center>";
	
	/* ### DO NOT CHANGE ANYTHING FROM HERE ### */
	header("Content-Type: application/json");
	echo json_encode($mPong);
?>