function ListifyComments($raw, $parentComment) { $returnArray = array(); $index = 0; for ($i = 0; $i < sizeof($raw); $i++) { if ($raw[$i]['parentComment'] == $parentComment) { $dateFormatted = format_date($raw[$i]['date']); $returnArray[$index]['commentId'] = $raw[$i]['comment_no']; $returnArray[$index]['deleted'] = $raw[$i]['deleted']; $returnArray[$index]['parentCommentId'] = $raw[$i]['parentComment']; $returnArray[$index]['canEdit'] = $raw[$i]['user_id'] == $_SESSION['UserID'] && $_SESSION['UserLevel'] <= new_user_level; $returnArray[$index]['canComment'] = $_SESSION['UserLevel'] < new_user_level; $returnArray[$index]['authorUserId'] = $raw[$i]['user_id']; $returnArray[$index]['author'] = $raw[$i]['user_name']; $returnArray[$index]['authorEmail'] = $raw[$i]['user_email']; $returnArray[$index]['content'] = $raw[$i]['content_original']; $returnArray[$index]['date'] = $dateFormatted[1]; $returnArray[$index]['epochtime'] = $raw[$i]['date']; $returnArray[$index]['children'] = ListifyComments($raw, $raw[$i]['comment_no']); $index++; } } return $returnArray; }
function ListifyComments($raw, $parentComment) { $returnArray = array(); $index = 0; for ($i = 0; $i < sizeof($raw); $i++) { if ($raw[$i]['parentComment'] == $parentComment) { $dateFormatted = format_date($raw[$i]['date']); $returnArray[$index]['commentId'] = $raw[$i]['comment_no']; $returnArray[$index]['deleted'] = $raw[$i]['deleted']; $returnArray[$index]['parentCommentId'] = $raw[$i]['parentComment']; $returnArray[$index]['canEdit'] = $raw[$i]['user_id'] == $_SESSION['UserID'] && $_SESSION['UserLevel'] <= new_user_level || $_SESSION['UserLevel'] == admin_level; $returnArray[$index]['canComment'] = $_SESSION['UserLevel'] < new_user_level; $returnArray[$index]['canDelete'] = $raw[$i]['user_id'] == $_SESSION['UserID'] || $_SESSION['UserLevel'] == admin_level; $returnArray[$index]['authorUserId'] = $raw[$i]['user_id']; $returnArray[$index]['author'] = htmlentities($raw[$i]['user_name'], ENT_QUOTES, "UTF-8"); $returnArray[$index]['authorEmail'] = $raw[$i]['user_email']; $returnArray[$index]['facebookId'] = $raw[$i]['facebook_user_id']; $returnArray[$index]['content'] = $raw[$i]['content_original']; $returnArray[$index]['date'] = $dateFormatted[1]; $returnArray[$index]['epochtime'] = $raw[$i]['date']; $returnArray[$index]['children'] = ListifyComments($raw, $raw[$i]['comment_no']); $returnArray[$index]['files'] = DBGetCommentFiles($raw[$i]['comment_no']); $index++; } } return $returnArray; }