定制 jandanielcz/simona 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jandanielcz/simona

Composer 安装命令:

composer require jandanielcz/simona

包简介

Simple language used to specify when and to whom to send notifications.

README 文档

README

Simple language used to specify when and to whom send notifications.

Purpose

For one side project (project management/IS/KB mix) I needed flexible but simple way to configure when should users get notifications for their tasks.

For example:

  • Notify responsible user one week and 3 days before if task is not done yet.
  • If task is one day delayed notify supervisor.
  • If task is more than 3 days delayed notify all admins.

Than I can every night check all recent and future task, process these rules and send emails.

Examples

Notify responsible user one week before:

(1):[responsible];

If task is one day delayed notify supervisor:

(-1!):[supervisor];

If task is more than 3 days delayed notify all admins.:

(-3..!):@admins;

We can combine rules to create simple escalation scenarios:

(7):[responsible];
(1!):[responsible];
(-1..!):[responsible];
(-2!):[supervisor],@admins;
(-3!):tom@example.org;

Lines not starting with ( and space after trailing ; can be used for comments.

(7):[responsible];
(1!):[responsible];
(-1..!):[responsible];      keep bugging him :)
(-2!):[supervisor],@admins; 

Tom from example corp. wants to know about it since 2017-01. Adam.
(-3!):tom@example.org;

Rule elements

  1. time window definition
  2. ! send notifications only if task is unsolved
  3. : separator
  4. list of recipients separated by , for my usage i decided to go with
    • specific email dan@example.org
    • relation to task [responsible]
    • user group @itdept
    • other plain_string (not used)
  5. trailing ;

Each rule should be on separate line.

Interval specification

For definition of days for notification Simone uses days count to task date:

                     
                    Day of task
        ...3  2  1  0 -1 -2 -3 -4...
--------------------|--------------------time-->
                                         
(..!)   ...X  X  X  X  X  X  X  X        every day until done
(2..-1)       X  X  X  X
(0..!)              X  X  X...           until done
(3)        X                             once

Negative numbers means task should be done in histoy.

Errors

If line starts with ( it is considered rule and invalid rules, should be reported to user. Every other line is ignored in processing.

PHP Usage

Basic usage

$rc = new RulesCollection();
$rc->parse('(1):a;');
$rc->whoToNotify(1, false); // $daysToTask, $isTaskCompleted?

// returns ['a']

Usage with recipient types

$rc = new RulesCollection();
$rc->parse('(1):[a],@allUsers;');
$rc->setRecipientReducer(['\JanDanielCz\Simona\RecipientUtils','groupRelMailPlainReducer']);
$rc->whoToNotify(1, false); // $daysToTask, $isTaskCompleted?

/* 
returns [
    'group' => ['allUsers'],
    'rel' => ['a'],
    'mail' => [],
    'plain' => []
    ];
*/

You can create your own reducer to sort recipients and introduce any special recipients syntax.

Limitations

Spaces inside recipient definition are removed before parsing by preg_replace('/\s+/', '', $string) pull request with better regex is welcomed.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固