<script type='text/javascript' src='<?php _e(get_javascript_directory_uri()); ?>/jquery.oembed.min.js'></script>
<script type='text/javascript' src='<?php _e(get_javascript_directory_uri()); ?>/jquery.oembed.js'></script>
<script type='text/javascript' src='<?php _e(get_javascript_directory_uri()); ?>/functions.js'></script>
<?php
/**
* ProjectPress collab wall feed
*
* @package ProjectPress
* @since 2.0
*/
// Starts the session.
session_start();
define('access',true);
require_once(dirname(__FILE__) . '/config.inc.php');
require_once(PM_DIR . 'pm-includes/global.inc.php');
require_once(PM_DIR . 'pm-includes/functions.php');
$next_records = 10;
$show_more_button = 0;
if(pmdb::connect()->escape($_REQUEST['value']))
{
$username = $_SESSION['username'];
//echo "INSERT INTO " . DB . "wall_posts (post,date_created,p_user,first_name,last_name,email) VALUES('".checkValues($_REQUEST['value'])."','".strtotime(date("Y-m-d H:i:s"))."','".$username."','".$_SESSION['first_name']."','".$_SESSION['last_name']."', (SELECT email FROM " . DB . "members where username = '$username')))";
pmdb::connect()->query("INSERT INTO " . DB . "wall_posts (post,date_created,p_user,email) VALUES('".pmdb::connect()->escape($_REQUEST['value'])."','".strtotime(date("Y-m-d H:i:s"))."','".$username."',(SELECT email FROM " . DB . "members where username = '$username'))");
$result = pmdb::connect()->query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM " . DB . "wall_posts order by p_id desc limit 1");
}
elseif($_REQUEST['show_more_post']) // more posting paging
{
$next_records = $_REQUEST['show_more_post'] + 10;
$result = pmdb::connect()->query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM " . DB . "wall_posts order by p_id desc limit ".$_REQUEST['show_more_post'].", 10");
$check_res = pmdb::connect()->query("SELECT * FROM " . DB . "wall_posts order by p_id desc limit ".$next_records.", 10");
$show_more_button = 0; // button in the end
$check_result = $check_res->num_rows;
if($check_result > 0)
{
$show_more_button = 1;
}
}
else
{
$show_more_button = 1;
$result = pmdb::connect()->query("SELECT *,
UNIX_TIMESTAMP() - date_created AS TimeSpent FROM " . DB . "wall_posts order by p_id desc limit 0,10");
}
while ($row = $result->fetch_object())
{
$username = $_SESSION['username'];
$like_ip = pmdb::connect()->query("SELECT count(*) FROM " . DB . "wall_likes_username where post_id = '".$row->p_id."' AND l_user='".$username."'");
$like_ip_num = $like_ip->num_rows;
$user = pmdb::connect()->query("SELECT l_user FROM " . DB . "wall_likes_username WHERE post_id = '".$row->p_id."' AND l_user = '".$username."'");
$user_likes = $user->num_rows;
$total_comments = pmdb::connect()->query("SELECT count(*) FROM " . DB . "wall_posts_comments where post_id = ".$row->p_id." ORDER BY date_created ASC");
$records = $total_comments->fetch_array();
$records = $records[0];
$total_likes = pmdb::connect()->query("SELECT * FROM " . DB . "wall_posts where p_id = ".$row->p_id." ");
$likes = $total_likes->fetch_array();
$likes = $likes['likes'];
$comments = pmdb::connect()->query("SELECT *,
UNIX_TIMESTAMP() - date_created AS CommentTimeSpent FROM " . DB . "wall_posts_comments where post_id = ".$row->p_id." ORDER BY date_created ASC limit 0,2");
//$comments = pmdb::connect()->query("SELECT *, UNIX_TIMESTAMP() - date_created AS CommentTimeSpent FROM " . DB . "wall_posts_comments where post_id = ".$row->p_id." order by c_id asc");
$comment_num_row = $comments->num_rows;?>
<div class="friends_area" id="record-<?php echo $row->p_id?>">
<?php echo get_user_avatar($row->p_user,$row->email,100); ?>
<label style="float:left" class="name">
<b><a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $row->p_user; ?>"><?php echo get_name($row->p_user);?></a></b>
<em><?php echo clickable_link($row->post);?></em>
<br clear="all" />
<span>
<?php
// echo strtotime($row->date_created,"Y-m-d H:i:s");
$days = floor($row->TimeSpent / (60 * 60 * 24));
$remainder = $row->TimeSpent % (60 * 60 * 24);
$hours = floor($remainder / (60 * 60));
$remainder = $remainder % (60 * 60);
$minutes = floor($remainder / 60);
$seconds = $remainder % 60;
if($days > 0)
echo date('F d Y', $row->date_created);
elseif($days == 0 && $hours == 0 && $minutes == 0)
echo "few seconds ago";
elseif($days == 0 && $hours == 0)
echo $minutes.' minutes ago';
elseif($days == 0 && $hours > 0)
echo $hours.' hour ago';
else
echo "few seconds ago";
?>
</span>
<a href="javascript: void(0)" id="post_id<?php echo $row->p_id?>" class="showCommentBox">Comments</a>
<span id="like-panel-<?php echo $row->p_id?>">
<?php
if($user_likes){?>
<a href="javascript: void(0)" id="post_id<?php echo $row->p_id?>" class="Unlike">Unlike</a>
<?php }else{?>
<a href="javascript: void(0)" id="post_id<?php echo $row->p_id?>" class="LikeThis">Like</a>
<?php }?>
</span>
</label>
<?php
$username = $_SESSION['username'];
if($row->p_user == $username){?>
<a href="#" class="delete"> Remove</a>
<?php
}?>
<input type="hidden" value="<?php echo $records?>" id="totals-<?php echo $row->p_id;?>" />
<br clear="all" />
<div class="commentPanel" align="left">
<img src="<?php echo PM_URI ?>/images/like.png" style="float:left;" alt="" />
<span class="likes" id="like-stats-<?php echo $row->p_id;?>"> <?php echo $likes;?> </span> <span class="likes">people like this.</span>
<span id="like-loader-<?php echo $row->p_id?>"> </span>
</div>
<?php
if ($records > 2)
{
$collapsed = true;?>
<div class="commentPanel" id="collapsed-<?php echo $row->p_id;?>" align="left">
<img src="<?php echo PM_URI ?>/images/cicon.png" style="float:left;" alt="" />
<a href="javascript: void(0)" class="ViewComments">
View all <?php echo $records;?> comments
</a>
<span id="loader-<?php echo $row->p_id?>"> </span>
</div>
<?php
}?>
<div id="CommentPosted<?php echo $row->p_id?>">
<?php
//$comment_num_row = mysql_num_rows(@$comments);
if($comment_num_row > 0)
{
while ($rows = $comments->fetch_object())
{
$days2 = floor($rows->CommentTimeSpent / (60 * 60 * 24));
$remainder = $rows->CommentTimeSpent % (60 * 60 * 24);
$hours = floor($remainder / (60 * 60));
$remainder = $remainder % (60 * 60);
$minutes = floor($remainder / 60);
$seconds = $remainder % 60; ?>
<div class="commentPanel" id="record-<?php echo $rows->c_id;?>" align="left">
<?php echo get_user_avatar($rows->c_user,$rows->email); ?>
<label class="postedComments">
<a href="<?php echo PM_URI ?>/profile/profile.php?username=<?php echo $rows->c_user; ?>"><span id="name"><?php echo get_name($rows->c_user); ?></span></a> <?php echo clickable_link($rows->comments);?>
</label>
<br clear="all" />
<span style="margin-left:43px; color:#666666; font-size:11px">
<?php
if($days2 > 0)
echo date('F d Y', $rows->date_created);
elseif($days2 == 0 && $hours == 0 && $minutes == 0)
echo "few seconds ago";
elseif($days2 == 0 && $hours == 0)
echo $minutes.' minutes ago';
elseif($days2 == 0 && $hours > 0)
echo $hours.' hour ago';
else
echo "few seconds ago";
?>
</span>
<?php
$username = $_SESSION['username'];
if($rows->c_user == $username){?>
<a href="#" id="CID-<?php echo $rows->c_id;?>" class="c_delete">Delete</a>
<?php
}?>
</div>
<?php
}?>
<?php
}?>
</div>
<div class="commentBox" align="right" id="commentBox-<?php echo $row->p_id;?>" <?php echo (($comment_num_row) ? '' :'style="display:none"')?>>
<?php echo get_user_avatar($_SESSION['username'],get_email($_SESSION['username']),30); ?>
<label id="record-<?php echo $row->p_id;?>">
<textarea class="commentMark" id="commentMark-<?php echo $row->p_id;?>" name="commentMark" cols="60"></textarea>
</label>
<br clear="all" />
<a id="SubmitComment" class="small button comment"> Comment</a>
</div>
</div>
<!--<div class="break"></div>-->
<?php
}
if($show_more_button == 1){?>
<div id="bottomMoreButton">
<a id="more_<?php echo @$next_records?>" class="more_records" href="javascript: void(0)">Older Posts</a>
</div>
<?php
}