<?
class admin_dialog_feedback extends admin_dialog {

var $params = array("target", "mode", "page", "id");


    function makeData() {
        parent::makeData();
        $this->feedback = func_new("feedback", $this->id);
        if($this->mode == "view") {
            $this->email = $this->feedback->row["email"];
            $this->form_fields["inp_email"] = $this->email;
            $this->addtime = date("H:i:s, F j, Y", $this->feedback->row["addtime"]);
            $txt = htmlspecialchars($this->feedback->row["message"]);
            $this->message = $txt;
        }
    }

    function action_delete() {
        if(isset($_REQUEST["ids"]) && is_array($_REQUEST["ids"])) {
            $n = func_new("feedback");
            foreach($_REQUEST["ids"] as $k => $v) {
                $n->delete($k);
            }
        }
    }


    function action_reply() {
        if(isset($_REQUEST["inp_email"]) && isset($_REQUEST["inp_answer"])) {
            $subject = $_REQUEST["inp_subject"];
            $body = $_REQUEST["inp_answer"];
            $to_email = $_REQUEST["inp_email"];
            $from_email = $_SESSION["email"];
            if(@mail($to_email, $subject, $body, "From: ".$from_email)) {
                $this->sendStatus = "send_ok";
            } else {
                $this->sendStatus = "send_error";
            }
        }
    }
}
?>