more error strings

v1.18.x
barisusakli 11 years ago
parent fdeaf3a16e
commit 0ac58dbee6

@ -6,12 +6,16 @@
"invalid-cid": "Invalid Category ID", "invalid-cid": "Invalid Category ID",
"invalid-tid": "Invalid Topic ID", "invalid-tid": "Invalid Topic ID",
"invalid-pid": "Invalid Post ID", "invalid-pid": "Invalid Post ID",
"invalid-uid": "Invalid User ID",
"no-category": "Category doesn't exist", "no-category": "Category doesn't exist",
"no-topic": "Topic doesn't exist", "no-topic": "Topic doesn't exist",
"no-post": "Post doesn't exist", "no-post": "Post doesn't exist",
"no-group": "Group doesn't exist",
"no-privileges": "You don't have enough privileges for this action.", "no-privileges": "You don't have enough privileges for this action.",
"category-disabled": "Category disabled",
"topic-locked": "Topic Locked", "topic-locked": "Topic Locked",
"still-uploading" : "Please wait for uploads to complete.", "still-uploading" : "Please wait for uploads to complete.",
@ -27,5 +31,9 @@
"cant-ban-other-admins": "You can't ban other admins!", "cant-ban-other-admins": "You can't ban other admins!",
"invalid-image-type": "Invalid image type" "invalid-image-type": "Invalid image type",
"group-name-too-short": "Group name too short",
"group-already-exists": "Group already exists",
"group-name-change-not-allowed": "Group name change not allowed"
} }

@ -64,7 +64,7 @@ var db = require('./database'),
Categories.getCategoryById = function(cid, start, end, uid, callback) { Categories.getCategoryById = function(cid, start, end, uid, callback) {
Categories.getCategoryData(cid, function(err, category) { Categories.getCategoryData(cid, function(err, category) {
if(err || !category) { if(err || !category) {
return callback(err || new Error('category-not-found [' + cid + ']')); return callback(err || new Error('[[error:invalid-cid]]'));
} }
if(parseInt(uid, 10)) { if(parseInt(uid, 10)) {
@ -278,7 +278,7 @@ var db = require('./database'),
Categories.getCategories = function(cids, uid, callback) { Categories.getCategories = function(cids, uid, callback) {
if (!Array.isArray(cids) || cids.length === 0) { if (!Array.isArray(cids) || cids.length === 0) {
return callback(new Error('invalid-cids')); return callback(new Error('[[error:invalid-cid]]'));
} }
async.parallel({ async.parallel({

@ -33,7 +33,7 @@ function userNotAllowed(res) {
function getUserDataByUserSlug(userslug, callerUID, callback) { function getUserDataByUserSlug(userslug, callerUID, callback) {
user.getUidByUserslug(userslug, function(err, uid) { user.getUidByUserslug(userslug, function(err, uid) {
if(err || !uid) { if(err || !uid) {
return callback(err || new Error('invalid-user')); return callback(err || new Error('[[error:invalid-uid]]'));
} }
async.parallel({ async.parallel({
@ -54,7 +54,7 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
} }
}, function(err, results) { }, function(err, results) {
if(err || !results.userData) { if(err || !results.userData) {
return callback(err || new Error('invalid-user')); return callback(err || new Error('[[error:invalid-uid]]'));
} }
var userData = results.userData; var userData = results.userData;

@ -70,7 +70,7 @@ categoriesController.get = function(req, res, next) {
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) { categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
if (!err) { if (!err) {
if (!categoryPrivileges.read) { if (!categoryPrivileges.read) {
next(new Error('not-enough-privileges')); next(new Error('[[error:no-privileges]]'));
} else { } else {
next(null, categoryPrivileges); next(null, categoryPrivileges);
} }
@ -95,7 +95,7 @@ categoriesController.get = function(req, res, next) {
if (categoryData) { if (categoryData) {
if (parseInt(categoryData.disabled, 10) === 1) { if (parseInt(categoryData.disabled, 10) === 1) {
return next(new Error('Category disabled'), null); return next(new Error('[[error:category-disabled]]'));
} }
} }

@ -26,7 +26,7 @@ topicsController.get = function(req, res, next) {
} }
if (!userPrivileges.read) { if (!userPrivileges.read) {
return next(new Error('not-enough-privileges')); return next(new Error('[[error:no-privileges]]'));
} }
privileges = userPrivileges; privileges = userPrivileges;
@ -45,7 +45,7 @@ topicsController.get = function(req, res, next) {
topics.getTopicWithPosts(tid, uid, start, end, function (err, topicData) { topics.getTopicWithPosts(tid, uid, start, end, function (err, topicData) {
if (topicData) { if (topicData) {
if (parseInt(topicData.deleted, 10) === 1 && parseInt(topicData.expose_tools, 10) === 0) { if (parseInt(topicData.deleted, 10) === 1 && parseInt(topicData.expose_tools, 10) === 0) {
return next(new Error('Topic deleted')); return next(new Error('[[error:no-topic]]'));
} }
topicData.currentPage = page; topicData.currentPage = page;
} }

@ -137,7 +137,7 @@
Groups.create = function(name, description, callback) { Groups.create = function(name, description, callback) {
if (name.length === 0) { if (name.length === 0) {
return callback(new Error('name-too-short')); return callback(new Error('[[error:group-name-too-short]]'));
} }
if (name === 'administrators' || name === 'registered-users') { if (name === 'administrators' || name === 'registered-users') {
@ -145,28 +145,32 @@
} }
Groups.exists(name, function (err, exists) { Groups.exists(name, function (err, exists) {
if (!exists) { if (err) {
var groupData = { return callback(err);
name: name, }
description: description,
deleted: '0',
hidden: '0',
system: system ? '1' : '0'
};
async.parallel([ if (exists) {
function(next) { return callback(new Error('[[error:group-already-exists]]'));
db.setAdd('groups', name, next);
},
function(next) {
db.setObject('group:' + name, groupData, function(err) {
Groups.get(name, {}, next);
});
}
], callback);
} else {
callback(new Error('group-exists'));
} }
var groupData = {
name: name,
description: description,
deleted: '0',
hidden: '0',
system: system ? '1' : '0'
};
async.parallel([
function(next) {
db.setAdd('groups', name, next);
},
function(next) {
db.setObject('group:' + name, groupData, function(err) {
Groups.get(name, {}, next);
});
}
], callback);
}); });
}; };
@ -184,12 +188,12 @@
db.setObject('group:' + groupName, values, callback); db.setObject('group:' + groupName, values, callback);
} else { } else {
if (callback) { if (callback) {
callback(new Error('name-change-not-allowed')); callback(new Error('[[error:group-name-change-not-allowed]]'));
} }
} }
} else { } else {
if (callback) { if (callback) {
callback(new Error('gid-not-found')); callback(new Error('[[error:no-group]]'));
} }
} }
}); });

Loading…
Cancel
Save