notifications = new VNotifications(); } /** * Notify when someone comments on a user's video */ public function notifyVideoComment($video_owner_id, $commenter_id, $commenter_name, $video_id, $video_title, $comment_text) { return $this->notifications->create( $video_owner_id, 'comment', "$commenter_name commented on your video", substr($comment_text, 0, 200), "/watch?v=$video_id#comments", $commenter_id, $video_id ); } /** * Notify when someone likes a video */ public function notifyVideoLike($video_owner_id, $liker_id, $liker_name, $video_id, $video_title) { return $this->notifications->create( $video_owner_id, 'like', "$liker_name liked your video", "\"$video_title\"", "/watch?v=$video_id", $liker_id, $video_id ); } /** * Notify when someone subscribes to a channel */ public function notifySubscribe($channel_owner_id, $subscriber_id, $subscriber_name) { return $this->notifications->create( $channel_owner_id, 'subscribe', "$subscriber_name subscribed to your channel", "", "/channel/$channel_owner_id", $subscriber_id ); } /** * Notify subscribers when a channel uploads a new video */ public function notifySubscribersNewVideo($channel_owner_id, $channel_name, $video_id, $video_title) { global $db; // Get all subscribers $sql = "SELECT subscriber_id FROM db_subscribers WHERE channel_id = ? AND active = 1"; $result = $db->execute($sql, [$channel_owner_id]); if (!$result) { return 0; } $count = 0; while ($row = $db->fetch($result)) { $this->notifications->create( $row['subscriber_id'], 'video_upload', "$channel_name uploaded a new video", "\"$video_title\"", "/watch?v=$video_id", $channel_owner_id, $video_id ); $count++; } return $count; } /** * Notify when someone mentions a user in a comment */ public function notifyMention($mentioned_user_id, $mentioner_id, $mentioner_name, $video_id, $comment_text) { return $this->notifications->create( $mentioned_user_id, 'mention', "$mentioner_name mentioned you in a comment", substr($comment_text, 0, 200), "/watch?v=$video_id#comments", $mentioner_id, $video_id ); } /** * Notify when someone replies to a user's comment */ public function notifyCommentReply($original_commenter_id, $replier_id, $replier_name, $video_id, $comment_id, $reply_text) { return $this->notifications->create( $original_commenter_id, 'comment', "$replier_name replied to your comment", substr($reply_text, 0, 200), "/watch?v=$video_id#comment-$comment_id", $replier_id, $video_id, $comment_id ); } /** * Send system notification (admin messages, moderation, etc.) */ public function notifySystem($user_id, $title, $message = '', $link = '') { return $this->notifications->create( $user_id, 'system', $title, $message, $link ); } /** * Batch notify multiple users (e.g., broadcast) */ public function notifyMultiple($user_ids, $type, $title, $message = '', $link = '', $actor_id = null) { $count = 0; foreach ($user_ids as $user_id) { if ($this->notifications->create($user_id, $type, $title, $message, $link, $actor_id)) { $count++; } } return $count; } }