/** * @param array $list */ private function getListDataParse(&$list) { if ($list === false) { Log::write(_("Get comment list of user error."), Log::SQL); $this->throwMsg(-2); } $ol = []; for ($i = 0, $l = count($list); $i < $l; ++$i) { $ol[$list[$i][$this->type . "_id"]] = $list[$i][$this->type . "_id"]; } $info = $this->cm->getCommentTypeInfo($this->type, $ol); for ($i = 0, $l = count($list); $i < $l; ++$i) { if (isset($info[$list[$i][$this->type . "_id"]])) { $list[$i]['info'] =& $info[$list[$i][$this->type . "_id"]]; } else { //此处数据出错,或者数据不完整 Log::write(_("Data loss on CommentList class."), Log::NOTICE); unset($list[$i]); } } }
public function message_like_comment($rt, $c_id, $u_id) { try { if (!is_array($rt)) { lib()->load('CommentManagement'); $rt = CommentManagement::getInstance()->getCommentType($c_id); } if (!isset($rt['comment']) || !isset($rt['type']) || count($rt['type']) !== 1) { return $rt; } /** * @var Comment $comment ; */ $comment =& $rt['comment']; if ($comment->getUser()->getId() != $u_id && $this->notice($comment->getUser()->getId(), 'message', 'like_comment')) { $like_user = User::getUser($u_id); if (!isset($rt['data_info'])) { $type = array_keys($rt['type'])[0]; $data_info = CommentManagement::getInstance()->getCommentTypeInfo($type, $rt['type'][$type]); $rt['data_info'] =& $data_info; } else { $data_info = $rt['data_info']; } if (!isset($data_info['user_id'])) { return $rt; } $mt = new MailTemplate("message_notice/like_comment.md"); $mt->setUserInfo($comment->getUser()->getInfo()); $mt->setValues(['post_title' => $data_info['title'], 'post_link' => $data_info['link'], 'comment_content' => $comment->getCommentContent(), 'comment_like_count' => $comment->getCommentLikeCount(), 'comment_time' => $comment->getCommentTime(), 'like_user_name' => $like_user->getAliases(), 'like_user_url' => user_link($like_user->getName())]); $this->message->addNoticeMsg($mt->getTitle(), $mt->getContent(), $comment->getUser()->getId()); } } catch (\Exception $ex) { Log::write(_("NoticeApply message_like_comment create a Exception.") . "EX:[" . $ex->getCode() . "]:" . $ex->getMessage(), Log::NOTICE); } return $rt; }
public function delete() { try { $this->throwMsgCheck('is_post', 'is_login'); $this->__lib('CommentManagement'); $cm = new CommentManagement(); $cm->delete(req()->post('id'), req()->post('type'), login_user()->getId()); $this->rt_msg['status'] = true; } catch (\Exception $ex) { $this->rt_msg['status'] = false; $this->rt_msg['msg'] = $ex->getMessage(); $this->rt_msg['code'] = $ex->getCode(); } }