This option is implemented by checking whether the comment text has a @ and if so, we just indent it and hide the reply link from the user so that this comment cannot be commented.
/home/webmaster/public_html/mod/thewire/views/default/object/thewire.php
1. check for the @ in the text
[code]
$haystack= $vars['entity']->description;
$needle = "@";
if($haystack[0] == $needle)
$shallIndent = TRUE;
else
$shallIndent = FALSE;
[/code]
2. use the indentation for the div which is a comment or a reply to a post made earlier.
[code]
if($shallIndent)
{
?>
<!-- style="margin-left:50px"-->
<div class="thewire-singlepage" style="margin-left:50px">
<?php
}
else
{
?>
<div class="thewire-singlepage">
<?php
}
?>
[/code]
3. code to display the link only when the user is logged in and when this post is not indented.
[code]
<?php
if (isloggedin() && !($shallIndent))
{
?>
<a href="<?php echo $vars['url']; ?>mod/thewire/add.php?wire_username=<?php echo $vars['entity']->getOwnerEntity()->username; ?>" class="reply">
<?php echo elgg_echo('thewire:reply');
?>
[/code]
4. The reply url is now modified to accomodate the parent post id like this in the file : /home/webmaster/public_html/mod/thewire/views/default/object/thewire.php
[code]
<a href="<?php echo $vars['url']; ?>mod/thewire/add.php?wire_username=<?php echo $vars['entity']->getOwnerEntity()->username; ?>&pid=<?php echo $_tpId;?>" class="reply">
[/code]
5. Now get this parent postid in the forms page so that it can be sent to the add actions page too
[code]
<input type="hidden" name="pid" id="pid" value="<?php echo get_input("pid"); ?>" />
[/code]
6. Now we have to store the received parent post id and the child postid in the post_relations table
[code]
$thispostID = thewire_save_post($avatar_cost,$avatar_id,$body, $access_id, $parent, $method);
/* save the parent and child relationships here */
global $CONFIG;
mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass);
mysql_select_db($CONFIG->dbname);
$tbl_prefix = $CONFIG->dbprefix;
$tableName = $tbl_prefix."post_relations";
$parendPostId = get_input("pid");
$insertRelationsQuery = "INSERT INTO $tableName(parentid,childid,type) VALUES ($parendPostId,$thispostID,'w')";
$result = mysql_query($insertRelationsQuery);
/* save operation ends */
[/code]
Comments
Post a Comment