메시지 시스템 외부로 연결중.
This commit is contained in:
+16
-3
@@ -104,6 +104,18 @@ class Message
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toArray():array{
|
||||
return [
|
||||
'id'=>$this->id,
|
||||
'msgType'=>$this->msgType,
|
||||
'src'=>($this->src)?($this->src->toArray()):[],
|
||||
'dest'=>($this->dest)?($this->dest->toArray()):[],
|
||||
'msg'=>$this->msg,
|
||||
'msgOption'=>$this->msgOption,
|
||||
'time'=>$this->date->format('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $row) : Message
|
||||
{
|
||||
$dbMessage = Json::decode($row['message']);
|
||||
@@ -165,7 +177,8 @@ class Message
|
||||
public static function getMessageByID(int $messageID) : Message
|
||||
{
|
||||
$db = DB::db();
|
||||
$row = $db->queryFirstRow('SELECT * FROM `message` WHERE `id` = %i', $messageID);
|
||||
$now = new \DateTime();
|
||||
$row = $db->queryFirstRow('SELECT * FROM `message` WHERE `id` = %i AND ValidUntil', $messageID);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
@@ -232,8 +245,8 @@ class Message
|
||||
'time' => $this->date->format('Y-m-d H:i:s'),
|
||||
'valid_until' => $this->validUntil->format('Y-m-d H:i:s'),
|
||||
'message' => Json::encode([
|
||||
'src' => $this->src->toArray(),
|
||||
'dest' =>$this->dest->toArray(),
|
||||
'src'=>($this->src)?($this->src->toArray()):[],
|
||||
'dest'=>($this->dest)?($this->dest->toArray()):[],
|
||||
'text' => $this->msg,
|
||||
'option' => $this->msgOption
|
||||
])
|
||||
|
||||
+28
-10
@@ -8,32 +8,49 @@ class MessageTarget extends Target {
|
||||
public $nationName;
|
||||
/** @var string */
|
||||
public $color;
|
||||
/** @var string */
|
||||
public $icon;
|
||||
|
||||
public function __construct(int $generalID, string $generalName, int $nationID, string $nationName, string $color){
|
||||
public function __construct(
|
||||
int $generalID,
|
||||
string $generalName,
|
||||
int $nationID,
|
||||
string $nationName,
|
||||
string $color,
|
||||
string $icon=''
|
||||
){
|
||||
|
||||
parent::__construct($generalID, $nationID);
|
||||
|
||||
if($mailbox > Message::MAILBOX_NATIONAL){
|
||||
$this->isGeneral = false;
|
||||
}
|
||||
else{
|
||||
$this->isGeneral = true;
|
||||
if(!$icon){
|
||||
$icon = ServConfig::getSharedIconPath().'/default.jpg';
|
||||
}
|
||||
|
||||
$this->generalName = $generalName;
|
||||
$this->nationName = $nationName;
|
||||
$this->color = $color;
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $arr) : MessageTarget
|
||||
{
|
||||
if(!Util::array_get($arr['nation'])){
|
||||
if(!$arr){
|
||||
return null;
|
||||
}
|
||||
if(!Util::array_get($arr['nation_id'])){
|
||||
$arr['nation'] = '재야';
|
||||
$arr['color'] = '#ffffff';
|
||||
$arr['color'] = '#000000';
|
||||
$arr['nation_id'] = 0;
|
||||
}
|
||||
|
||||
return new MessageTarget($arr['id'], $arr['name'], $arr['nation_id'], $arr['nation'], $arr['color']);
|
||||
return new MessageTarget(
|
||||
$arr['id'],
|
||||
$arr['name'],
|
||||
$arr['nation_id'],
|
||||
$arr['nation'],
|
||||
$arr['color'],
|
||||
$arr['icon']??''
|
||||
);
|
||||
}
|
||||
|
||||
public function toArray() : array{
|
||||
@@ -42,7 +59,8 @@ class MessageTarget extends Target {
|
||||
'name'=>$this->generalName,
|
||||
'nation_id'=>$this->nationID,
|
||||
'nation'=>$this->nationName,
|
||||
'color'=>$this->color
|
||||
'color'=>$this->color,
|
||||
'icon'=>$this->icon
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user