From e70a3aa7486fd4b759918893476dff1c4e6147ef Mon Sep 17 00:00:00 2001 From: Eltrac <45323514+BigCoke233@users.noreply.github.com> Date: Mon, 5 Aug 2019 12:54:44 +0800 Subject: =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96/=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96/Bug=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Contents.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'libs/Contents.php') diff --git a/libs/Contents.php b/libs/Contents.php index 40a27c6..c376824 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -50,7 +50,29 @@ class Contents } return $text; } - + + /** + * 通过查询数据库 + * 获取上级评论人 + */ + public static function getParent($comment) + { + $recipients = []; + $db = Typecho_Db::get(); + $widget = new Widget_Abstract_Comments(new Typecho_Request(), new Typecho_Response()); + // 查询 + $select = $widget->select()->where('coid' . ' = ?', $comment->parent)->limit(1); + $parent = $db->fetchRow($select, [$widget, 'push']); // 获取上级评论对象 + if ($parent && $parent['mail']) { + $recipients = [ + 'name' => $parent['author'], + 'mail' => $parent['mail'], + ]; + } + return $recipients; + } + + //从这里开始的代码来自 熊猫小A (https://imalan.cn) /** * 根据 id 返回对应的对象 * 此方法在 Typecho 1.2 以上可以直接调用 Helper::widgetById(); -- cgit v1.2.3