-->
julis

Sharetronix Extension - Like Dislike Part 3

in this part i will show the change of controller part,
in the controller we will add two files,
one for handle the 'Like' part and the other will handle the 'Dislike' part

So, let's begin

first create file named ajax_likepost.php in folder System\controllers\
the file will contain this
// begin -------------------------------------------------------------------------------------
<?php
if( !$this->network->id ) {
echo 'ERROR';
return;
}
if( !$this->user->is_logged ) {
echo 'ERROR';
return;
}

if( isset($_POST['postid']) && preg_match('/^(public|private)_([0-9]+)$/', $_POST['postid'], $m) )
{
$p = new post($m[1], $m[2]);
if( $p->error ) {
echo 'ERROR';
return;
}
if( $p->like_post() ) {
echo 'OK';
return;
}
}
echo 'ERROR';
return;
?>
// end ------------------------------------------------------------------------------------------------------

secondly, create file named ajax_dislikepost.php in folder system\controllers\
file content is
// begin ---------------------------------------------------------------------------------------------------
<?php
if( !$this->network->id ) {
echo 'ERROR';
return;
}
if( !$this->user->is_logged ) {
echo 'ERROR';
return;
}

if( isset($_POST['postid']) && preg_match('/^(public|private)_([0-9]+)$/', $_POST['postid'], $m) )
{
$p = new post($m[1], $m[2]);
if( $p->error ) {
echo 'ERROR';
return;
}
if( $p->dislike_post() ) {
echo 'OK';
return;
}
}
echo 'ERROR';
return;
?>
// end -----------------------------------------------------------------------------------------------------

next we will create View part (from MVC), please comment, thanks
julis
julis
Load comments