<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
class StellaCore{
    public $userId;

    public function preference_exists($preference, $value){
        global $db_con;  
    } 

    public function getAdminMessage(){
        global $db_con;
        $sql = $db_con->prepare('SELECT * FROM website_misc WHERE misc_name = "admin_message"');
        $sql->execute();
        if($sql->rowCount() > 0){
            $_message = $sql->fetch(PDO::FETCH_ASSOC);
            $message = $_message['misc_value'];
            if(strlen($message) > 0){
                echo json_encode($message);
            }
        }
    }

    public function sendMessage($uemail, $utitle, $umessage){
        global $db_con;
        $sql = $db_con->prepare('INSERT INTO message_table (user_email, message_title, user_message) VALUES (:user_email, :message_title, :user_message)');
        $sql->bindValue(':user_email', $uemail);
        $sql->bindValue(':message_title', $utitle);
        $sql->bindValue(':user_message', $umessage);
        $sql->execute();
    }
}