2014-12-09 22:57:25 +00:00
|
|
|
<?php
|
|
|
|
namespace chat\data\user;
|
|
|
|
use wcf\system\WCF;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User related chat actions.
|
|
|
|
*
|
|
|
|
* @author Maximilian Mader
|
|
|
|
* @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 data.user
|
|
|
|
*/
|
|
|
|
class UserAction extends \wcf\data\AbstractDatabaseObjectAction {
|
2014-12-09 23:18:21 +00:00
|
|
|
/**
|
|
|
|
* @see \wcf\data\AbstractDatabaseObjectAction::$className
|
|
|
|
*/
|
2014-12-09 22:57:25 +00:00
|
|
|
protected $className = 'wcf\data\user\UserEditor';
|
|
|
|
|
2014-12-09 23:18:21 +00:00
|
|
|
/**
|
|
|
|
* Validates invite preparation.
|
|
|
|
*/
|
2014-12-09 22:57:25 +00:00
|
|
|
public function validatePrepareInvite() {
|
|
|
|
// Todo: Proper validation
|
|
|
|
}
|
|
|
|
|
2014-12-09 23:18:21 +00:00
|
|
|
/**
|
|
|
|
* Prepares invites.
|
|
|
|
*/
|
2014-12-09 22:57:25 +00:00
|
|
|
public function prepareInvite() {
|
|
|
|
$followingList = new \wcf\data\user\follow\UserFollowingList();
|
|
|
|
$followingList->getConditionBuilder()->add('user_follow.userID = ?', array(WCF::getUser()->userID));
|
|
|
|
$followingList->readObjects();
|
|
|
|
$users = $followingList->getObjects();
|
|
|
|
|
|
|
|
WCF::getTPL()->assign(array(
|
|
|
|
'users' => $users
|
|
|
|
));
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'template' => WCF::getTPL()->fetch('userInviteDialog', 'chat')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-12-09 23:18:21 +00:00
|
|
|
/**
|
|
|
|
* Validates invites.
|
|
|
|
*/
|
2014-12-09 22:57:25 +00:00
|
|
|
public function validateInvite() {
|
2014-12-09 23:18:21 +00:00
|
|
|
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
|
2014-12-09 22:57:25 +00:00
|
|
|
|
|
|
|
if (WCF::getUser()->chatRoomID) {
|
|
|
|
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom(WCF::getUser()->chatRoomID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw new \wcf\system\exception\UserInputException("roomID");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 23:18:21 +00:00
|
|
|
/**
|
|
|
|
* Invites users.
|
|
|
|
*/
|
2014-12-09 22:57:25 +00:00
|
|
|
public function invite() {
|
2014-12-09 23:18:21 +00:00
|
|
|
\wcf\system\user\notification\UserNotificationHandler::getInstance()->fireEvent('invited', 'be.bastelstu.chat.room', new \chat\system\user\notification\object\RoomUserNotificationObject($this->room), $this->parameters['recipients'], array('userID' => WCF::getUser()->userID));
|
2014-12-09 22:57:25 +00:00
|
|
|
}
|
|
|
|
}
|