Browse Source

Fix displaying the options in the UI only when the user has permissions

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/353/head
Joas Schilling 8 years ago
parent
commit
c7a3c95962
No known key found for this signature in database GPG Key ID: E166FD8976B3BAC8
  1. 4
      css/style.css
  2. 19
      js/views/roomlistview.js
  3. 24
      lib/Controller/RoomController.php

4
css/style.css

@ -525,6 +525,10 @@ video {
overflow: hidden;
}
#app-navigation .app-navigation-entry-menu input.first-option {
margin-top: 5px;
}
#app-navigation .app-navigation-entry-menu li span {
display: inline-block;
height: 36px;

19
js/views/roomlistview.js

@ -42,6 +42,7 @@
'</div>'+
'<div class="app-navigation-entry-menu">'+
'<ul class="app-navigation-entry-menu-list">'+
'{{#if canModerate}}'+
'<li>'+
'<button class="add-person-button">'+
'<span class="icon-add"></span>'+
@ -67,6 +68,13 @@
'<div class="clipboardButton icon-clippy private-room" data-clipboard-target="#shareInput-{{id}}"></div>'+
'<div class="icon-delete private-room"></div>'+
'</li>'+
'{{/if}}'+
'{{#if showShareLink}}'+
'<li>'+
'<input id="shareInput-{{id}}" class="share-link-input private-room first-option" readonly="readonly" type="text"/>'+
'<div class="clipboardButton icon-clippy private-room" data-clipboard-target="#shareInput-{{id}}"></div>'+
'</li>'+
'{{/if}}'+
'<li>'+
'<button class="leave-room-button">'+
'<span class="{{#if isDeletable}}icon-close{{else}}icon-delete{{/if}}"></span>'+
@ -82,9 +90,11 @@
'</li>'+
'{{/if}}'+
'</ul>'+
'{{#if canModerate}}'+
'<form class="oca-spreedme-add-person hidden">'+
'<input class="add-person-input" type="text" placeholder="Type name..."/>'+
'</form>'+
'{{/if}}'+
'</div>';
var RoomItenView = Marionette.View.extend({
@ -116,6 +126,15 @@
}
});
},
templateContext: function() {
var canModerate = this.model.get('participantType') === 1 || this.model.get('participantType') === 2;
return {
canModerate: canModerate,
showShareLink: !canModerate && this.model.get('type') === ROOM_TYPE_PUBLIC_CALL,
isNameEditable: canModerate && this.model.get('type') !== ROOM_TYPE_ONE_TO_ONE,
isDeletable: canModerate && (Object.keys(this.model.get('participants')).length > 2 || this.model.get('numGuests') > 0)
}
},
onRender: function() {
var roomURL, completeURL;

24
lib/Controller/RoomController.php

@ -162,7 +162,14 @@ class RoomController extends OCSController {
$participantType = Participant::GUEST;
}
$canModerate = $participantType === Participant::MODERATOR || $participantType === Participant::OWNER;
$activeGuests = array_filter($participants['guests'], function($data) {
return $data['lastPing'] > time() - 30;
});
$numActiveGuests = count($activeGuests);
if ($numActiveGuests !== count($participants['guests'])) {
$room->cleanGuestParticipants();
}
$roomData = [
'id' => $room->getId(),
@ -170,25 +177,14 @@ class RoomController extends OCSController {
'type' => $room->getType(),
'name' => $room->getName(),
'displayName' => $room->getName(),
'isNameEditable' => $room->getType() !== Room::ONE_TO_ONE_CALL,
'isModerator' => $participantType === Participant::MODERATOR,
'isOwner' => $participantType === Participant::OWNER,
'isDeletable' => $canModerate && (count($participantList) > 2 || !empty($participants['guests'])),
'participantType' => $participantType,
'count' => $room->getNumberOfParticipants(time() - 30),
'lastPing' => isset($participants['users'][$this->userId]['lastPing']) ? $participants['users'][$this->userId]['lastPing'] : 0,
'sessionId' => isset($participants['users'][$this->userId]['sessionId']) ? $participants['users'][$this->userId]['sessionId'] : '0',
'participants' => $participantList,
'numGuests' => $numActiveGuests,
];
$activeGuests = array_filter($participants['guests'], function($data) {
return $data['lastPing'] > time() - 30;
});
$numActiveGuests = count($activeGuests);
if ($numActiveGuests !== count($participants['guests'])) {
$room->cleanGuestParticipants();
}
if ($this->userId !== null) {
unset($participantList[$this->userId]);
$numOtherParticipants = count($participantList);

Loading…
Cancel
Save