2017 © Pedro Peláez
 

library simona

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

image

jandanielcz/simona

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

  • Wednesday, March 8, 2017
  • by jandanielcz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Simona

Simple language used to specify when and to whom send notifications., (*1)

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., (*2)

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., (*3)

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

Examples

Notify responsible user one week before:, (*5)

(1):[responsible];

If task is one day delayed notify supervisor:, (*6)

(-1!):[supervisor];

If task is more than 3 days delayed notify all admins.:, (*7)

(-3..!):@admins;

We can combine rules to create simple escalation scenarios:, (*8)

(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., (*9)

(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., (*10)

Interval specification

For definition of days for notification Simone uses days count to task date:, (*11)


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., (*12)

Errors

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

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., (*14)

Limitations

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

The Versions

08/03 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • ext-mbstring *

 

The Development Requires

by Jan Daniel Dolezal

08/03 2017

1.1.1

1.1.1.0

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

  Sources   Download

MIT

The Requires

  • ext-mbstring *

 

The Development Requires

by Jan Daniel Dolezal

08/03 2017

1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Development Requires

by Jan Daniel Dolezal

08/03 2017

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Development Requires

by Jan Daniel Dolezal