模块属性参数:内容发布通知多人

2022-09-27 11:26 0

开发实例:模块内容用户投稿后,通知到指定的账号(可多个账号)

后台设置效果界面:

模块属性参数:内容发布通知多人


例子以Demo模块为例,其他模块请自己修改目录名称。

1、新建配置控制器文件:dayrui/App/Demo/Controllers/Admin/Param.php

_Module_Param();
   }

}


2、新建控制器模板文件:dayrui/App/Demo/Views/param.html

{template "header.html"}


    

{dr_lang('更改数据之后需要更新缓存之后才能生效')}

    {$form}                                                                   {dr_lang('参数设置')}                                        
                                                         {dr_lang('内容用户投稿后通知')}                                                                                                                                                      {dr_lang('短信')}                                                                                                                     {dr_lang('邮件')}                                                                                                                     {dr_lang('微信')}                                                                                                                     {dr_lang('消息')}                                                                                                                    {dr_lang('内容设置')}                                                                      
                            
                                                                                              {dr_lang('保存')}               {template "footer.html"}


3、访问这个页面,并设置数据,效果见首图

admin.php?s=demo&c=param&m=index


4、模块钩子开发,写入程序逻辑代码:dayrui/App/Demo/Config/Hooks.php

module['setting']['param']['notice'][$name]['username']) && \Phpcmf\Service::C()->module['setting']['param']['notice'][$name]['username']) {
  $var = dr_array2array($data[1], $data[0]);
  $fields = \Phpcmf\Service::C()->module['field'];
  $fields['inputtime'] = ['fieldtype' => 'Date'];
  $fields['updatetime'] = ['fieldtype' => 'Date'];
  $var = \Phpcmf\Service::L('Field')->format_value($fields, $var, 1);
  $arr = explode(',', \Phpcmf\Service::C()->module['setting']['param']['notice'][$name]['username']);
  foreach ($arr as $autor) {
   $user = dr_member_username_info($autor);
   if (!$user) {
    log_message('error', '自定义钩子:已开启通知提醒,但通知人['.$autor.']有误');
   } else {
    \Phpcmf\Service::L('Notice')->send_notice_user(
     'my_send_'.APP_DIR.'_'.$name,
     $user['id'],
     $var,
     \Phpcmf\Service::C()->module['setting']['param']['notice'][$name],
     1 // 1立即发送
    );
   }
  }
 }
 
 
}







咨询
微信
电话