Merge remote-tracking branch 'origin/master' into grunt-dev

v1.18.x
psychobunny 10 years ago
commit 7fe8180cf4

@ -1,10 +1,19 @@
'use strict';
/* globals define, socket, app */
define('forum/notifications', function() {
var Notifications = {};
Notifications.init = function() {
var listEl = $('.notifications-list');
listEl.on('click', 'li', function(e) {
this.querySelector('a').click();
listEl.on('click', 'a', function(e) {
var nid = $(this).parents('[data-nid]').attr('data-nid');
socket.emit('notifications.markRead', nid, function(err) {
if (err) {
return app.alertError(err);
}
});
});
$('span.timeago').timeago();
@ -20,8 +29,7 @@ define('forum/notifications', function() {
listEl.empty();
});
});
}
};
return Notifications;
});

@ -16,6 +16,7 @@ var async = require('async'),
helpers = require('./helpers');
var Controllers = {
posts: require('./posts'),
topics: require('./topics'),
categories: require('./categories'),
tags: require('./tags'),

@ -0,0 +1,36 @@
"use strict";
var async = require('async'),
posts = require('../posts'),
privileges = require('../privileges'),
helpers = require('./helpers'),
postsController = {};
postsController.getPost = function(req, res, next) {
var uid = req.user ? parseInt(req.user.uid) : 0;
async.parallel({
canRead: function(next) {
privileges.posts.can('read', req.params.pid, uid, next);
},
postData: function(next) {
posts.getPostData(req.params.pid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
if (!results.postData) {
return helpers.notFound(req, res);
}
if (!results.canRead) {
return helpers.notAllowed(req, res);
}
res.json(results.postData);
});
};
module.exports = postsController;

@ -13,10 +13,7 @@ module.exports = function(Posts) {
},
function(tid, next) {
topics.getTopicField(tid, 'cid', next);
},
function(cid, next) {
next(!cid ? new Error('[[error:invalid-cid]]') : null, cid);
}
}
], callback);
};

@ -46,6 +46,9 @@ module.exports = function(privileges) {
};
privileges.categories.can = function(privilege, cid, uid, callback) {
if (!cid) {
return callback(null, false);
}
categories.getCategoryField(cid, 'disabled', function(err, disabled) {
if (err) {
return callback(err);

@ -153,9 +153,10 @@ module.exports = function(privileges) {
helpers.some([
function(next) {
posts.getCidByPid(pid, function(err, cid) {
if (err) {
return next(err);
if (err || !cid) {
return next(err, false);
}
user.isModerator(uid, cid, next);
});
},

@ -16,6 +16,7 @@ module.exports = function(app, middleware, controllers) {
router.get('/widgets/render', controllers.api.renderWidgets);
router.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.accounts.getUserByUID);
router.get('/post/:pid', controllers.posts.getPost);
router.get('/get_templates_listing', templatesController.getTemplatesListing);
router.get('/categories/:cid/moderators', getModerators);
router.get('/recent/posts/:term?', getRecentPosts);

@ -113,12 +113,18 @@ Categories.setGroupPrivilege = function(socket, data, callback) {
Categories.groupsList = function(socket, cid, callback) {
groups.list({
expand: false,
isAdmin: true,
showSystemGroups: true
}, function(err, data) {
if(err) {
return callback(err);
}
// Remove privilege groups
data = data.filter(function(groupObj) {
return groupObj.name.indexOf(':privileges:') === -1;
});
async.map(data, function(groupObj, next) {
privileges.categories.groupPrivileges(cid, groupObj.name, function(err, privileges) {
if(err) {

@ -41,6 +41,10 @@ module.exports = function(Topics) {
posts.getCidByPid(mainPid, callback);
}
}, function(err, results) {
if (err) {
return callback(err);
}
Topics.create({uid: results.postData.uid, title: title, cid: results.cid}, function(err, tid) {
if (err) {
return callback(err);

@ -16,100 +16,100 @@
</script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script>__lt_ie_9__ = 1;</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<script>__lt_ie_9__ = 1;</script>
<![endif]-->
<script type="text/javascript" src="{relative_path}/vendor/chart.js/chart.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/hammer/hammer.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/nodebb.min.js?{cache-buster}"></script>
<script>
require.config({
baseUrl: "{relative_path}/src/modules",
waitSeconds: 3,
urlArgs: "{cache-buster}",
paths: {
'admin': '../admin',
'vendor': '../../vendor',
'buzz': '../../vendor/buzz/buzz.min'
}
});
<script type="text/javascript" src="{relative_path}/vendor/chart.js/chart.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/hammer/hammer.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/nodebb.min.js?{cache-buster}"></script>
<script>
require.config({
baseUrl: "{relative_path}/src/modules",
waitSeconds: 3,
urlArgs: "{cache-buster}",
paths: {
'admin': '../admin',
'vendor': '../../vendor',
'buzz': '../../vendor/buzz/buzz.min'
}
});
app.inAdmin = true;
</script>
<script type="text/javascript" src="{relative_path}/vendor/colorpicker/colorpicker.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/src/admin/admin.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/ace/ace.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/nanoscroller/nanoscroller.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/event/jquery.event.drag.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/event/jquery.event.drop.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/semver/semver.browser.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/serializeObject/jquery.ba-serializeobject.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/deserialize/jquery.deserialize.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/mousetrap/mousetrap.js?{cache-buster}"></script>
app.inAdmin = true;
</script>
<script type="text/javascript" src="{relative_path}/vendor/colorpicker/colorpicker.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/src/admin/admin.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/ace/ace.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/nanoscroller/nanoscroller.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/event/jquery.event.drag.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/event/jquery.event.drop.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/semver/semver.browser.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/serializeObject/jquery.ba-serializeobject.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/jquery/deserialize/jquery.deserialize.min.js?{cache-buster}"></script>
<script type="text/javascript" src="{relative_path}/vendor/mousetrap/mousetrap.js?{cache-buster}"></script>
<!-- BEGIN scripts -->
<script type="text/javascript" src="{scripts.src}"></script>
<!-- END scripts -->
</head>
<!-- BEGIN scripts -->
<script type="text/javascript" src="{scripts.src}"></script>
<!-- END scripts -->
</head>
<body class="admin">
<nav class="navbar navbar-inverse navbar-fixed-top header">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand nodebb-logo" href="{relative_path}/admin/general/dashboard"><img src="{relative_path}/images/logo.png" alt="NodeBB ACP" /> Admin Control Panel <span id="breadcrumbs" class="hidden-xs"></span></a>
<ul class="nav navbar-nav pull-left">
<li>
<a href="#" id="reconnect"></a>
</li>
</ul>
<body class="admin">
<nav class="navbar navbar-inverse navbar-fixed-top header">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand nodebb-logo" href="{relative_path}/admin/general/dashboard"><img src="{relative_path}/images/logo.png" alt="NodeBB ACP" /> Admin Control Panel <span id="breadcrumbs" class="hidden-xs"></span></a>
<ul class="nav navbar-nav pull-left">
<li>
<a href="#" id="reconnect"></a>
</li>
</ul>
</div>
<div class="navbar-collapse collapse">
<ul id="logged-in-menu" class="navbar-nav nav navbar-right pull-right">
<li style="float:left;">
<form class="navbar-form hidden-xs" role="search">
<div class="form-group" id="acp-search" >
<div class="dropdown" >
<input type="text" data-toggle="dropdown" class="form-control" placeholder="/">
<ul class="dropdown-menu" role="menu"></ul>
</div>
</div>
</form>
</li>
<li id="user_label" class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="user_dropdown">
<img src="{user.picture}"/>
</a>
<ul id="user-control-list" class="dropdown-menu" aria-labelledby="user_dropdown">
<li>
<a id="user-profile-link" href="{relative_path}/user/{user.userslug}" target="_top"><span>Profile</span></a>
</li>
<li id="logout-link">
<a href="#">Log out</a>
</li>
</ul>
</li>
<li class="nav-home pull-right">
<a href="{relative_path}/" target="_blank" title="Open forum homepage" data-original-title="Open forum homepage">
<i class="fa fa-home fa-fw"></i>
</a>
</li>
</ul>
</div>
</div>
<div class="navbar-collapse collapse">
<ul id="logged-in-menu" class="navbar-nav nav navbar-right pull-right">
<li style="float:left;">
<form class="navbar-form hidden-xs" role="search">
<div class="form-group" id="acp-search" >
<div class="dropdown" >
<input type="text" data-toggle="dropdown" class="form-control" placeholder="/">
<ul class="dropdown-menu" role="menu"></ul>
</div>
</div>
</form>
</li>
<li id="user_label" class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="user_dropdown">
<img src="{user.picture}"/>
</a>
<ul id="user-control-list" class="dropdown-menu" aria-labelledby="user_dropdown">
<li>
<a id="user-profile-link" href="{relative_path}/user/{user.userslug}" target="_top"><span>Profile</span></a>
</li>
<li id="logout-link">
<a href="#">Log out</a>
</li>
</ul>
</li>
<li class="nav-home pull-right">
<a href="{relative_path}/" target="_blank" title="Open forum homepage" data-original-title="Open forum homepage">
<i class="fa fa-home fa-fw"></i>
</a>
</li>
</ul>
</div>
</div>
</nav>
</nav>
<div class="wrapper">
<div id="main-menu" class="nano">
<div class="nano-content">
<!-- IMPORT admin/partials/menu.tpl -->
<div class="wrapper">
<div id="main-menu" class="nano">
<div class="nano-content">
<!-- IMPORT admin/partials/menu.tpl -->
</div>
</div>
</div>
<div class="col-sm-12" id="content">
<div class="col-sm-12" id="content">
Loading…
Cancel
Save