From c78f8b8e77ca2e64d2639e08ba929f85a7e9deed Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 30 Apr 2013 18:11:41 -0400 Subject: [PATCH] Return false for group.filesEditable if group.editable is false It's possible for filesEditable in the DB to be set to 1 even if editable is 0. We generally check editable first anyway, but let's be safe. Also make editable/filesEditable return booleans instead of numbers --- chrome/content/zotero/xpcom/data/group.js | 6 +++--- chrome/content/zotero/xpcom/data/libraries.js | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/group.js b/chrome/content/zotero/xpcom/data/group.js index 4f39eaf00..120a41bc9 100644 --- a/chrome/content/zotero/xpcom/data/group.js +++ b/chrome/content/zotero/xpcom/data/group.js @@ -59,7 +59,7 @@ Zotero.Group.prototype.__defineGetter__('description', function () { return this Zotero.Group.prototype.__defineSetter__('description', function (val) { this._set('description', val); }); Zotero.Group.prototype.__defineGetter__('editable', function () { return this._get('editable'); }); Zotero.Group.prototype.__defineSetter__('editable', function (val) { this._set('editable', val); }); -Zotero.Group.prototype.__defineGetter__('filesEditable', function () { return this._get('filesEditable'); }); +Zotero.Group.prototype.__defineGetter__('filesEditable', function () { if (!this.editable) { return false; } return this._get('filesEditable'); }); Zotero.Group.prototype.__defineSetter__('filesEditable', function (val) { this._set('filesEditable', val); }); @@ -146,8 +146,8 @@ Zotero.Group.prototype.loadFromRow = function(row) { this._libraryID = row.libraryID; this._name = row.name; this._description = row.description; - this._editable = row.editable; - this._filesEditable = row.filesEditable; + this._editable = !!row.editable; + this._filesEditable = !!row.filesEditable; } diff --git a/chrome/content/zotero/xpcom/data/libraries.js b/chrome/content/zotero/xpcom/data/libraries.js index 9150ddaf7..b5acc583e 100644 --- a/chrome/content/zotero/xpcom/data/libraries.js +++ b/chrome/content/zotero/xpcom/data/libraries.js @@ -93,10 +93,6 @@ Zotero.Libraries = new function () { this.isFilesEditable = function (libraryID) { - if (!this.isEditable(libraryID)) { - return false; - } - var type = this.getType(libraryID); switch (type) { case 'user':