From: Christian Weiske Date: Wed, 20 Dec 2023 21:12:17 +0000 (+0100) Subject: Update phing build script to use composer installation only X-Git-Tag: v0.7.0 X-Git-Url: https://git.cweiske.de/bdrem.git/commitdiff_plain/refs/remotes/github/master?hp=d6b4a3d614aeaccf45fb047a3e990f77b935a333 Update phing build script to use composer installation only --- diff --git a/.gitignore b/.gitignore index 17e3ba1..2512199 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /lib /bin/phar-bdrem.php /README.html +vendor/ diff --git a/ChangeLog b/ChangeLog index 53065e8..eb0b2c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2023-12-20 Christian Weiske + + * Add support for vCard folder source + * Version 0.7.0 + +2016-06-21 Christian Weiske + + * Inline CSS for HTML mails improves compatibility with mail clients + * Dummy data set for testing + * Version 0.6.1 + 2015-03-18 Christian Weiske * New source: CSV file @@ -13,4 +24,3 @@ * Output: HTML * Output: iCalendar * Version 0.5.0 - diff --git a/README.rst b/README.rst index e503d3b..1257d36 100644 --- a/README.rst +++ b/README.rst @@ -17,9 +17,11 @@ Data sources - Any SQL database. - Multiple date fields per record supported. -- An LDAP server +- An LDAP server with ``evolutionPerson`` records - `Birthday reminder `_ files (``.bdf``) - CSV files +- A directory of .vcf vCard files + Output formats ============== @@ -41,9 +43,9 @@ After configuration_, you can test and use *bdrem* via command line:: ----------------------------------------------------------- Days Age Name Event Date Day ----------------------------------------------------------- - 0 32 Foo Bar Birthday 20.03.1982 Do - 1 33 Andrea Milestone Birthday 21.03.1981 Fr - 7 32 Hugh Success Birthday 27.03.1982 Do + 0 32 Foo Bar Birthday 20.03.1982 Do + 1 33 Andrea Milestone Birthday 21.03.1981 Fr + 7 32 Hugh Success Birthday 27.03.1982 Do 12 Welt Scherztag 01.04.???? Di Help @@ -53,7 +55,7 @@ To find out about all supported command line options, use ``--help``:: Usage: ./bin/bdrem.php [options] ./bin/bdrem.php [options] [options] - + Options: -n NUM, --next=NUM Show NUM days after date -p NUM, --prev=NUM Show NUM days before date @@ -62,9 +64,11 @@ To find out about all supported command line options, use ``--help``:: -e, --stoponempty Output nothing when list is empty -d date, --date=date Date to show events for -c FILE, --config=FILE Path to configuration file + --debug Development helper (mail) + --no-color Do not output ANSI color codes -h, --help show this help message and exit -v, --version show the program version and exit - + Commands: readme Show README.rst file config Extract configuration file @@ -130,8 +134,8 @@ Configure your source as follows:: $source = array('Bdf', '/path/to/birthday.bdf'); -__ http://cweiske.de/birthday.htm -__ http://cweiske.de/birthday3.htm +__ http://cweiske.de/birthday.htm +__ http://cweiske.de/birthday3.htm CSV file @@ -174,7 +178,7 @@ Configuration options Default: ``array('name' => 0, 'event' => 1, 'date' => 2)`` - + ``defaultEvent`` Text to use as event if there is no event column. @@ -276,6 +280,10 @@ Dependencies Note that the ``.phar`` file already includes all dependencies; you do not need to install anything. +When running from a git checkout, install the dependencies with composer:: + + $ composer install + ======= License diff --git a/build.xml b/build.xml index 845a053..008e4cb 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - + @@ -12,17 +12,27 @@ + + + + + + + + + + + + + + - - - - - @@ -49,33 +59,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9524114 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "require": { + "pear/console_color2": "^0.1.2", + "pear/console_commandline": "^1.2", + "pear/console_table": "^1.3", + "pear/mail_mime": "^1.10", + "pear/net_ldap2": "^2.3", + "sabre/vobject": "^4.5" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..7d7e616 --- /dev/null +++ b/composer.lock @@ -0,0 +1,678 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "39ce09afd7a686424abd7e671905368d", + "packages": [ + { + "name": "pear/console_color2", + "version": "0.1.2", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_Color2.git", + "reference": "cab2b886aa55cc9e23464d1f49edf97bee9f5a63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_Color2/zipball/cab2b886aa55cc9e23464d1f49edf97bee9f5a63", + "reference": "cab2b886aa55cc9e23464d1f49edf97bee9f5a63", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Console_Color2": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniel O'Connor", + "email": "daniel.oconnor@gmail.com", + "role": "Pear Developer" + }, + { + "name": "Stefan Walk", + "email": "et@php.net" + }, + { + "name": "Scott Mattocks", + "email": "scottmattocks@php.net" + } + ], + "description": "This Class allows you to easily use ANSI console colors in your application.", + "homepage": "https://github.com/pear/Console_Color2", + "keywords": [ + "console" + ], + "support": { + "source": "https://github.com/pear/Console_Color2/tree/0.1.2" + }, + "time": "2012-10-23T11:52:18+00:00" + }, + { + "name": "pear/console_commandline", + "version": "v1.2.6", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_CommandLine.git", + "reference": "611c5bff2e47ec5a184748cb5fedc2869098ff28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_CommandLine/zipball/611c5bff2e47ec5a184748cb5fedc2869098ff28", + "reference": "611c5bff2e47ec5a184748cb5fedc2869098ff28", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xml": "*", + "pear/pear_exception": "^1.0.0", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "psr-0": { + "Console": "./" + }, + "exclude-from-classmap": [ + "tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Richard Quadling", + "email": "rquadling@gmail.com" + }, + { + "name": "David Jean Louis", + "email": "izimobil@gmail.com" + } + ], + "description": "A full featured command line options and arguments parser.", + "homepage": "https://github.com/pear/Console_CommandLine", + "keywords": [ + "console" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_CommandLine", + "source": "https://github.com/pear/Console_CommandLine" + }, + "time": "2023-04-02T18:49:53+00:00" + }, + { + "name": "pear/console_getopt", + "version": "v1.4.3", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_Getopt.git", + "reference": "a41f8d3e668987609178c7c4a9fe48fecac53fa0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/a41f8d3e668987609178c7c4a9fe48fecac53fa0", + "reference": "a41f8d3e668987609178c7c4a9fe48fecac53fa0", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Console": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "./" + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Andrei Zmievski", + "email": "andrei@php.net", + "role": "Lead" + }, + { + "name": "Stig Bakken", + "email": "stig@php.net", + "role": "Developer" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net", + "role": "Helper" + } + ], + "description": "More info available on: http://pear.php.net/package/Console_Getopt", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_Getopt", + "source": "https://github.com/pear/Console_Getopt" + }, + "time": "2019-11-20T18:27:48+00:00" + }, + { + "name": "pear/console_table", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/pear/Console_Table.git", + "reference": "1930c11897ca61fd24b95f2f785e99e0f36dcdea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Console_Table/zipball/1930c11897ca61fd24b95f2f785e99e0f36dcdea", + "reference": "1930c11897ca61fd24b95f2f785e99e0f36dcdea", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "suggest": { + "pear/Console_Color2": ">=0.1.2" + }, + "type": "library", + "autoload": { + "classmap": [ + "Table.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jan Schneider", + "homepage": "http://pear.php.net/user/yunosh" + }, + { + "name": "Tal Peer", + "homepage": "http://pear.php.net/user/tal" + }, + { + "name": "Xavier Noguer", + "homepage": "http://pear.php.net/user/xnoguer" + }, + { + "name": "Richard Heyes", + "homepage": "http://pear.php.net/user/richard" + } + ], + "description": "Library that makes it easy to build console style tables.", + "homepage": "http://pear.php.net/package/Console_Table/", + "keywords": [ + "console" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Console_Table", + "source": "https://github.com/pear/Console_Table" + }, + "time": "2018-01-25T20:47:17+00:00" + }, + { + "name": "pear/mail_mime", + "version": "1.10.11", + "source": { + "type": "git", + "url": "https://github.com/pear/Mail_Mime.git", + "reference": "d4fb9ce61201593d0f8c6db629c45e29c3409c14" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Mail_Mime/zipball/d4fb9ce61201593d0f8c6db629c45e29c3409c14", + "reference": "d4fb9ce61201593d0f8c6db629c45e29c3409c14", + "shasum": "" + }, + "require": { + "pear/pear-core-minimal": "*", + "php": ">=5.2.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Mail": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "./" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Cipriano Groenendal", + "email": "cipri@php.net", + "role": "Lead" + }, + { + "name": "Aleksander Machniak", + "email": "alec@php.net", + "role": "Lead" + } + ], + "description": "Mail_Mime provides classes to create MIME messages", + "homepage": "http://pear.php.net/package/Mail_Mime", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Mail_Mime", + "source": "https://github.com/pear/Mail_Mime" + }, + "time": "2021-09-05T08:42:45+00:00" + }, + { + "name": "pear/net_ldap2", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/pear/Net_LDAP2.git", + "reference": "6eae6d20533469ffe1c01684923cd09f0fae3b77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/Net_LDAP2/zipball/6eae6d20533469ffe1c01684923cd09f0fae3b77", + "reference": "6eae6d20533469ffe1c01684923cd09f0fae3b77", + "shasum": "" + }, + "require": { + "ext-ldap": "*", + "pear/pear-core-minimal": "^1.10.1" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^10.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Net/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "." + ], + "license": [ + "LGPL-3.0" + ], + "description": "Object oriented interface for searching and manipulating LDAP-entries", + "homepage": "http://pear.php.net/package/Net_LDAP2", + "keywords": [ + "PEAR", + "ldap" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_LDAP2", + "source": "https://github.com/pear/Net_LDAP2" + }, + "time": "2023-10-12T20:00:01+00:00" + }, + { + "name": "pear/pear-core-minimal", + "version": "v1.10.13", + "source": { + "type": "git", + "url": "https://github.com/pear/pear-core-minimal.git", + "reference": "aed862e95fd286c53cc546734868dc38ff4b5b1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/aed862e95fd286c53cc546734868dc38ff4b5b1d", + "reference": "aed862e95fd286c53cc546734868dc38ff4b5b1d", + "shasum": "" + }, + "require": { + "pear/console_getopt": "~1.4", + "pear/pear_exception": "~1.0" + }, + "replace": { + "rsky/pear-core-min": "self.version" + }, + "type": "library", + "autoload": { + "psr-0": { + "": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "src/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "cweiske@php.net", + "role": "Lead" + } + ], + "description": "Minimal set of PEAR core files to be used as composer dependency", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR", + "source": "https://github.com/pear/pear-core-minimal" + }, + "time": "2023-04-19T19:15:47+00:00" + }, + { + "name": "pear/pear_exception", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/pear/PEAR_Exception.git", + "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", + "reference": "b14fbe2ddb0b9f94f5b24cf08783d599f776fff0", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "<9" + }, + "type": "class", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "PEAR/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "." + ], + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Helgi Thormar", + "email": "dufuz@php.net" + }, + { + "name": "Greg Beaver", + "email": "cellog@php.net" + } + ], + "description": "The PEAR Exception base class.", + "homepage": "https://github.com/pear/PEAR_Exception", + "keywords": [ + "exception" + ], + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", + "source": "https://github.com/pear/PEAR_Exception" + }, + "time": "2021-03-21T15:43:46+00:00" + }, + { + "name": "sabre/uri", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "1774043c843f1db7654ecc93368a98be29b07544" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/1774043c843f1db7654ecc93368a98be29b07544", + "reference": "1774043c843f1db7654ecc93368a98be29b07544", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.17", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5", + "phpunit/phpunit": "^9.6" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/uri/issues", + "source": "https://github.com/fruux/sabre-uri" + }, + "time": "2023-06-09T07:04:02+00:00" + }, + { + "name": "sabre/vobject", + "version": "4.5.4", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/vobject.git", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/vobject/zipball/a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "reference": "a6d53a3e5bec85ed3dd78868b7de0f5b4e12f772", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabre/xml": "^2.1 || ^3.0 || ^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.17.1", + "phpstan/phpstan": "^0.12", + "phpunit/php-invoker": "^2.0 || ^3.1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.0" + }, + "suggest": { + "hoa/bench": "If you would like to run the benchmark scripts" + }, + "bin": [ + "bin/vobject", + "bin/generate_vcards" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabre\\VObject\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Dominik Tobschall", + "email": "dominik@fruux.com", + "homepage": "http://tobschall.de/", + "role": "Developer" + }, + { + "name": "Ivan Enderlin", + "email": "ivan.enderlin@hoa-project.net", + "homepage": "http://mnt.io/", + "role": "Developer" + } + ], + "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "homepage": "http://sabre.io/vobject/", + "keywords": [ + "availability", + "freebusy", + "iCalendar", + "ical", + "ics", + "jCal", + "jCard", + "recurrence", + "rfc2425", + "rfc2426", + "rfc2739", + "rfc4770", + "rfc5545", + "rfc5546", + "rfc6321", + "rfc6350", + "rfc6351", + "rfc6474", + "rfc6638", + "rfc6715", + "rfc6868", + "vCalendar", + "vCard", + "vcf", + "xCal", + "xCard" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/vobject/issues", + "source": "https://github.com/fruux/sabre-vobject" + }, + "time": "2023-11-09T12:54:37+00:00" + }, + { + "name": "sabre/xml", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/xml.git", + "reference": "99caa5dd248776ca6a1e1d2cfdef556a3fa63456" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/99caa5dd248776ca6a1e1d2cfdef556a3fa63456", + "reference": "99caa5dd248776ca6a1e1d2cfdef556a3fa63456", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "lib-libxml": ">=2.6.20", + "php": "^7.4 || ^8.0", + "sabre/uri": ">=2.0,<4.0.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.38", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.6" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Deserializer/functions.php", + "lib/Serializer/functions.php" + ], + "psr-4": { + "Sabre\\Xml\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Markus Staab", + "email": "markus.staab@redaxo.de", + "role": "Developer" + } + ], + "description": "sabre/xml is an XML library that you may not hate.", + "homepage": "https://sabre.io/xml/", + "keywords": [ + "XMLReader", + "XMLWriter", + "dom", + "xml" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/xml/issues", + "source": "https://github.com/fruux/sabre-xml" + }, + "time": "2023-11-09T10:47:15+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/data/bdrem.config.php.dist b/data/bdrem.config.php.dist index 3689d1b..55dbe81 100644 --- a/data/bdrem.config.php.dist +++ b/data/bdrem.config.php.dist @@ -1,57 +1,60 @@ '/path/to/file.csv', - 'columns' => array( + 'columns' => [ 'name' => 0, 'event' => 1, 'date' => 2 - ), + ], 'firstLineIsHeader' => true, 'defaultEvent' => 'Birthday', 'separator' => ',', - ) -); + ] +]; //Source: SQL database -$source = array( +$source = [ 'Sql', - array( + [ 'dsn' => 'mysql:dbname=bdrem;host=127.0.0.1', 'user' => 'FIXME', 'password' => 'FIXME', 'table' => 'contacts', - 'fields' => array( - 'date' => array( + 'fields' => [ + 'date' => [ //column name => event title 'c_birthday' => 'Birthday' - ), + ], //column with name, or array with column names - 'name' => array('c_name'), + 'name' => ['c_name'], //sprintf-compatible name formatting instruction 'nameFormat' => '%s', - ) - ) -); + ] + ] +]; //Source: LDAP -$source = array( +$source = [ 'Ldap', - array( + [ 'host' => 'ldap.example.org', 'basedn' => 'ou=adressbuch,dc=example,dc=org', 'binddn' => 'cn=FIXME,ou=users,dc=example,dc=org', 'bindpw' => 'FIXME' - ) -); + ] +]; + +//Source: Directory of .vcf vCard files (2 subfolder levels supported) +$source = ['vCard', '/home/user/contacts/']; $daysPrev = 3; @@ -60,5 +63,5 @@ $locale = 'de_DE.UTF-8'; //email settings $mail_from = 'birthday@example.org'; -$mail_to = array('a@example.org', 'b@example.org'); +$mail_to = ['a@example.org', 'b@example.org']; ?> diff --git a/src/bdrem/Autoloader.php b/src/bdrem/Autoloader.php index cebd0eb..e3884d9 100644 --- a/src/bdrem/Autoloader.php +++ b/src/bdrem/Autoloader.php @@ -52,6 +52,10 @@ class Autoloader get_include_path() . PATH_SEPARATOR . __DIR__ . '/../' ); spl_autoload_register(array(new self(), 'load')); + + if (file_exists(__DIR__ . '/../../vendor/autoload.php')) { + require_once __DIR__ . '/../../vendor/autoload.php'; + } } } -?> \ No newline at end of file +?> diff --git a/src/bdrem/Renderer.php b/src/bdrem/Renderer.php index 7357af6..6612447 100644 --- a/src/bdrem/Renderer.php +++ b/src/bdrem/Renderer.php @@ -74,7 +74,7 @@ abstract class Renderer */ protected function getLocalDate($dateStr) { - if ($dateStr{0} != '?') { + if ($dateStr[0] != '?') { return strftime('%x', strtotime($dateStr)); } diff --git a/src/bdrem/Renderer/Mail.php b/src/bdrem/Renderer/Mail.php index 0efa3af..2d526c0 100644 --- a/src/bdrem/Renderer/Mail.php +++ b/src/bdrem/Renderer/Mail.php @@ -69,6 +69,7 @@ class Renderer_Mail extends Renderer $hdrs = array( 'From' => $this->config->get('mail_from', 'birthday@example.org'), + 'Date' => date('r'), 'Auto-Submitted' => 'auto-generated' ); $mime = new \Mail_mime( @@ -241,4 +242,4 @@ class Renderer_Mail extends Renderer return $html; } } -?> \ No newline at end of file +?> diff --git a/src/bdrem/Source/vCard.php b/src/bdrem/Source/vCard.php new file mode 100644 index 0000000..3d55915 --- /dev/null +++ b/src/bdrem/Source/vCard.php @@ -0,0 +1,107 @@ + + * @copyright 2023 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @link http://cweiske.de/bdrem.htm + */ +namespace bdrem; + +use Sabre\VObject; +use Sabre\VObject\Component\VCard; + +/** + * Read a folder of vcard files + * 2 subfolder levels are supported. + * + * @category Tools + * @package Bdrem + * @author Christian Weiske + * @copyright 2023 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @link http://cweiske.de/bdrem.htm + */ +class Source_vCard +{ + /** + * Full path to a folder with .vcf files + */ + protected string $folder; + + /** + * Set the VCard folder path + */ + public function __construct($config) + { + if (is_string($config)) { + $config = array( + 'folder' => $config + ); + } + $this->folder = $config['folder']; + if (!is_dir($this->folder)) { + throw new \Exception( + 'VCard folder does not exist: ' . $this->folder + ); + } + } + + /** + * Return all events for the given date range + * + * @param string $strDate Date the events shall be found for, + * YYYY-MM-DD + * @param integer $nDaysPrevious Include number of days before $strDate + * @param integer $nDaysNext Include number of days after $strDate + * + * @return Event[] Array of matching event objects + */ + public function getEvents($strDate, $nDaysPrevious, $nDaysNext) + { + $vcfFiles = glob($this->folder . '/{*,*/*,*/*/*}.vcf', GLOB_BRACE); + if (count($vcfFiles) == 0) { + throw new \Exception('No .vcf files found in folder'); + } + + $arEvents = []; + foreach ($vcfFiles as $vcfFile) { + $vcard = VObject\Reader::read(file_get_contents($vcfFile)); + + if (isset($vcard->BDAY)) { + $event = new Event( + $this->getName($vcard), + 'Birthday', + $vcard->BDAY->getDateTime()->format('Y-m-d') + ); + if ($event->isWithin($strDate, $nDaysPrevious, $nDaysNext)) { + $arEvents[] = $event; + } + } + + if (isset($vcard->{'X-ANNIVERSARY'})) { + $event = new Event( + $this->getName($vcard), + 'Anniversary', + $vcard->{'X-ANNIVERSARY'}->getDateTime()->format('Y-m-d') + ); + if ($event->isWithin($strDate, $nDaysPrevious, $nDaysNext)) { + $arEvents[] = $event; + } + } + } + + return $arEvents; + } + + protected function getName(VCard $vcard) + { + return (string) $vcard->FN; + } +} +?>