1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Add first pieces of invitation system

This commit is contained in:
Tim Düsterhus 2014-09-29 01:38:13 +02:00
parent e694e51354
commit 8397645354
8 changed files with 182 additions and 0 deletions

View File

@ -0,0 +1,75 @@
<?php
namespace chat\system\user\notification\event;
/**
*
*
* @author Tim Düsterhus
* @copyright 2010-2014 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.user.notification.event
*/
class InvitedUserNotificationEvent extends \wcf\system\user\notification\event\AbstractUserNotificationEvent {
/**
* @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
*/
protected $stackable = false;
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getAuthorID()
*/
public function getAuthorID() {
return $this->getAuthor()->userID;
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getAuthor()
*/
public function getAuthor() {
// TODO: caching
return new \wcf\data\user\UserProfile(new \wcf\data\user\User($this->additionalData['userID']));
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
*/
public function getTitle() {
return $this->getLanguage()->get('chat.notification.invited.title');
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
*/
public function getMessage() {
return $this->getLanguage()->getDynamicVariable('chat.notification.invited.message', array(
'userNotificationObject' => $this->userNotificationObject,
'author' => $this->author
));
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
*/
public function getLink() {
return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'application' => 'chat',
'object' => $this->userNotificationObject->getDecoratedObject()
));
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification()
*/
public function supportsEmailNotification() {
return false;
}
/**
* @see \wcf\system\user\notification\event\IUserNotificationEvent::checkAccess()
*/
public function checkAccess() {
// TODO
return true;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace chat\system\user\notification\object;
/**
*
*
* @author Tim Düsterhus
* @copyright 2010-2014 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.user.notification.object
*/
class RoomUserNotificationObject extends \wcf\data\DatabaseObjectDecorator implements \wcf\system\user\notification\object\IUserNotificationObject {
/**
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
*/
protected static $baseClass = 'chat\data\room\Room';
/**
* @see \wcf\system\user\notification\object\IUserNotificationObject::getObjectID()
*/
public function getObjectID() {
return $this->roomID;
}
/**
* @see \wcf\system\user\notification\object\IUserNotificationObject::getTitle()
*/
public function getTitle() {
return $this->getDecoratedObject()->getTitle();
}
/**
* @see \wcf\system\user\notification\object\IUserNotificationObject::getURL()
*/
public function getURL() {
return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(
'application' => 'chat',
'object' => $this->userNotificationObject->getRoom(),
));
}
/**
* @see \wcf\system\user\notification\object\IUserNotificationObject::getAuthorID()
*/
public function getAuthorID() {
// this value is ignored
return PHP_INT_MAX;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace chat\system\user\notification\object\type;
/**
*
*
* @author Tim Düsterhus
* @copyright 2010-2014 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.user.notification.object.type
*/
class RoomUserNotificationObjectType extends \wcf\system\user\notification\object\type\AbstractUserNotificationObjectType {
/**
* @see \wcf\system\user\notification\object\type\AbstractUserNotificationObjectType::$decoratorClassName
*/
protected static $decoratorClassName = 'chat\system\user\notification\object\RoomUserNotificationObject';
/**
* @see \wcf\system\user\notification\object\type\AbstractUserNotificationObjectType::$objectClassName
*/
protected static $objectClassName = 'chat\data\room\Room';
/**
* @see \wcf\system\user\notification\object\type\AbstractUserNotificationObjectType::$objectListClassName
*/
protected static $objectListClassName = 'chat\data\room\RoomList';
}

View File

@ -39,6 +39,11 @@
<item name="chat.acp.menu.link.suspension.list"><![CDATA[Sanktionen auflisten]]></item>
</category>
<category name="chat.notification">
<item name="chat.notification.invited.title"><![CDATA[Jemand möchte mit Ihnen chatten!]]></item>
<item name="chat.notification.invited.message"><![CDATA[„{$author->username}“ möchte mit Ihnen im Chatraum „{$userNotificationObject->getTitle()}“ chatten!]]></item>
</category>
<category name="wcf.acl.option">
<item name="wcf.acl.option.category.be.bastelstu.chat.room.user"><![CDATA[Benutzerrechte]]></item>
<item name="wcf.acl.option.category.be.bastelstu.chat.room.mod"><![CDATA[Moderative Rechte]]></item>

View File

@ -39,6 +39,11 @@
<item name="chat.acp.menu.link.suspension.list"><![CDATA[List Suspensions]]></item>
</category>
<category name="chat.notification">
<item name="chat.notification.invited.title"><![CDATA[TODO: Jemand möchte mit Ihnen chatten!]]></item>
<item name="chat.notification.invited.message"><![CDATA[TODO: „{$author->username}“ möchte mit Ihnen im Chatraum „{$userNotificationObject->getTitle()}“ chatten!]]></item>
</category>
<category name="wcf.acl.option">
<item name="wcf.acl.option.category.be.bastelstu.chat.room.user"><![CDATA[User Permissions]]></item>
<item name="wcf.acl.option.category.be.bastelstu.chat.room.mod"><![CDATA[Moderator Permissions]]></item>

View File

@ -27,5 +27,11 @@
<definitionname>com.woltlab.wcf.attachment.objectType</definitionname>
<classname>chat\system\attachment\MessageAttachmentObjectType</classname>
</type>
<type>
<name>be.bastelstu.chat.room</name>
<definitionname>com.woltlab.wcf.notification.objectType</definitionname>
<classname>chat\system\user\notification\object\type\RoomUserNotificationObjectType</classname>
<category>be.bastelstu.chat</category>
</type>
</import>
</data>

View File

@ -29,6 +29,7 @@
<instruction type="acpTemplate">acptemplate.tar</instruction>
<instruction type="sql">install.sql</instruction>
<instruction type="objectType">objectType.xml</instruction>
<instruction type="userNotificationEvent">userNotificationEvent.xml</instruction>
<instruction type="option">option.xml</instruction>
<instruction type="templateListener">templateListener.xml</instruction>
<instruction type="pageMenu">pageMenu.xml</instruction>

12
userNotificationEvent.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/userNotificationEvent.xsd">
<import>
<event>
<name>invited</name>
<objecttype>be.bastelstu.chat.room</objecttype>
<classname>chat\system\user\notification\event\InvitedUserNotificationEvent</classname>
<preset>1</preset>
<options>module_chat</options>
</event>
</import>
</data>