Skip to content

Commit 96ab31d

Browse files
committed
Initial commit
0 parents  commit 96ab31d

File tree

9 files changed

+286
-0
lines changed

9 files changed

+286
-0
lines changed

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Linux
2+
# backup files
3+
*~
4+
5+
# Windows
6+
# thumbnails
7+
Thumbs.db
8+
9+
# Mac OS X
10+
# metadata
11+
.DS_Store
12+
# thumbnails
13+
._*
14+
15+
# Visual Studio PHP
16+
*.sln
17+
*.phpproj
18+
*.puo
19+
*.suo
20+
*.cache
21+
22+
# Netbeans
23+
nbproject/
24+
catalog.xml
25+
nbactions.xml
26+
27+
# Eclipse
28+
.settings/
29+
.buildpath
30+
.classpath
31+
.project
32+
33+
# SVN
34+
# svn folders
35+
.svn/
36+
37+
# PHPStorm
38+
.idea/
39+
.nameencodings
40+
.xmlmisc
41+
.xmlmodules
42+
.xmlprojectCodeStyle
43+
.xmlvcs.xml
44+
*.imlworkspace
45+
.xml
46+
47+
# Sublime Text 2
48+
*.sublime-*
49+
50+
# Textmate
51+
*.tmproj
52+
53+
# Community Framework
54+
# Ignore packages build directly in the workspace. They can however be added manually via git add, if wanted.
55+
*.tar
56+
*.tar.gz
57+
58+
# Javascript - CoffeeScript is used instead ;)
59+
*.js
60+
.sass-cache
61+
*.css
62+
63+
*.bak

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright © 2014 Maximilian Mader <max@bastelstu.be>
2+
This work is free. You can redistribute it and/or modify it under the
3+
terms of the Do What The Fuck You Want To Public License, Version 2,
4+
as published by Sam Hocevar.
5+
6+
---------------------------------------------------------------------
7+
8+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
9+
Version 2, December 2004
10+
11+
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
12+
13+
Everyone is permitted to copy and distribute verbatim or modified
14+
copies of this license document, and changing it is allowed as long
15+
as the name is changed.
16+
17+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
18+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
19+
20+
0. You just DO WHAT THE FUCK YOU WANT TO.
21+

contrib/build.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env php
2+
<?php
3+
namespace de\bisaboard\bisaboard;
4+
/**
5+
* Builds be.bastelstu.max.pushNotification
6+
*
7+
* @author Tim Düsterhus, edited by Maximilian Mader
8+
* @copyright 2012-2013 Tim Düsterhus
9+
* @license BSD 3-Clause License <http://opensource.org/licenses/BSD-3-Clause>
10+
* @package be.bastelstu.wcf.nodePush
11+
*/
12+
$packageXML = file_get_contents('package.xml');
13+
preg_match('/<version>(.*?)<\/version>/', $packageXML, $matches);
14+
echo "Building be.bastelstu.max.pushNotification $matches[1]\n";
15+
echo str_repeat("=", strlen("Building be.bastelstu.max.pushNotification $matches[1]"))."\n";
16+
17+
echo <<<EOT
18+
Cleaning up
19+
-----------
20+
21+
EOT;
22+
if (file_exists('package.xml.old')) {
23+
file_put_contents('package.xml', file_get_contents('package.xml.old'));
24+
unlink('package.xml.old');
25+
}
26+
if (file_exists('file.tar')) unlink('file.tar');
27+
if (file_exists('acptemplates.tar')) unlink('acptemplates.tars');
28+
if (file_exists('be.bastelstu.max.pushNotification')) unlink('be.bastelstu.max.pushNotification');
29+
echo <<<EOT
30+
31+
Checking PHP for Syntax Errors
32+
------------------------------
33+
34+
EOT;
35+
chdir('file');
36+
$check = null;
37+
$check = function ($folder) use (&$check) {
38+
if (is_file($folder)) {
39+
if (substr($folder, -4) === '.php') {
40+
passthru('php -l '.escapeshellarg($folder), $code);
41+
if ($code != 0) exit($code);
42+
}
43+
44+
return;
45+
}
46+
$file = glob($folder.'/*');
47+
foreach ($file as $file) {
48+
$check($file);
49+
}
50+
};
51+
$check('.');
52+
echo <<<EOT
53+
54+
Building file.tar
55+
------------------
56+
57+
EOT;
58+
passthru('tar cvf ../file.tar --exclude=.git -- *', $code);
59+
if ($code != 0) exit($code);
60+
echo <<<EOT
61+
62+
Building acptemplates.tar
63+
-------------------------
64+
65+
EOT;
66+
if (is_dir('../acptemplates')) {
67+
chdir('../acptemplates');
68+
passthru('tar cvf ../acptemplates.tar *', $code);
69+
if ($code != 0) exit($code);
70+
}
71+
else {
72+
echo 'No ACP templates found.';
73+
}
74+
75+
echo <<<EOT
76+
77+
Building be.bastelstu.max.pushNotification
78+
------------------------------------------
79+
80+
EOT;
81+
chdir('..');
82+
file_put_contents('package.xml.old', file_get_contents('package.xml'));
83+
file_put_contents('package.xml', preg_replace('~<date>\d{4}-\d{2}-\d{2}</date>~', '<date>'.date('Y-m-d').'</date>', file_get_contents('package.xml')));
84+
passthru('tar cvf be.bastelstu.max.pushNotification.tar --exclude=*.old --exclude=file --exclude=contrib -- *', $code);
85+
if (file_exists('package.xml.old')) {
86+
file_put_contents('package.xml', file_get_contents('package.xml.old'));
87+
unlink('package.xml.old');
88+
}
89+
if ($code != 0) exit($code);
90+
91+
if (file_exists('file.tar')) unlink('file.tar');
92+
if (file_exists('acptemplates.tar')) unlink('acptemplates.tar');

eventListener.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/eventListener.xsd">
3+
<import>
4+
<eventlistener>
5+
<eventclassname>wcf\data\user\notification\UserNotificationAction</eventclassname>
6+
<eventname>finalizeAction</eventname>
7+
<listenerclassname>wcf\system\event\listener\UserNotificationNodePushListener</listenerclassname>
8+
<environment>user</environment>
9+
</eventlistener>
10+
</import>
11+
</data>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
namespace wcf\system\event\listener;
3+
use wcf\system\event\IEventListener;
4+
5+
/**
6+
* Sends notifications to users via nodePush
7+
*
8+
* @author Maximilian Mader
9+
* @copyright 2014 Maximilian Mader
10+
* @license DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 <http://www.wtfpl.net/about/>
11+
* @package com.woltlab.wcf
12+
* @subpackage system.event.listener
13+
* @category Community Framework
14+
*/
15+
class UserNotificationNodePushListener implements IEventListener {
16+
/**
17+
* @see \wcf\system\event\IEventListener::execute()
18+
*/
19+
public function execute($eventObj, $className, $eventName) {
20+
if ($eventObj->getActionName() !== 'addRecipients') return;
21+
22+
$parameters = $eventObj->getParameters();
23+
24+
$recipients = array_map(function($user) {
25+
return $user->userID;
26+
}, $parameters['recipients']);
27+
28+
\wcf\system\nodePush\NodePushHandler::getInstance()->sendMessage('be.bastelstu.max.wcf.user.newNotification', $recipients);
29+
}
30+
}

language/de.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de">
3+
<category name="wcf.user.notification">
4+
<item name="wcf.user.notification.new"><![CDATA[Sie haben eine neue Benachrichtigung erhalten.]]></item>
5+
</category>
6+
</language>

language/en.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en">
3+
<category name="wcf.user.notification">
4+
<item name="wcf.user.notification.new"><![CDATA[You have received a new notification.]]></item>
5+
</category>
6+
</language>

package.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package name="be.bastelstu.max.wcf.pushNotification" xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/package.xsd">
3+
<packageinformation>
4+
<packagename language="de"><![CDATA[nodePush-Benachrichtigungen]]></packagename>
5+
<packagename language="en"><![CDATA[nodePush notifications]]></packagename>
6+
<packagedescription language="de"><![CDATA[Zeigt ein Benachrichtigungs-Pop-Up beim Erhalt neuer Benachrichtigungen an.]]></packagedescription>
7+
<packagedescription language="en"><![CDATA[Shows a notification pop-up when receiving new notifications.]]></packagedescription>
8+
<version>1.0.0</version>
9+
<date>2014-08-14</date>
10+
</packageinformation>
11+
12+
<authorinformation>
13+
<author><![CDATA[Maximilian Mader]]></author>
14+
<authorurl><![CDATA[http://tims.bastelstu.be]]></authorurl>
15+
</authorinformation>
16+
17+
<requiredpackages>
18+
<requiredpackage minversion="2.0.0">com.woltlab.wcf</requiredpackage>
19+
</requiredpackages>
20+
21+
<excludedpackages>
22+
<excludedpackage version="2.1.0">com.woltlab.wcf</excludedpackage>
23+
</excludedpackages>
24+
25+
<instructions type="install">
26+
<instruction type="language">language/*.xml</instruction>
27+
<instruction type="file">file.tar</instruction>
28+
<instruction type="eventListener">eventListener.xml</instruction>
29+
<instruction type="templateListener">templateListener.xml</instruction>
30+
</instructions>
31+
32+
<instructions type="update" fromversion="*">
33+
<instruction type="language">language/*.xml</instruction>
34+
<instruction type="file">file.tar</instruction>
35+
<instruction type="eventListener">eventListener.xml</instruction>
36+
<instruction type="templateListener">templateListener.xml</instruction>
37+
</instructions>
38+
</package>

templateListener.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/templateListener.xsd">
3+
<import>
4+
<templatelistener name="userNotificationNodePushListener">
5+
<environment>user</environment>
6+
<templatename>headInclude</templatename>
7+
<eventname>javascriptInit</eventname>
8+
<templatecode><![CDATA[{if $__wcf->user->userID}
9+
(function() {
10+
var notification = new WCF.System.Notification('{lang}wcf.user.notification.new{/lang}', 'info');
11+
12+
be.bastelstu.wcf.nodePush.onMessage('be.bastelstu.max.wcf.user.newNotification', function() {
13+
// You have mail!
14+
notification.show(null, 10e3);
15+
});
16+
})();{/if}]]></templatecode>
17+
</templatelistener>
18+
</import>
19+
</data>

0 commit comments

Comments
 (0)