feat: Add campaign comments functionality with API support and database migration
This commit is contained in:
@@ -103,7 +103,7 @@ class Campaigns
|
||||
echo json_encode( [
|
||||
'chart_data' => $chart_data,
|
||||
'dates' => $dates,
|
||||
'comments' => []
|
||||
'comments' => \factory\Campaigns::get_campaign_comments( $campaign_id )
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
@@ -221,4 +221,38 @@ class Campaigns
|
||||
echo json_encode( [ 'success' => true, 'deleted' => $deleted ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function comment_add()
|
||||
{
|
||||
$campaign_id = (int) \S::get( 'campaign_id' );
|
||||
$comment = trim( \S::get( 'comment' ) );
|
||||
$date = \S::get( 'date' );
|
||||
|
||||
if ( !$campaign_id || !$comment )
|
||||
{
|
||||
echo json_encode( [ 'success' => false, 'message' => 'Brak wymaganych parametrów' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = \factory\Campaigns::add_campaign_comment( $campaign_id, $comment, $date ?: null );
|
||||
|
||||
echo json_encode( [ 'success' => $result ? true : false ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function comment_delete()
|
||||
{
|
||||
$comment_id = (int) \S::get( 'comment_id' );
|
||||
|
||||
if ( !$comment_id )
|
||||
{
|
||||
echo json_encode( [ 'success' => false, 'message' => 'Nie podano komentarza' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = \factory\Campaigns::delete_campaign_comment( $comment_id );
|
||||
|
||||
echo json_encode( [ 'success' => $result ? true : false ] );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user