看板初始化提交

This commit is contained in:
zephyr
2026-06-01 21:23:12 -07:00
commit 27411ebedc
1827 changed files with 192340 additions and 0 deletions
@@ -0,0 +1,48 @@
<?php
namespace Kanboard\Notification;
use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/**
* Activity Stream Notification
*
* @package Kanboard\Notification
* @author Frederic Guillot
*/
class ActivityStreamNotification extends Base implements NotificationInterface
{
/**
* Send notification to a user
*
* @access public
* @param array $user
* @param string $event_name
* @param array $event_data
*/
public function notifyUser(array $user, $event_name, array $event_data)
{
}
/**
* Send notification to a project
*
* @access public
* @param array $project
* @param string $event_name
* @param array $event_data
*/
public function notifyProject(array $project, $event_name, array $event_data)
{
if ($this->userSession->isLogged()) {
$this->projectActivityModel->createEvent(
$project['id'],
$event_data['task']['id'],
$this->userSession->getId(),
$event_name,
$event_data
);
}
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace Kanboard\Notification;
use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/**
* Email Notification
*
* @package Kanboard\Notification
* @author Frederic Guillot
*/
class MailNotification extends Base implements NotificationInterface
{
/**
* Notification type
*
* @var string
*/
const TYPE = 'email';
/**
* Send notification to a user
*
* @access public
* @param array $user
* @param string $event_name
* @param array $event_data
*/
public function notifyUser(array $user, $event_name, array $event_data)
{
if (! empty($user['email'])) {
$this->emailClient->send(
$user['email'],
$user['name'] ?: $user['username'],
$this->getMailSubject($event_name, $event_data),
$this->getMailContent($event_name, $event_data)
);
}
}
/**
* Send notification to a project
*
* @access public
* @param array $project
* @param string $event_name
* @param array $event_data
*/
public function notifyProject(array $project, $event_name, array $event_data)
{
}
/**
* Get the mail content for a given template name
*
* @access public
* @param string $event_name Event name
* @param array $event_data Event data
* @return string
*/
public function getMailContent($event_name, array $event_data)
{
return $this->template->render('notification/'.str_replace('.', '_', $event_name), $event_data);
}
/**
* Get the mail subject for a given template name
*
* @access public
* @param string $eventName Event name
* @param array $eventData Event data
* @return string
*/
public function getMailSubject($eventName, array $eventData)
{
return sprintf(
'[%s] %s',
isset($eventData['project_name']) ? $eventData['project_name'] : $eventData['task']['project_name'],
$this->notificationModel->getTitleWithoutAuthor($eventName, $eventData)
);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Kanboard\Notification;
use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/**
* Web Notification
*
* @package Kanboard\Notification
* @author Frederic Guillot
*/
class WebNotification extends Base implements NotificationInterface
{
/**
* Notification type
*
* @var string
*/
const TYPE = 'web';
/**
* Send notification to a user
*
* @access public
* @param array $user
* @param string $event_name
* @param array $event_data
*/
public function notifyUser(array $user, $event_name, array $event_data)
{
$this->userUnreadNotificationModel->create($user['id'], $event_name, $event_data);
}
/**
* Send notification to a project
*
* @access public
* @param array $project
* @param string $event_name
* @param array $event_data
*/
public function notifyProject(array $project, $event_name, array $event_data)
{
}
}
+62
View File
@@ -0,0 +1,62 @@
<?php
namespace Kanboard\Notification;
use Kanboard\Core\Base;
use Kanboard\Core\Notification\NotificationInterface;
/**
* Webhook Notification
*
* @package Kanboard\Notification
* @author Frederic Guillot
*/
class WebhookNotification extends Base implements NotificationInterface
{
/**
* Send notification to a user
*
* @access public
* @param array $user
* @param string $event_name
* @param array $event_data
*/
public function notifyUser(array $user, $event_name, array $event_data)
{
}
/**
* Send notification to a project
*
* @access public
* @param array $project
* @param string $event_name
* @param array $event_data
*/
public function notifyProject(array $project, $event_name, array $event_data)
{
$url = $this->configModel->get('webhook_url');
$token = $this->configModel->get('webhook_token');
if (! empty($url)) {
if (! WEBHOOK_ALLOW_PRIVATE_NETWORKS && $this->httpClient->isPrivateURL($url)) {
$this->logger->info('Blocked webhook request to private network URL: '.$url);
return;
}
if (strpos($url, '?') !== false) {
$url .= '&token='.$token;
} else {
$url .= '?token='.$token;
}
$payload = array(
'event_name' => $event_name,
'event_data' => $event_data,
'event_author' => ($this->userSession->isLogged() ? $this->userSession->getUsername() : null),
);
$this->httpClient->postJson($url, $payload, [], false, false);
}
}
}