[various] Move Notify "type" and "otype" into own enum classes #956

Merged
nupplaphil merged 2 commits from task/move_enotify_parts into develop 2020-02-06 02:29:31 +01:00
3 changed files with 8 additions and 5 deletions

View file

@ -11,6 +11,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Notify\Type;
function gnot_install() { function gnot_install() {
@ -92,6 +93,6 @@ function gnot_settings(&$a,&$s) {
function gnot_enotify_mail(&$a,&$b) { function gnot_enotify_mail(&$a,&$b) {
if((! $b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable')))) if((! $b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable'))))
return; return;
if($b['type'] == NOTIFY_COMMENT) if($b['type'] == Type::COMMENT)
$b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']); $b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);
} }

View file

@ -13,6 +13,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Notify\Type;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -67,7 +68,7 @@ function public_server_cron($a, $b)
foreach ($r as $rr) { foreach ($r as $rr) {
notification([ notification([
'uid' => $rr['uid'], 'uid' => $rr['uid'],
'type' => NOTIFY_SYSTEM, 'type' => Type::SYSTEM,
'system_type' => 'public_server_expire', 'system_type' => 'public_server_expire',
'language' => $rr['language'], 'language' => $rr['language'],
'to_name' => $rr['username'], 'to_name' => $rr['username'],
@ -123,7 +124,7 @@ function public_server_cron($a, $b)
function public_server_enotify(&$a, &$b) function public_server_enotify(&$a, &$b)
{ {
if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM if (!empty($b['params']) && $b['params']['type'] == Type::SYSTEM
&& !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'public_server_expire') {
$b['itemlink'] = DI::baseUrl()->get(); $b['itemlink'] = DI::baseUrl()->get();
$b['epreamble'] = $b['preamble'] = DI::l10n()->t('Your account on %s will expire in a few days.', DI::config()->get('system', 'sitename')); $b['epreamble'] = $b['preamble'] = DI::l10n()->t('Your account on %s will expire in a few days.', DI::config()->get('system', 'sitename'));

View file

@ -11,6 +11,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Notify\Type;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\ConfigFileLoader; use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -69,7 +70,7 @@ function testdrive_cron($a,$b) {
foreach($r as $rr) { foreach($r as $rr) {
notification([ notification([
'uid' => $rr['uid'], 'uid' => $rr['uid'],
'type' => NOTIFY_SYSTEM, 'type' => Type::SYSTEM,
'system_type' => 'testdrive_expire', 'system_type' => 'testdrive_expire',
'language' => $rr['language'], 'language' => $rr['language'],
'to_name' => $rr['username'], 'to_name' => $rr['username'],
@ -96,7 +97,7 @@ function testdrive_cron($a,$b) {
} }
function testdrive_enotify(&$a, &$b) { function testdrive_enotify(&$a, &$b) {
if (!empty($b['params']) && $b['params']['type'] == NOTIFY_SYSTEM if (!empty($b['params']) && $b['params']['type'] == Type::SYSTEM
&& !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') { && !empty($b['params']['system_type']) && $b['params']['system_type'] === 'testdrive_expire') {
$b['itemlink'] = DI::baseUrl()->get(); $b['itemlink'] = DI::baseUrl()->get();
$b['epreamble'] = $b['preamble'] = DI::l10n()->t('Your account on %s will expire in a few days.', DI::config()->get('system', 'sitename')); $b['epreamble'] = $b['preamble'] = DI::l10n()->t('Your account on %s will expire in a few days.', DI::config()->get('system', 'sitename'));