2020-06-15 17:23:53 +02:00
|
|
|
<?php
|
2020-06-19 09:28:58 +02:00
|
|
|
|
2020-06-15 17:23:53 +02:00
|
|
|
namespace OCA\BigBlueButton\Db;
|
|
|
|
|
|
|
|
use JsonSerializable;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Db\Entity;
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
class RoomShare extends Entity implements JsonSerializable {
|
|
|
|
public const PERMISSION_ADMIN = 0;
|
|
|
|
public const PERMISSION_MODERATOR = 1;
|
|
|
|
public const PERMISSION_USER = 2;
|
2020-06-15 17:23:53 +02:00
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public const SHARE_TYPE_USER = 0;
|
|
|
|
public const SHARE_TYPE_GROUP = 1;
|
2020-06-15 17:23:53 +02:00
|
|
|
|
|
|
|
protected $roomId;
|
|
|
|
protected $shareType;
|
|
|
|
protected $shareWith;
|
|
|
|
protected $shareWithDisplayName;
|
|
|
|
protected $permission;
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function __construct() {
|
2020-06-15 17:23:53 +02:00
|
|
|
$this->addType('roomId', 'integer');
|
|
|
|
$this->addType('shareType', 'integer');
|
|
|
|
$this->addType('permission', 'integer');
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function jsonSerialize(): array {
|
2020-06-15 17:23:53 +02:00
|
|
|
return [
|
|
|
|
'id' => $this->id,
|
|
|
|
'roomId' => $this->roomId,
|
|
|
|
'shareType' => $this->shareType,
|
|
|
|
'shareWith' => $this->shareWith,
|
|
|
|
'shareWithDisplayName' => $this->shareWithDisplayName,
|
|
|
|
'permission' => $this->permission,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function hasUserPermission(): bool {
|
2020-06-15 17:23:53 +02:00
|
|
|
return $this->permission === self::PERMISSION_ADMIN || $this->permission === self::PERMISSION_MODERATOR || $this->permission === self::PERMISSION_USER;
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function hasModeratorPermission(): bool {
|
2020-06-15 17:23:53 +02:00
|
|
|
return $this->permission === self::PERMISSION_ADMIN || $this->permission === self::PERMISSION_MODERATOR;
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function hasAdminPermission(): bool {
|
2020-06-15 17:23:53 +02:00
|
|
|
return $this->permission === self::PERMISSION_ADMIN;
|
|
|
|
}
|
|
|
|
}
|