迅睿CMS框架是一款PHP8高性能·简单易用的CMS开源开发框架, 基于MIT开源许可协议发布,不限制商业使用,以多端互联为设计理念, 支持的微信公众号、小程序、APP客户端、移动端网站、PC网站等多终端式管理系统。
发布评论之后钩子中如何判断是否是否是管理员发布的评论?
Models/Content.php
// 评论成功操作之后 public function _comment_after($data) { if 判断是否是管理员发的评论 { 是 } else { 不是 } }
public function _comment_after($data) { // 格式化 $title = dr_clearhtml($data['content']); if (IS_ADMIN) { //回复提醒发布者 $info = [ 'uid' => $data[1]['uid'],, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf', $info); } else { //回复提醒管理员 $info = [ 'uid' => 1, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf_admin', $info); } }
<?php namespace Phpcmf\Model\Fuwu; // 模块内容模型类 class Content extends \Phpcmf\Model\Content { // 评论成功操作之后 public function _comment_after($data) { // 格式化 $title = dr_clearhtml($data['content']); if (IS_ADMIN) { //回复提醒发布者 $info = [ 'uid' => $data[1]['uid'],, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf', $info); } else { //回复提醒管理员 $info = [ 'uid' => 1, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf_admin', $info); } } }
if (IS_ADMIN) {
public function _comment_after($data) { // 格式化 $title = dr_clearhtml($data['content']); if (IS_ADMIN) { //回复提醒发布者 $info = [ 'uid' => $data[1]['uid'],, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf', $info); } else { //回复提醒管理员 $info = [ 'uid' => 1, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf_admin', $info); } }<?php namespace Phpcmf\Model\Fuwu; // 模块内容模型类 class Content extends \Phpcmf\Model\Content { // 评论成功操作之后 public function _comment_after($data) { // 格式化 $title = dr_clearhtml($data['content']); if (IS_ADMIN) { //回复提醒发布者 $info = [ 'uid' => $data[1]['uid'],, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf', $info); } else { //回复提醒管理员 $info = [ 'uid' => 1, 'username' => $data[1]['author'], 'url' => $data['index']['url'], 'title' => $title, 'inputtiem' => SYS_TIME, ]; \Phpcmf\Service::L('Notice')->send_notice('workorder_hf_admin', $info); } } }在没有判断的时候是正常的,加上官方说的这个判断就出错了if (IS_ADMIN) {说明这个判断语法是错误的吧, 另外我也不知道这个模块的报错,为啥错误日志跟ask有关用phpstorm编辑器,会自动提示错误语法