also guard deleteEntity and getEntityProperties with canEdit. make canEdit available to javascript

This commit is contained in:
Seth Alves 2015-02-05 16:22:52 -08:00
parent d19ab4c36f
commit bad44c540a
2 changed files with 29 additions and 20 deletions

View file

@ -73,6 +73,8 @@ EntityItemID EntityScriptingInterface::identifyEntity(EntityItemID entityID) {
EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID entityID) {
EntityItemProperties results;
if (canEdit()) {
EntityItemID identity = identifyEntity(entityID);
if (_entityTree) {
_entityTree->lockForRead();
@ -98,6 +100,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
}
_entityTree->unlock();
}
}
return results;
}
@ -148,6 +151,9 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E
void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
if (! canEdit())
return;
EntityItemID actualID = entityID;
// if the entity is unknown, attempt to look it up

View file

@ -60,9 +60,12 @@ public:
void setEntityTree(EntityTree* modelTree) { _entityTree = modelTree; }
EntityTree* getEntityTree(EntityTree*) { return _entityTree; }
bool canEdit();
public slots:
// returns true if the DomainServer will allow this Node/Avatar to make changes
Q_INVOKABLE bool canEdit();
/// adds a model with the specific properties
Q_INVOKABLE EntityItemID addEntity(const EntityItemProperties& properties);